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 +4 -4
- data/README.md +2 -0
- data/lib/jekyll-crypto-donations/version.rb +1 -1
- data/lib/jekyll-crypto-donations.rb +101 -31
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92b4068f4fdac48c92aa24986a1c675e6c7edb3a855b6df6abf1c1595011fad3
|
4
|
+
data.tar.gz: cd5cf6d1cff184697d86d940f4c453e8e1d03ccb7b5cab6d106b0fcae010ff5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d3160fb73cd97ca22df47ea6cd60ba3e5a5ee6b1a806a41c3da7eafd52719d742f9a90fb888606f3c1d43102d262606c0c320be6a67b5ddc9e63965761120dc
|
7
|
+
data.tar.gz: 1dc4a9e9693f60c1fee59b78cb3771adbdce8c17ef033455cca20d8fcebd3dd88df5b9eb8ffb7a72a95facbd54f4c95c800a4eab4d468a33016258301e3f6ee0
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Jekyll::CryptoDonations 🤑
|
2
2
|
|
3
|
+
[](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.
|
@@ -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
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
-
|
47
|
-
|
48
|
-
const usdtAddress = '#{usdt_address}'
|
103
|
+
HTML
|
104
|
+
end
|
49
105
|
|
50
|
-
|
51
|
-
|
106
|
+
def closing_js
|
107
|
+
<<~JS
|
108
|
+
});
|
109
|
+
</script>
|
110
|
+
JS
|
111
|
+
end
|
52
112
|
|
53
|
-
|
54
|
-
|
113
|
+
def render(context)
|
114
|
+
site_config(context)
|
115
|
+
return if btc_address.nil? && eth_address.nil? && usdt_address.nil?
|
55
116
|
|
56
|
-
|
57
|
-
document.getElementById('eth-donations').innerText = `Total received: ${ethDonations} ETH`;
|
117
|
+
content = opening_html
|
58
118
|
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|