jekyll-patreon 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,115 @@
1
+ # jekyll-patreon [![Build Status](https://travis-ci.org/uta-org/jekyll-patreon.svg?branch=master)](https://travis-ci.org/uta-org/jekyll-patreon) [![Gem Version](https://badge.fury.io/rb/jekyll-patreon.svg)](http://badge.fury.io/rb/jekyll-patreon)
2
+
3
+ Requires Ruby 2.5+ and Jekyll 3.8+
4
+
5
+ > A Jekyll plugins that adds Patreon support in your blog to easily embed a widget with goals
6
+
7
+ ## Features
8
+
9
+ * Supports several designs: default, fancy, minimal, streamlined, reversed, swapped
10
+ * Supports several colors: red, green, orange, red nostripes, green nostripes, orange nostripes, blue nostripes
11
+ * Supports i18n (compatible with [jekyll-language-plugin](https://github.com/vwochnik/jekyll-language-plugin))
12
+ * Supports Markdown on your Patreon goals
13
+
14
+ > To see the possible styles && designs navigate to the assets folder where the screenshots are located
15
+
16
+ ## Installation
17
+
18
+ Add this line to your site's Gemfile:
19
+
20
+ ```ruby
21
+ gem 'jekyll-patreon'
22
+ ```
23
+
24
+ Add this configuration to your _config.yml file:
25
+
26
+ ```yaml
27
+ ####################
28
+ # Patreon Settings #
29
+ ####################
30
+
31
+ patreon:
32
+ enabled: true
33
+ design: 'default' # Supports the following desings: default, fancy, minimal, streamlined, reversed, swapped
34
+ title: 'Example title'
35
+ metercolor: 'green' # Supports the following colors: red, green, orange, red nostripes, green nostripes, orange nostripes, blue nostripes
36
+ toptext: 'Example top text' # Text that appears in before the progress bar (optional)
37
+ bottomtext: 'Example bottom text' # Text that appears in after the progress bar (optional)
38
+ showgoaltext: true # Display the goal text?
39
+ showbutton: true # Display the "Become a patron" button?
40
+ username: 'Your username here'
41
+ default_lang: "en" # The default language to use (to avoid writing twice the same text from Patreon)
42
+ ```
43
+
44
+ ## Usage
45
+
46
+ Simply just put the following tag where you need this:
47
+
48
+ `{% patreon %}`
49
+
50
+ ### i18n
51
+
52
+ To support languages just use [jekyll-language-plugin](https://github.com/vwochnik/jekyll-language-plugin) configuration. Or if you don't use it, do the following steps.
53
+
54
+ First, in your main index.html (or wherever you need the i18n support) declare the following lines:
55
+
56
+ ```yaml
57
+ ---
58
+ layout: <layout>
59
+ language: en
60
+ ---
61
+ ```
62
+
63
+ Or if you want to support several languages in the same page:
64
+
65
+ ```yaml
66
+ ---
67
+ layout: <layout>
68
+ languages:
69
+ - en
70
+ - es
71
+ ---
72
+ ```
73
+
74
+ Then, in "_data/lang/" create one file for each lang.
75
+
76
+ > Example: `en.yml` and `es.yml`.
77
+
78
+ Then, put the translations of you goals like this:
79
+
80
+ ```yaml
81
+ #################
82
+ # Patreon Goals #
83
+ #################
84
+
85
+ patreon_goal_0: "..."
86
+ patreon_goal_1: "..."
87
+ patreon_goal_2: "..."
88
+ # etc etc...
89
+ ```
90
+
91
+ There you will need to create as much translations as the number of goals that your Patreon page have. (**Note:** starting index is 0 (zero))
92
+
93
+ ## Issues
94
+
95
+ Having issues? Just report in [the issue section](https://github.com/uta-org/jekyll-patreon/issues). **Thanks for the feedback!**
96
+
97
+ ## Contribute
98
+
99
+ Fork this repository, make your changes and then issue a pull request. If you find bugs or have new ideas that you do not want to implement yourself, file a bug report.
100
+
101
+ ## Donate
102
+
103
+ Become a patron, by simply clicking on this button (**very appreciated!**):
104
+
105
+ [![](https://c5.patreon.com/external/logo/become_a_patron_button.png)](https://www.patreon.com/z3nth10n)
106
+
107
+ ... Or if you prefer an one-time donation:
108
+
109
+ [![](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://paypal.me/z3nth10n)
110
+
111
+ ## Copyright
112
+
113
+ Copyright (c) 2019 z3nth10n (United Teamwork Association).
114
+
115
+ License: MIT
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -9,6 +9,8 @@ require "jekyll-patreon/version"
9
9
  # Files needed for the widget generator
10
10
  require "jekyll-patreon/generator/defaults"
11
11
  require "jekyll-patreon/generator/patreonGenerator"
12
+ # Files needed for parsing
13
+ require "jekyll-patreon/parsers/patreonParser"
12
14
  # Files needed for displaying the widget
13
15
  require "jekyll-patreon/tags/patreonTag"
14
16
 
@@ -67,7 +67,8 @@ var patreon = {
67
67
  {
68
68
  pledgeSum = Math.floor(this.GetPledgeSum(campaignData));
69
69
 
70
- $("#patreon_paypername").html("per " + campaignData.pay_per_name);
70
+ var payper = campaignData.pay_per_name;
71
+ $("#patreon_paypername").html("#{per} " + (payper == "month" ? "#{month}" : "#{patrons}"));
71
72
  }
72
73
 
73
74
  if (goalData)
@@ -75,20 +76,18 @@ var patreon = {
75
76
  goalTotal = Math.floor(this.GetGoalTotal(goalData));
76
77
 
77
78
  if (patreonShowGoalText)
78
- {
79
79
  $("#patreon_goaltext").html(goalData.description);
80
- }
81
80
  }
82
81
 
83
82
  if (pledgeSum < goalTotal)
84
83
  {
85
- $("#patreon_goalmoneytext").html("$" + pledgeSum + " of $" + goalTotal);
84
+ $("#patreon_goalmoneytext").html("$" + pledgeSum + " #{of} $" + goalTotal);
86
85
  $("#patreon_goalreached").html("");
87
86
  }
88
87
  else
89
88
  {
90
89
  $("#patreon_goalmoneytext").html("$" + goalTotal);
91
- $("#patreon_goalreached").html("- reached!");
90
+ $("#patreon_goalreached").html("- #{reached}");
92
91
  }
93
92
  },
94
93
  CreateDummyGoal: function(campaignData) {
@@ -0,0 +1,140 @@
1
+ <link href="https://c5.patreon.com/external/fonts/gt-america.css" rel="stylesheet" type="text/css">
2
+ <link href="https://c6.patreon.com/widget.css" rel="stylesheet" type="text/css">
3
+ <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Lato:400,100,100italic,300,300italic,400italic,500,700,700italic,900,900italic">
4
+
5
+ <style>
6
+ ._2KV-widgets-shared--patreonWidgetWrapper {
7
+ -webkit-font-smoothing: antialiased;
8
+ -moz-osx-font-smoothing: grayscale;
9
+ text-rendering: optimizeLegibility;
10
+ }
11
+
12
+ .hNJHmD:active {
13
+ background-color: rgb(229, 72, 49);
14
+ }
15
+
16
+ .hNJHmD:hover {
17
+ background-color: rgb(231, 81, 59);
18
+ }
19
+
20
+ .hNJHmD {
21
+ backface-visibility: hidden;
22
+ background-color: rgb(232, 91, 70);
23
+ box-sizing: border-box;
24
+ cursor: pointer;
25
+ display: inline-block;
26
+ font-weight: 500;
27
+ position: relative;
28
+ pointer-events: unset;
29
+ text-align: center;
30
+ text-transform: none;
31
+ user-select: none;
32
+ white-space: unset;
33
+ width: 100%;
34
+ color: rgb(255, 255, 255) !important;
35
+ font-size: 0.875rem !important;
36
+ border-radius: 9999px;
37
+ border-width: initial;
38
+ border-style: none;
39
+ border-color: initial;
40
+ border-image: initial;
41
+ padding: 0.5rem 0.75rem;
42
+ text-decoration: none;
43
+ transition: all 300ms cubic-bezier(0.19, 1, 0.22, 1) 0s;
44
+ }
45
+
46
+ .bDCJxk {
47
+ -webkit-box-align: center;
48
+ align-items: center;
49
+ box-sizing: border-box;
50
+ display: flex;
51
+ -webkit-box-pack: center;
52
+ justify-content: center;
53
+ padding-top: 0rem;
54
+ padding-right: 0rem;
55
+ padding-bottom: 0rem;
56
+ padding-left: 0rem;
57
+ margin-top: 0rem;
58
+ margin-right: 0rem;
59
+ margin-bottom: 0rem;
60
+ margin-left: 0rem;
61
+ visibility: visible;
62
+ transition: all 300ms cubic-bezier(0.19, 1, 0.22, 1) 0s;
63
+ }
64
+
65
+ .hnTNrw {
66
+ align-self: center;
67
+ -webkit-box-align: center;
68
+ align-items: center;
69
+ display: inline-flex;
70
+ filter: none;
71
+ cursor: unset;
72
+ vertical-align: unset;
73
+ height: unset;
74
+ width: unset;
75
+ }
76
+
77
+ .gBDeVU {
78
+ width: 0.75rem;
79
+ height: 1px;
80
+ }
81
+
82
+ .ZmzLr, .ZmzLr svg {
83
+ height: 12px;
84
+ width: 12px;
85
+ }
86
+
87
+ .ZmzLr {
88
+ display: flex;
89
+ }
90
+
91
+ .ZmzLr svg {
92
+ align-self: center;
93
+ fill: transparent;
94
+ stroke-width: 1.2px;
95
+ }
96
+
97
+ .ZmzLr svg * {
98
+ vector-effect: non-scaling-stroke;
99
+ transition: all 300ms cubic-bezier(0.19, 1, 0.22, 1) 0s;
100
+ }
101
+
102
+ .ZmzLr svg [data-color="1"], .ZmzLr svg [data-fill="1"] {
103
+ fill: rgb(255, 255, 255);
104
+ }
105
+
106
+ .ZmzLr svg [data-color="2"], .ZmzLr svg [data-fill="2"] {
107
+ fill: rgb(5, 45, 73);
108
+ }
109
+
110
+ .button-text {
111
+ font-family: 'America', 'GT America', 'Lato', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
112
+ font-size: 16px;
113
+ color: white;
114
+ }
115
+ </style>
116
+
117
+ <div>
118
+ <div class="_2KV-widgets-shared--patreonWidgetWrapper">
119
+ <div class="">
120
+ <div class="s16n3jhk-0 cTHxSM">
121
+ <a color="primary" class="sc-hMqMXs hNJHmD" tabindex="0" type="button" href="" role="button" target="_blank">
122
+ <div display="flex" class="sc-cSHVUG bDCJxk">
123
+ <div class="sc-ckVGcZ hnTNrw"><span class="sc-dxgOiQ ZmzLr"><svg viewBox="0 0 569 546" xmlns="http://www.w3.org/2000/svg"><g><circle data-fill="1" id="Oval" cx="362.589996" cy="204.589996" r="204.589996"></circle><rect data-fill="2" id="Rectangle" x="0" y="0" width="100" height="545.799988"></rect></g></svg></span></div>
124
+ <div class="sc-hSdWYo gBDeVU"></div>
125
+ <div class="button-text">#{caption}</div>
126
+ </div>
127
+ </a>
128
+ <script>
129
+ // https://www.patreon.com/bePatron?u=18277220&amp;redirect_uri=http%3A%2F%2F127.0.0.1%3A4000%2Fes%2F&amp;utm_medium=widget
130
+ // $(document).ready(function() { $(".sc-hMqMXs.hNJHmD").attr("href", "https://www.patreon.com/bePatron?u=#{pid}&amp;redirect_uri=" + escape(window.location.href) + "&amp;utm_medium=widget"); });
131
+
132
+ document.addEventListener("DOMContentLoaded", function(event) {
133
+ var url = "https://www.patreon.com/bePatron?u=#{pid}&amp;redirect_uri=" + escape(window.location.href) + "&amp;utm_medium=widget";
134
+ document.getElementsByClassName("sc-hMqMXs")[0].setAttribute("href", url);
135
+ });
136
+ </script>
137
+ </div>
138
+ </div>
139
+ </div>
140
+ </div>
@@ -10,7 +10,9 @@ module Jekyll
10
10
  'toptext' => "", # Text that appears in before the progress bar
11
11
  'bottomtext' => "", # Text that appears in after the progress bar
12
12
  'showgoaltext' => true,
13
- 'showbutton' => false
13
+ 'showbutton' => false,
14
+ 'username' => 'z3nth10n',
15
+ 'default_lang' => "en"
14
16
  }
15
17
 
16
18
  end # module Patreon
@@ -1,8 +1,5 @@
1
1
  module Jekyll
2
- module Patreon::Generator
3
-
4
- @@config = nil
5
-
2
+ module Patreon::Generator
6
3
  #
7
4
  # The main entry point into the generator, called by Jekyll
8
5
  # this function extracts all the necessary information from the jekyll end and passes it into the pagination
@@ -10,6 +7,17 @@ module Jekyll
10
7
  # (such as how to create new pages)
11
8
  #
12
9
  class PatreonGenerator < Generator
10
+ # The constants
11
+
12
+ PatreonWebsiteURL = "https://www.patreon.com/"
13
+ PatreonUserAPIURL = "https://api.patreon.com/user/"
14
+
15
+ # The vars
16
+
17
+ @@config ||= nil
18
+ @@PatreonID ||= nil
19
+ @@json ||= nil
20
+
13
21
  # This generator is safe from arbitrary code execution.
14
22
  safe true
15
23
 
@@ -22,15 +30,85 @@ module Jekyll
22
30
  # Returns nothing.
23
31
  def generate(site)
24
32
  #begin
33
+
34
+ Jekyll.logger.info "Patreon:","Initializating"
35
+
36
+ start = Time.now
25
37
 
26
38
  # Retrieve and merge the Patreon configuration from the site yml file
27
39
  default_config = Jekyll::Utils.deep_merge_hashes(DEFAULT, site.config['patreon'] || {})
28
40
  @@config = default_config
41
+
42
+ username = @@config["username"]
43
+
44
+ if username.nil?
45
+ username = "z3nth10n"
46
+ end
47
+
48
+ if @@PatreonID.nil?
49
+ @@PatreonID = internalGetPatreonID(username)
50
+ else
51
+ infoSpended(start)
52
+ return
53
+ end
54
+
55
+ # Jekyll.logger.info "Patreon lang:",@config['lang']
56
+
57
+ @@json = Net::HTTP.get_response(URI.parse("#{PatreonUserAPIURL}#{@@PatreonID}")).body.force_encoding('UTF-8')
58
+ infoSpended(start)
59
+ end
60
+
61
+ def infoSpended(start)
62
+ spended = Time.now - start
63
+ Jekyll.logger.info "Patreon:", "Initialized in #{spended} seconds"
64
+ end
65
+
66
+ def internalGetPatreonID(username)
67
+ patreon_url = URI.encode("#{PatreonWebsiteURL}#{username}")
68
+
69
+ # Jekyll.logger.info "Patreon profile url:",patreon_url
70
+ patreon_source = Net::HTTP.get_response(URI.parse(patreon_url)).body.force_encoding('UTF-8').delete!("\r\n\\")
71
+
72
+ patreon_id_index = patreon_source.index("\"creator_id\": ")
73
+
74
+ unless patreon_id_index.nil?
75
+
76
+ patreon_id_index += 14
77
+ endidpos = patreon_source.from(patreon_id_index).index("\n")
78
+
79
+ if endidpos.nil?
80
+ endidpos = patreon_source.from(patreon_id_index).index("}")
81
+ end
82
+
83
+ if endidpos.nil?
84
+ raiseError()
85
+ end
86
+
87
+ patreon_id = patreon_source.from(patreon_id_index)[0, endidpos].strip
88
+
89
+ # Jekyll.logger.info "Patreon ID:",patreon_id
90
+
91
+ if patreon_id.nil?
92
+ raiseError()
93
+ end
94
+
95
+ return Integer(patreon_id)
96
+ end
97
+
98
+ return -1
29
99
  end
30
100
 
31
101
  def self.getConfig
32
102
  @@config
33
103
  end
104
+
105
+ def self.getPatreonID
106
+ @@PatreonID
107
+ end
108
+
109
+ def self.getJSON
110
+ @@json
111
+ end
34
112
  end
35
113
  end
36
114
  end
@@ -0,0 +1,8 @@
1
+ # Static translations for this plugins
2
+
3
+ per: "per"
4
+ month: "month"
5
+ patrons: "patrons"
6
+ of: "of"
7
+ reached: "reached!"
8
+ caption: "Become a patron"
@@ -0,0 +1,8 @@
1
+ # Static translations for this plugins
2
+
3
+ per: "por"
4
+ month: "mes"
5
+ patrons: "patreons"
6
+ of: "de"
7
+ reached: "¡conseguido!"
8
+ caption: "¡Suscríbete a mi patreon!"