Skip to content

Commit

Permalink
Initialize gem (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
madmatvey authored Jun 7, 2024
1 parent 19fcb88 commit da22a43
Show file tree
Hide file tree
Showing 23 changed files with 587 additions and 5 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/main.yml
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
13 changes: 13 additions & 0 deletions .gitignore
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/
3 changes: 3 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--format documentation
--color
--require spec_helper
17 changes: 17 additions & 0 deletions .rubocop.yml
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## [Unreleased]

## [0.1.0] - 2024-06-06

- Initial release
12 changes: 12 additions & 0 deletions Gemfile
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"
122 changes: 122 additions & 0 deletions Gemfile.lock
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
10 changes: 5 additions & 5 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MIT License
The MIT License (MIT)

Copyright (c) 2024 Eugene Leontev

Expand All @@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
51 changes: 51 additions & 0 deletions README.md
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).
12 changes: 12 additions & 0 deletions Rakefile
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]
18 changes: 18 additions & 0 deletions _includes/crypto_donations.html
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>
52 changes: 52 additions & 0 deletions assets/js/crypto-donations/crypto-donations.js
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';
}
});
}
15 changes: 15 additions & 0 deletions bin/console
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__)
8 changes: 8 additions & 0 deletions bin/setup
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
Loading

0 comments on commit da22a43

Please sign in to comment.