jekyll-crypto-donations 0.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.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +51 -0
- data/assets/js/crypto-donations/crypto-donations.js +52 -0
- data/lib/jekyll-crypto-donations/version.rb +7 -0
- data/lib/jekyll-crypto-donations.rb +74 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a5d5ea87cefd682c25c18bab453335ef3dc97aaf35c218cd77573e224bc311f1
|
4
|
+
data.tar.gz: 07d2b2de58ce62db995ad2274ee00476489cdaa55817a20e2608aef3540a8d8f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8489eee5de4ba22a6e47c8fa9244907f31318515942cafef6966620f46df9c3564b57e915a36129fdb2006853a45e3f92f743399b55c7060af3b70fee9ac0b20
|
7
|
+
data.tar.gz: eb967af2aab40612fc708deea2cccdce13091361c2a146a53f974f6f6b6ae189bb617e577879768885ee2a20db64f891b7d91b1725f73cdcf5512c0e6508f995
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Eugene Leontev
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# Jekyll::CryptoDonations 🤑
|
2
|
+
|
3
|
+
## About
|
4
|
+
|
5
|
+
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.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add to your Gemfile:
|
10
|
+
```ruby
|
11
|
+
group :jekyll_plugins do
|
12
|
+
gem 'jekyll-crypto-donations'
|
13
|
+
end
|
14
|
+
```
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
Add donation addresses to your `_config.yaml`
|
19
|
+
|
20
|
+
```yaml
|
21
|
+
crypto_donations:
|
22
|
+
btc_address: "YOUR_BTC_ADDRESS"
|
23
|
+
eth_address: "YOUR_ETH_ADDRESS"
|
24
|
+
usdt_address: "YOUR_USDT_TRC20_ADDRES"
|
25
|
+
```
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
Use NodeJS version 20 LTS
|
34
|
+
```bash
|
35
|
+
$ nvm use 20 --lts
|
36
|
+
```
|
37
|
+
install Typescrypt: `npm install typescript`
|
38
|
+
|
39
|
+
Do not change `assets/js/crypto-donations/crypto-donations.js` manually, make changes with TS at `src/crypto-donations/crypto-donations.ts` and then run:
|
40
|
+
```bash
|
41
|
+
$ npx tsc
|
42
|
+
```
|
43
|
+
local gem build: `gem build jekyll-crypto-donations.gemspec`
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/madmatvey/jekyll-crypto-donations.
|
48
|
+
|
49
|
+
## License
|
50
|
+
|
51
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -0,0 +1,52 @@
|
|
1
|
+
// assets/crypto-donations/crypto-donations.ts
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
function fetchCryptoData(url) {
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
13
|
+
const response = yield fetch(url);
|
14
|
+
return response.json();
|
15
|
+
});
|
16
|
+
}
|
17
|
+
export function getDonations(currency, address) {
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
19
|
+
try {
|
20
|
+
let response;
|
21
|
+
switch (currency) {
|
22
|
+
case 'btc':
|
23
|
+
const btcApiUrl = `https://api.blockcypher.com/v1/btc/main/addrs/${address}/balance`;
|
24
|
+
response = yield fetch(btcApiUrl);
|
25
|
+
if (!response.ok)
|
26
|
+
throw new Error('blockcypher api response was not ok');
|
27
|
+
const btcData = yield response.json();
|
28
|
+
return (btcData.total_received / 100000000).toFixed(8);
|
29
|
+
case 'eth':
|
30
|
+
const etcApiUrl = `https://api.ethplorer.io/getAddressInfo/${address}?apiKey=freekey`;
|
31
|
+
response = yield fetch(etcApiUrl);
|
32
|
+
if (!response.ok)
|
33
|
+
throw new Error('etherscan api response was not ok');
|
34
|
+
const ethData = yield response.json();
|
35
|
+
return (ethData.ETH.balance).toFixed(18);
|
36
|
+
case 'usdt':
|
37
|
+
response = yield fetch(`https://apilist.tronscan.org/api/account?address=${address}`);
|
38
|
+
if (!response.ok)
|
39
|
+
throw new Error('tronscan.org API response was not ok');
|
40
|
+
const usdtData = yield response.json();
|
41
|
+
const usdtToken = usdtData.trc20token_balances.find((token) => token.tokenAbbr === 'USDT');
|
42
|
+
return (usdtToken.balance / 1000000).toFixed(2); // Balance USDT
|
43
|
+
default:
|
44
|
+
throw new Error('Unsupported currency');
|
45
|
+
}
|
46
|
+
}
|
47
|
+
catch (error) {
|
48
|
+
console.error('Error fetching donation data:', error);
|
49
|
+
return '0.0';
|
50
|
+
}
|
51
|
+
});
|
52
|
+
}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "jekyll"
|
4
|
+
require "jekyll-crypto-donations/version"
|
5
|
+
# require "jekyll_crypto_donations/generator"
|
6
|
+
|
7
|
+
module Jekyll
|
8
|
+
module CryptoDonations
|
9
|
+
# describe {% crypto_donations %} tag content
|
10
|
+
class DonationsTag < Liquid::Tag
|
11
|
+
def initialize(tag_name, text, tokens)
|
12
|
+
super
|
13
|
+
@text = text
|
14
|
+
end
|
15
|
+
|
16
|
+
def render(context)
|
17
|
+
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")
|
21
|
+
|
22
|
+
<<~HTML
|
23
|
+
<div id="crypto-donations">
|
24
|
+
<h2>Support Us with Crypto Donations</h2>
|
25
|
+
<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>
|
41
|
+
</div>
|
42
|
+
<script type="module">
|
43
|
+
import { getDonations } from '/assets/js/crypto-donations/crypto-donations.js';
|
44
|
+
|
45
|
+
document.addEventListener('DOMContentLoaded', async () => {
|
46
|
+
const btcAddress = '#{btc_address}';
|
47
|
+
const ethAddress = '#{eth_address}';
|
48
|
+
const usdtAddress = '#{usdt_address}'
|
49
|
+
|
50
|
+
const usdtDonations = await getDonations('usdt', usdtAddress);
|
51
|
+
document.getElementById('usdt-donations').innerText = `Total received: ${usdtDonations} USDT`;
|
52
|
+
|
53
|
+
const btcDonations = await getDonations('btc', btcAddress);
|
54
|
+
document.getElementById('btc-donations').innerText = `Total received: ${btcDonations} BTC`;
|
55
|
+
|
56
|
+
const ethDonations = await getDonations('eth', ethAddress);
|
57
|
+
document.getElementById('eth-donations').innerText = `Total received: ${ethDonations} ETH`;
|
58
|
+
|
59
|
+
});
|
60
|
+
</script>
|
61
|
+
HTML
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
Liquid::Template.register_tag("crypto_donations", Jekyll::CryptoDonations::DonationsTag)
|
68
|
+
|
69
|
+
Jekyll::Hooks.register :site, :post_write do |site|
|
70
|
+
source = File.expand_path("../assets/js/crypto-donations/crypto-donations.js", __dir__)
|
71
|
+
destination = File.join(site.dest, "assets/js/crypto-donations/crypto-donations.js")
|
72
|
+
FileUtils.mkdir_p(File.dirname(destination))
|
73
|
+
FileUtils.cp(source, destination)
|
74
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-crypto-donations
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- madmatvey
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-06-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '13.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '13.0'
|
55
|
+
description: This plugin allows you to collect and display cryptocurrency donations
|
56
|
+
on your Jekyll site.
|
57
|
+
email:
|
58
|
+
- potehin@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files:
|
62
|
+
- README.md
|
63
|
+
- LICENSE
|
64
|
+
files:
|
65
|
+
- LICENSE
|
66
|
+
- README.md
|
67
|
+
- assets/js/crypto-donations/crypto-donations.js
|
68
|
+
- lib/jekyll-crypto-donations.rb
|
69
|
+
- lib/jekyll-crypto-donations/version.rb
|
70
|
+
homepage: https://github.com/madmatvey/jekyll-crypto-donations
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata:
|
74
|
+
homepage_uri: https://github.com/madmatvey/jekyll-crypto-donations
|
75
|
+
source_code_uri: https://github.com/madmatvey/jekyll-crypto-donations.git
|
76
|
+
changelog_uri: https://github.com/madmatvey/jekyll-crypto-donations/blob/master/CHANGELOG.md
|
77
|
+
rubygems_mfa_required: 'true'
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 2.6.0
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubygems_version: 3.2.3
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: A Jekyll plugin for crypto donations
|
97
|
+
test_files: []
|