Skip to content

Commit

Permalink
Adds empty title test to Makefile and fixes titles in generated walle…
Browse files Browse the repository at this point in the history
…t pages
  • Loading branch information
kuzzmi committed Jul 19, 2017
1 parent eff6536 commit 4476af6
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
20 changes: 18 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## This file is licensed under the MIT License (MIT) available on
## http://opensource.org/licenses/MIT.

S=@ ## Silent: only print errors by default;
S=@ ## Silent: only print errors by default;
## run `make S='' [other args]` to print commands as they're run

SITEDIR=_site
Expand Down Expand Up @@ -67,6 +67,7 @@ post-build-tests-fast: check-for-build-errors ensure-each-svg-has-a-png check-fo
check-for-missing-anchors check-for-broken-markdown-reference-links \
check-for-broken-kramdown-tables check-for-duplicate-header-ids \
check-for-headers-containing-auto-link check-for-missing-subhead-links \
check-for-empty-title-tag \
check-for-subheading-anchors \
check-jshint \
check-for-javascript-in-svgs
Expand Down Expand Up @@ -126,7 +127,7 @@ ensure-each-svg-has-a-png:
; do test -f $${file%.svg}.png || echo "$$file missing corresponding PNG" \
; done | eval $(ERROR_ON_OUTPUT)


## Some Jekyll errors leave error messages in the text
check-for-liquid-errors:
$S grep -r 'Liquid syntax error:' $(SITEDIR)/ | eval $(ERROR_ON_OUTPUT)
Expand Down Expand Up @@ -182,6 +183,21 @@ check-for-headers-containing-auto-link:
## 'class="auto-link"' produced by autocrossref
$S grep '<\(h[2-6]\).*\?>[^>]\+class="auto-link".*</\1>' _site/en/developer-* | eval $(ERROR_ON_OUTPUT)

check-for-empty-title-tag:
## The autocrossref plugin can mess up subheadings (h2, etc), so ensure
## none of the generated subheadings contain the string
## 'class="auto-link"' produced by autocrossref
$S find ./_site -name '*.html' -type f \
| xargs grep '<title></title>' \
| eval $(ERROR_ON_OUTPUT)

check-for-missing-subhead-links:
## Make sure each subhead (h2-h6) either has the subhead links
## (edit,issue,etc) or something like <!-- no subhead-links here -->
$S egrep -n -A1 '<h[2-6]' _site/en/developer-* \
| egrep -v 'developer-documentation|<h[2-6]|^--|subhead-links' \
| eval $(ERROR_ON_OUTPUT)

check-for-missing-subhead-links:
## Make sure each subhead (h2-h6) either has the subhead links
## (edit,issue,etc) or something like <!-- no subhead-links here -->
Expand Down
31 changes: 27 additions & 4 deletions _plugins/wallets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
module Jekyll

class WalletPage < Page
def initialize(site, base, dir, wallet, platform, os, lang)
def initialize(site, base, dir, wallet, platform, os, title, lang)
@site = site
@base = base
@dir = dir
Expand All @@ -19,11 +19,12 @@ def initialize(site, base, dir, wallet, platform, os, lang)
self.data['os'] = os
self.data['id'] = ['wallets', platform['name'], os['name'], wallet['id']].join('-')
self.data['lang'] = lang
self.data['title'] = title
end
end

class PlatformPage < Page
def initialize(site, base, dir, platform, os, lang)
def initialize(site, base, dir, platform, os, title, lang)
@site = site
@base = base
@dir = dir
Expand All @@ -35,6 +36,7 @@ def initialize(site, base, dir, platform, os, lang)
self.data['os'] = os
self.data['id'] = ['wallets', platform['name'], os['name']].join('-')
self.data['lang'] = lang
self.data['title'] = title
end
end

Expand Down Expand Up @@ -70,13 +72,23 @@ def generate(site)

# Getting information about each found wallet
locs.each do |lang,value|
title = locs[lang]['choose-your-wallet']['title']

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)

platformTitle = locs[lang]['choose-your-wallet']['walletcat' + platform['name']]
osTitle = locs[lang]['choose-your-wallet']['platform' + os['name']]
if osTitle.nil?
fullTitle = [platformTitle, title].join(' - ')
else
fullTitle = [platformTitle, osTitle, title].join(' - ')
end
site.pages << PlatformPage.new(site, site.source, File.join(lang, walletsDir, dir), platform, os, fullTitle, lang)
end

walletsCol.docs.each do |doc|
Expand All @@ -92,7 +104,18 @@ def generate(site)
# 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)

platformTitle = locs[lang]['choose-your-wallet']['walletcat' + platform['name']]
osTitle = locs[lang]['choose-your-wallet']['platform' + os['name']]
walletTitle = wallet['title']

if osTitle.nil?
fullTitle = [walletTitle, platformTitle, title].join(' - ')
else
fullTitle = [walletTitle, platformTitle, osTitle, title].join(' - ')
end

site.pages << WalletPage.new(site, site.source, File.join(lang, walletsDir, dir), wallet, platform, os, fullTitle, lang)
end

end
Expand Down

0 comments on commit 4476af6

Please sign in to comment.