Compare commits
32 Commits
master
...
wbnns-ruby
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
584e891622 | ||
|
|
de0bcb6ce1 | ||
|
|
282bfd16d7 | ||
|
|
bbbc8bacf1 | ||
|
|
37d489f067 | ||
|
|
0612d9ee37 | ||
|
|
0d453a8e81 | ||
|
|
7d604c17aa | ||
|
|
87d07e80d1 | ||
|
|
4c1cdc8ab8 | ||
|
|
921e1e8745 | ||
|
|
3c4ad630cb | ||
|
|
a3d721fc37 | ||
|
|
5a0393e9b9 | ||
|
|
bb4384e21c | ||
|
|
27fd55c69e | ||
|
|
83e952492e | ||
|
|
be1d9eafe5 | ||
|
|
a695caded4 | ||
|
|
813568b74f | ||
|
|
61c2a62f84 | ||
|
|
191231f557 | ||
|
|
1726f03489 | ||
|
|
9b86998e35 | ||
|
|
bde3080333 | ||
|
|
b647a60d26 | ||
|
|
ce38dbe3e7 | ||
|
|
38ce5741c9 | ||
|
|
91042a0c0d | ||
|
|
6abfe1a476 | ||
|
|
b180541f16 | ||
|
|
a01a15ef47 |
1
.rubocop.yml
Normal file
1
.rubocop.yml
Normal file
@ -0,0 +1 @@
|
||||
inherit_from: .rubocop_todo.yml
|
||||
487
.rubocop_todo.yml
Normal file
487
.rubocop_todo.yml
Normal file
@ -0,0 +1,487 @@
|
||||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config`
|
||||
# on 2019-01-02 16:42:51 -0600 using RuboCop version 0.62.0.
|
||||
# The point is for the user to remove these configuration records
|
||||
# one by one as the offenses are removed from the code base.
|
||||
# Note that changes in the inspected code, or installation of new
|
||||
# versions of RuboCop, may require this file to be generated again.
|
||||
|
||||
# Offense count: 20
|
||||
Metrics/AbcSize:
|
||||
Max: 136
|
||||
|
||||
# Offense count: 4
|
||||
# Configuration parameters: CountComments, ExcludedMethods.
|
||||
# ExcludedMethods: refine
|
||||
Metrics/BlockLength:
|
||||
Max: 45
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: CountComments.
|
||||
Metrics/ClassLength:
|
||||
Max: 105
|
||||
|
||||
# Offense count: 14
|
||||
Metrics/CyclomaticComplexity:
|
||||
Max: 25
|
||||
|
||||
# Offense count: 21
|
||||
# Configuration parameters: CountComments, ExcludedMethods.
|
||||
Metrics/MethodLength:
|
||||
Max: 66
|
||||
|
||||
# Offense count: 6
|
||||
# Configuration parameters: CountKeywordArgs.
|
||||
Metrics/ParameterLists:
|
||||
Max: 8
|
||||
|
||||
# Offense count: 13
|
||||
Metrics/PerceivedComplexity:
|
||||
Max: 25
|
||||
|
||||
# Offense count: 3
|
||||
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
||||
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
|
||||
Naming/FileName:
|
||||
Exclude:
|
||||
- '_plugins/inline-template.rb'
|
||||
- '_plugins/liquid-die.rb'
|
||||
- '_plugins/liquid-warn.rb'
|
||||
|
||||
# Offense count: 3
|
||||
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
||||
# AllowedNames: io, id, to, by, on, in, at, ip, db
|
||||
Naming/UncommunicativeMethodParamName:
|
||||
Exclude:
|
||||
- '_plugins/releases.rb'
|
||||
- '_plugins/wallets.rb'
|
||||
|
||||
# Offense count: 13
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: snake_case, camelCase
|
||||
Naming/VariableName:
|
||||
Exclude:
|
||||
- '_plugins/wallets.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Performance/RegexpMatch:
|
||||
Exclude:
|
||||
- '_plugins/include_absolute.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
Performance/StringReplacement:
|
||||
Exclude:
|
||||
- '_contrib/comparelinks.rb'
|
||||
- '_plugins/inline-template.rb'
|
||||
|
||||
# Offense count: 3
|
||||
Security/MarshalLoad:
|
||||
Exclude:
|
||||
- '_plugins/contributors.rb'
|
||||
- '_plugins/events.rb'
|
||||
|
||||
# Offense count: 2
|
||||
Security/Open:
|
||||
Exclude:
|
||||
- '_plugins/contributors.rb'
|
||||
- '_plugins/events.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Security/YAMLLoad:
|
||||
Exclude:
|
||||
- '_plugins/inline-template.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: prefer_alias, prefer_alias_method
|
||||
Style/Alias:
|
||||
Exclude:
|
||||
- '_plugins/contributors.rb'
|
||||
- '_plugins/events.rb'
|
||||
|
||||
# Offense count: 54
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: always, conditionals
|
||||
Style/AndOr:
|
||||
Exclude:
|
||||
- '_contrib/updatetx.rb'
|
||||
- '_plugins/alerts.rb'
|
||||
- '_plugins/alphab_for.rb'
|
||||
- '_plugins/autocrossref.rb'
|
||||
- '_plugins/contributors.rb'
|
||||
- '_plugins/events.rb'
|
||||
- '_plugins/githubify.rb'
|
||||
- '_plugins/glossary.rb'
|
||||
- '_plugins/redirects.rb'
|
||||
- '_plugins/releases.rb'
|
||||
- '_plugins/sitemap.rb'
|
||||
- '_plugins/templates.rb'
|
||||
- '_plugins/translate.rb'
|
||||
- '_plugins/wallets.rb'
|
||||
|
||||
# Offense count: 19
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods.
|
||||
# SupportedStyles: line_count_based, semantic, braces_for_chaining
|
||||
# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
|
||||
# FunctionalMethods: let, let!, subject, watch
|
||||
# IgnoredMethods: lambda, proc, it
|
||||
Style/BlockDelimiters:
|
||||
Exclude:
|
||||
- '_contrib/comparelinks.rb'
|
||||
- '_plugins/autocrossref.rb'
|
||||
- '_plugins/githubify.rb'
|
||||
- '_plugins/glossary.rb'
|
||||
|
||||
# Offense count: 7
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: braces, no_braces, context_dependent
|
||||
Style/BracesAroundHashParameters:
|
||||
Exclude:
|
||||
- '_contrib/bco-htmlproof'
|
||||
- '_plugins/env.rb'
|
||||
- '_plugins/glossary.rb'
|
||||
- '_plugins/htmlescape.rb'
|
||||
|
||||
# Offense count: 5
|
||||
# Cop supports --auto-correct.
|
||||
Style/ColonMethodCall:
|
||||
Exclude:
|
||||
- '_plugins/events.rb'
|
||||
- '_plugins/sitemap.rb'
|
||||
- '_plugins/translate.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: Keywords.
|
||||
# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW
|
||||
Style/CommentAnnotation:
|
||||
Exclude:
|
||||
- '_plugins/alerts.rb'
|
||||
- '_plugins/releases.rb'
|
||||
|
||||
# Offense count: 9
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
|
||||
# SupportedStyles: assign_to_condition, assign_inside_condition
|
||||
Style/ConditionalAssignment:
|
||||
Exclude:
|
||||
- '_contrib/bco-htmlproof'
|
||||
- '_contrib/jshint'
|
||||
- '_contrib/updatetx.rb'
|
||||
- '_plugins/events.rb'
|
||||
- '_plugins/glossary.rb'
|
||||
- '_plugins/wallets.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Style/DefWithParentheses:
|
||||
Exclude:
|
||||
- '_contrib/comparelinks.rb'
|
||||
|
||||
# Offense count: 38
|
||||
Style/Documentation:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
Style/EmptyLiteral:
|
||||
Exclude:
|
||||
- '_plugins/autocrossref.rb'
|
||||
- '_plugins/glossary.rb'
|
||||
|
||||
# Offense count: 7
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: each, for
|
||||
Style/For:
|
||||
Exclude:
|
||||
- '_plugins/alphab_for.rb'
|
||||
- '_plugins/contributors.rb'
|
||||
- '_plugins/glossary.rb'
|
||||
- '_plugins/translate.rb'
|
||||
|
||||
# Offense count: 27
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: when_needed, always, never
|
||||
Style/FrozenStringLiteralComment:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 5
|
||||
# Configuration parameters: MinBodyLength.
|
||||
Style/GuardClause:
|
||||
Exclude:
|
||||
- '_build/txpreview/addlang.rb'
|
||||
- '_plugins/include_absolute.rb'
|
||||
- '_plugins/releases.rb'
|
||||
|
||||
# Offense count: 6
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
||||
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
||||
Style/HashSyntax:
|
||||
EnforcedStyle: hash_rockets
|
||||
|
||||
# Offense count: 23
|
||||
# Cop supports --auto-correct.
|
||||
Style/IfUnlessModifier:
|
||||
Exclude:
|
||||
- '_contrib/comparelinks.rb'
|
||||
- '_plugins/alerts.rb'
|
||||
- '_plugins/alphab_for.rb'
|
||||
- '_plugins/autocrossref.rb'
|
||||
- '_plugins/contributors.rb'
|
||||
- '_plugins/events.rb'
|
||||
- '_plugins/glossary.rb'
|
||||
- '_plugins/include_absolute.rb'
|
||||
- '_plugins/redirects.rb'
|
||||
- '_plugins/sitemap.rb'
|
||||
- '_plugins/templates.rb'
|
||||
- '_plugins/translate.rb'
|
||||
|
||||
# Offense count: 11
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: IgnoredMethods.
|
||||
Style/MethodCallWithoutArgsParentheses:
|
||||
Exclude:
|
||||
- '_contrib/comparelinks.rb'
|
||||
- '_contrib/schema-validator.rb'
|
||||
- '_plugins/events.rb'
|
||||
- '_plugins/githubify.rb'
|
||||
- '_plugins/glossary.rb'
|
||||
- '_plugins/inline-template.rb'
|
||||
- '_plugins/sitemap.rb'
|
||||
|
||||
# Offense count: 14
|
||||
Style/MultipleComparison:
|
||||
Exclude:
|
||||
- '_contrib/updatetx.rb'
|
||||
- '_plugins/alerts.rb'
|
||||
- '_plugins/alphab_for.rb'
|
||||
- '_plugins/glossary.rb'
|
||||
- '_plugins/releases.rb'
|
||||
- '_plugins/sitemap.rb'
|
||||
- '_plugins/templates.rb'
|
||||
- '_plugins/translate.rb'
|
||||
- '_plugins/wallets.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Style/MutableConstant:
|
||||
Exclude:
|
||||
- '_plugins/include_absolute.rb'
|
||||
|
||||
# Offense count: 26
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: both, prefix, postfix
|
||||
Style/NegatedIf:
|
||||
Exclude:
|
||||
- '_contrib/comparelinks.rb'
|
||||
- '_contrib/jshint'
|
||||
- '_contrib/updatetx.rb'
|
||||
- '_plugins/alerts.rb'
|
||||
- '_plugins/alphab_for.rb'
|
||||
- '_plugins/autocrossref.rb'
|
||||
- '_plugins/contributors.rb'
|
||||
- '_plugins/events.rb'
|
||||
- '_plugins/include_absolute.rb'
|
||||
- '_plugins/redirects.rb'
|
||||
- '_plugins/sitemap.rb'
|
||||
- '_plugins/templates.rb'
|
||||
- '_plugins/translate.rb'
|
||||
- '_plugins/wallets.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, MinBodyLength.
|
||||
# SupportedStyles: skip_modifier_ifs, always
|
||||
Style/Next:
|
||||
Exclude:
|
||||
- '_plugins/wallets.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: Strict.
|
||||
Style/NumericLiterals:
|
||||
MinDigits: 8
|
||||
|
||||
# Offense count: 5
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
|
||||
# SupportedStyles: predicate, comparison
|
||||
Style/NumericPredicate:
|
||||
Exclude:
|
||||
- 'spec/**/*'
|
||||
- '_contrib/comparelinks.rb'
|
||||
- '_plugins/alerts.rb'
|
||||
- '_plugins/contributors.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AllowSafeAssignment, AllowInMultilineConditions.
|
||||
Style/ParenthesesAroundCondition:
|
||||
Exclude:
|
||||
- '_contrib/comparelinks.rb'
|
||||
- '_plugins/contributors.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Cop supports --auto-correct.
|
||||
Style/PerlBackrefs:
|
||||
Exclude:
|
||||
- '_plugins/githubify.rb'
|
||||
|
||||
# Offense count: 24
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: short, verbose
|
||||
Style/PreferredHashMethods:
|
||||
Exclude:
|
||||
- '_contrib/comparelinks.rb'
|
||||
- '_plugins/alerts.rb'
|
||||
- '_plugins/alphab_for.rb'
|
||||
- '_plugins/autocrossref.rb'
|
||||
- '_plugins/contributors.rb'
|
||||
- '_plugins/events.rb'
|
||||
- '_plugins/releases.rb'
|
||||
- '_plugins/translate.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Style/RedundantParentheses:
|
||||
Exclude:
|
||||
- '_contrib/comparelinks.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AllowMultipleReturnValues.
|
||||
Style/RedundantReturn:
|
||||
Exclude:
|
||||
- '_contrib/comparelinks.rb'
|
||||
- '_plugins/alphab_for.rb'
|
||||
- '_plugins/events.rb'
|
||||
- '_plugins/releases.rb'
|
||||
|
||||
# Offense count: 82
|
||||
# Cop supports --auto-correct.
|
||||
Style/RedundantSelf:
|
||||
Exclude:
|
||||
- '_plugins/alerts.rb'
|
||||
- '_plugins/contributors.rb'
|
||||
- '_plugins/events.rb'
|
||||
- '_plugins/glossary.rb'
|
||||
- '_plugins/redirects.rb'
|
||||
- '_plugins/releases.rb'
|
||||
- '_plugins/templates.rb'
|
||||
- '_plugins/wallets.rb'
|
||||
|
||||
# Offense count: 11
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
|
||||
# SupportedStyles: slashes, percent_r, mixed
|
||||
Style/RegexpLiteral:
|
||||
Exclude:
|
||||
- '_contrib/bco-htmlproof'
|
||||
- '_contrib/comparelinks.rb'
|
||||
- '_plugins/autocrossref.rb'
|
||||
- '_plugins/include_absolute.rb'
|
||||
- '_plugins/templates.rb'
|
||||
|
||||
# Offense count: 4
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: implicit, explicit
|
||||
Style/RescueStandardError:
|
||||
Exclude:
|
||||
- '_plugins/contributors.rb'
|
||||
- '_plugins/events.rb'
|
||||
- '_plugins/include_absolute.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Style/SelfAssignment:
|
||||
Exclude:
|
||||
- '_plugins/templates.rb'
|
||||
|
||||
# Offense count: 5
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AllowAsExpressionSeparator.
|
||||
Style/Semicolon:
|
||||
Exclude:
|
||||
- '_plugins/sitemap.rb'
|
||||
- '_plugins/templates.rb'
|
||||
- '_plugins/wallets.rb'
|
||||
|
||||
# Offense count: 110
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
||||
# SupportedStyles: single_quotes, double_quotes
|
||||
Style/StringLiterals:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: IgnoredMethods.
|
||||
# IgnoredMethods: respond_to, define_method
|
||||
Style/SymbolProc:
|
||||
Exclude:
|
||||
- '_plugins/releases.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyleForMultiline.
|
||||
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
|
||||
Style/TrailingCommaInHashLiteral:
|
||||
Exclude:
|
||||
- '_contrib/bco-htmlproof'
|
||||
|
||||
# Offense count: 7
|
||||
# Cop supports --auto-correct.
|
||||
Style/UnneededCondition:
|
||||
Exclude:
|
||||
- '_plugins/env.rb'
|
||||
- '_plugins/glossary.rb'
|
||||
- '_plugins/releases.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Style/UnneededInterpolation:
|
||||
Exclude:
|
||||
- '_plugins/markdown.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
Style/WhileUntilDo:
|
||||
Exclude:
|
||||
- '_plugins/contributors.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: MinSize, WordRegex.
|
||||
# SupportedStyles: percent, brackets
|
||||
Style/WordArray:
|
||||
EnforcedStyle: brackets
|
||||
|
||||
# Offense count: 6
|
||||
# Cop supports --auto-correct.
|
||||
Style/ZeroLengthPredicate:
|
||||
Exclude:
|
||||
- '_contrib/comparelinks.rb'
|
||||
- '_contrib/jshint'
|
||||
- '_plugins/alerts.rb'
|
||||
- '_plugins/contributors.rb'
|
||||
|
||||
# Offense count: 108
|
||||
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
||||
# URISchemes: http, https
|
||||
Metrics/LineLength:
|
||||
Max: 237
|
||||
|
||||
# Add Rubocop to Travis
|
||||
9
Gemfile
9
Gemfile
@ -15,14 +15,15 @@ ruby '2.4.1'
|
||||
group :development do
|
||||
gem 'ffi-icu'
|
||||
gem 'jekyll', '~>3.0'
|
||||
gem 'jshintrb', '~>0.3.0'
|
||||
gem 'json', '>= 1.9'
|
||||
gem 'less', '2.4.0'
|
||||
gem 'json-schema'
|
||||
gem 'kramdown'
|
||||
gem 'RedCloth', ">= 4.3.0"
|
||||
gem 'therubyracer' # required by less
|
||||
gem 'jshintrb', '~>0.3.0'
|
||||
gem 'less', '2.4.0'
|
||||
gem 'rubocop'
|
||||
gem 'safe_yaml'
|
||||
gem 'json-schema'
|
||||
gem 'therubyracer' # required by less
|
||||
end
|
||||
|
||||
## Not used on build server. Only used by developers and Travis CI, so
|
||||
|
||||
17
Gemfile.lock
17
Gemfile.lock
@ -3,6 +3,7 @@ GEM
|
||||
specs:
|
||||
RedCloth (4.3.2)
|
||||
addressable (2.4.0)
|
||||
ast (2.4.0)
|
||||
colorator (0.1)
|
||||
colored (1.2)
|
||||
commonjs (0.2.7)
|
||||
@ -20,6 +21,7 @@ GEM
|
||||
parallel (~> 1.3)
|
||||
typhoeus (~> 0.7)
|
||||
yell (~> 2.0)
|
||||
jaro_winkler (1.5.1)
|
||||
jekyll (3.0.1)
|
||||
colorator (~> 0.1)
|
||||
jekyll-sass-converter (~> 1.0)
|
||||
@ -55,11 +57,24 @@ GEM
|
||||
mini_portile2 (~> 2.4.0)
|
||||
parallel (1.12.0)
|
||||
rake (13.0.1)
|
||||
parser (2.5.3.0)
|
||||
ast (~> 2.4.0)
|
||||
powerpack (0.1.2)
|
||||
rainbow (3.0.0)
|
||||
rb-fsevent (0.9.7)
|
||||
rb-inotify (0.9.5)
|
||||
ffi (>= 0.5.0)
|
||||
ref (2.0.0)
|
||||
rouge (1.10.1)
|
||||
rubocop (0.62.0)
|
||||
jaro_winkler (~> 1.5.1)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 2.5, != 2.5.1.1)
|
||||
powerpack (~> 0.1)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (~> 1.4.0)
|
||||
ruby-progressbar (1.10.0)
|
||||
safe_yaml (1.0.4)
|
||||
sass (3.4.20)
|
||||
therubyracer (0.12.3)
|
||||
@ -67,6 +82,7 @@ GEM
|
||||
ref
|
||||
typhoeus (0.8.0)
|
||||
ethon (>= 0.8.0)
|
||||
unicode-display_width (1.4.1)
|
||||
yell (2.0.7)
|
||||
|
||||
PLATFORMS
|
||||
@ -82,6 +98,7 @@ DEPENDENCIES
|
||||
json-schema
|
||||
kramdown
|
||||
less (= 2.4.0)
|
||||
rubocop
|
||||
safe_yaml
|
||||
therubyracer
|
||||
|
||||
|
||||
4
_build/txpreview/addlang.rb
Normal file → Executable file
4
_build/txpreview/addlang.rb
Normal file → Executable file
@ -14,8 +14,8 @@ end
|
||||
contents = File.read(PATH + '/_config.yml')
|
||||
|
||||
if Regexp.new('langsorder:.*?' + "\n" + '- \'' + la + '\'' + "\n", Regexp::MULTILINE).match(contents).nil?
|
||||
contents.gsub!(Regexp.new("(langsorder:.*?)\n\n", Regexp::MULTILINE),'\1' + "\n" + '- \'' + la + '\'' + "\n\n")
|
||||
contents.gsub!(Regexp.new("(langs:.*?)\n\n", Regexp::MULTILINE),'\1' + "\n" + ' \'' + la + '\': \'' + la + '\'' + "\n\n")
|
||||
contents.gsub!(Regexp.new("(langsorder:.*?)\n\n", Regexp::MULTILINE), '\1' + "\n" + '- \'' + la + '\'' + "\n\n")
|
||||
contents.gsub!(Regexp.new("(langs:.*?)\n\n", Regexp::MULTILINE), '\1' + "\n" + ' \'' + la + '\': \'' + la + '\'' + "\n\n")
|
||||
end
|
||||
|
||||
File.open(PATH + '/_config.yml', 'w') do |file|
|
||||
|
||||
@ -3,18 +3,17 @@
|
||||
require 'html/proofer'
|
||||
|
||||
if ARGV[0].nil?
|
||||
path_to_check="./_site"
|
||||
path_to_check = "./_site"
|
||||
else
|
||||
path_to_check=ARGV[0]
|
||||
path_to_check = ARGV[0]
|
||||
end
|
||||
|
||||
## Will throw an exception (exiting false) if any internal links don't
|
||||
## work. The Makefile will terminate on the failure
|
||||
HTML::Proofer.new(
|
||||
## To test, uncomment the array below and comment out ./_site and :disable_external
|
||||
#[ "/foo/bar#baz", "/foo/bar", "#", "#wallet", "/foo.css", "/bar.png", "/zh_TW/bitcoin-for-businesses" ],
|
||||
# [ "/foo/bar#baz", "/foo/bar", "#", "#wallet", "/foo.css", "/bar.png", "/zh_TW/bitcoin-for-businesses" ],
|
||||
path_to_check,
|
||||
|
||||
{
|
||||
## Disable external link checking by default to avoid spurious
|
||||
## Travis CI failures. TODO: take an argument to optionally
|
||||
@ -56,10 +55,20 @@ HTML::Proofer.new(
|
||||
/\$$/ => '',
|
||||
},
|
||||
|
||||
<<<<<<< HEAD
|
||||
## It'd be nice if we had a _local_config.yaml file or something
|
||||
## for settings specific to particular systems, but for now I
|
||||
## think 2 is a good setting for Travis CI ("1.5 processors")
|
||||
## and me (usually 2 processors)
|
||||
:parallel => { :in_processes => 2 },
|
||||
}
|
||||
).run
|
||||
=======
|
||||
## It'd be nice if we had a _local_config.yaml file or something
|
||||
## for settings specific to particular systems, but for now I
|
||||
## think 2 is a good setting for Travis CI ("1.5 processors")
|
||||
## and me (usually 2 processors)
|
||||
:parallel => { :in_processes => 2 }
|
||||
}
|
||||
).run
|
||||
>>>>>>> 3f9dc02e... rubocop: Remove extra spaces
|
||||
|
||||
@ -27,32 +27,30 @@ if !File.exist?('_config.yml')
|
||||
end
|
||||
|
||||
def fetchlinks()
|
||||
|
||||
# Fetch new list of links
|
||||
links = {}
|
||||
dirs = Dir.glob(WORKDIR + "/_site/**/*.html").each { |file|
|
||||
Dir.glob(WORKDIR + "/_site/**/*.html").each { |file|
|
||||
content = File.read(file)
|
||||
content.scan(/ href *= *"(.*?)"/).each { |link|
|
||||
link = link[0].to_s.gsub(/^(https?:\/\/(www\.)?bitcoin\.org)?\//,'/')
|
||||
link = link[0].to_s.gsub(/^(https?:\/\/(www\.)?bitcoin\.org)?\//, '/')
|
||||
next if (link.match(/^#|^http:\/\/www.meetup.com\//))
|
||||
if(!link.match(/^https?:\/\/|^\/[^\/]|^mailto:/))
|
||||
link = File.dirname(file.sub(WORKDIR + '/_site','')) + '/' + File.basename(link)
|
||||
|
||||
if (!link.match(/^https?:\/\/|^\/[^\/]|^mailto:/))
|
||||
link = File.dirname(file.sub(WORKDIR + '/_site', '')) + '/' + File.basename(link)
|
||||
end
|
||||
links[link] = "0"
|
||||
}
|
||||
content.scan(/ src *= *"(.*?)"/).each { |link|
|
||||
link = link[0].to_s.gsub(/^(https?:\/\/(www\.)?bitcoin\.org)?\//,'/')
|
||||
link = link[0].to_s.gsub(/^(https?:\/\/(www\.)?bitcoin\.org)?\//, '/')
|
||||
links[link] = "0"
|
||||
}
|
||||
}
|
||||
|
||||
return links
|
||||
|
||||
end
|
||||
|
||||
Dir.mktmpdir{|workdir|
|
||||
|
||||
WORKDIR=workdir.gsub("\n",'')
|
||||
Dir.mktmpdir { |workdir|
|
||||
WORKDIR = workdir.gsub("\n", '')
|
||||
|
||||
# Copy current repository to a temporary directory
|
||||
`rsync -a ./ "#{WORKDIR}/"`
|
||||
@ -62,7 +60,6 @@ Dir.mktmpdir{|workdir|
|
||||
newlinks = {}
|
||||
|
||||
Dir.chdir(WORKDIR) do
|
||||
|
||||
`git checkout #{srcbr}`
|
||||
`jekyll`
|
||||
oldlinks = fetchlinks()
|
||||
@ -70,18 +67,19 @@ Dir.mktmpdir{|workdir|
|
||||
`git checkout #{dstbr}`
|
||||
`jekyll`
|
||||
newlinks = fetchlinks()
|
||||
|
||||
end
|
||||
|
||||
# Find added links, removed links
|
||||
diffaddlinks = []
|
||||
diffrmlinks = []
|
||||
newlinks.each { |link, etag|
|
||||
newlinks.each { |link, _etag|
|
||||
next if oldlinks.has_key?(link)
|
||||
|
||||
diffaddlinks.push(link)
|
||||
}
|
||||
oldlinks.each { |link, etag|
|
||||
oldlinks.each { |link, _etag|
|
||||
next if newlinks.has_key?(link)
|
||||
|
||||
diffrmlinks.push(link)
|
||||
}
|
||||
|
||||
@ -94,5 +92,4 @@ Dir.mktmpdir{|workdir|
|
||||
diff = diff + "## links removed\n\n" + diffrmlinks.join("\n") + "\n\n"
|
||||
end
|
||||
print diff
|
||||
|
||||
}
|
||||
|
||||
5
_contrib/jshint
Normal file → Executable file
5
_contrib/jshint
Normal file → Executable file
@ -8,13 +8,14 @@
|
||||
require 'jshintrb'
|
||||
|
||||
if ARGV[0].nil?
|
||||
path_to_check="./_site/js"
|
||||
path_to_check = "./_site/js"
|
||||
else
|
||||
path_to_check=ARGV[0]
|
||||
path_to_check = ARGV[0]
|
||||
end
|
||||
|
||||
Dir.foreach(path_to_check) do |file|
|
||||
next if !/\.js$/.match(file)
|
||||
|
||||
res = Jshintrb.report(File.read(path_to_check + '/' + file), :jshintrc)
|
||||
print path_to_check + '/' + file + "\n" + res if res.length != 0
|
||||
end
|
||||
|
||||
@ -3,8 +3,8 @@
|
||||
# This file is licensed under the MIT License (MIT) available on
|
||||
# http://opensource.org/licenses/MIT.
|
||||
|
||||
#Drop outdated fallback HTML code in all layouts for specified language.
|
||||
#Example: ./_contrib/updatetx.rb
|
||||
# Drop outdated fallback HTML code in all layouts for specified language.
|
||||
# Example: ./_contrib/updatetx.rb
|
||||
|
||||
def prompt(*args)
|
||||
print(*args)
|
||||
@ -17,31 +17,32 @@ else
|
||||
lang = ARGV[0]
|
||||
end
|
||||
|
||||
lang = lang.gsub(/[^a-zA-Z_]/,'')
|
||||
lang = lang.gsub(/[^a-zA-Z_]/, '')
|
||||
|
||||
if !File.exist?('_translations/' + lang + '.yml')
|
||||
print "Wrong language code. \n"
|
||||
exit
|
||||
end
|
||||
|
||||
dirs = [ '_templates', '_layouts' ]
|
||||
dirs = ['_templates', '_layouts']
|
||||
|
||||
dirs.each do |dir|
|
||||
Dir.foreach(dir) do |file|
|
||||
next if file == '.' or file == '..'
|
||||
|
||||
contents = File.read(dir + '/' + file)
|
||||
# Drop HTML code applied to current language only ( until next {% when / else / endcase %} statement )
|
||||
contents.gsub!(Regexp.new("{% when '" + lang + "' %}((?!{% endcase %})(?!{% else %}).)*?{% when", Regexp::MULTILINE),'{% when')
|
||||
contents.gsub!(Regexp.new("{% when '" + lang + "' %}((?!{% endcase %}).)*?{% else %}", Regexp::MULTILINE),'{% else %}')
|
||||
contents.gsub!(Regexp.new("{% when '" + lang + "' %}.*?{% endcase %}", Regexp::MULTILINE),'{% endcase %}')
|
||||
contents.gsub!(Regexp.new("{% when '" + lang + "' %}((?!{% endcase %})(?!{% else %}).)*?{% when", Regexp::MULTILINE), '{% when')
|
||||
contents.gsub!(Regexp.new("{% when '" + lang + "' %}((?!{% endcase %}).)*?{% else %}", Regexp::MULTILINE), '{% else %}')
|
||||
contents.gsub!(Regexp.new("{% when '" + lang + "' %}.*?{% endcase %}", Regexp::MULTILINE), '{% endcase %}')
|
||||
# Drop complete {% case / endcase %} statements when not used by any language anymore
|
||||
contents.gsub!(Regexp.new("{% case page.lang %}(((?!{% endcase %})(?!{% when ).)*?){% else %}(.*?){% endcase %}", Regexp::MULTILINE),'\1 \3')
|
||||
contents.gsub!(Regexp.new("{% case page.lang %}(((?!{% when ).)*?){% endcase %}", Regexp::MULTILINE),'\1')
|
||||
contents.gsub!(Regexp.new("{% case page.lang %}(((?!{% endcase %})(?!{% when ).)*?){% else %}(.*?){% endcase %}", Regexp::MULTILINE), '\1 \3')
|
||||
contents.gsub!(Regexp.new("{% case page.lang %}(((?!{% when ).)*?){% endcase %}", Regexp::MULTILINE), '\1')
|
||||
# Drop language in statements applied to many languages ( e.g. {% when 'ar' or 'fr' .. %} )
|
||||
contents.gsub!(Regexp.new("{% when '" + lang + "' or (.*?) %}"),'{% when \1 %}')
|
||||
contents.gsub!(Regexp.new("{% when (.*?) or '" + lang + "' (.*?)%}"),'{% when \1 \2%}')
|
||||
File.open(dir + '/' + file, 'w') do |file|
|
||||
file.write(contents)
|
||||
contents.gsub!(Regexp.new("{% when '" + lang + "' or (.*?) %}"), '{% when \1 %}')
|
||||
contents.gsub!(Regexp.new("{% when (.*?) or '" + lang + "' (.*?)%}"), '{% when \1 \2%}')
|
||||
File.open(dir + '/' + file, 'w') do |f|
|
||||
f.write(contents)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,46 +1,45 @@
|
||||
# This file is licensed under the MIT License (MIT) available on
|
||||
# http://opensource.org/licenses/MIT.
|
||||
|
||||
#alerts.rb generates alert pages using files in _alerts
|
||||
#and assign them the 'alert' category.
|
||||
# alerts.rb generates alert pages using files in _alerts
|
||||
# and assign them the 'alert' category.
|
||||
|
||||
#This is later used to loop through site.pages in order
|
||||
#to display the alert's list in chronological order, both
|
||||
#on the "Alerts" page and RSS file.
|
||||
# This is later used to loop through site.pages in order
|
||||
# to display the alert's list in chronological order, both
|
||||
# on the "Alerts" page and RSS file.
|
||||
|
||||
#If "banner" variable is set in one alert file, site.ALERT
|
||||
#variable is set, allowing a clickable alert banner to be
|
||||
#displayed in _layouts/base.html .
|
||||
# If "banner" variable is set in one alert file, site.ALERT
|
||||
# variable is set, allowing a clickable alert banner to be
|
||||
# displayed in _layouts/base.html .
|
||||
|
||||
#If "shorturl" variable is set in one alert file, a short alias
|
||||
#file for the alert (like /android.html) is generated for
|
||||
#Bitcoin Core non-clickable alerts.
|
||||
# If "shorturl" variable is set in one alert file, a short alias
|
||||
# file for the alert (like /android.html) is generated for
|
||||
# Bitcoin Core non-clickable alerts.
|
||||
|
||||
require 'yaml'
|
||||
|
||||
module Jekyll
|
||||
|
||||
class AlertPage < Page
|
||||
def initialize(site, base, lang, srcdir, src, dstdir, dst, date)
|
||||
@site = site
|
||||
@base = base
|
||||
@dir = '/'+dstdir
|
||||
@dir = '/' + dstdir
|
||||
@name = dst
|
||||
extension = dst.split('.')[-1]
|
||||
self.process(dst)
|
||||
self.read_yaml(File.join(base, srcdir), src)
|
||||
self.data['lang'] = lang
|
||||
self.data['date'] = date
|
||||
self.data['path'] = srcdir+'/'+src
|
||||
self.data['path'] = srcdir + '/' + src
|
||||
self.data['layout'] = 'alert'
|
||||
if dstdir == ''
|
||||
self.data['canonical'] = '/en/alert/' + src.split('.')[0]
|
||||
else
|
||||
self.data['category'] = 'alert'
|
||||
if self.data.has_key?('banner') and !self.data['banner'].nil? and self.data['banner'].length>0
|
||||
site.config['ALERT']=self.data['banner']
|
||||
site.config['ALERTURL']='/'+dstdir+'/'+dst.gsub('.html','').gsub('.md','')
|
||||
if self.data.has_key?('bannerclass') and !self.data['bannerclass'].nil? and self.data['bannerclass'].length>0
|
||||
if self.data.has_key?('banner') and !self.data['banner'].nil? and self.data['banner'].length > 0
|
||||
site.config['ALERT'] = self.data['banner']
|
||||
site.config['ALERTURL'] = '/' + dstdir + '/' + dst.gsub('.html', '').gsub('.md', '')
|
||||
if self.data.has_key?('bannerclass') and !self.data['bannerclass'].nil? and self.data['bannerclass'].length > 0
|
||||
site.config['ALERTCLASS'] = self.data['bannerclass']
|
||||
end
|
||||
end
|
||||
@ -48,8 +47,8 @@ module Jekyll
|
||||
site.config['STATUS'] = 1
|
||||
end
|
||||
if self.data.has_key?('shorturl')
|
||||
site.pages << AlertPage.new(site, base, lang, srcdir, src, '', self.data['shorturl']+'.'+extension, date)
|
||||
site.pages << AlertPage.new(site, base, lang, srcdir, src, '', self.data['shorturl']+'/index.'+extension, date)
|
||||
site.pages << AlertPage.new(site, base, lang, srcdir, src, '', self.data['shorturl'] + '.' + extension, date)
|
||||
site.pages << AlertPage.new(site, base, lang, srcdir, src, '', self.data['shorturl'] + '/index.' + extension, date)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -57,31 +56,32 @@ module Jekyll
|
||||
|
||||
class AlertPageGenerator < Generator
|
||||
def generate(site)
|
||||
#Generate each alert based on templates
|
||||
# Generate each alert based on templates
|
||||
site.config['STATUS'] = 0
|
||||
site.config['ALERTCLASS'] = 'alert'
|
||||
#Do nothing if plugin is disabled
|
||||
# Do nothing if plugin is disabled
|
||||
if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index('alerts').nil?
|
||||
print 'Alerts disabled' + "\n"
|
||||
return
|
||||
end
|
||||
Dir.foreach('_alerts') do |file|
|
||||
next if file == '.' or file == '..'
|
||||
|
||||
lang = 'en'
|
||||
src = file
|
||||
dst = file
|
||||
srcdir = '_alerts'
|
||||
dstdir = lang + '/alert'
|
||||
date = dst.split('-')
|
||||
next if date.length < 4
|
||||
|
||||
date = date[0] + '-' + date[1] + '-' + date[2]
|
||||
next if !/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/.match(date)
|
||||
|
||||
site.pages << AlertPage.new(site, site.source, lang, '_alerts', src, dstdir, dst, date)
|
||||
end
|
||||
#TODO alerts are only generated for english language,
|
||||
#but they could also be translated at some point. They would however
|
||||
#need to fallback to english when no translation is available.
|
||||
# TODO alerts are only generated for english language,
|
||||
# but they could also be translated at some point. They would however
|
||||
# need to fallback to english when no translation is available.
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -1,60 +1,62 @@
|
||||
# This file is licensed under the MIT License (MIT) available on
|
||||
# http://opensource.org/licenses/MIT.
|
||||
|
||||
#alphab_for allows to loop in an array sorted by the translated value of
|
||||
#each key using appropriate collation for the current language. In short,
|
||||
#this is used to generate translated table of contents.
|
||||
# alphab_for allows to loop in an array sorted by the translated value of
|
||||
# each key using appropriate collation for the current language. In short,
|
||||
# this is used to generate translated table of contents.
|
||||
|
||||
#Example:
|
||||
#{% alphab_for v in page.voc %}
|
||||
# Example:
|
||||
# {% alphab_for v in page.voc %}
|
||||
# ..
|
||||
#{% endalphab_for %}
|
||||
# {% endalphab_for %}
|
||||
|
||||
require 'yaml'
|
||||
require 'ffi-icu'
|
||||
|
||||
module Jekyll
|
||||
|
||||
module AlphabForImpl
|
||||
def render(context)
|
||||
#Load translations
|
||||
# Load translations
|
||||
site = context.registers[:site].config
|
||||
if !site.has_key?("loc")
|
||||
site['loc'] = {}
|
||||
Dir.foreach('_translations') do |file|
|
||||
next if file == '.' or file == '..' or file == 'COPYING'
|
||||
lang=file.split('.')[0]
|
||||
site['loc'][lang] = YAML.load_file('_translations/'+file)[lang]
|
||||
|
||||
lang = file.split('.')[0]
|
||||
site['loc'][lang] = YAML.load_file('_translations/' + file)[lang]
|
||||
end
|
||||
end
|
||||
#load collection and context variables
|
||||
# load collection and context variables
|
||||
sorted_collection = collection_to_sort context
|
||||
return if sorted_collection.empty?
|
||||
|
||||
lang = Liquid::Template.parse('{{page.lang}}').render context
|
||||
page = Liquid::Template.parse('{{page.id}}').render context
|
||||
#build translated array and associative hash
|
||||
# build translated array and associative hash
|
||||
translated = []
|
||||
assoc = {}
|
||||
for key in sorted_collection do
|
||||
next if !site['loc'][lang].has_key?(page) || !site['loc'][lang][page].has_key?(key) || site['loc'][lang][page][key].nil? || site['loc'][lang][page][key] == ' '
|
||||
|
||||
t = site['loc'][lang][page][key]
|
||||
translated.push(t)
|
||||
assoc[key] = t
|
||||
end
|
||||
#sort translated array using appropriate collation
|
||||
# sort translated array using appropriate collation
|
||||
translated = ICU::Collation.collate(lang, translated)
|
||||
#recreate collection with new ordering
|
||||
# recreate collection with new ordering
|
||||
sorted_collection = []
|
||||
for va in translated do
|
||||
val = assoc.select{|k,v| v == va}
|
||||
#compatibility with old ruby versions that return an Array
|
||||
val = assoc.select { |_k, v| v == va }
|
||||
# compatibility with old ruby versions that return an Array
|
||||
if val.is_a?(Array)
|
||||
val = { val[0][0] => va }
|
||||
end
|
||||
val = val.keys[0]
|
||||
sorted_collection.push(val)
|
||||
end
|
||||
#return modified array
|
||||
# return modified array
|
||||
original_name = @collection_name
|
||||
result = nil
|
||||
context.stack do
|
||||
@ -78,7 +80,6 @@ module Jekyll
|
||||
'endalphab_for'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Liquid::Template.register_tag('alphab_for', Jekyll::AlphabForTag)
|
||||
|
||||
@ -21,11 +21,9 @@
|
||||
## <!--[-->`src/qt/paymentrequest.proto`<!--]-->
|
||||
|
||||
module Jekyll
|
||||
|
||||
require 'yaml'
|
||||
require 'yaml'
|
||||
|
||||
class AutoCrossRefBlock < Liquid::Block
|
||||
|
||||
def initialize(tag_name, text, tokens)
|
||||
super
|
||||
end
|
||||
@ -47,9 +45,7 @@ require 'yaml'
|
||||
|
||||
if site.has_key?("crossref")
|
||||
## We already have refs loaded, so merge
|
||||
site['crossref'].merge!(unvalidated_refs) {
|
||||
|key, old_value, new_value|
|
||||
|
||||
site['crossref'].merge!(unvalidated_refs) { |key, old_value, new_value|
|
||||
if old_value != new_value
|
||||
abort("Error: autocrossref key '#{key}' wants to point to both '#{old_value}' and '#{new_value}'")
|
||||
end
|
||||
@ -63,13 +59,11 @@ require 'yaml'
|
||||
site['crossref_loaded'] = true
|
||||
end
|
||||
|
||||
|
||||
## Sort terms by reverse length, so longest matches get linked
|
||||
## first (e.g. "block chain" before "block"). Otherwise short
|
||||
## terms would get linked first and there'd be nothing for long
|
||||
## terms to link to.
|
||||
site['crossref'].sort_by { |k, v| -k.length }.each { |term|
|
||||
|
||||
site['crossref'].sort_by { |k, _v| -k.length }.each { |term|
|
||||
term[1] = term[0] if term[1].nil? || term[1].empty?
|
||||
|
||||
term[0] = Regexp.escape(term[0])
|
||||
@ -99,7 +93,7 @@ require 'yaml'
|
||||
(?!\w) ## Don't match inside words
|
||||
(?!.*(<\/h{1-6}>)) ## Don't match inside words
|
||||
(?!`) ## Don't match strings ending with a tic, unless the xref itself ends with a tic
|
||||
/xmi) {|s|
|
||||
/xmi) { |s|
|
||||
if term[1] == "do not autocrossref"
|
||||
s.gsub(/( |$)/, "<!--noref-->\\&")
|
||||
else
|
||||
@ -107,7 +101,7 @@ require 'yaml'
|
||||
end
|
||||
}
|
||||
}
|
||||
output.gsub!(/<!--.*?-->/m,'') ## Remove all HTML comments
|
||||
output.gsub!(/<!--.*?-->/m, '') ## Remove all HTML comments
|
||||
|
||||
output
|
||||
end
|
||||
@ -115,11 +109,9 @@ require 'yaml'
|
||||
end
|
||||
|
||||
module Jekyll
|
||||
|
||||
require 'yaml'
|
||||
require 'yaml'
|
||||
|
||||
class AutoCrossRefBlockDisabled < Liquid::Block
|
||||
|
||||
def initialize(tag_name, text, tokens)
|
||||
super
|
||||
end
|
||||
@ -132,9 +124,7 @@ require 'yaml'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#Do nothing if plugin is disabled
|
||||
# Do nothing if plugin is disabled
|
||||
if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index('autocrossref').nil?
|
||||
print 'Autocrossref disabled' + "\n"
|
||||
Liquid::Template.register_tag('autocrossref', Jekyll::AutoCrossRefBlockDisabled)
|
||||
|
||||
@ -1,17 +1,15 @@
|
||||
# This file is licensed under the MIT License (MIT) available on
|
||||
# http://opensource.org/licenses/MIT.
|
||||
|
||||
#contributors.rb fetches Bitcoin Core contributors list and set
|
||||
#site.contributors array. This is later used to display the
|
||||
#list of contributors on the "Development" page.
|
||||
# contributors.rb fetches Bitcoin Core contributors list and set
|
||||
# site.contributors array. This is later used to display the
|
||||
# list of contributors on the "Development" page.
|
||||
|
||||
require 'open-uri'
|
||||
require 'json'
|
||||
|
||||
module Jekyll
|
||||
|
||||
class CategoryGenerator < Generator
|
||||
|
||||
def contributors(repo, aliases)
|
||||
contributors = []
|
||||
# Call GitHub API with 100 results per page
|
||||
@ -19,7 +17,7 @@ module Jekyll
|
||||
data = []
|
||||
while page < 10 do
|
||||
begin
|
||||
ar = JSON.parse(open("https://api.github.com/repos/"+repo+"/contributors?page=#{page}&per_page=100","User-Agent"=>"Ruby/#{RUBY_VERSION}").read)
|
||||
ar = JSON.parse(open("https://api.github.com/repos/" + repo + "/contributors?page=#{page}&per_page=100", "User-Agent" => "Ruby/#{RUBY_VERSION}").read)
|
||||
# Prevent any error to stop the build process, return an empty array instead
|
||||
rescue
|
||||
print 'GitHub API Call Failed!'
|
||||
@ -35,6 +33,7 @@ module Jekyll
|
||||
end
|
||||
# Stop calling GitHub API when no new results are returned
|
||||
break if (ar.length == 0)
|
||||
|
||||
# Merge contributors into a single array
|
||||
data.push(*ar)
|
||||
page += 1
|
||||
@ -45,6 +44,7 @@ module Jekyll
|
||||
# Skip incomplete / invalid data and set contributor's name
|
||||
next if !c.is_a?(Hash)
|
||||
next if !c.has_key?('contributions') or !c['contributions'].is_a?(Integer) or c['contributions'] > 1000000
|
||||
|
||||
if c.has_key?('name') and c['name'].is_a?(String) and /^[A-Za-z0-9\-]{1,150}$/.match(c['name'])
|
||||
name = c['name']
|
||||
elsif c.has_key?('login') and c['login'].is_a?(String) and /^[A-Za-z0-9\-]{1,150}$/.match(c['login'])
|
||||
@ -70,15 +70,15 @@ module Jekyll
|
||||
end
|
||||
end
|
||||
# Generate final ordered contributors array
|
||||
result.each do |key, value|
|
||||
result.each do |_key, value|
|
||||
contributors.push(value)
|
||||
end
|
||||
contributors.sort_by{|c| - c['contributions']}
|
||||
contributors.sort_by { |commits| - commits['contributions'] }
|
||||
end
|
||||
|
||||
def generate(site)
|
||||
# Set site.contributors global variables for liquid/jekyll
|
||||
if ! site.respond_to?('corecontributors')
|
||||
if !site.respond_to?('corecontributors')
|
||||
class << site
|
||||
attr_accessor :corecontributors
|
||||
attr_accessor :sitecontributors
|
||||
@ -98,14 +98,14 @@ module Jekyll
|
||||
site.corecontributors = {}
|
||||
site.sitecontributors = {}
|
||||
|
||||
#Do nothing if plugin is disabled
|
||||
# Do nothing if plugin is disabled
|
||||
if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index('contributors').nil?
|
||||
print 'Contributors disabled' + "\n"
|
||||
return
|
||||
end
|
||||
|
||||
## Create cache directory if it doesn't exist
|
||||
if !File.exists?('_cache')
|
||||
if !File.exist?('_cache')
|
||||
Dir.mkdir('_cache')
|
||||
end
|
||||
|
||||
@ -117,7 +117,7 @@ module Jekyll
|
||||
# file has to be updated, they both get updated.
|
||||
corecontributors_cache = '_cache/corecontributors.marshall'
|
||||
sitecontributors_cache = '_cache/sitecontributors.marshall'
|
||||
if File.exists?(corecontributors_cache) && File.exists?(sitecontributors_cache)
|
||||
if File.exist?(corecontributors_cache) && File.exist?(sitecontributors_cache)
|
||||
corecontributors_cache_age = (Time.now - File.stat(corecontributors_cache).mtime).to_i
|
||||
sitecontributors_cache_age = (Time.now - File.stat(sitecontributors_cache).mtime).to_i
|
||||
else
|
||||
@ -126,25 +126,22 @@ module Jekyll
|
||||
end
|
||||
|
||||
if corecontributors_cache_age > 86400 || sitecontributors_cache_age > 86400
|
||||
site.corecontributors = contributors('bitcoin/bitcoin',site.config['aliases'])
|
||||
File.open(corecontributors_cache,'w') do |file|
|
||||
site.corecontributors = contributors('bitcoin/bitcoin', site.config['aliases'])
|
||||
File.open(corecontributors_cache, 'w') do |file|
|
||||
Marshal.dump(site.corecontributors, file)
|
||||
end
|
||||
site.sitecontributors = contributors('bitcoin-dot-org/bitcoin.org',site.config['aliases'])
|
||||
File.open(sitecontributors_cache,'w') do |file|
|
||||
site.sitecontributors = contributors('bitcoin-dot-org/bitcoin.org', site.config['aliases'])
|
||||
File.open(sitecontributors_cache, 'w') do |file|
|
||||
Marshal.dump(site.sitecontributors, file)
|
||||
end
|
||||
else
|
||||
File.open(corecontributors_cache,'r') do |file|
|
||||
File.open(corecontributors_cache, 'r') do |file|
|
||||
site.corecontributors = Marshal.load(file)
|
||||
end
|
||||
File.open(sitecontributors_cache,'r') do |file|
|
||||
File.open(sitecontributors_cache, 'r') do |file|
|
||||
site.sitecontributors = Marshal.load(file)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -12,7 +12,7 @@ module Jekyll
|
||||
site.config["env"] = site.config["env"] ? site.config["env"] : {}
|
||||
|
||||
## Load matching environmental variables in to array
|
||||
ENV.keys.grep /^BITCOINORG_/ do |key|
|
||||
ENV.keys.grep(/^BITCOINORG_/) do |key|
|
||||
site.config['env'].merge!({ key => ENV[key] })
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
# This file is licensed under the MIT License (MIT) available on
|
||||
# http://opensource.org/licenses/MIT.
|
||||
|
||||
#events.rb sets the site.conferences array based
|
||||
#on events in _events/
|
||||
#This is later used to populate the events map and display the
|
||||
#list in chronological order, in the RSS file and events pages.
|
||||
# events.rb sets the site.conferences array based
|
||||
# on events in _events/
|
||||
# This is later used to populate the events map and display the
|
||||
# list in chronological order, in the RSS file and events pages.
|
||||
|
||||
require 'open-uri'
|
||||
require 'json'
|
||||
@ -13,22 +13,22 @@ require 'yaml'
|
||||
require 'cgi'
|
||||
|
||||
module Jekyll
|
||||
|
||||
class EventPageGenerator < Generator
|
||||
|
||||
def conferences
|
||||
conferences = []
|
||||
# Loop in _events.yml
|
||||
YAML.load_file('_events.yml').each do |data|
|
||||
# Skip event if it has started more than five days ago
|
||||
date = data['date'].to_s.split('-')
|
||||
next if Time.new.to_i > (Time.new(date[0].to_i,date[1].to_i,date[2].to_i).to_i + 432000)
|
||||
next if Time.new.to_i > (Time.new(date[0].to_i, date[1].to_i, date[2].to_i).to_i + 432000)
|
||||
|
||||
# Get geolocalisation data from Google Maps
|
||||
if data.has_key?('address')
|
||||
begin
|
||||
geoloc = JSON.parse(open("https://maps.googleapis.com/maps/api/geocode/json?address=" + CGI::escape(data['address'] + ', ' + data['city'] + ', ' + data['country']) + "&sensor=false","User-Agent"=>"Ruby/#{RUBY_VERSION}").read)
|
||||
geoloc =
|
||||
JSON.parse(open("https://maps.googleapis.com/maps/api/geocode/json?address=" + CGI::escape(data['address'] + ', ' + data['city'] + ', ' + data['country']) + "&sensor=false", "User-Agent" => "Ruby/#{RUBY_VERSION}").read)
|
||||
if geoloc['status'] == 'OK'
|
||||
data['geoloc'] = {'lat' => geoloc['results'][0]['geometry']['location']['lat'].to_s, 'lon' => geoloc['results'][0]['geometry']['location']['lng'].to_s}
|
||||
data['geoloc'] = { 'lat' => geoloc['results'][0]['geometry']['location']['lat'].to_s, 'lon' => geoloc['results'][0]['geometry']['location']['lng'].to_s }
|
||||
end
|
||||
rescue
|
||||
print 'Google Maps API Call Failed!'
|
||||
@ -42,7 +42,7 @@ module Jekyll
|
||||
|
||||
def generate(site)
|
||||
# Set site.meetups and site.conferences global variables for liquid/jekyll
|
||||
if ! site.respond_to?('conferences')
|
||||
if !site.respond_to?('conferences')
|
||||
class << site
|
||||
attr_accessor :meetups, :conferences
|
||||
alias event_site_payload site_payload
|
||||
@ -59,14 +59,14 @@ module Jekyll
|
||||
# Set site.conferences array
|
||||
site.conferences = {}
|
||||
|
||||
#Do nothing if plugin is disabled
|
||||
# Do nothing if plugin is disabled
|
||||
if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index('events').nil?
|
||||
print 'Events disabled' + "\n"
|
||||
return
|
||||
end
|
||||
|
||||
## Create cache directory if it doesn't exist
|
||||
if !File.exists?('_cache')
|
||||
if !File.exist?('_cache')
|
||||
Dir.mkdir('_cache')
|
||||
end
|
||||
|
||||
@ -78,7 +78,7 @@ module Jekyll
|
||||
events_file = '_events.yml'
|
||||
|
||||
events_file_unix_time = File.stat(events_file).mtime.to_i
|
||||
if File.exists?(conferences_cache)
|
||||
if File.exist?(conferences_cache)
|
||||
conferences_cache_unix_time = File.stat(conferences_cache).mtime.to_i
|
||||
else
|
||||
conferences_cache_unix_time = 0
|
||||
@ -86,17 +86,14 @@ module Jekyll
|
||||
|
||||
if events_file_unix_time >= conferences_cache_unix_time
|
||||
site.conferences = conferences()
|
||||
File.open(conferences_cache,'w') do |file|
|
||||
File.open(conferences_cache, 'w') do |file|
|
||||
Marshal.dump(site.conferences, file)
|
||||
end
|
||||
else
|
||||
File.open(conferences_cache,'r') do |file|
|
||||
File.open(conferences_cache, 'r') do |file|
|
||||
site.conferences = Marshal.load(file)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -10,11 +10,9 @@
|
||||
## {% endgithubify %}
|
||||
|
||||
module Jekyll
|
||||
|
||||
require 'yaml'
|
||||
require 'yaml'
|
||||
|
||||
class GitHubifyBlock < Liquid::Block
|
||||
|
||||
def initialize(tag_name, text, tokens)
|
||||
super
|
||||
@repository_url = text.strip()
|
||||
@ -27,14 +25,14 @@ require 'yaml'
|
||||
## If #1234 links to an issue, GitHub automatically redirects
|
||||
#
|
||||
## Require at least two digits to reduce false positive matches
|
||||
output.gsub!(/#([0-9][0-9][0-9]*)/){ |s|
|
||||
output.gsub!(/#([0-9][0-9][0-9]*)/) { |s|
|
||||
'<a href="' + @repository_url + '/pull/' + $1 + '">' + s + '</a>'
|
||||
}
|
||||
|
||||
## Convert `123abcd` into URL for the commit
|
||||
#
|
||||
## Only operate on 7 to 10 chars to reduce false positive matches
|
||||
output.gsub!(/`([0-9abcdef]{7,10})`/){ |s|
|
||||
output.gsub!(/`([0-9abcdef]{7,10})`/) { |s|
|
||||
'<a href="' + @repository_url + '/commit/' + $1 + '">' + s + '</a>'
|
||||
}
|
||||
|
||||
@ -43,14 +41,11 @@ require 'yaml'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
## Code to run if plugin is disabled
|
||||
module Jekyll
|
||||
|
||||
require 'yaml'
|
||||
require 'yaml'
|
||||
|
||||
class GitHubifyBlockDisabled < Liquid::Block
|
||||
|
||||
def initialize(tag_name, text, tokens)
|
||||
super
|
||||
end
|
||||
@ -63,7 +58,7 @@ require 'yaml'
|
||||
end
|
||||
end
|
||||
|
||||
#Do nothing if plugin is disabled
|
||||
# Do nothing if plugin is disabled
|
||||
plugin_name = "githubify"
|
||||
if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index(plugin_name).nil?
|
||||
print plugin_name + ' disabled' + "\n"
|
||||
|
||||
@ -5,9 +5,7 @@ require 'yaml'
|
||||
require 'json'
|
||||
|
||||
module Jekyll
|
||||
|
||||
class GlossaryPage < Page
|
||||
|
||||
def initialize(site, base, lang, srcdir, src, output_directory)
|
||||
@site = site
|
||||
@base = base
|
||||
@ -44,7 +42,7 @@ module Jekyll
|
||||
if self.data["optional"]["synonyms_and_pluralizations_not_shown_in_glossary"].nil?
|
||||
mixed_case_terms = self.data["required"]["synonyms_shown_in_glossary_capitalize_first_letter"]
|
||||
else
|
||||
mixed_case_terms = self.data["required"]["synonyms_shown_in_glossary_capitalize_first_letter"] +\
|
||||
mixed_case_terms = self.data["required"]["synonyms_shown_in_glossary_capitalize_first_letter"] + \
|
||||
self.data["optional"]["synonyms_and_pluralizations_not_shown_in_glossary"]
|
||||
end
|
||||
|
||||
@ -58,9 +56,7 @@ module Jekyll
|
||||
## Add all synonyms to the autocrossref hash table for automatic linking
|
||||
site.config["crossref"] = site.config["crossref"] ? site.config["crossref"] : {}
|
||||
for term in terms do
|
||||
site.config["crossref"].merge!({ term => output_full_path }) {
|
||||
|key, old_value, new_value|
|
||||
|
||||
site.config["crossref"].merge!({ term => output_full_path }) { |key, old_value, new_value|
|
||||
if old_value != new_value
|
||||
abort("Error: autocrossref key '#{key}' wants to point to both '#{old_value}' and '#{new_value}'")
|
||||
end
|
||||
@ -102,57 +98,54 @@ module Jekyll
|
||||
## do support this feature, so if we upgrade to Jekyll 2.2 or
|
||||
## higher, look at doing this at template time to save CPU cycles
|
||||
## and increase flexibility
|
||||
site.config["devsearches"]["Glossary"][lang].sort_by!{|hash|
|
||||
hash.to_s.downcase.gsub(/"=>.*/,'')
|
||||
site.config["devsearches"]["Glossary"][lang].sort_by! { |hash|
|
||||
hash.to_s.downcase.gsub(/"=>.*/, '')
|
||||
}
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
class GlossaryPageGenerator < Generator
|
||||
def generate(site)
|
||||
|
||||
#Do nothing if plugin is disabled
|
||||
# Do nothing if plugin is disabled
|
||||
if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index('glossary').nil?
|
||||
print 'Glossary disabled' + "\n"
|
||||
return
|
||||
end
|
||||
|
||||
main_dir='_data/glossary/'
|
||||
main_dir = '_data/glossary/'
|
||||
|
||||
Dir.foreach(main_dir) do |dir|
|
||||
next if dir == '.' or dir == '..'
|
||||
lang=dir
|
||||
glossary_dir=main_dir+lang
|
||||
|
||||
#Generate each definition page based on templates
|
||||
lang = dir
|
||||
glossary_dir = main_dir + lang
|
||||
|
||||
# Generate each definition page based on templates
|
||||
Dir.foreach(glossary_dir) do |file|
|
||||
next if file == '.' or file == '..'
|
||||
|
||||
src = file
|
||||
output_directory = lang + '/glossary/'
|
||||
site.pages << GlossaryPage.new(site, site.source, lang, glossary_dir, src, output_directory)
|
||||
end
|
||||
|
||||
devsearches_json = []
|
||||
site.config["devsearches"].each {| cat, items |
|
||||
devsearches_data_item = {}
|
||||
|
||||
site.config["devsearches"].each { |cat, items|
|
||||
if cat == "Glossary"
|
||||
items.each {| lang, list |
|
||||
|
||||
list.each {| el |
|
||||
items.each { |language, list|
|
||||
list.each { |el|
|
||||
flat = el.flatten
|
||||
devsearches_json.push({
|
||||
"label" => flat[0],
|
||||
"uri" => flat[1],
|
||||
"category" => cat,
|
||||
"lang" => lang
|
||||
"language" => language
|
||||
})
|
||||
}
|
||||
# puts list
|
||||
}
|
||||
else
|
||||
items.each {| el |
|
||||
items.each { |el|
|
||||
flat = el.flatten
|
||||
devsearches_json.push({
|
||||
"label" => flat[0],
|
||||
@ -174,5 +167,4 @@ module Jekyll
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -1,19 +1,17 @@
|
||||
# This file is licensed under the MIT License (MIT) available on
|
||||
# http://opensource.org/licenses/MIT.
|
||||
|
||||
#htmlescape espaces special html characters. This is a replacement for
|
||||
#CGI::escapeHTML, which has an inconsistent behavior with single quotes
|
||||
#on different ruby versions ( 1.9 and 2.0 ).
|
||||
# htmlescape espaces special html characters. This is a replacement for
|
||||
# CGI::escapeHTML, which has an inconsistent behavior with single quotes
|
||||
# on different ruby versions ( 1.9 and 2.0 ).
|
||||
|
||||
#Example:
|
||||
# Example:
|
||||
# {{ page.title | htmlescape }}
|
||||
|
||||
module Entities
|
||||
|
||||
def htmlescape(input)
|
||||
input.gsub(/['&\"<>]/, { "'" => ''', '&' => '&', '"' => '"', '<' => '<', '>' => '>' })
|
||||
end
|
||||
|
||||
Liquid::Template.register_filter self
|
||||
|
||||
end
|
||||
|
||||
@ -10,21 +10,19 @@
|
||||
## {% enditemplate %}
|
||||
|
||||
module Jekyll
|
||||
|
||||
require 'yaml'
|
||||
require 'yaml'
|
||||
|
||||
class InlineTemplateBlock < Liquid::Block
|
||||
|
||||
def initialize(tag_name, text, tokens)
|
||||
super
|
||||
@template_name = '_templates/' + text.gsub(' ','') + '.inline'
|
||||
@template_name = '_templates/' + text.gsub(' ', '') + '.inline'
|
||||
end
|
||||
|
||||
def render(context)
|
||||
output = super
|
||||
|
||||
data = YAML.load(output)
|
||||
template = File.open(@template_name, mode="r")
|
||||
template = File.open(@template_name)
|
||||
@mytemplate = Liquid::Template.parse(template.read())
|
||||
@mytemplate.render('entry' => data)
|
||||
end
|
||||
@ -32,11 +30,9 @@ require 'yaml'
|
||||
end
|
||||
|
||||
module Jekyll
|
||||
|
||||
require 'yaml'
|
||||
require 'yaml'
|
||||
|
||||
class InlineTemplateBlockDisabled < Liquid::Block
|
||||
|
||||
def initialize(tag_name, text, tokens)
|
||||
super
|
||||
end
|
||||
@ -45,19 +41,7 @@ require 'yaml'
|
||||
output = super
|
||||
|
||||
output
|
||||
#return('Inline Template (itemplate) disabled' + "\n")
|
||||
# return('Inline Template (itemplate) disabled' + "\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#Do nothing if plugin is disabled
|
||||
## Note: tested 2015-04-12 and the site actually compiles 5 seconds
|
||||
## *faster* with this enabled, so hardcoding it to enabled for now
|
||||
if false #!ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index('itemplate').nil?
|
||||
print 'Inline Template (itemplate) disabled' + "\n"
|
||||
Liquid::Template.register_tag('itemplate', Jekyll::InlineTemplateBlockDisabled)
|
||||
else
|
||||
Liquid::Template.register_tag('itemplate', Jekyll::InlineTemplateBlock)
|
||||
end
|
||||
|
||||
@ -12,20 +12,17 @@
|
||||
## {% endif %}
|
||||
|
||||
module Jekyll
|
||||
|
||||
class LiquidDie < Liquid::Tag
|
||||
|
||||
def initialize(tag_name, text, tokens)
|
||||
super
|
||||
@error = text
|
||||
end
|
||||
|
||||
def render(context)
|
||||
def render(_context)
|
||||
## Produces: Liquid die tag called. [<Error.>] -- Error creating output [in <output file name>]
|
||||
abort("Liquid die tag called. " + @error + " -- Error creating output" )
|
||||
abort("Liquid die tag called. " + @error + " -- Error creating output")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Liquid::Template.register_tag('die', Jekyll::LiquidDie)
|
||||
|
||||
@ -12,15 +12,13 @@
|
||||
## {% endif %}
|
||||
|
||||
module Jekyll
|
||||
|
||||
class LiquidWarn < Liquid::Tag
|
||||
|
||||
def initialize(tag_name, text, tokens)
|
||||
super
|
||||
@warning = text
|
||||
end
|
||||
|
||||
def render(context)
|
||||
def render(_context)
|
||||
## Use "notice" instead of "warning" because we use grep to
|
||||
## treat some Jekyll warnings as errors
|
||||
print "Notice: " + @warning + "\n"
|
||||
|
||||
@ -1,14 +1,13 @@
|
||||
# This file is licensed under the MIT License (MIT) available on
|
||||
# http://opensource.org/licenses/MIT.
|
||||
|
||||
#redirects.rb generates all redirection pages
|
||||
#from _config.yml .
|
||||
# redirects.rb generates all redirection pages
|
||||
# from _config.yml .
|
||||
|
||||
require 'yaml'
|
||||
require 'cgi'
|
||||
|
||||
module Jekyll
|
||||
|
||||
class PageRedirect < Page
|
||||
def initialize(site, base, srcdir, src, dst)
|
||||
@site = site
|
||||
@ -25,20 +24,19 @@ module Jekyll
|
||||
|
||||
class RedirectPageGenerator < Generator
|
||||
def generate(site)
|
||||
|
||||
#Do nothing if plugin is disabled
|
||||
# Do nothing if plugin is disabled
|
||||
if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index('redirects').nil?
|
||||
print 'Redirects disabled' + "\n"
|
||||
return
|
||||
end
|
||||
|
||||
#Load redirections
|
||||
# Load redirections
|
||||
redirects = YAML.load_file("_config.yml")['redirects']
|
||||
#Generate each redirection page
|
||||
# Generate each redirection page
|
||||
if !File.directory?(site.dest)
|
||||
Dir.mkdir(site.dest)
|
||||
end
|
||||
redirects.each do |src,dst|
|
||||
redirects.each do |src, dst|
|
||||
srcar = src.split('/')
|
||||
src = srcar.pop + '.html'
|
||||
srcdir = srcar.join('/')
|
||||
@ -46,5 +44,4 @@ module Jekyll
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
# This file is licensed under the MIT License (MIT) available on
|
||||
# http://opensource.org/licenses/MIT.
|
||||
|
||||
#releases.rb generates release pages using files in _releases
|
||||
#and assign them the 'release' category.
|
||||
# releases.rb generates release pages using files in _releases
|
||||
# and assign them the 'release' category.
|
||||
|
||||
#This is later used to loop through site.pages in order
|
||||
#to display the release's list in version order, both
|
||||
#on the "Version history" page and RSS file.
|
||||
# This is later used to loop through site.pages in order
|
||||
# to display the release's list in version order, both
|
||||
# on the "Version history" page and RSS file.
|
||||
|
||||
# This plugin also finds the highest required_version of
|
||||
# Bitcoin Core and populates the Download page with variables set in
|
||||
@ -15,9 +15,7 @@
|
||||
require 'yaml'
|
||||
|
||||
module Jekyll
|
||||
|
||||
class ReleasePage < Page
|
||||
|
||||
def initialize(site, base, lang, srcdir, src, output_directory)
|
||||
@site = site
|
||||
@base = base
|
||||
@ -62,37 +60,34 @@ module Jekyll
|
||||
|
||||
def versiontoint(v)
|
||||
x = 0
|
||||
ar = v.split('.').map{|s| s.to_i}
|
||||
ar = v.split('.').map { |s| s.to_i }
|
||||
ar.each_index do |k|
|
||||
x += ar[k] * (1000 ** (5 - k))
|
||||
x += ar[k] * (1000**(5 - k))
|
||||
end
|
||||
return x
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class ReleasePageGenerator < Generator
|
||||
def generate(site)
|
||||
|
||||
#Do nothing if plugin is disabled
|
||||
# Do nothing if plugin is disabled
|
||||
if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index('releases').nil?
|
||||
print 'Releases disabled' + "\n"
|
||||
return
|
||||
end
|
||||
|
||||
#generate each release based on templates
|
||||
# generate each release based on templates
|
||||
Dir.foreach('_releases') do |file|
|
||||
next if file == '.' or file == '..'
|
||||
|
||||
lang = 'en'
|
||||
src = file
|
||||
srcdir = '_releases'
|
||||
output_directory = lang + '/release'
|
||||
site.pages << ReleasePage.new(site, site.source, lang, '_releases', src, output_directory)
|
||||
end
|
||||
#TODO releases are only generated for english language,
|
||||
#but they could also be translated at some point. They would however
|
||||
#need to fallback to english when no translation is available.
|
||||
# TODO releases are only generated for english language,
|
||||
# but they could also be translated at some point. They would however
|
||||
# need to fallback to english when no translation is available.
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -1,14 +1,13 @@
|
||||
# This file is licensed under the MIT License (MIT) available on
|
||||
# http://opensource.org/licenses/MIT.
|
||||
|
||||
#sitemap.rb generates a sitemap.xml file, which also includes
|
||||
#alternate hreflang for each translated version of each page.
|
||||
# sitemap.rb generates a sitemap.xml file, which also includes
|
||||
# alternate hreflang for each translated version of each page.
|
||||
|
||||
require 'yaml'
|
||||
require 'cgi'
|
||||
|
||||
module Jekyll
|
||||
|
||||
class SitemapFile < StaticFile
|
||||
def write(dest)
|
||||
# do nothing
|
||||
@ -17,85 +16,93 @@ module Jekyll
|
||||
|
||||
class SitemapGenerator < Generator
|
||||
def generate(site)
|
||||
#Do nothing if plugin is disabled
|
||||
# Do nothing if plugin is disabled
|
||||
if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index('sitemap').nil?
|
||||
print 'Sitemap disabled' + "\n"
|
||||
return
|
||||
end
|
||||
#Load translations
|
||||
# Load translations
|
||||
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 lang if disabled
|
||||
|
||||
lang = file.split('.')[0]
|
||||
# Ignore lang if disabled
|
||||
if lang != 'en' and !enabled.nil? and !enabled.include?(lang)
|
||||
next
|
||||
end
|
||||
locs[lang] = YAML.load_file('_translations/'+file)[lang]
|
||||
|
||||
locs[lang] = YAML.load_file('_translations/' + file)[lang]
|
||||
end
|
||||
#Create destination directory if does not exists
|
||||
# Create destination directory if does not exists
|
||||
if !File.directory?(site.dest)
|
||||
Dir.mkdir(site.dest)
|
||||
end
|
||||
File.open(File.join(site.dest, 'sitemap.xml'), 'w+') do |sitemap|
|
||||
#Open sitemap
|
||||
# Open sitemap
|
||||
sitemap.puts '<?xml version="1.0" encoding="UTF-8"?>'
|
||||
sitemap.puts '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"'
|
||||
sitemap.puts ' xmlns:xhtml="http://www.w3.org/1999/xhtml">'
|
||||
#Add translated pages with their alternative in each languages
|
||||
locs['en']['url'].each do |id,value|
|
||||
locs.each do |lang,value|
|
||||
#Don't add a page if their url is not translated
|
||||
# Add translated pages with their alternative in each languages
|
||||
locs['en']['url'].each do |id, _value|
|
||||
locs.each do |lang, _var|
|
||||
# Don't add a page if their url is not translated
|
||||
next if locs[lang]['url'][id].nil? or locs[lang]['url'][id] == ''
|
||||
|
||||
sitemap.puts '<url>'
|
||||
sitemap.puts ' <loc>https://bitcoin.org/'+lang+'/'+CGI::escape(locs[lang]['url'][id])+'</loc>'
|
||||
locs.each do |altlang,value|
|
||||
sitemap.puts ' <loc>https://bitcoin.org/' + lang + '/' + CGI::escape(locs[lang]['url'][id]) + '</loc>'
|
||||
locs.each do |altlang, _altvar|
|
||||
next if locs[altlang]['url'][id].nil? or locs[altlang]['url'][id] == '' or altlang == lang
|
||||
|
||||
sitemap.puts ' <xhtml:link'
|
||||
sitemap.puts ' rel="alternate"'
|
||||
sitemap.puts ' hreflang="'+altlang+'"'
|
||||
sitemap.puts ' href="https://bitcoin.org/'+altlang+'/'+CGI::escape(locs[altlang]['url'][id])+'" />'
|
||||
sitemap.puts ' hreflang="' + altlang + '"'
|
||||
sitemap.puts ' href="https://bitcoin.org/' + altlang + '/' + CGI::escape(locs[altlang]['url'][id]) + '" />'
|
||||
end
|
||||
sitemap.puts '</url>'
|
||||
end
|
||||
end
|
||||
#Add static non-translated pages
|
||||
# Add static non-translated pages
|
||||
Dir.glob('en/**/*.{md,html}').concat(Dir.glob('*.{md,html}')).each do |file|
|
||||
next if file == 'index.html' or file == '404.html' or file == 'README.md'
|
||||
#Ignore google webmaster tools
|
||||
|
||||
# Ignore google webmaster tools
|
||||
data = File.read(file)
|
||||
next if !data.index('google-site-verification:').nil?
|
||||
|
||||
sitemap.puts '<url>'
|
||||
sitemap.puts ' <loc>https://bitcoin.org/'+file.gsub('.html','').gsub('.md','')+'</loc>'
|
||||
sitemap.puts ' <loc>https://bitcoin.org/' + file.gsub('.html', '').gsub('.md', '') + '</loc>'
|
||||
sitemap.puts '</url>'
|
||||
end
|
||||
#Add alerts pages
|
||||
# Add alerts pages
|
||||
Dir.foreach('_alerts') do |file|
|
||||
next if file == '.' or file == '..'
|
||||
|
||||
sitemap.puts '<url>'
|
||||
sitemap.puts ' <loc>https://bitcoin.org/en/alert/'+file.gsub('.html','')+'</loc>'
|
||||
sitemap.puts ' <loc>https://bitcoin.org/en/alert/' + file.gsub('.html', '') + '</loc>'
|
||||
sitemap.puts '</url>'
|
||||
end
|
||||
#Add releases pages
|
||||
# Add releases pages
|
||||
Dir.foreach('_releases') do |file|
|
||||
next if file == '.' or file == '..'
|
||||
|
||||
file = file.split('-')
|
||||
next if file.length < 4
|
||||
|
||||
file.shift()
|
||||
file.shift()
|
||||
file.shift()
|
||||
file = file.join('-')
|
||||
sitemap.puts '<url>'
|
||||
sitemap.puts ' <loc>https://bitcoin.org/en/release/'+file.gsub('.md','').gsub('.html','')+'</loc>'
|
||||
sitemap.puts ' <loc>https://bitcoin.org/en/release/' + file.gsub('.md', '').gsub('.html', '') + '</loc>'
|
||||
sitemap.puts '</url>'
|
||||
end
|
||||
#Close sitemap
|
||||
# Close sitemap
|
||||
sitemap.puts '</urlset>'
|
||||
end
|
||||
site.static_files << SitemapFile.new(site, site.source, '', 'sitemap.xml')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -1,20 +1,19 @@
|
||||
# This file is licensed under the MIT License (MIT) available on
|
||||
# http://opensource.org/licenses/MIT.
|
||||
|
||||
#templates.rb generates all translated pages using templates in
|
||||
#_templates. The final file name of each page is defined in
|
||||
#the url section of each translations in _translations.
|
||||
# templates.rb generates all translated pages using templates in
|
||||
# _templates. The final file name of each page is defined in
|
||||
# the url section of each translations in _translations.
|
||||
|
||||
require 'yaml'
|
||||
require 'cgi'
|
||||
|
||||
module Jekyll
|
||||
|
||||
class TranslatePage < Page
|
||||
def initialize(site, base, lang, srcdir, src, dstdir, dst)
|
||||
@site = site
|
||||
@base = base
|
||||
@dir = '/'+dstdir
|
||||
@dir = '/' + dstdir
|
||||
@name = dst
|
||||
self.process(dst)
|
||||
self.read_yaml(File.join(base, srcdir), src)
|
||||
@ -23,41 +22,43 @@ module Jekyll
|
||||
end
|
||||
class TranslatePageGenerator < Generator
|
||||
def generate(site)
|
||||
#load translations files
|
||||
# load translations files
|
||||
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 lang if disabled
|
||||
# Ignore lang if disabled
|
||||
if lang != 'en' and !enabled.nil? and !enabled.include?(lang)
|
||||
print 'Lang ' + lang + ' disabled' + "\n"
|
||||
next
|
||||
end
|
||||
locs[lang] = YAML.load_file("_translations/"+file)[lang]
|
||||
locs[lang] = YAML.load_file("_translations/" + file)[lang]
|
||||
end
|
||||
#Generate each translated page based on templates
|
||||
# Generate each translated page based on templates
|
||||
if !File.directory?(site.dest)
|
||||
Dir.mkdir(site.dest)
|
||||
end
|
||||
locs.each do |lang,value|
|
||||
locs.each do |lang, _value|
|
||||
Dir.foreach('_templates') do |file|
|
||||
next if file == '.' or file == '..'
|
||||
|
||||
id = file.split('.')[0]
|
||||
dst = locs[lang]['url'][id]
|
||||
next if dst.nil? or dst == ''
|
||||
|
||||
src = file
|
||||
## For files ending in a slash, such as path/to/dir/, give them
|
||||
## the index.html file name
|
||||
dst.gsub!(/\/$/, '/index')
|
||||
|
||||
dst = dst+'.html'
|
||||
dst = dst + '.html'
|
||||
site.pages << TranslatePage.new(site, site.source, lang, '_templates', src, lang, dst)
|
||||
end
|
||||
site.pages << TranslatePage.new(site, site.source, lang, '_templates', 'index.html', lang, 'index.html')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -1,50 +1,49 @@
|
||||
# This file is licensed under the MIT License (MIT) available on
|
||||
# http://opensource.org/licenses/MIT.
|
||||
|
||||
#translate( id [,category ,lang] )
|
||||
#Return translated string using translations files
|
||||
# translate( id [,category ,lang] )
|
||||
# Return translated string using translations files
|
||||
|
||||
#category and lang are set to current page.id and page.lang, but they can
|
||||
#also be set manually to get translations for global layout and urls.
|
||||
#Example: {% translate button-wallet layout %} will return the
|
||||
#translated button-wallet string for the global layout file
|
||||
# category and lang are set to current page.id and page.lang, but they can
|
||||
# also be set manually to get translations for global layout and urls.
|
||||
# Example: {% translate button-wallet layout %} will return the
|
||||
# translated button-wallet string for the global layout file
|
||||
|
||||
#dynamic variables can be used as arguments
|
||||
#Example: {% translate menu-{{id}} %}
|
||||
# dynamic variables can be used as arguments
|
||||
# Example: {% translate menu-{{id}} %}
|
||||
|
||||
#urls and anchors are automatically replaced and translated.
|
||||
#Example: #vocabulary##[vocabulary.wallet] is replaced by
|
||||
#/en/vocabulary#wallet when the page is in english or
|
||||
#/fr/vocabulaire#porte-monnaie when the page is in french.
|
||||
# urls and anchors are automatically replaced and translated.
|
||||
# Example: #vocabulary##[vocabulary.wallet] is replaced by
|
||||
# /en/vocabulary#wallet when the page is in english or
|
||||
# /fr/vocabulaire#porte-monnaie when the page is in french.
|
||||
|
||||
require 'yaml'
|
||||
require 'cgi'
|
||||
|
||||
module Jekyll
|
||||
|
||||
class TranslateTag < Liquid::Tag
|
||||
|
||||
def initialize(tag_name, id, tokens)
|
||||
super
|
||||
@id = id
|
||||
end
|
||||
|
||||
def render(context)
|
||||
#Load translations
|
||||
# Load translations
|
||||
site = context.registers[:site].config
|
||||
if !site.has_key?("loc")
|
||||
site['loc'] = {}
|
||||
Dir.foreach('_translations') do |file|
|
||||
next if file == '.' or file == '..'
|
||||
lang=file.split('.')[0]
|
||||
site['loc'][lang] = YAML.load_file('_translations/'+file)[lang]
|
||||
|
||||
lang = file.split('.')[0]
|
||||
site['loc'][lang] = YAML.load_file('_translations/' + file)[lang]
|
||||
end
|
||||
end
|
||||
#define id, category and lang
|
||||
# define id, category and lang
|
||||
defaulten = true
|
||||
lang = Liquid::Template.parse("{{page.lang}}").render context
|
||||
cat = Liquid::Template.parse("{{page.id}}").render context
|
||||
id=@id.split(' ')
|
||||
id = @id.split(' ')
|
||||
if !id[1].nil?
|
||||
cat = Liquid::Template.parse(id[1]).render context
|
||||
end
|
||||
@ -52,62 +51,63 @@ module Jekyll
|
||||
lang = Liquid::Template.parse(id[2]).render context
|
||||
defaulten = false
|
||||
end
|
||||
id=Liquid::Template.parse(id[0]).render context
|
||||
id = Liquid::Template.parse(id[0]).render context
|
||||
if lang == ''
|
||||
lang = 'en'
|
||||
end
|
||||
#get translated string
|
||||
# get translated string
|
||||
text = ''
|
||||
keys = cat.split('.')
|
||||
ar = site['loc'][lang]
|
||||
#recursive loop to handle cases where category is like "anchor.vocabulary"
|
||||
# recursive loop to handle cases where category is like "anchor.vocabulary"
|
||||
for key in keys do
|
||||
break if !ar.is_a?(Hash) || !ar.has_key?(key) || !ar[key].is_a?(Hash)
|
||||
|
||||
ar = ar[key]
|
||||
end
|
||||
if ar.has_key?(id) && ar[id].is_a?(String)
|
||||
text = ar[id]
|
||||
end
|
||||
#fallback to English if string is empty
|
||||
# fallback to English if string is empty
|
||||
if text == '' and defaulten == true
|
||||
lang = 'en'
|
||||
ar = site['loc'][lang]
|
||||
for key in keys do
|
||||
break if !ar.is_a?(Hash) || !ar.has_key?(key) || !ar[key].is_a?(Hash)
|
||||
|
||||
ar = ar[key]
|
||||
end
|
||||
if ar.has_key?(id) && ar[id].is_a?(String)
|
||||
text = ar[id]
|
||||
end
|
||||
end
|
||||
#interpret Liquid templating in string
|
||||
# interpret Liquid templating in string
|
||||
text = Liquid::Template.parse(text).render context
|
||||
|
||||
#replace urls and anchors in string
|
||||
# replace urls and anchors in string
|
||||
url = site['loc'][lang]['url']
|
||||
url.each do |key,value|
|
||||
url.each do |k, v|
|
||||
if !value.nil?
|
||||
text.gsub!("#"+key+"#",'/'+lang+'/'+CGI::escape(value))
|
||||
text.gsub!("#" + k + "#", '/' + lang + '/' + CGI::escape(v))
|
||||
end
|
||||
end
|
||||
|
||||
## Hack for renaming links to the Bitcoin paper. Safe to remove
|
||||
## when all languages have "bitcoin-paper:" defined in the "url:"
|
||||
## section of their '_translations' YAML file.
|
||||
text.gsub!('#bitcoin-paper#','/bitcoin.pdf')
|
||||
text.gsub!('#bitcoin-paper#', '/bitcoin.pdf')
|
||||
|
||||
anc = site['loc'][lang]['anchor']
|
||||
anc.each do |page,anch|
|
||||
anch.each do |key,value|
|
||||
anc.each do |page, anch|
|
||||
anch.each do |k, v|
|
||||
if !value.nil?
|
||||
text.gsub!("["+page+'.'+key+"]",CGI::escape(value))
|
||||
text.gsub!("[" + page + '.' + k + "]", CGI::escape(v))
|
||||
end
|
||||
end
|
||||
end
|
||||
text
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Liquid::Template.register_tag('translate', Jekyll::TranslateTag)
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
require 'yaml'
|
||||
|
||||
module Jekyll
|
||||
|
||||
class WalletPage < Page
|
||||
def initialize(site, base, dir, wallet, platform, os, title, lang)
|
||||
@site = site
|
||||
@ -61,17 +60,18 @@ module Jekyll
|
||||
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]
|
||||
locs[lang] = YAML.load_file("_translations/" + file)[lang]
|
||||
end
|
||||
|
||||
# Getting information about each found wallet
|
||||
locs.each do |lang,value|
|
||||
locs.each do |lang, _value|
|
||||
title = locs[lang]['choose-your-wallet']['title']
|
||||
|
||||
platformsCol.docs.each do |doc|
|
||||
@ -104,7 +104,6 @@ module Jekyll
|
||||
# platforms and OSes
|
||||
walletPlatforms.each do |platform|
|
||||
platform['os'].each do |os|
|
||||
|
||||
# This allows generation only of valid wallet pages
|
||||
if platform['name']
|
||||
if platform['name'] == os['name']
|
||||
@ -125,13 +124,10 @@ module Jekyll
|
||||
|
||||
site.pages << WalletPage.new(site, site.source, File.join(lang, walletsDir, dir), wallet, platform, os, fullTitle, lang)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user