jekyll-crypto-donations 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5d5ea87cefd682c25c18bab453335ef3dc97aaf35c218cd77573e224bc311f1
4
- data.tar.gz: 07d2b2de58ce62db995ad2274ee00476489cdaa55817a20e2608aef3540a8d8f
3
+ metadata.gz: 92b4068f4fdac48c92aa24986a1c675e6c7edb3a855b6df6abf1c1595011fad3
4
+ data.tar.gz: cd5cf6d1cff184697d86d940f4c453e8e1d03ccb7b5cab6d106b0fcae010ff5a
5
5
  SHA512:
6
- metadata.gz: 8489eee5de4ba22a6e47c8fa9244907f31318515942cafef6966620f46df9c3564b57e915a36129fdb2006853a45e3f92f743399b55c7060af3b70fee9ac0b20
7
- data.tar.gz: eb967af2aab40612fc708deea2cccdce13091361c2a146a53f974f6f6b6ae189bb617e577879768885ee2a20db64f891b7d91b1725f73cdcf5512c0e6508f995
6
+ metadata.gz: 6d3160fb73cd97ca22df47ea6cd60ba3e5a5ee6b1a806a41c3da7eafd52719d742f9a90fb888606f3c1d43102d262606c0c320be6a67b5ddc9e63965761120dc
7
+ data.tar.gz: 1dc4a9e9693f60c1fee59b78cb3771adbdce8c17ef033455cca20d8fcebd3dd88df5b9eb8ffb7a72a95facbd54f4c95c800a4eab4d468a33016258301e3f6ee0
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Jekyll::CryptoDonations 🤑
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/jekyll-crypto-donations.svg)](https://badge.fury.io/rb/jekyll-crypto-donations)
4
+
3
5
  ## About
4
6
 
5
7
  The **Jekyll Crypto Donations** plugin is a simple and efficient solution for integrating cryptocurrency donations into Jekyll-generated websites. In the initial iteration, the plugin supports Bitcoin (BTC), Ethereum (ETH), and USDT (TRC-20). It allows website owners to display current donation amounts and provide easy access for visitors to contribute using these cryptocurrencies. The plugin is designed to be easy to install and configure, making it a seamless addition to any Jekyll site. By leveraging real-time API calls, it ensures that the displayed donation amounts are always up-to-date, providing transparency and encouraging more contributions.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module CryptoDonations
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.1"
6
6
  end
7
7
  end
@@ -8,57 +8,127 @@ module Jekyll
8
8
  module CryptoDonations
9
9
  # describe {% crypto_donations %} tag content
10
10
  class DonationsTag < Liquid::Tag
11
+ attr_reader :btc_address, :eth_address, :usdt_address
12
+
11
13
  def initialize(tag_name, text, tokens)
12
14
  super
13
15
  @text = text
14
16
  end
15
17
 
16
- def render(context)
18
+ def btc_html
19
+ return "" unless btc_address
20
+
21
+ <<~HTML
22
+ <div>
23
+ <h3>Bitcoin (BTC)</h3>
24
+ <p>Address: #{btc_address}</p>
25
+ <p id="btc-donations">Loading...</p>
26
+ </div>
27
+ HTML
28
+ end
29
+
30
+ def eth_html
31
+ return "" unless eth_address
32
+
33
+ <<~HTML
34
+ <div>
35
+ <h3>Ethereum (ETH)</h3>
36
+ <p>Address: #{eth_address}</p>
37
+ <p id="eth-donations">Loading...</p>
38
+ </div>
39
+ HTML
40
+ end
41
+
42
+ def usdt_html
43
+ return "" unless usdt_address
44
+
45
+ <<~HTML
46
+ <div>
47
+ <h3>USDT (TRC-20)</h3>
48
+ <p>Address: #{usdt_address}</p>
49
+ <p id="usdt-donations">Loading...</p>
50
+ </div>
51
+ HTML
52
+ end
53
+
54
+ def btc_js
55
+ return "" unless btc_address
56
+
57
+ <<~JS
58
+ const btcDonations = await getDonations('btc', '#{btc_address}');
59
+ document.getElementById('btc-donations').innerText = `Total received: ${btcDonations} BTC`;
60
+ JS
61
+ end
62
+
63
+ def eth_js
64
+ return "" unless eth_address
65
+
66
+ <<~JS
67
+ const ethDonations = await getDonations('eth', '#{eth_address}');
68
+ document.getElementById('eth-donations').innerText = `Total received: ${ethDonations} ETH`;
69
+ JS
70
+ end
71
+
72
+ def usdt_js
73
+ return "" unless usdt_address
74
+
75
+ <<~JS
76
+ const usdtDonations = await getDonations('usdt', '#{usdt_address}');
77
+ document.getElementById('usdt-donations').innerText = `Total received: ${usdtDonations} USDT`;
78
+ JS
79
+ end
80
+
81
+ def site_config(context)
17
82
  site_config = context.registers.fetch(:site).config
18
- btc_address = site_config.dig("crypto_donations", "btc_address")
19
- eth_address = site_config.dig("crypto_donations", "eth_address")
20
- usdt_address = site_config.dig("crypto_donations", "usdt_address")
83
+ @btc_address = site_config.dig("crypto_donations", "btc_address")
84
+ @eth_address = site_config.dig("crypto_donations", "eth_address")
85
+ @usdt_address = site_config.dig("crypto_donations", "usdt_address")
86
+ end
21
87
 
88
+ def opening_html
22
89
  <<~HTML
23
90
  <div id="crypto-donations">
24
91
  <h2>Support Us with Crypto Donations</h2>
25
92
  <p>#{@text}</p>
26
- <div>
27
- <h3>Bitcoin (BTC)</h3>
28
- <p id="btc-address">#{btc_address}</p>
29
- <p id="btc-donations">Loading...</p>
30
- </div>
31
- <div>
32
- <h3>Ethereum (ETH)</h3>
33
- <p id="eth-address">#{eth_address}</p>
34
- <p id="eth-donations">Loading...</p>
35
- </div>
36
- <div>
37
- <h3>USDT (TRC-20)</h3>
38
- <p id="usdt-address">Address: #{usdt_address}</p>
39
- <p id="usdt-donations">Loading...</p>
40
- </div>
93
+ HTML
94
+ end
95
+
96
+ def closing_html
97
+ <<~HTML
41
98
  </div>
42
99
  <script type="module">
43
100
  import { getDonations } from '/assets/js/crypto-donations/crypto-donations.js';
44
101
 
45
102
  document.addEventListener('DOMContentLoaded', async () => {
46
- const btcAddress = '#{btc_address}';
47
- const ethAddress = '#{eth_address}';
48
- const usdtAddress = '#{usdt_address}'
103
+ HTML
104
+ end
49
105
 
50
- const usdtDonations = await getDonations('usdt', usdtAddress);
51
- document.getElementById('usdt-donations').innerText = `Total received: ${usdtDonations} USDT`;
106
+ def closing_js
107
+ <<~JS
108
+ });
109
+ </script>
110
+ JS
111
+ end
52
112
 
53
- const btcDonations = await getDonations('btc', btcAddress);
54
- document.getElementById('btc-donations').innerText = `Total received: ${btcDonations} BTC`;
113
+ def render(context)
114
+ site_config(context)
115
+ return if btc_address.nil? && eth_address.nil? && usdt_address.nil?
55
116
 
56
- const ethDonations = await getDonations('eth', ethAddress);
57
- document.getElementById('eth-donations').innerText = `Total received: ${ethDonations} ETH`;
117
+ content = opening_html
58
118
 
59
- });
60
- </script>
61
- HTML
119
+ content += btc_html
120
+ content += eth_html
121
+ content += usdt_html
122
+
123
+ content += closing_html
124
+
125
+ content += btc_js
126
+ content += eth_js
127
+ content += usdt_js
128
+
129
+ content += closing_js
130
+
131
+ content
62
132
  end
63
133
  end
64
134
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-crypto-donations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - madmatvey