jekyll-patreon 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/jekyll-patreon.gemspec +24 -0
- data/lib/jekyll-patreon/_inc/button.html +2 -0
- data/lib/jekyll-patreon/_inc/css/common.css +7 -0
- data/lib/jekyll-patreon/_inc/css/design_default.css +146 -0
- data/lib/jekyll-patreon/_inc/css/design_fancy.css +152 -0
- data/lib/jekyll-patreon/_inc/css/design_minimal.css +146 -0
- data/lib/jekyll-patreon/_inc/css/design_reversed.css +146 -0
- data/lib/jekyll-patreon/_inc/css/design_streamlined.css +146 -0
- data/lib/jekyll-patreon/_inc/css/design_swapped.css +146 -0
- data/lib/jekyll-patreon/_inc/design_default.html +16 -0
- data/lib/jekyll-patreon/_inc/design_fancy.html +16 -0
- data/lib/jekyll-patreon/_inc/design_minimal.html +10 -0
- data/lib/jekyll-patreon/_inc/design_reversed.html +18 -0
- data/lib/jekyll-patreon/_inc/design_streamlined.html +16 -0
- data/lib/jekyll-patreon/_inc/design_swapped.html +16 -0
- data/lib/jekyll-patreon/_inc/js/patreon.js +127 -0
- data/lib/jekyll-patreon/generator/defaults.rb +17 -0
- data/lib/jekyll-patreon/generator/patreonGenerator.rb +36 -0
- data/lib/jekyll-patreon/tags/patreonTag.rb +99 -0
- data/lib/jekyll-patreon/utils/string-utils.rb +35 -0
- data/lib/jekyll-patreon/version.rb +5 -0
- data/lib/jekyll-patreon.rb +18 -0
- metadata +109 -0
@@ -0,0 +1,146 @@
|
|
1
|
+
.meter {
|
2
|
+
height: 8px;
|
3
|
+
position: relative;
|
4
|
+
background: #f2f4f5;
|
5
|
+
-moz-border-radius: 4px;
|
6
|
+
-webkit-border-radius: 4px;
|
7
|
+
border-radius: 4px;
|
8
|
+
padding: 0px;
|
9
|
+
-webkit-box-shadow: inset 0 -1px 1px rgba(255, 255, 255, 0.3);
|
10
|
+
-moz-box-shadow: inset 0 -1px 1px rgba(255, 255, 255, 0.3);
|
11
|
+
box-shadow: inset 0 -1px 1px rgba(255, 255, 255, 0.3);
|
12
|
+
}
|
13
|
+
|
14
|
+
.meter > span {
|
15
|
+
display: block;
|
16
|
+
height: 100%;
|
17
|
+
-webkit-border-top-right-radius: 20px;
|
18
|
+
-webkit-border-bottom-right-radius: 20px;
|
19
|
+
-moz-border-radius-topright: 20px;
|
20
|
+
-moz-border-radius-bottomright: 20px;
|
21
|
+
border-top-right-radius: 20px;
|
22
|
+
border-bottom-right-radius: 20px;
|
23
|
+
-webkit-border-top-left-radius: 20px;
|
24
|
+
-webkit-border-bottom-left-radius: 20px;
|
25
|
+
-moz-border-radius-topleft: 20px;
|
26
|
+
-moz-border-radius-bottomleft: 20px;
|
27
|
+
border-top-left-radius: 20px;
|
28
|
+
border-bottom-left-radius: 20px;
|
29
|
+
background-color: rgb(43, 194, 83);
|
30
|
+
background-image: -webkit-gradient(
|
31
|
+
linear,
|
32
|
+
left bottom,
|
33
|
+
left top,
|
34
|
+
color-stop(0, rgb(43, 194, 83)),
|
35
|
+
color-stop(1, rgb(84, 240, 84))
|
36
|
+
);
|
37
|
+
background-image: -moz-linear-gradient(
|
38
|
+
center bottom,
|
39
|
+
rgb(43, 194, 83) 37%,
|
40
|
+
rgb(84, 240, 84) 69%
|
41
|
+
);
|
42
|
+
position: relative;
|
43
|
+
overflow: hidden;
|
44
|
+
}
|
45
|
+
|
46
|
+
.meter > span:after, .animate > span > span {
|
47
|
+
content: "";
|
48
|
+
position: absolute;
|
49
|
+
top: 0;
|
50
|
+
left: 0;
|
51
|
+
bottom: 0;
|
52
|
+
right: 0;
|
53
|
+
background-image: -webkit-gradient(linear, 0 0, 100% 100%,
|
54
|
+
color-stop(.25, rgba(255, 255, 255, .2)),
|
55
|
+
color-stop(.25, transparent), color-stop(.5, transparent),
|
56
|
+
color-stop(.5, rgba(255, 255, 255, .2)),
|
57
|
+
color-stop(.75, rgba(255, 255, 255, .2)),
|
58
|
+
color-stop(.75, transparent), to(transparent)
|
59
|
+
);
|
60
|
+
background-image: -moz-linear-gradient(
|
61
|
+
-45deg,
|
62
|
+
rgba(255, 255, 255, .2) 25%,
|
63
|
+
transparent 25%,
|
64
|
+
transparent 50%,
|
65
|
+
rgba(255, 255, 255, .2) 50%,
|
66
|
+
rgba(255, 255, 255, .2) 75%,
|
67
|
+
transparent 75%,
|
68
|
+
transparent
|
69
|
+
);
|
70
|
+
z-index: 1;
|
71
|
+
-webkit-background-size: 50px 50px;
|
72
|
+
-moz-background-size: 50px 50px;
|
73
|
+
-webkit-animation: move 2s linear infinite;
|
74
|
+
-webkit-border-top-right-radius: 20px;
|
75
|
+
-webkit-border-bottom-right-radius: 20px;
|
76
|
+
-moz-border-radius-topright: 20px;
|
77
|
+
-moz-border-radius-bottomright: 20px;
|
78
|
+
border-top-right-radius: 20px;
|
79
|
+
border-bottom-right-radius: 20px;
|
80
|
+
-webkit-border-top-left-radius: 20px;
|
81
|
+
-webkit-border-bottom-left-radius: 20px;
|
82
|
+
-moz-border-radius-topleft: 20px;
|
83
|
+
-moz-border-radius-bottomleft: 20px;
|
84
|
+
border-top-left-radius: 20px;
|
85
|
+
border-bottom-left-radius: 20px;
|
86
|
+
overflow: hidden;
|
87
|
+
}
|
88
|
+
|
89
|
+
.animate > span:after {
|
90
|
+
display: none;
|
91
|
+
}
|
92
|
+
|
93
|
+
@-webkit-keyframes move {
|
94
|
+
0% {
|
95
|
+
background-position: 0 0;
|
96
|
+
}
|
97
|
+
100% {
|
98
|
+
background-position: 50px 50px;
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
.orange > span {
|
103
|
+
background-color: #e6461a;
|
104
|
+
background-image: -moz-linear-gradient(top, #e6461a, #e6461a);
|
105
|
+
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #e6461a), color-stop(1, #e6461a));
|
106
|
+
background-image: -webkit-linear-gradient(#e6461a, #e6461a);
|
107
|
+
}
|
108
|
+
|
109
|
+
.red > span {
|
110
|
+
background-color: #f0a3a3;
|
111
|
+
background-image: -moz-linear-gradient(top, #f0a3a3, #f42323);
|
112
|
+
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #f0a3a3), color-stop(1, #f42323));
|
113
|
+
background-image: -webkit-linear-gradient(#f0a3a3, #f42323);
|
114
|
+
}
|
115
|
+
|
116
|
+
.blue > span {
|
117
|
+
background-color: #3EB7CA;
|
118
|
+
background-image: -moz-linear-gradient(top, #3EB7CA, #1DABC1);
|
119
|
+
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #3EB7CA), color-stop(1, #1DABC1));
|
120
|
+
background-image: -webkit-linear-gradient(#3EB7CA, #1DABC1);
|
121
|
+
}
|
122
|
+
|
123
|
+
.nostripes > span > span, .nostripes > span:after {
|
124
|
+
-webkit-animation: none;
|
125
|
+
background-image: none;
|
126
|
+
}
|
127
|
+
|
128
|
+
#patreon_goalmoneytext {
|
129
|
+
}
|
130
|
+
|
131
|
+
#patreon_goaltext {
|
132
|
+
padding-top: 10px;
|
133
|
+
}
|
134
|
+
|
135
|
+
#patreon_paypername {
|
136
|
+
color: #a7b2b8;
|
137
|
+
}
|
138
|
+
|
139
|
+
span.goalreached {
|
140
|
+
color: #e6461a;
|
141
|
+
}
|
142
|
+
|
143
|
+
.patreon_button {
|
144
|
+
padding-top: 10px;
|
145
|
+
padding-bottom: 10px;
|
146
|
+
}
|
@@ -0,0 +1,146 @@
|
|
1
|
+
.meter {
|
2
|
+
height: 8px;
|
3
|
+
position: relative;
|
4
|
+
background: #f2f4f5;
|
5
|
+
-moz-border-radius: 4px;
|
6
|
+
-webkit-border-radius: 4px;
|
7
|
+
border-radius: 4px;
|
8
|
+
padding: 0px;
|
9
|
+
-webkit-box-shadow: inset 0 -1px 1px rgba(255, 255, 255, 0.3);
|
10
|
+
-moz-box-shadow: inset 0 -1px 1px rgba(255, 255, 255, 0.3);
|
11
|
+
box-shadow: inset 0 -1px 1px rgba(255, 255, 255, 0.3);
|
12
|
+
}
|
13
|
+
|
14
|
+
.meter > span {
|
15
|
+
display: block;
|
16
|
+
height: 100%;
|
17
|
+
-webkit-border-top-right-radius: 20px;
|
18
|
+
-webkit-border-bottom-right-radius: 20px;
|
19
|
+
-moz-border-radius-topright: 20px;
|
20
|
+
-moz-border-radius-bottomright: 20px;
|
21
|
+
border-top-right-radius: 20px;
|
22
|
+
border-bottom-right-radius: 20px;
|
23
|
+
-webkit-border-top-left-radius: 20px;
|
24
|
+
-webkit-border-bottom-left-radius: 20px;
|
25
|
+
-moz-border-radius-topleft: 20px;
|
26
|
+
-moz-border-radius-bottomleft: 20px;
|
27
|
+
border-top-left-radius: 20px;
|
28
|
+
border-bottom-left-radius: 20px;
|
29
|
+
background-color: rgb(43, 194, 83);
|
30
|
+
background-image: -webkit-gradient(
|
31
|
+
linear,
|
32
|
+
left bottom,
|
33
|
+
left top,
|
34
|
+
color-stop(0, rgb(43, 194, 83)),
|
35
|
+
color-stop(1, rgb(84, 240, 84))
|
36
|
+
);
|
37
|
+
background-image: -moz-linear-gradient(
|
38
|
+
center bottom,
|
39
|
+
rgb(43, 194, 83) 37%,
|
40
|
+
rgb(84, 240, 84) 69%
|
41
|
+
);
|
42
|
+
position: relative;
|
43
|
+
overflow: hidden;
|
44
|
+
}
|
45
|
+
|
46
|
+
.meter > span:after, .animate > span > span {
|
47
|
+
content: "";
|
48
|
+
position: absolute;
|
49
|
+
top: 0;
|
50
|
+
left: 0;
|
51
|
+
bottom: 0;
|
52
|
+
right: 0;
|
53
|
+
background-image: -webkit-gradient(linear, 0 0, 100% 100%,
|
54
|
+
color-stop(.25, rgba(255, 255, 255, .2)),
|
55
|
+
color-stop(.25, transparent), color-stop(.5, transparent),
|
56
|
+
color-stop(.5, rgba(255, 255, 255, .2)),
|
57
|
+
color-stop(.75, rgba(255, 255, 255, .2)),
|
58
|
+
color-stop(.75, transparent), to(transparent)
|
59
|
+
);
|
60
|
+
background-image: -moz-linear-gradient(
|
61
|
+
-45deg,
|
62
|
+
rgba(255, 255, 255, .2) 25%,
|
63
|
+
transparent 25%,
|
64
|
+
transparent 50%,
|
65
|
+
rgba(255, 255, 255, .2) 50%,
|
66
|
+
rgba(255, 255, 255, .2) 75%,
|
67
|
+
transparent 75%,
|
68
|
+
transparent
|
69
|
+
);
|
70
|
+
z-index: 1;
|
71
|
+
-webkit-background-size: 50px 50px;
|
72
|
+
-moz-background-size: 50px 50px;
|
73
|
+
-webkit-animation: move 2s linear infinite;
|
74
|
+
-webkit-border-top-right-radius: 20px;
|
75
|
+
-webkit-border-bottom-right-radius: 20px;
|
76
|
+
-moz-border-radius-topright: 20px;
|
77
|
+
-moz-border-radius-bottomright: 20px;
|
78
|
+
border-top-right-radius: 20px;
|
79
|
+
border-bottom-right-radius: 20px;
|
80
|
+
-webkit-border-top-left-radius: 20px;
|
81
|
+
-webkit-border-bottom-left-radius: 20px;
|
82
|
+
-moz-border-radius-topleft: 20px;
|
83
|
+
-moz-border-radius-bottomleft: 20px;
|
84
|
+
border-top-left-radius: 20px;
|
85
|
+
border-bottom-left-radius: 20px;
|
86
|
+
overflow: hidden;
|
87
|
+
}
|
88
|
+
|
89
|
+
.animate > span:after {
|
90
|
+
display: none;
|
91
|
+
}
|
92
|
+
|
93
|
+
@-webkit-keyframes move {
|
94
|
+
0% {
|
95
|
+
background-position: 0 0;
|
96
|
+
}
|
97
|
+
100% {
|
98
|
+
background-position: 50px 50px;
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
.orange > span {
|
103
|
+
background-color: #e6461a;
|
104
|
+
background-image: -moz-linear-gradient(top, #e6461a, #e6461a);
|
105
|
+
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #e6461a), color-stop(1, #e6461a));
|
106
|
+
background-image: -webkit-linear-gradient(#e6461a, #e6461a);
|
107
|
+
}
|
108
|
+
|
109
|
+
.red > span {
|
110
|
+
background-color: #f0a3a3;
|
111
|
+
background-image: -moz-linear-gradient(top, #f0a3a3, #f42323);
|
112
|
+
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #f0a3a3), color-stop(1, #f42323));
|
113
|
+
background-image: -webkit-linear-gradient(#f0a3a3, #f42323);
|
114
|
+
}
|
115
|
+
|
116
|
+
.blue > span {
|
117
|
+
background-color: #3EB7CA;
|
118
|
+
background-image: -moz-linear-gradient(top, #3EB7CA, #1DABC1);
|
119
|
+
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #3EB7CA), color-stop(1, #1DABC1));
|
120
|
+
background-image: -webkit-linear-gradient(#3EB7CA, #1DABC1);
|
121
|
+
}
|
122
|
+
|
123
|
+
.nostripes > span > span, .nostripes > span:after {
|
124
|
+
-webkit-animation: none;
|
125
|
+
background-image: none;
|
126
|
+
}
|
127
|
+
|
128
|
+
#patreon_goalmoneytext {
|
129
|
+
}
|
130
|
+
|
131
|
+
#patreon_goaltext {
|
132
|
+
padding-top: 10px;
|
133
|
+
}
|
134
|
+
|
135
|
+
#patreon_paypername {
|
136
|
+
color: #a7b2b8;
|
137
|
+
}
|
138
|
+
|
139
|
+
span.goalreached {
|
140
|
+
color: #e6461a;
|
141
|
+
}
|
142
|
+
|
143
|
+
.patreon_button {
|
144
|
+
padding-top: 10px;
|
145
|
+
padding-bottom: 10px;
|
146
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<script>
|
2
|
+
var PatreonData = JSON.parse("#{json}");
|
3
|
+
var patreonShowGoalText = #{showgoaltext};
|
4
|
+
</script>
|
5
|
+
<div id="patreon_toptext">#{toptext}</div>
|
6
|
+
<div class="patreon_goalmoney">
|
7
|
+
<span id="patreon_goalmoneytext"></span>
|
8
|
+
<span id="patreon_goalreached" class='goalreached'></span>
|
9
|
+
</div>
|
10
|
+
<div id="patreon_paypername"></div>
|
11
|
+
<div class="meter #{metercolor}" id="patreon_meter">
|
12
|
+
<span style="width: 0%"></span>
|
13
|
+
</div>
|
14
|
+
<div id="patreon_goaltext"></div>
|
15
|
+
<div id="patreon_bottomtext">#{bottomtext}</div>
|
16
|
+
<div class="patreon_button">#{patreon_button}</div>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<script>
|
2
|
+
var PatreonData = JSON.parse("#{json}");
|
3
|
+
var patreonShowGoalText = #{showgoaltext};
|
4
|
+
</script>
|
5
|
+
<div id="patreon_toptext">#{toptext}</div>
|
6
|
+
<div class="patreon_goalmoney">
|
7
|
+
<span id="patreon_goalmoneytext"></span>
|
8
|
+
<span id="patreon_goalreached" class='goalreached'></span>
|
9
|
+
</div>
|
10
|
+
<div id="patreon_paypername"></div>
|
11
|
+
<div class="meter #{metercolor}" id="patreon_meter">
|
12
|
+
<span style="width: 0%"></span>
|
13
|
+
</div>
|
14
|
+
<div id="patreon_goaltext"></div>
|
15
|
+
<div id="patreon_bottomtext">#{bottomtext}</div>
|
16
|
+
<div class="patreon_button">#{patreon_button}</div>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<script>
|
2
|
+
var PatreonData = JSON.parse("#{json}");
|
3
|
+
var patreonShowGoalText = #{showgoaltext};
|
4
|
+
</script>
|
5
|
+
<div id="patreon_toptext">#{toptext}</div>
|
6
|
+
<div class="meter #{metercolor}" id="patreon_meter">
|
7
|
+
<span style="width: 0%"></span>
|
8
|
+
</div>
|
9
|
+
<div id="patreon_bottomtext">#{bottomtext}</div>
|
10
|
+
<div class="patreon_button">#{patreon_button}</div>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<script>
|
2
|
+
var PatreonData = JSON.parse("#{json}");
|
3
|
+
var patreonShowGoalText = #{showgoaltext};
|
4
|
+
</script>
|
5
|
+
<div id="patreon_bottomtext">#{bottomtext}</div>
|
6
|
+
<div id="patreon_goaltext"></div>
|
7
|
+
<div class="meter #{metercolor}" id="patreon_meter">
|
8
|
+
<span style="width: 0%"></span>
|
9
|
+
</div>
|
10
|
+
<div class="patreon_streamlinetext">
|
11
|
+
<span id="patreon_toptext">#{toptext}</span>
|
12
|
+
<div class="patreon_goalmoney">
|
13
|
+
<span id="patreon_goalmoneytext"></span>
|
14
|
+
<span id="patreon_paypername"></span>
|
15
|
+
<span id="patreon_goalreached" class='goalreached'></span>
|
16
|
+
</div>
|
17
|
+
</div>
|
18
|
+
<div class="patreon_button">#{patreon_button}</div>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<script>
|
2
|
+
var PatreonData = JSON.parse("#{json}");
|
3
|
+
var patreonShowGoalText = #{showgoaltext};
|
4
|
+
</script>
|
5
|
+
<div class="patreon_streamlinetext">
|
6
|
+
<span id="patreon_toptext">#{toptext}</span>
|
7
|
+
<span id="patreon_goalmoneytext"></span>
|
8
|
+
<span id="patreon_paypername"></span>
|
9
|
+
<span id="patreon_goalreached" class='goalreached'></span>
|
10
|
+
</div>
|
11
|
+
<div class="meter #{metercolor}" id="patreon_meter">
|
12
|
+
<span style="width: 0%"></span>
|
13
|
+
</div>
|
14
|
+
<div id="patreon_goaltext"></div>
|
15
|
+
<div id="patreon_bottomtext">#{bottomtext}</div>
|
16
|
+
<div class="patreon_button">#{patreon_button}</div>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<script language="JavaScript">
|
2
|
+
var PatreonData = JSON.parse("#{json}");
|
3
|
+
var patreonShowGoalText = #{showgoaltext};
|
4
|
+
</script>
|
5
|
+
<div class="meter #{metercolor}" id="patreon_meter">
|
6
|
+
<span style="width: 0%"></span>
|
7
|
+
</div>
|
8
|
+
<div class="patreon_streamlinetext">
|
9
|
+
<span id="patreon_toptext">#{toptext}</span>
|
10
|
+
<span id="patreon_goalmoneytext"></span>
|
11
|
+
<span id="patreon_paypername"></span>
|
12
|
+
<span id="patreon_goalreached" class='goalreached'></span>
|
13
|
+
</div>
|
14
|
+
<div id="patreon_goaltext"></div>
|
15
|
+
<div id="patreon_bottomtext">#{bottomtext}</div>
|
16
|
+
<div class="patreon_button">#{patreon_button}</div>
|
@@ -0,0 +1,127 @@
|
|
1
|
+
// 'use strict';
|
2
|
+
|
3
|
+
var patreon = {
|
4
|
+
GetCampaign: function() {
|
5
|
+
for (var idx in PatreonData.included) {
|
6
|
+
var linkedData = PatreonData.included[idx];
|
7
|
+
if (linkedData.type == "campaign")
|
8
|
+
{
|
9
|
+
return linkedData.attributes;
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
return null;
|
14
|
+
},
|
15
|
+
GetPatronCount: function(campaignData) {
|
16
|
+
return campaignData.patron_count;
|
17
|
+
},
|
18
|
+
GetPledgeSum: function(campaignData) {
|
19
|
+
return campaignData.pledge_sum / 100.0;
|
20
|
+
},
|
21
|
+
GetGoalTotal: function(goalData) {
|
22
|
+
return goalData.amount_cents / 100.0;
|
23
|
+
},
|
24
|
+
GetActiveGoal: function() {
|
25
|
+
var campaign = this.GetCampaign();
|
26
|
+
var pledged_cents = this.GetPledgeSum(campaign) * 100;
|
27
|
+
var lastGoal = null;
|
28
|
+
for (var idx in PatreonData.included) {
|
29
|
+
var linkedData = PatreonData.included[idx];
|
30
|
+
if (linkedData.type == "goal")
|
31
|
+
{
|
32
|
+
if ((lastGoal != null) && (pledged_cents > lastGoal.amount_cents) && (pledged_cents < linkedData.attributes.amount_cents))
|
33
|
+
{
|
34
|
+
lastGoal = linkedData.attributes;
|
35
|
+
break;
|
36
|
+
}
|
37
|
+
else if ((lastGoal != null) && (pledged_cents < linkedData.attributes.amount_cents))
|
38
|
+
{
|
39
|
+
break;
|
40
|
+
}
|
41
|
+
else
|
42
|
+
{
|
43
|
+
lastGoal = linkedData.attributes;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
return lastGoal;
|
49
|
+
},
|
50
|
+
ShowGoalProgress: function(perc) {
|
51
|
+
var percWidth = perc > 100 ? 100 : perc;
|
52
|
+
|
53
|
+
$("#patreon_meter > span").each(function() {
|
54
|
+
$(this)
|
55
|
+
.data("origWidth", percWidth + "%")
|
56
|
+
.width(0)
|
57
|
+
.animate({
|
58
|
+
width: $(this).data("origWidth")
|
59
|
+
}, 1200);
|
60
|
+
});
|
61
|
+
},
|
62
|
+
GoalTextFromTo: function(campaignData, goalData) {
|
63
|
+
var pledgeSum = 0;
|
64
|
+
var goalTotal = 0;
|
65
|
+
|
66
|
+
if (campaignData)
|
67
|
+
{
|
68
|
+
pledgeSum = Math.floor(this.GetPledgeSum(campaignData));
|
69
|
+
|
70
|
+
$("#patreon_paypername").html("per " + campaignData.pay_per_name);
|
71
|
+
}
|
72
|
+
|
73
|
+
if (goalData)
|
74
|
+
{
|
75
|
+
goalTotal = Math.floor(this.GetGoalTotal(goalData));
|
76
|
+
|
77
|
+
if (patreonShowGoalText)
|
78
|
+
{
|
79
|
+
$("#patreon_goaltext").html(goalData.description);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
if (pledgeSum < goalTotal)
|
84
|
+
{
|
85
|
+
$("#patreon_goalmoneytext").html("$" + pledgeSum + " of $" + goalTotal);
|
86
|
+
$("#patreon_goalreached").html("");
|
87
|
+
}
|
88
|
+
else
|
89
|
+
{
|
90
|
+
$("#patreon_goalmoneytext").html("$" + goalTotal);
|
91
|
+
$("#patreon_goalreached").html("- reached!");
|
92
|
+
}
|
93
|
+
},
|
94
|
+
CreateDummyGoal: function(campaignData) {
|
95
|
+
return {
|
96
|
+
"description": "",
|
97
|
+
"amount_cents": campaignData.pledge_sum
|
98
|
+
};
|
99
|
+
}
|
100
|
+
};
|
101
|
+
|
102
|
+
document.addEventListener("DOMContentLoaded", function(event) {
|
103
|
+
$(document).ready(function() {
|
104
|
+
if (typeof PatreonData['data'] == "object")
|
105
|
+
{
|
106
|
+
var campaignData = patreon.GetCampaign();
|
107
|
+
var goalData = patreon.GetActiveGoal();
|
108
|
+
if (!goalData)
|
109
|
+
{
|
110
|
+
goalData = patreon.CreateDummyGoal(campaignData);
|
111
|
+
}
|
112
|
+
|
113
|
+
var goalperc = Math.floor((campaignData.pledge_sum / goalData.amount_cents) * 100.0);
|
114
|
+
$("#patreon_percentage").val(goalperc);
|
115
|
+
patreon.GoalTextFromTo(campaignData, goalData);
|
116
|
+
patreon.ShowGoalProgress(goalperc)
|
117
|
+
}
|
118
|
+
|
119
|
+
if($("#patreon_toptext").text() == "")
|
120
|
+
$("#patreon_toptext").remove();
|
121
|
+
|
122
|
+
if($("#patreon_bottomtext").text() == "")
|
123
|
+
$("#patreon_bottomtext").remove();
|
124
|
+
|
125
|
+
// $(".patreon_button").remove();
|
126
|
+
});
|
127
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module Patreon::Generator
|
3
|
+
|
4
|
+
# The default configuration for the Patreon widget
|
5
|
+
DEFAULT = {
|
6
|
+
'enabled' => false,
|
7
|
+
'design' => 'default', # Supports the following desings: default, fancy, minimal, streamlined, reversed, swapped
|
8
|
+
'title' => '',
|
9
|
+
'metercolor' => "green", # Supports the following colors: reed, green, orange, red nostripes, green nostripes, orange nostripes, blue nostripes
|
10
|
+
'toptext' => "", # Text that appears in before the progress bar
|
11
|
+
'bottomtext' => "", # Text that appears in after the progress bar
|
12
|
+
'showgoaltext' => true,
|
13
|
+
'showbutton' => false
|
14
|
+
}
|
15
|
+
|
16
|
+
end # module Patreon
|
17
|
+
end # module Jekyll
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module Patreon::Generator
|
3
|
+
|
4
|
+
@@config = nil
|
5
|
+
|
6
|
+
#
|
7
|
+
# The main entry point into the generator, called by Jekyll
|
8
|
+
# this function extracts all the necessary information from the jekyll end and passes it into the pagination
|
9
|
+
# logic. Additionally it also contains all site specific actions that the pagination logic needs access to
|
10
|
+
# (such as how to create new pages)
|
11
|
+
#
|
12
|
+
class PatreonGenerator < Generator
|
13
|
+
# This generator is safe from arbitrary code execution.
|
14
|
+
safe true
|
15
|
+
|
16
|
+
# This generator should be passive with regard to its execution
|
17
|
+
priority :lowest
|
18
|
+
|
19
|
+
# Generate paginated pages if necessary (Default entry point)
|
20
|
+
# site - The Site.
|
21
|
+
#
|
22
|
+
# Returns nothing.
|
23
|
+
def generate(site)
|
24
|
+
#begin
|
25
|
+
|
26
|
+
# Retrieve and merge the Patreon configuration from the site yml file
|
27
|
+
default_config = Jekyll::Utils.deep_merge_hashes(DEFAULT, site.config['patreon'] || {})
|
28
|
+
@@config = default_config
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.getConfig
|
32
|
+
@@config
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# Jekyll - Easy Patreon Embed
|
2
|
+
#
|
3
|
+
# z3nth10n - https://github.com/z3nth10n
|
4
|
+
# United Teamwork Association - https://github.com/uta-org
|
5
|
+
#
|
6
|
+
# Input:
|
7
|
+
# {% patreon z3nth10n %}
|
8
|
+
# Output: Patreon donation widget
|
9
|
+
|
10
|
+
require "jekyll-patreon/version"
|
11
|
+
require 'net/http'
|
12
|
+
|
13
|
+
module Jekyll
|
14
|
+
module Patreon::Tags
|
15
|
+
class PatreonTag < Liquid::Tag
|
16
|
+
PatreonWebsiteURL = "https://www.patreon.com/"
|
17
|
+
PatreonUserAPIURL = "https://api.patreon.com/user/"
|
18
|
+
|
19
|
+
@inc = nil
|
20
|
+
@username = nil
|
21
|
+
@PatreonID = nil
|
22
|
+
@config = nil
|
23
|
+
|
24
|
+
def initialize(tag_name, markup, tokens)
|
25
|
+
super
|
26
|
+
|
27
|
+
@inc = File.expand_path("../../_inc", __FILE__)
|
28
|
+
@username = markup.strip
|
29
|
+
@config = Jekyll::Patreon::Generator::PatreonGenerator.getConfig
|
30
|
+
end
|
31
|
+
|
32
|
+
def render(context)
|
33
|
+
unless @config['enabled']
|
34
|
+
return
|
35
|
+
end
|
36
|
+
|
37
|
+
if @PatreonID.nil?
|
38
|
+
@PatreonID = getPatreonID(@username)
|
39
|
+
end
|
40
|
+
|
41
|
+
json = Net::HTTP.get_response(URI.parse("#{PatreonUserAPIURL}#{@PatreonID}")).body.force_encoding('UTF-8').escape_json
|
42
|
+
|
43
|
+
source = "<script>" + File.read(File.join(@inc, "js", "patreon.js")) + "</script>"
|
44
|
+
source += File.read(File.join(@inc, "design_" + @config['design'] + ".html")).interpolate({ json: json, showgoaltext: @config['showgoaltext'], toptext: @config['toptext'], metercolor: @config['metercolor'], bottomtext: @config['bottomtext'], patreon_button: @config['patreon_button'] })
|
45
|
+
|
46
|
+
if @config['showbutton']
|
47
|
+
source += File.read(File.join(@inc, "button.html")).interpolate(pid: @PatreonID)
|
48
|
+
end
|
49
|
+
|
50
|
+
source += "<style>" + File.read(File.join(@inc, "css", "design_" + @config['design'] + ".css")) + "</style>"
|
51
|
+
source += "<style>" + File.read(File.join(@inc, "css", "common.css")) + "</style>"
|
52
|
+
|
53
|
+
source
|
54
|
+
end
|
55
|
+
|
56
|
+
def getPatreonID(username)
|
57
|
+
patreon_url = URI.encode("#{PatreonWebsiteURL}#{username}")
|
58
|
+
|
59
|
+
# Jekyll.logger.info "Patreon profile url:",patreon_url
|
60
|
+
patreon_source = Net::HTTP.get_response(URI.parse(patreon_url)).body.force_encoding('UTF-8').delete!("\r\n\\")
|
61
|
+
|
62
|
+
patreon_id_index = patreon_source.index("\"creator_id\": ")
|
63
|
+
|
64
|
+
unless patreon_id_index.nil?
|
65
|
+
|
66
|
+
patreon_id_index += 14
|
67
|
+
endidpos = patreon_source.from(patreon_id_index).index("\n")
|
68
|
+
|
69
|
+
if endidpos.nil?
|
70
|
+
endidpos = patreon_source.from(patreon_id_index).index("}")
|
71
|
+
end
|
72
|
+
|
73
|
+
if endidpos.nil?
|
74
|
+
raiseError()
|
75
|
+
end
|
76
|
+
|
77
|
+
patreon_id = patreon_source.from(patreon_id_index)[0, endidpos].strip
|
78
|
+
|
79
|
+
# Jekyll.logger.info "Patreon ID:",patreon_id
|
80
|
+
|
81
|
+
if patreon_id.nil?
|
82
|
+
raiseError()
|
83
|
+
end
|
84
|
+
|
85
|
+
return Integer(patreon_id)
|
86
|
+
end
|
87
|
+
|
88
|
+
return -1
|
89
|
+
end
|
90
|
+
|
91
|
+
def raiseError()
|
92
|
+
raise RuntimeError, "An error occurred getting the ID from your Patreon profile"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# Jekyll.logger.info "Patreon:","Test"
|
99
|
+
Liquid::Template.register_tag('patreon', Jekyll::Patreon::Tags::PatreonTag)
|