diff --git a/_platforms/hardware.html b/_platforms/hardware.html index 46d3ef44..fbae9a3c 100644 --- a/_platforms/hardware.html +++ b/_platforms/hardware.html @@ -5,4 +5,6 @@ id: wallets-hardware platform: name: hardware +os: + name: hardware --- diff --git a/_platforms/web.html b/_platforms/web.html index 5a015334..b796c59e 100644 --- a/_platforms/web.html +++ b/_platforms/web.html @@ -5,4 +5,6 @@ id: wallets-web platform: name: web +os: + name: web --- diff --git a/_plugins/wallets.rb b/_plugins/wallets.rb index 515ca1d8..3d8fa866 100644 --- a/_plugins/wallets.rb +++ b/_plugins/wallets.rb @@ -22,6 +22,22 @@ module Jekyll end end + class PlatformPage < Page + def initialize(site, base, dir, platform, os, lang) + @site = site + @base = base + @dir = dir + @name = 'index.html' + + self.process(@name) + self.read_yaml(File.join(base, '_layouts'), 'wallet-platform.html') + self.data['platform'] = platform + self.data['os'] = os + self.data['id'] = ['wallets', platform['name'], os['name']].join('-') + self.data['lang'] = lang + end + end + class WalletsPageGenerator < Generator safe true @@ -29,6 +45,9 @@ module Jekyll # Get the collection of wallets from _wallets walletsCol = site.collections['wallets']; + # Get the collection of wallets from _wallets + platformsCol = site.collections['platforms']; + # Output dir # TODO: Make this configurable and "translatable" walletsDir = 'wallets' @@ -49,38 +68,38 @@ module Jekyll 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'] + locs.each do |lang,value| + platformsCol.docs.each do |doc| + file = doc.path + data = YAML.load_file(file) + platform = data['platform'] + os = data['os'] + dir = File.join(platform['name'], os['name']) + site.pages << PlatformPage.new(site, site.source, File.join(lang, walletsDir, dir), platform, os, lang) + end - puts(wallet['id'] + ' is loaded. Generating pages...') + walletsCol.docs.each do |doc| + file = doc.path + wallet = YAML.load_file(file) + walletPlatforms = wallet['platform'] - # Going through all available combinations of - # platforms and OSes - walletPlatforms.each do |platform| - platform['os'].each do |os| + # 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| + # This allows generation only of valid wallet pages + if platform['name'] dir = File.join(platform['name'], os['name'], wallet['id']) site.pages << WalletPage.new(site, site.source, File.join(lang, walletsDir, dir), wallet, platform, os, lang) end - end + end end end - - puts(wallet['id'] + ' is processed.') end - puts('----- Wallet pages generated -----') - end end