Skip to content

Commit

Permalink
Adds wallet page generator
Browse files Browse the repository at this point in the history
  • Loading branch information
kuzzmi committed Jul 18, 2017
1 parent d02f388 commit 6e7b5eb
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
3 changes: 1 addition & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,7 @@ collections:
permalink: /en/release/:path
## _wallets
wallets:
output: true
permalink: /en/wallets/:path/
output: false
## _platforms
platforms:
output: true
Expand Down
52 changes: 52 additions & 0 deletions _plugins/wallets.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This file is licensed under the MIT License (MIT) available on
# http://opensource.org/licenses/MIT.

require 'yaml'

module Jekyll

class WalletPage < Page
def initialize(site, base, dir, wallet, platform, os)
@site = site
@base = base
@dir = dir
@name = 'index.html'

self.process(@name)
self.read_yaml(File.join(base, '_layouts'), 'wallet-container.html')
self.data['wallet'] = wallet
self.data['platform'] = platform
self.data['os'] = os
self.data['id'] = ['wallets', platform['name'], os['name'], wallet['id']].join('-')
end
end

class WalletsPageGenerator < Generator
safe true

def generate(site)
walletsCol = site.collections['wallets'];
walletsDir = 'wallets'

walletsCol.docs.each do |doc|
file = doc.path
wallet = YAML.load_file(file)
walletPlatforms = wallet['platform']

puts('---------------------')
puts(wallet['id'])

walletPlatforms.each do |platform|
platform['os'].each do |os|
if platform['name']
dir = File.join(platform['name'], os['name'], wallet['id'])
site.pages << WalletPage.new(site, site.source, File.join('en', walletsDir, dir), wallet, platform, os)
end
end
end
end

end
end

end

0 comments on commit 6e7b5eb

Please sign in to comment.