-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
587 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Ruby | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
name: Ruby ${{ matrix.ruby }} | ||
strategy: | ||
matrix: | ||
ruby: | ||
- '2.6.5' | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: ${{ matrix.ruby }} | ||
bundler-cache: true | ||
- name: Run the default task | ||
run: bundle exec rake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/.bundle/ | ||
/.yardoc | ||
/_yardoc/ | ||
/coverage/ | ||
/doc/ | ||
/pkg/ | ||
/spec/reports/ | ||
/tmp/ | ||
|
||
# rspec failure tracking | ||
.rspec_status | ||
*.gem | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--format documentation | ||
--color | ||
--require spec_helper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
AllCops: | ||
TargetRubyVersion: 2.6 | ||
NewCops: enable | ||
|
||
Style/StringLiterals: | ||
Enabled: true | ||
EnforcedStyle: double_quotes | ||
|
||
Style/StringLiteralsInInterpolation: | ||
Enabled: true | ||
EnforcedStyle: double_quotes | ||
|
||
Layout/LineLength: | ||
Max: 120 | ||
|
||
Naming/FileName: | ||
Enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## [Unreleased] | ||
|
||
## [0.1.0] - 2024-06-06 | ||
|
||
- Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
source "https://rubygems.org" | ||
|
||
# Specify your gem's dependencies in jekyll-crypto-donations.gemspec | ||
gemspec | ||
|
||
gem "rake", "~> 13.0" | ||
|
||
gem "rspec", "~> 3.0" | ||
|
||
gem "rubocop", "~> 1.21" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
jekyll-crypto-donations (0.1.0) | ||
jekyll (~> 4.3) | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
addressable (2.8.6) | ||
public_suffix (>= 2.0.2, < 6.0) | ||
ast (2.4.2) | ||
colorator (1.1.0) | ||
concurrent-ruby (1.3.1) | ||
diff-lcs (1.5.1) | ||
em-websocket (0.5.3) | ||
eventmachine (>= 0.12.9) | ||
http_parser.rb (~> 0) | ||
eventmachine (1.2.7) | ||
ffi (1.17.0) | ||
forwardable-extended (2.6.0) | ||
google-protobuf (3.23.4-x86_64-darwin) | ||
google-protobuf (3.23.4-x86_64-linux) | ||
http_parser.rb (0.8.0) | ||
i18n (1.14.5) | ||
concurrent-ruby (~> 1.0) | ||
jekyll (4.3.3) | ||
addressable (~> 2.4) | ||
colorator (~> 1.0) | ||
em-websocket (~> 0.5) | ||
i18n (~> 1.0) | ||
jekyll-sass-converter (>= 2.0, < 4.0) | ||
jekyll-watch (~> 2.0) | ||
kramdown (~> 2.3, >= 2.3.1) | ||
kramdown-parser-gfm (~> 1.0) | ||
liquid (~> 4.0) | ||
mercenary (>= 0.3.6, < 0.5) | ||
pathutil (~> 0.9) | ||
rouge (>= 3.0, < 5.0) | ||
safe_yaml (~> 1.0) | ||
terminal-table (>= 1.8, < 4.0) | ||
webrick (~> 1.7) | ||
jekyll-sass-converter (3.0.0) | ||
sass-embedded (~> 1.54) | ||
jekyll-watch (2.2.1) | ||
listen (~> 3.0) | ||
json (2.7.2) | ||
kramdown (2.4.0) | ||
rexml | ||
kramdown-parser-gfm (1.1.0) | ||
kramdown (~> 2.0) | ||
liquid (4.0.4) | ||
listen (3.9.0) | ||
rb-fsevent (~> 0.10, >= 0.10.3) | ||
rb-inotify (~> 0.9, >= 0.9.10) | ||
mercenary (0.4.0) | ||
parallel (1.24.0) | ||
parser (3.3.2.0) | ||
ast (~> 2.4.1) | ||
racc | ||
pathutil (0.16.2) | ||
forwardable-extended (~> 2.6) | ||
public_suffix (5.0.5) | ||
racc (1.8.0) | ||
rainbow (3.1.1) | ||
rake (13.2.1) | ||
rb-fsevent (0.11.2) | ||
rb-inotify (0.11.1) | ||
ffi (~> 1.0) | ||
regexp_parser (2.9.2) | ||
rexml (3.2.8) | ||
strscan (>= 3.0.9) | ||
rouge (3.30.0) | ||
rspec (3.13.0) | ||
rspec-core (~> 3.13.0) | ||
rspec-expectations (~> 3.13.0) | ||
rspec-mocks (~> 3.13.0) | ||
rspec-core (3.13.0) | ||
rspec-support (~> 3.13.0) | ||
rspec-expectations (3.13.0) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.13.0) | ||
rspec-mocks (3.13.1) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.13.0) | ||
rspec-support (3.13.1) | ||
rubocop (1.50.2) | ||
json (~> 2.3) | ||
parallel (~> 1.10) | ||
parser (>= 3.2.0.0) | ||
rainbow (>= 2.2.2, < 4.0) | ||
regexp_parser (>= 1.8, < 3.0) | ||
rexml (>= 3.2.5, < 4.0) | ||
rubocop-ast (>= 1.28.0, < 2.0) | ||
ruby-progressbar (~> 1.7) | ||
unicode-display_width (>= 2.4.0, < 3.0) | ||
rubocop-ast (1.30.0) | ||
parser (>= 3.2.1.0) | ||
ruby-progressbar (1.13.0) | ||
safe_yaml (1.0.5) | ||
sass-embedded (1.58.3) | ||
google-protobuf (~> 3.21) | ||
rake (>= 10.0.0) | ||
strscan (3.1.0) | ||
terminal-table (3.0.2) | ||
unicode-display_width (>= 1.1.1, < 3) | ||
unicode-display_width (2.5.0) | ||
webrick (1.8.1) | ||
|
||
PLATFORMS | ||
x86_64-darwin-21 | ||
x86_64-linux | ||
|
||
DEPENDENCIES | ||
bundler (~> 2.0) | ||
jekyll-crypto-donations! | ||
rake (~> 13.0) | ||
rspec (~> 3.0) | ||
rubocop (~> 1.21) | ||
|
||
BUNDLED WITH | ||
2.4.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Jekyll::CryptoDonations 🤑 | ||
|
||
## About | ||
|
||
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. | ||
|
||
## Installation | ||
|
||
Add to your Gemfile: | ||
```ruby | ||
group :jekyll_plugins do | ||
gem 'jekyll-crypto-donations' | ||
end | ||
``` | ||
|
||
## Usage | ||
|
||
Add donation addresses to your `_config.yaml` | ||
|
||
```yaml | ||
crypto_donations: | ||
btc_address: "YOUR_BTC_ADDRESS" | ||
eth_address: "YOUR_ETH_ADDRESS" | ||
usdt_address: "YOUR_USDT_TRC20_ADDRES" | ||
``` | ||
## Development | ||
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. | ||
|
||
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). | ||
|
||
Use NodeJS version 20 LTS | ||
```bash | ||
$ nvm use 20 --lts | ||
``` | ||
install Typescrypt: `npm install typescript` | ||
|
||
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: | ||
```bash | ||
$ npx tsc | ||
``` | ||
local gem build: `gem build jekyll-crypto-donations.gemspec` | ||
|
||
## Contributing | ||
|
||
Bug reports and pull requests are welcome on GitHub at https://github.com/madmatvey/jekyll-crypto-donations. | ||
|
||
## License | ||
|
||
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
require "bundler/gem_tasks" | ||
require "rspec/core/rake_task" | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
require "rubocop/rake_task" | ||
|
||
RuboCop::RakeTask.new | ||
|
||
task default: %i[spec rubocop] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!-- _includes/crypto_donations.html --> | ||
<div class="crypto-donations"> | ||
<h2>Support us with crypto-donations</h2> | ||
<p>Already :</p> | ||
<ul> | ||
<li>Bitcoin: <span id="btc-donations">0.00000000</span> BTC</li> | ||
<li>Ethereum: <span id="eth-donations">0.00000000</span> ETH</li> | ||
<li>Monero: <span id="xmr-donations">0.00000000</span> XMR</li> | ||
<li>USDT (TRC-20): <span id="usdt-donations">0.00</span> USDT</li> | ||
</ul> | ||
<p>Отправьте донат:</p> | ||
<ul> | ||
<li>Bitcoin: <img src="https://chart.googleapis.com/chart?chs=200x200&cht=qr&chl=bitcoin:YOUR_BITCOIN_ADDRESS" alt="Bitcoin QR Code"></li> | ||
<li>Ethereum: <img src="https://chart.googleapis.com/chart?chs=200x200&cht=qr&chl=ethereum:YOUR_ETHEREUM_ADDRESS" alt="Ethereum QR Code"></li> | ||
<li>Monero: <img src="https://chart.googleapis.com/chart?chs=200x200&cht=qr&chl=monero:YOUR_MONERO_ADDRESS" alt="Monero QR Code"></li> | ||
<li>USDT (TRC-20): <img src="https://chart.googleapis.com/chart?chs=200x200&cht=qr&chl=trc20:YOUR_USDT_ADDRESS" alt="USDT QR Code"></li> | ||
</ul> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// assets/crypto-donations/crypto-donations.ts | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
function fetchCryptoData(url) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const response = yield fetch(url); | ||
return response.json(); | ||
}); | ||
} | ||
export function getDonations(currency, address) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
let response; | ||
switch (currency) { | ||
case 'btc': | ||
const btcApiUrl = `https://api.blockcypher.com/v1/btc/main/addrs/${address}/balance`; | ||
response = yield fetch(btcApiUrl); | ||
if (!response.ok) | ||
throw new Error('blockcypher api response was not ok'); | ||
const btcData = yield response.json(); | ||
return (btcData.total_received / 100000000).toFixed(8); | ||
case 'eth': | ||
const etcApiUrl = `https://api.ethplorer.io/getAddressInfo/${address}?apiKey=freekey`; | ||
response = yield fetch(etcApiUrl); | ||
if (!response.ok) | ||
throw new Error('etherscan api response was not ok'); | ||
const ethData = yield response.json(); | ||
return (ethData.ETH.balance).toFixed(18); | ||
case 'usdt': | ||
response = yield fetch(`https://apilist.tronscan.org/api/account?address=${address}`); | ||
if (!response.ok) | ||
throw new Error('tronscan.org API response was not ok'); | ||
const usdtData = yield response.json(); | ||
const usdtToken = usdtData.trc20token_balances.find((token) => token.tokenAbbr === 'USDT'); | ||
return (usdtToken.balance / 1000000).toFixed(2); // Balance USDT | ||
default: | ||
throw new Error('Unsupported currency'); | ||
} | ||
} | ||
catch (error) { | ||
console.error('Error fetching donation data:', error); | ||
return '0.0'; | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env ruby | ||
# frozen_string_literal: true | ||
|
||
require "bundler/setup" | ||
require "jekyll_crypto_donations" | ||
|
||
# You can add fixtures and/or initialization code here to make experimenting | ||
# with your gem easier. You can also use a different console, if you like. | ||
|
||
# (If you use this, don't forget to add pry to your Gemfile!) | ||
# require "pry" | ||
# Pry.start | ||
|
||
require "irb" | ||
IRB.start(__FILE__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
set -vx | ||
|
||
bundle install | ||
|
||
# Do any other automated setup that you need to do here |
Oops, something went wrong.