mirror of
https://github.com/seigler/dash-docs
synced 2025-07-27 01:36:13 +00:00
Updating choose-your-wallet. Adds wallets page generator with translations.
This commit is contained in:
parent
c68f7ed7b5
commit
d206471809
3 changed files with 46 additions and 108 deletions
|
@ -3,6 +3,7 @@
|
|||
# http://opensource.org/licenses/MIT.
|
||||
|
||||
layout: wallet-platform-container
|
||||
max_wallet_text_length: 418 ## Unicode characters
|
||||
---
|
||||
|
||||
<div class="wallet">
|
||||
|
|
|
@ -6,7 +6,7 @@ require 'yaml'
|
|||
module Jekyll
|
||||
|
||||
class WalletPage < Page
|
||||
def initialize(site, base, dir, wallet, platform, os)
|
||||
def initialize(site, base, dir, wallet, platform, os, lang)
|
||||
@site = site
|
||||
@base = base
|
||||
@dir = dir
|
||||
|
@ -18,6 +18,7 @@ module Jekyll
|
|||
self.data['platform'] = platform
|
||||
self.data['os'] = os
|
||||
self.data['id'] = ['wallets', platform['name'], os['name'], wallet['id']].join('-')
|
||||
self.data['lang'] = lang
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -25,27 +26,61 @@ module Jekyll
|
|||
safe true
|
||||
|
||||
def generate(site)
|
||||
# Get the collection of wallets from _wallets
|
||||
walletsCol = site.collections['wallets'];
|
||||
|
||||
# Output dir
|
||||
# TODO: Make this configurable and "translatable"
|
||||
walletsDir = 'wallets'
|
||||
|
||||
# Loading translations.
|
||||
# Copy-paste from _plugins/templates.rb
|
||||
locs = {}
|
||||
enabled = ENV['ENABLED_LANGS'];
|
||||
enabled = enabled.split(' ') if !enabled.nil?
|
||||
Dir.foreach('_translations') do |file|
|
||||
next if file == '.' or file == '..' or file == 'COPYING'
|
||||
lang = file.split('.')[0]
|
||||
# Ignore language if it's disabled
|
||||
if lang != 'en' and !enabled.nil? and !enabled.include?(lang)
|
||||
puts('Lang ' + lang + ' disabled')
|
||||
next
|
||||
end
|
||||
locs[lang] = YAML.load_file("_translations/"+file)[lang]
|
||||
end
|
||||
|
||||
puts('----- Generating wallet pages -----')
|
||||
|
||||
# Getting information about each found wallet
|
||||
walletsCol.docs.each do |doc|
|
||||
file = doc.path
|
||||
wallet = YAML.load_file(file)
|
||||
walletPlatforms = wallet['platform']
|
||||
|
||||
puts('---------------------')
|
||||
puts(wallet['id'])
|
||||
puts(wallet['id'] + ' is loaded. Generating pages...')
|
||||
|
||||
# Going through all available combinations of
|
||||
# platforms and OSes
|
||||
walletPlatforms.each do |platform|
|
||||
platform['os'].each do |os|
|
||||
|
||||
# This allows generation only of valid wallet pages
|
||||
if platform['name']
|
||||
|
||||
locs.each do |lang,value|
|
||||
dir = File.join(platform['name'], os['name'], wallet['id'])
|
||||
site.pages << WalletPage.new(site, site.source, File.join('en', walletsDir, dir), wallet, platform, os)
|
||||
site.pages << WalletPage.new(site, site.source, File.join(lang, walletsDir, dir), wallet, platform, os, lang)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
puts(wallet['id'] + ' is processed.')
|
||||
end
|
||||
|
||||
puts('----- Wallet pages generated -----')
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -5,109 +5,11 @@
|
|||
# Definitions for the property checks below can be found here:
|
||||
# https://github.com/bitcoin-dot-org/bitcoin.org/blob/master/_translations/en.yml
|
||||
|
||||
layout: base
|
||||
layout: wallet-platform
|
||||
id: choose-your-wallet
|
||||
max_wallet_text_length: 418 ## Unicode characters
|
||||
|
||||
platform:
|
||||
name: desktop
|
||||
os:
|
||||
name: windows
|
||||
---
|
||||
|
||||
<!-- Note: this file exempt from check-for-subheading-anchors check -->
|
||||
|
||||
<h1>{% translate pagetitle %}</h1>
|
||||
<p class="summary">{% translate pagedesc %}</p>
|
||||
|
||||
<div class="walletmenu" id="walletmenu" onclick="walletMenuListener(event);" ontouchstart="walletMenuListener(event);">
|
||||
<ul>
|
||||
<li class="wallet-mobile">
|
||||
<a id="mobile" data-walletcompat="mobile">{% translate walletcatmobile %}</a>
|
||||
<ul>
|
||||
<li class="wallet-android"><a id="android" data-walletcompat="android">{% translate platformandroid %}</a></li>
|
||||
<li class="wallet-ios"><a id="ios" data-walletcompat="ios">{% translate platformios %}</a></li>
|
||||
<li class="wallet-windowsphone"><a id="windowsphone" data-walletcompat="windowsphone">{% translate platformwindowsphone %}</a></li>
|
||||
<li class="wallet-blackberry"><a id="blackberry" data-walletcompat="blackberry">{% translate platformblackberry %}</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="wallet-desktop">
|
||||
<a id="desktop" data-walletcompat="desktop">{% translate walletcatdesktop %}</a>
|
||||
<ul>
|
||||
<li class="wallet-windows"><a id="windows" data-walletcompat="windows">{% translate platformwindows %}</a></li>
|
||||
<li class="wallet-mac"><a id="mac" data-walletcompat="mac">{% translate platformmac %}</a></li>
|
||||
<li class="wallet-linux"><a id="linux" data-walletcompat="linux">{% translate platformlinux %}</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="wallet-hardware"><a id="hardware" data-walletcompat="hardware">{% translate walletcathardware %}</a></li>
|
||||
<li class="wallet-web"><a id="web" data-walletcompat="web">{% translate walletcatweb %}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="wallets" id="wallets" onclick="walletListener(event);" ontouchstart="walletListener(event);">
|
||||
{% for wallet in site.wallets %}{% for wallet in wallet %}{% if wallet[1].platform.mobile %}{% assign platform = wallet[1].platform.mobile %}{% elsif wallet[1].platform.desktop %}{% assign platform = wallet[1].platform.desktop %}{% elsif wallet[1].platform.hardware %}{% assign platform = wallet[1].platform.hardware %}{% else %}{% assign platform = wallet[1].platform.web %}{% endif %}
|
||||
<div id="wallet-{{ wallet[0] }}" data-walletcompat="{{ wallet[1].compat }}" data-walletlevel="{{ wallet[1].level }}">
|
||||
<span></span>
|
||||
<div>
|
||||
<h2>{{ wallet[1].title }}</h2>
|
||||
<div>{% for os in platform.os %}<img src="/img/os/{{ os }}.png" alt="{% translate platform{{os}} %}" title="{% translate platform{{os}} %}" />{% unless wallet[1].compat contains os %}{% die platform not listed in compat field %}{% endunless %}{% endfor %}</div>
|
||||
<div>{% if platform.link == 'bitcoincore' %}<a href="/{{ page.lang }}/{% translate download url %}">{% translate walletdownload %}</a>{% elsif platform.link contains 'play.google.com' or platform.link contains 'itunes.apple.com' or platform.link contains 'chrome.google.com' %}<a href="{{ platform.link }}">{% translate walletdownload %}</a>{% else %}<a href="{{ platform.link }}">{% translate walletvisit %}</a>{% endif %}{% if platform.source %}<a href="{{ platform.source }}">{% translate walletsourcecode %}</a>{% endif %}</div>
|
||||
<div ontouchstart="walletScoreListener(event);" onclick="walletScoreListener(event);">
|
||||
{% for check in platform.check %}{% if check[0] == 'privacy' and platform.privacycheck %}
|
||||
<div class="check{{ check[0] }} {% if check[1] contains "checkgood" %}checkgood{% elsif check[1] contains "checkpass" %}checkpass{% elsif check[1] contains "checkneutral" %}checkneutral{% else %}checkfail{% endif %}">{% translate {{check[1]}} %}<div><div>
|
||||
{% for privacycheck in platform.privacycheck %}
|
||||
<div class="check{{ privacycheck[0] }} {% if privacycheck[1] contains "checkgood" %}checkgood{% elsif privacycheck[1] contains "checkpass" %}checkpass{% elsif privacycheck[1] contains "checkneutral" %}checkneutral{% else %}checkfail{% endif %}">
|
||||
<p>{% translate {{privacycheck[1]}} %}</p>
|
||||
<p>{% translate {{privacycheck[1]}}txt %}</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div><span></span></div></div>
|
||||
{% else %}
|
||||
<div class="check{{ check[0] }} {% if check[1] contains "checkgood" %}checkgood{% elsif check[1] contains "checkpass" %}checkpass{% elsif check[1] contains "checkneutral" %}checkneutral{% else %}checkfail{% endif %}">{% translate {{check[1]}} %}<div><p>{% translate {{check[1]}}txt %}</p><span></span></div></div>
|
||||
{% endif %}{% endfor %}
|
||||
</div>
|
||||
{% capture platform_text %}{% translate {{platform.text}} %}{% endcapture %}
|
||||
{% assign platform_text_length = platform_text | size %}
|
||||
<p>{% if platform_text_length > page.max_wallet_text_length %}{% die Wallet text too long %}{% else %}{{platform_text}}{% endif %}</p>
|
||||
<div><img src="/img/screenshots/{{ platform.screenshot }}" alt="screenshot"></div>
|
||||
</div>
|
||||
<a><img src="/img/wallet/{{ wallet[0] }}.png" alt="{{ wallet[1].title }}" />{{ wallet[1].titleshort }}<span></span></a>
|
||||
</div>
|
||||
{% endfor %}{% endfor %}
|
||||
</div>
|
||||
|
||||
<div class="wallets walletsswitch" id="walletsswitch">
|
||||
{% for wallet in page.wallets %}{% for wallet in wallet %}{% for platform in wallet[1].platform %}
|
||||
<div id="wallet-{{ wallet[0] }}-{{ platform[0] }}" data-walletcompat="{{ wallet[1].compat }}" data-walletlevel="{{ wallet[1].level }}">
|
||||
<span></span>
|
||||
<div>
|
||||
<h2>{{ wallet[1].title }}</h2>
|
||||
<div>{% for os in platform[1].os %}<img src="/img/os/{{ os }}.png" alt="{% translate platform{{os}} %}" title="{% translate platform{{os}} %}" />{% endfor %}</div>
|
||||
<div>{% if platform[1].link == 'bitcoincore' %}<a href="/{{ page.lang }}/{% translate download url %}">{% translate walletdownload %}</a>{% elsif platform[1].link contains 'play.google.com' or platform[1].link contains 'itunes.apple.com' or platform[1].link contains 'chrome.google.com' %}<a href="{{ platform[1].link }}">{% translate walletdownload %}</a>{% else %}<a href="{{ platform[1].link }}">{% translate walletvisit %}</a>{% endif %}{% if platform[1].source %}<a href="{{ platform[1].source }}">{% translate walletsourcecode %}</a>{% endif %}</div>
|
||||
<div ontouchstart="walletScoreListener(event);" onclick="walletScoreListener(event);">
|
||||
{% for check in platform[1].check %}{% if check[0] == 'privacy' and platform[1].privacycheck %}
|
||||
<div class="check{{ check[0] }} {% if check[1] contains "checkgood" %}checkgood{% elsif check[1] contains "checkpass" %}checkpass{% elsif check[1] contains "checkneutral" %}checkneutral{% else %}checkfail{% endif %}">{% translate {{check[1]}} %}<div><div>
|
||||
{% for privacycheck in platform[1].privacycheck %}
|
||||
<div class="check{{ privacycheck[0] }} {% if privacycheck[1] contains "checkgood" %}checkgood{% elsif privacycheck[1] contains "checkpass" %}checkpass{% elsif privacycheck[1] contains "checkneutral" %}checkneutral{% else %}checkfail{% endif %}">
|
||||
<p>{% translate {{privacycheck[1]}} %}</p>
|
||||
<p>{% translate {{privacycheck[1]}}txt %}</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div><span></span></div></div>
|
||||
{% else %}
|
||||
<div class="check{{ check[0] }} {% if check[1] contains "checkgood" %}checkgood{% elsif check[1] contains "checkpass" %}checkpass{% elsif check[1] contains "checkneutral" %}checkneutral{% else %}checkfail{% endif %}">{% translate {{check[1]}} %}<div><p>{% translate {{check[1]}}txt %}</p><span></span></div></div>
|
||||
{% endif %}{% endfor %}
|
||||
</div>
|
||||
{% capture platform_text %}{% translate {{platform[1].text}} %}{% endcapture %}
|
||||
{% assign platform_text_length = platform_text | size %}
|
||||
<p>{% if platform_text_length > page.max_wallet_text_length %}{% die Wallet text too long %}{% else %}{{platform_text}}{% endif %}</p>
|
||||
<div><img src="/img/screenshots/{{ platform[1].screenshot }}" alt="screenshot"></div>
|
||||
</div>
|
||||
<a><img src="/img/wallet/{{ wallet[0] }}.png" alt="{{ wallet[1].title }}" />{{ wallet[1].titleshort }}<span></span></a>
|
||||
</div>
|
||||
{% endfor %}{% endfor %}{% endfor %}
|
||||
</div>
|
||||
|
||||
<div class="wallets walletsmobile" id="walletsmobile"></div>
|
||||
|
||||
<script>if (isMobile()) walletShowPlatform('mobile'); else walletShowPlatform('default');</script>
|
||||
|
||||
<div class="walletsdisclaimer">
|
||||
<h2><img src="/img/icons/warning.svg" class="warningicon" alt="warning">{% translate educate %}</h2>
|
||||
<p>{% translate educatetxt %}</p>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue