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
|
group :development do
|
||||||
gem 'ffi-icu'
|
gem 'ffi-icu'
|
||||||
gem 'jekyll', '~>3.0'
|
gem 'jekyll', '~>3.0'
|
||||||
|
gem 'jshintrb', '~>0.3.0'
|
||||||
gem 'json', '>= 1.9'
|
gem 'json', '>= 1.9'
|
||||||
gem 'less', '2.4.0'
|
gem 'json-schema'
|
||||||
gem 'kramdown'
|
gem 'kramdown'
|
||||||
gem 'RedCloth', ">= 4.3.0"
|
gem 'RedCloth', ">= 4.3.0"
|
||||||
gem 'therubyracer' # required by less
|
gem 'less', '2.4.0'
|
||||||
gem 'jshintrb', '~>0.3.0'
|
gem 'rubocop'
|
||||||
gem 'safe_yaml'
|
gem 'safe_yaml'
|
||||||
gem 'json-schema'
|
gem 'therubyracer' # required by less
|
||||||
end
|
end
|
||||||
|
|
||||||
## Not used on build server. Only used by developers and Travis CI, so
|
## 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:
|
specs:
|
||||||
RedCloth (4.3.2)
|
RedCloth (4.3.2)
|
||||||
addressable (2.4.0)
|
addressable (2.4.0)
|
||||||
|
ast (2.4.0)
|
||||||
colorator (0.1)
|
colorator (0.1)
|
||||||
colored (1.2)
|
colored (1.2)
|
||||||
commonjs (0.2.7)
|
commonjs (0.2.7)
|
||||||
@ -20,6 +21,7 @@ GEM
|
|||||||
parallel (~> 1.3)
|
parallel (~> 1.3)
|
||||||
typhoeus (~> 0.7)
|
typhoeus (~> 0.7)
|
||||||
yell (~> 2.0)
|
yell (~> 2.0)
|
||||||
|
jaro_winkler (1.5.1)
|
||||||
jekyll (3.0.1)
|
jekyll (3.0.1)
|
||||||
colorator (~> 0.1)
|
colorator (~> 0.1)
|
||||||
jekyll-sass-converter (~> 1.0)
|
jekyll-sass-converter (~> 1.0)
|
||||||
@ -55,11 +57,24 @@ GEM
|
|||||||
mini_portile2 (~> 2.4.0)
|
mini_portile2 (~> 2.4.0)
|
||||||
parallel (1.12.0)
|
parallel (1.12.0)
|
||||||
rake (13.0.1)
|
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-fsevent (0.9.7)
|
||||||
rb-inotify (0.9.5)
|
rb-inotify (0.9.5)
|
||||||
ffi (>= 0.5.0)
|
ffi (>= 0.5.0)
|
||||||
ref (2.0.0)
|
ref (2.0.0)
|
||||||
rouge (1.10.1)
|
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)
|
safe_yaml (1.0.4)
|
||||||
sass (3.4.20)
|
sass (3.4.20)
|
||||||
therubyracer (0.12.3)
|
therubyracer (0.12.3)
|
||||||
@ -67,6 +82,7 @@ GEM
|
|||||||
ref
|
ref
|
||||||
typhoeus (0.8.0)
|
typhoeus (0.8.0)
|
||||||
ethon (>= 0.8.0)
|
ethon (>= 0.8.0)
|
||||||
|
unicode-display_width (1.4.1)
|
||||||
yell (2.0.7)
|
yell (2.0.7)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
@ -82,6 +98,7 @@ DEPENDENCIES
|
|||||||
json-schema
|
json-schema
|
||||||
kramdown
|
kramdown
|
||||||
less (= 2.4.0)
|
less (= 2.4.0)
|
||||||
|
rubocop
|
||||||
safe_yaml
|
safe_yaml
|
||||||
therubyracer
|
therubyracer
|
||||||
|
|
||||||
|
|||||||
6
_build/txpreview/addlang.rb
Normal file → Executable file
6
_build/txpreview/addlang.rb
Normal file → Executable file
@ -14,10 +14,10 @@ end
|
|||||||
contents = File.read(PATH + '/_config.yml')
|
contents = File.read(PATH + '/_config.yml')
|
||||||
|
|
||||||
if Regexp.new('langsorder:.*?' + "\n" + '- \'' + la + '\'' + "\n", Regexp::MULTILINE).match(contents).nil?
|
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("(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("(langs:.*?)\n\n", Regexp::MULTILINE), '\1' + "\n" + ' \'' + la + '\': \'' + la + '\'' + "\n\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
File.open(PATH + '/_config.yml', 'w') do |file|
|
File.open(PATH + '/_config.yml', 'w') do |file|
|
||||||
file.write(contents)
|
file.write(contents)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -3,63 +3,72 @@
|
|||||||
require 'html/proofer'
|
require 'html/proofer'
|
||||||
|
|
||||||
if ARGV[0].nil?
|
if ARGV[0].nil?
|
||||||
path_to_check="./_site"
|
path_to_check = "./_site"
|
||||||
else
|
else
|
||||||
path_to_check=ARGV[0]
|
path_to_check = ARGV[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
## Will throw an exception (exiting false) if any internal links don't
|
## Will throw an exception (exiting false) if any internal links don't
|
||||||
## work. The Makefile will terminate on the failure
|
## work. The Makefile will terminate on the failure
|
||||||
HTML::Proofer.new(
|
HTML::Proofer.new(
|
||||||
## To test, uncomment the array below and comment out ./_site and :disable_external
|
## 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,
|
path_to_check,
|
||||||
|
{
|
||||||
|
## Disable external link checking by default to avoid spurious
|
||||||
|
## Travis CI failures. TODO: take an argument to optionally
|
||||||
|
## enable external link checking as part of the Makefile
|
||||||
|
## manual checks
|
||||||
|
:disable_external => true,
|
||||||
|
|
||||||
{
|
## Check whether HTML is well-formed
|
||||||
## Disable external link checking by default to avoid spurious
|
:check_html => true,
|
||||||
## Travis CI failures. TODO: take an argument to optionally
|
|
||||||
## enable external link checking as part of the Makefile
|
|
||||||
## manual checks
|
|
||||||
:disable_external => true,
|
|
||||||
|
|
||||||
## Check whether HTML is well-formed
|
## Links to ignore
|
||||||
:check_html => true,
|
:href_ignore => [
|
||||||
|
'#', ## hrefs pointing to the current page (htmlproofer fails them)
|
||||||
|
/^$/, ## anchors with no href attribute set (for clickable javascript elements)
|
||||||
|
/^\/bin/, ## /bin dir is not part of repository; holds Bitcoin Core binaries
|
||||||
|
'bitcoin:3FkenCiXpSLqD8L79intRNXUgjRoH9sjXa', ## bitcoin address handlers
|
||||||
|
/^\/stats/ ## /stats dir is not part of repository; generated by separate stats script
|
||||||
|
],
|
||||||
|
|
||||||
## Links to ignore
|
## Mangle links. If we enable external link checking, this will
|
||||||
:href_ignore => [
|
## require updating
|
||||||
'#', ## hrefs pointing to the current page (htmlproofer fails them)
|
:href_swap => {
|
||||||
/^$/, ## anchors with no href attribute set (for clickable javascript elements)
|
## (Hack) Append '$' to the ends of filenames we don't want to append .html to
|
||||||
/^\/bin/, ## /bin dir is not part of repository; holds Bitcoin Core binaries
|
/(css|png|rss|pdf|jpg|asc|xml)$/ => '\1$',
|
||||||
'bitcoin:3FkenCiXpSLqD8L79intRNXUgjRoH9sjXa', ## bitcoin address handlers
|
|
||||||
/^\/stats/ ## /stats dir is not part of repository; generated by separate stats script
|
|
||||||
],
|
|
||||||
|
|
||||||
## Mangle links. If we enable external link checking, this will
|
## Append .html to end of most URLs so proofer can find the local files
|
||||||
## require updating
|
/^(
|
||||||
:href_swap => {
|
[^#]+ ## Don't match URL containing a hash, we'll deal with them separately
|
||||||
## (Hack) Append '$' to the ends of filenames we don't want to append .html to
|
[^\/$] ## Don't match URLs ending in a slash or $
|
||||||
/(css|png|rss|pdf|jpg|asc|xml)$/ => '\1$',
|
)$/x => '\1.html',
|
||||||
|
|
||||||
## Append .html to end of most URLs so proofer can find the local files
|
## Insert .html between page and anchor, but only if there's a
|
||||||
/^(
|
## page name
|
||||||
[^#]+ ## Don't match URL containing a hash, we'll deal with them separately
|
/^(.+)(#.+)/ => '\1.html\2',
|
||||||
[^\/$] ## Don't match URLs ending in a slash or $
|
|
||||||
)$/x => '\1.html',
|
|
||||||
|
|
||||||
## Insert .html between page and anchor, but only if there's a
|
/\/(.html#.+)/ => '\1',
|
||||||
## page name
|
|
||||||
/^(.+)(#.+)/ => '\1.html\2',
|
|
||||||
|
|
||||||
/\/(.html#.+)/ => '\1',
|
## (Un-hack) Remove previously-appended '$' from URLs
|
||||||
|
/\$$/ => '',
|
||||||
## (Un-hack) Remove previously-appended '$' from URLs
|
},
|
||||||
/\$$/ => '',
|
|
||||||
},
|
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
## It'd be nice if we had a _local_config.yaml file or something
|
## It'd be nice if we had a _local_config.yaml file or something
|
||||||
## for settings specific to particular systems, but for now I
|
## for settings specific to particular systems, but for now I
|
||||||
## think 2 is a good setting for Travis CI ("1.5 processors")
|
## think 2 is a good setting for Travis CI ("1.5 processors")
|
||||||
## and me (usually 2 processors)
|
## and me (usually 2 processors)
|
||||||
:parallel => { :in_processes => 2 },
|
: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
|
).run
|
||||||
|
>>>>>>> 3f9dc02e... rubocop: Remove extra spaces
|
||||||
|
|||||||
@ -9,8 +9,8 @@
|
|||||||
require 'tmpdir'
|
require 'tmpdir'
|
||||||
|
|
||||||
def prompt(*args)
|
def prompt(*args)
|
||||||
print(*args)
|
print(*args)
|
||||||
gets
|
gets
|
||||||
end
|
end
|
||||||
|
|
||||||
if !ARGV.empty? && !ARGV[0].empty? && !ARGV[1].empty?
|
if !ARGV.empty? && !ARGV[0].empty? && !ARGV[1].empty?
|
||||||
@ -27,72 +27,69 @@ if !File.exist?('_config.yml')
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fetchlinks()
|
def fetchlinks()
|
||||||
|
# Fetch new list of links
|
||||||
|
links = {}
|
||||||
|
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)?\//, '/')
|
||||||
|
next if (link.match(/^#|^http:\/\/www.meetup.com\//))
|
||||||
|
|
||||||
# Fetch new list of links
|
if (!link.match(/^https?:\/\/|^\/[^\/]|^mailto:/))
|
||||||
links = {}
|
link = File.dirname(file.sub(WORKDIR + '/_site', '')) + '/' + File.basename(link)
|
||||||
dirs = Dir.glob(WORKDIR + "/_site/**/*.html").each { |file|
|
end
|
||||||
content = File.read(file)
|
links[link] = "0"
|
||||||
content.scan(/ href *= *"(.*?)"/).each { |link|
|
}
|
||||||
link = link[0].to_s.gsub(/^(https?:\/\/(www\.)?bitcoin\.org)?\//,'/')
|
content.scan(/ src *= *"(.*?)"/).each { |link|
|
||||||
next if (link.match(/^#|^http:\/\/www.meetup.com\//))
|
link = link[0].to_s.gsub(/^(https?:\/\/(www\.)?bitcoin\.org)?\//, '/')
|
||||||
if(!link.match(/^https?:\/\/|^\/[^\/]|^mailto:/))
|
links[link] = "0"
|
||||||
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)?\//,'/')
|
|
||||||
links[link] = "0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return links
|
|
||||||
|
|
||||||
|
return links
|
||||||
end
|
end
|
||||||
|
|
||||||
Dir.mktmpdir{|workdir|
|
Dir.mktmpdir { |workdir|
|
||||||
|
WORKDIR = workdir.gsub("\n", '')
|
||||||
|
|
||||||
WORKDIR=workdir.gsub("\n",'')
|
# Copy current repository to a temporary directory
|
||||||
|
`rsync -a ./ "#{WORKDIR}/"`
|
||||||
|
|
||||||
# Copy current repository to a temporary directory
|
# Build both version of the website and fetch all links
|
||||||
`rsync -a ./ "#{WORKDIR}/"`
|
oldlinks = {}
|
||||||
|
newlinks = {}
|
||||||
|
|
||||||
# Build both version of the website and fetch all links
|
Dir.chdir(WORKDIR) do
|
||||||
oldlinks = {}
|
`git checkout #{srcbr}`
|
||||||
newlinks = {}
|
`jekyll`
|
||||||
|
oldlinks = fetchlinks()
|
||||||
|
|
||||||
Dir.chdir(WORKDIR) do
|
`git checkout #{dstbr}`
|
||||||
|
`jekyll`
|
||||||
|
newlinks = fetchlinks()
|
||||||
|
end
|
||||||
|
|
||||||
`git checkout #{srcbr}`
|
# Find added links, removed links
|
||||||
`jekyll`
|
diffaddlinks = []
|
||||||
oldlinks = fetchlinks()
|
diffrmlinks = []
|
||||||
|
newlinks.each { |link, _etag|
|
||||||
|
next if oldlinks.has_key?(link)
|
||||||
|
|
||||||
`git checkout #{dstbr}`
|
diffaddlinks.push(link)
|
||||||
`jekyll`
|
}
|
||||||
newlinks = fetchlinks()
|
oldlinks.each { |link, _etag|
|
||||||
|
next if newlinks.has_key?(link)
|
||||||
|
|
||||||
end
|
diffrmlinks.push(link)
|
||||||
|
}
|
||||||
# Find added links, removed links
|
|
||||||
diffaddlinks = []
|
|
||||||
diffrmlinks = []
|
|
||||||
newlinks.each { |link, etag|
|
|
||||||
next if oldlinks.has_key?(link)
|
|
||||||
diffaddlinks.push(link)
|
|
||||||
}
|
|
||||||
oldlinks.each { |link, etag|
|
|
||||||
next if newlinks.has_key?(link)
|
|
||||||
diffrmlinks.push(link)
|
|
||||||
}
|
|
||||||
|
|
||||||
# Display resulting diff
|
|
||||||
diff = ''
|
|
||||||
if diffaddlinks.length > 0
|
|
||||||
diff = diff + "## links added\n\n" + diffaddlinks.join("\n") + "\n\n"
|
|
||||||
end
|
|
||||||
if diffrmlinks.length > 0
|
|
||||||
diff = diff + "## links removed\n\n" + diffrmlinks.join("\n") + "\n\n"
|
|
||||||
end
|
|
||||||
print diff
|
|
||||||
|
|
||||||
|
# Display resulting diff
|
||||||
|
diff = ''
|
||||||
|
if diffaddlinks.length > 0
|
||||||
|
diff = diff + "## links added\n\n" + diffaddlinks.join("\n") + "\n\n"
|
||||||
|
end
|
||||||
|
if diffrmlinks.length > 0
|
||||||
|
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'
|
require 'jshintrb'
|
||||||
|
|
||||||
if ARGV[0].nil?
|
if ARGV[0].nil?
|
||||||
path_to_check="./_site/js"
|
path_to_check = "./_site/js"
|
||||||
else
|
else
|
||||||
path_to_check=ARGV[0]
|
path_to_check = ARGV[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
Dir.foreach(path_to_check) do |file|
|
Dir.foreach(path_to_check) do |file|
|
||||||
next if !/\.js$/.match(file)
|
next if !/\.js$/.match(file)
|
||||||
|
|
||||||
res = Jshintrb.report(File.read(path_to_check + '/' + file), :jshintrc)
|
res = Jshintrb.report(File.read(path_to_check + '/' + file), :jshintrc)
|
||||||
print path_to_check + '/' + file + "\n" + res if res.length != 0
|
print path_to_check + '/' + file + "\n" + res if res.length != 0
|
||||||
end
|
end
|
||||||
|
|||||||
@ -3,12 +3,12 @@
|
|||||||
# This file is licensed under the MIT License (MIT) available on
|
# This file is licensed under the MIT License (MIT) available on
|
||||||
# http://opensource.org/licenses/MIT.
|
# http://opensource.org/licenses/MIT.
|
||||||
|
|
||||||
#Drop outdated fallback HTML code in all layouts for specified language.
|
# Drop outdated fallback HTML code in all layouts for specified language.
|
||||||
#Example: ./_contrib/updatetx.rb
|
# Example: ./_contrib/updatetx.rb
|
||||||
|
|
||||||
def prompt(*args)
|
def prompt(*args)
|
||||||
print(*args)
|
print(*args)
|
||||||
gets
|
gets
|
||||||
end
|
end
|
||||||
|
|
||||||
if ARGV.empty?
|
if ARGV.empty?
|
||||||
@ -17,31 +17,32 @@ else
|
|||||||
lang = ARGV[0]
|
lang = ARGV[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
lang = lang.gsub(/[^a-zA-Z_]/,'')
|
lang = lang.gsub(/[^a-zA-Z_]/, '')
|
||||||
|
|
||||||
if !File.exist?('_translations/' + lang + '.yml')
|
if !File.exist?('_translations/' + lang + '.yml')
|
||||||
print "Wrong language code. \n"
|
print "Wrong language code. \n"
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
|
|
||||||
dirs = [ '_templates', '_layouts' ]
|
dirs = ['_templates', '_layouts']
|
||||||
|
|
||||||
dirs.each do |dir|
|
dirs.each do |dir|
|
||||||
Dir.foreach(dir) do |file|
|
Dir.foreach(dir) do |file|
|
||||||
next if file == '.' or file == '..'
|
next if file == '.' or file == '..'
|
||||||
|
|
||||||
contents = File.read(dir + '/' + file)
|
contents = File.read(dir + '/' + file)
|
||||||
# Drop HTML code applied to current language only ( until next {% when / else / endcase %} statement )
|
# 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 %}).)*?{% when", Regexp::MULTILINE), '{% when')
|
||||||
contents.gsub!(Regexp.new("{% when '" + lang + "' %}((?!{% endcase %}).)*?{% else %}", Regexp::MULTILINE),'{% else %}')
|
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 %}", Regexp::MULTILINE), '{% endcase %}')
|
||||||
# Drop complete {% case / endcase %} statements when not used by any language anymore
|
# 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 %}(((?!{% 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 %}(((?!{% when ).)*?){% endcase %}", Regexp::MULTILINE), '\1')
|
||||||
# Drop language in statements applied to many languages ( e.g. {% when 'ar' or 'fr' .. %} )
|
# 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 '" + lang + "' or (.*?) %}"), '{% when \1 %}')
|
||||||
contents.gsub!(Regexp.new("{% when (.*?) or '" + lang + "' (.*?)%}"),'{% when \1 \2%}')
|
contents.gsub!(Regexp.new("{% when (.*?) or '" + lang + "' (.*?)%}"), '{% when \1 \2%}')
|
||||||
File.open(dir + '/' + file, 'w') do |file|
|
File.open(dir + '/' + file, 'w') do |f|
|
||||||
file.write(contents)
|
f.write(contents)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,46 +1,45 @@
|
|||||||
# This file is licensed under the MIT License (MIT) available on
|
# This file is licensed under the MIT License (MIT) available on
|
||||||
# http://opensource.org/licenses/MIT.
|
# http://opensource.org/licenses/MIT.
|
||||||
|
|
||||||
#alerts.rb generates alert pages using files in _alerts
|
# alerts.rb generates alert pages using files in _alerts
|
||||||
#and assign them the 'alert' category.
|
# and assign them the 'alert' category.
|
||||||
|
|
||||||
#This is later used to loop through site.pages in order
|
# This is later used to loop through site.pages in order
|
||||||
#to display the alert's list in chronological order, both
|
# to display the alert's list in chronological order, both
|
||||||
#on the "Alerts" page and RSS file.
|
# on the "Alerts" page and RSS file.
|
||||||
|
|
||||||
#If "banner" variable is set in one alert file, site.ALERT
|
# If "banner" variable is set in one alert file, site.ALERT
|
||||||
#variable is set, allowing a clickable alert banner to be
|
# variable is set, allowing a clickable alert banner to be
|
||||||
#displayed in _layouts/base.html .
|
# displayed in _layouts/base.html .
|
||||||
|
|
||||||
#If "shorturl" variable is set in one alert file, a short alias
|
# If "shorturl" variable is set in one alert file, a short alias
|
||||||
#file for the alert (like /android.html) is generated for
|
# file for the alert (like /android.html) is generated for
|
||||||
#Bitcoin Core non-clickable alerts.
|
# Bitcoin Core non-clickable alerts.
|
||||||
|
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class AlertPage < Page
|
class AlertPage < Page
|
||||||
def initialize(site, base, lang, srcdir, src, dstdir, dst, date)
|
def initialize(site, base, lang, srcdir, src, dstdir, dst, date)
|
||||||
@site = site
|
@site = site
|
||||||
@base = base
|
@base = base
|
||||||
@dir = '/'+dstdir
|
@dir = '/' + dstdir
|
||||||
@name = dst
|
@name = dst
|
||||||
extension = dst.split('.')[-1]
|
extension = dst.split('.')[-1]
|
||||||
self.process(dst)
|
self.process(dst)
|
||||||
self.read_yaml(File.join(base, srcdir), src)
|
self.read_yaml(File.join(base, srcdir), src)
|
||||||
self.data['lang'] = lang
|
self.data['lang'] = lang
|
||||||
self.data['date'] = date
|
self.data['date'] = date
|
||||||
self.data['path'] = srcdir+'/'+src
|
self.data['path'] = srcdir + '/' + src
|
||||||
self.data['layout'] = 'alert'
|
self.data['layout'] = 'alert'
|
||||||
if dstdir == ''
|
if dstdir == ''
|
||||||
self.data['canonical'] = '/en/alert/' + src.split('.')[0]
|
self.data['canonical'] = '/en/alert/' + src.split('.')[0]
|
||||||
else
|
else
|
||||||
self.data['category'] = 'alert'
|
self.data['category'] = 'alert'
|
||||||
if self.data.has_key?('banner') and !self.data['banner'].nil? and self.data['banner'].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['ALERT'] = self.data['banner']
|
||||||
site.config['ALERTURL']='/'+dstdir+'/'+dst.gsub('.html','').gsub('.md','')
|
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?('bannerclass') and !self.data['bannerclass'].nil? and self.data['bannerclass'].length > 0
|
||||||
site.config['ALERTCLASS'] = self.data['bannerclass']
|
site.config['ALERTCLASS'] = self.data['bannerclass']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -48,8 +47,8 @@ module Jekyll
|
|||||||
site.config['STATUS'] = 1
|
site.config['STATUS'] = 1
|
||||||
end
|
end
|
||||||
if self.data.has_key?('shorturl')
|
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'] + '.' + 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'] + '/index.' + extension, date)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -57,31 +56,32 @@ module Jekyll
|
|||||||
|
|
||||||
class AlertPageGenerator < Generator
|
class AlertPageGenerator < Generator
|
||||||
def generate(site)
|
def generate(site)
|
||||||
#Generate each alert based on templates
|
# Generate each alert based on templates
|
||||||
site.config['STATUS'] = 0
|
site.config['STATUS'] = 0
|
||||||
site.config['ALERTCLASS'] = 'alert'
|
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?
|
if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index('alerts').nil?
|
||||||
print 'Alerts disabled' + "\n"
|
print 'Alerts disabled' + "\n"
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
Dir.foreach('_alerts') do |file|
|
Dir.foreach('_alerts') do |file|
|
||||||
next if file == '.' or file == '..'
|
next if file == '.' or file == '..'
|
||||||
|
|
||||||
lang = 'en'
|
lang = 'en'
|
||||||
src = file
|
src = file
|
||||||
dst = file
|
dst = file
|
||||||
srcdir = '_alerts'
|
|
||||||
dstdir = lang + '/alert'
|
dstdir = lang + '/alert'
|
||||||
date = dst.split('-')
|
date = dst.split('-')
|
||||||
next if date.length < 4
|
next if date.length < 4
|
||||||
|
|
||||||
date = date[0] + '-' + date[1] + '-' + date[2]
|
date = date[0] + '-' + date[1] + '-' + date[2]
|
||||||
next if !/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/.match(date)
|
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)
|
site.pages << AlertPage.new(site, site.source, lang, '_alerts', src, dstdir, dst, date)
|
||||||
end
|
end
|
||||||
#TODO alerts are only generated for english language,
|
# TODO alerts are only generated for english language,
|
||||||
#but they could also be translated at some point. They would however
|
# but they could also be translated at some point. They would however
|
||||||
#need to fallback to english when no translation is available.
|
# need to fallback to english when no translation is available.
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,60 +1,62 @@
|
|||||||
# This file is licensed under the MIT License (MIT) available on
|
# This file is licensed under the MIT License (MIT) available on
|
||||||
# http://opensource.org/licenses/MIT.
|
# http://opensource.org/licenses/MIT.
|
||||||
|
|
||||||
#alphab_for allows to loop in an array sorted by the translated value of
|
# 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,
|
# each key using appropriate collation for the current language. In short,
|
||||||
#this is used to generate translated table of contents.
|
# this is used to generate translated table of contents.
|
||||||
|
|
||||||
#Example:
|
# Example:
|
||||||
#{% alphab_for v in page.voc %}
|
# {% alphab_for v in page.voc %}
|
||||||
# ..
|
# ..
|
||||||
#{% endalphab_for %}
|
# {% endalphab_for %}
|
||||||
|
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'ffi-icu'
|
require 'ffi-icu'
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
module AlphabForImpl
|
module AlphabForImpl
|
||||||
def render(context)
|
def render(context)
|
||||||
#Load translations
|
# Load translations
|
||||||
site = context.registers[:site].config
|
site = context.registers[:site].config
|
||||||
if !site.has_key?("loc")
|
if !site.has_key?("loc")
|
||||||
site['loc'] = {}
|
site['loc'] = {}
|
||||||
Dir.foreach('_translations') do |file|
|
Dir.foreach('_translations') do |file|
|
||||||
next if file == '.' or file == '..' or file == 'COPYING'
|
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
|
||||||
end
|
end
|
||||||
#load collection and context variables
|
# load collection and context variables
|
||||||
sorted_collection = collection_to_sort context
|
sorted_collection = collection_to_sort context
|
||||||
return if sorted_collection.empty?
|
return if sorted_collection.empty?
|
||||||
|
|
||||||
lang = Liquid::Template.parse('{{page.lang}}').render context
|
lang = Liquid::Template.parse('{{page.lang}}').render context
|
||||||
page = Liquid::Template.parse('{{page.id}}').render context
|
page = Liquid::Template.parse('{{page.id}}').render context
|
||||||
#build translated array and associative hash
|
# build translated array and associative hash
|
||||||
translated = []
|
translated = []
|
||||||
assoc = {}
|
assoc = {}
|
||||||
for key in sorted_collection do
|
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] == ' '
|
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]
|
t = site['loc'][lang][page][key]
|
||||||
translated.push(t)
|
translated.push(t)
|
||||||
assoc[key] = t
|
assoc[key] = t
|
||||||
end
|
end
|
||||||
#sort translated array using appropriate collation
|
# sort translated array using appropriate collation
|
||||||
translated = ICU::Collation.collate(lang, translated)
|
translated = ICU::Collation.collate(lang, translated)
|
||||||
#recreate collection with new ordering
|
# recreate collection with new ordering
|
||||||
sorted_collection = []
|
sorted_collection = []
|
||||||
for va in translated do
|
for va in translated do
|
||||||
val = assoc.select{|k,v| v == va}
|
val = assoc.select { |_k, v| v == va }
|
||||||
#compatibility with old ruby versions that return an Array
|
# compatibility with old ruby versions that return an Array
|
||||||
if val.is_a?(Array)
|
if val.is_a?(Array)
|
||||||
val = { val[0][0] => va }
|
val = { val[0][0] => va }
|
||||||
end
|
end
|
||||||
val = val.keys[0]
|
val = val.keys[0]
|
||||||
sorted_collection.push(val)
|
sorted_collection.push(val)
|
||||||
end
|
end
|
||||||
#return modified array
|
# return modified array
|
||||||
original_name = @collection_name
|
original_name = @collection_name
|
||||||
result = nil
|
result = nil
|
||||||
context.stack do
|
context.stack do
|
||||||
@ -78,7 +80,6 @@ module Jekyll
|
|||||||
'endalphab_for'
|
'endalphab_for'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Liquid::Template.register_tag('alphab_for', Jekyll::AlphabForTag)
|
Liquid::Template.register_tag('alphab_for', Jekyll::AlphabForTag)
|
||||||
|
|||||||
@ -21,11 +21,9 @@
|
|||||||
## <!--[-->`src/qt/paymentrequest.proto`<!--]-->
|
## <!--[-->`src/qt/paymentrequest.proto`<!--]-->
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
require 'yaml'
|
||||||
require 'yaml'
|
|
||||||
|
|
||||||
class AutoCrossRefBlock < Liquid::Block
|
class AutoCrossRefBlock < Liquid::Block
|
||||||
|
|
||||||
def initialize(tag_name, text, tokens)
|
def initialize(tag_name, text, tokens)
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
@ -47,9 +45,7 @@ require 'yaml'
|
|||||||
|
|
||||||
if site.has_key?("crossref")
|
if site.has_key?("crossref")
|
||||||
## We already have refs loaded, so merge
|
## We already have refs loaded, so merge
|
||||||
site['crossref'].merge!(unvalidated_refs) {
|
site['crossref'].merge!(unvalidated_refs) { |key, old_value, new_value|
|
||||||
|key, old_value, new_value|
|
|
||||||
|
|
||||||
if old_value != new_value
|
if old_value != new_value
|
||||||
abort("Error: autocrossref key '#{key}' wants to point to both '#{old_value}' and '#{new_value}'")
|
abort("Error: autocrossref key '#{key}' wants to point to both '#{old_value}' and '#{new_value}'")
|
||||||
end
|
end
|
||||||
@ -63,13 +59,11 @@ require 'yaml'
|
|||||||
site['crossref_loaded'] = true
|
site['crossref_loaded'] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
## Sort terms by reverse length, so longest matches get linked
|
## Sort terms by reverse length, so longest matches get linked
|
||||||
## first (e.g. "block chain" before "block"). Otherwise short
|
## first (e.g. "block chain" before "block"). Otherwise short
|
||||||
## terms would get linked first and there'd be nothing for long
|
## terms would get linked first and there'd be nothing for long
|
||||||
## terms to link to.
|
## 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[1] = term[0] if term[1].nil? || term[1].empty?
|
||||||
|
|
||||||
term[0] = Regexp.escape(term[0])
|
term[0] = Regexp.escape(term[0])
|
||||||
@ -99,15 +93,15 @@ require 'yaml'
|
|||||||
(?!\w) ## Don't match inside words
|
(?!\w) ## Don't match inside words
|
||||||
(?!.*(<\/h{1-6}>)) ## 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
|
(?!`) ## 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"
|
if term[1] == "do not autocrossref"
|
||||||
s.gsub(/( |$)/, "<!--noref-->\\&")
|
s.gsub(/( |$)/, "<!--noref-->\\&")
|
||||||
else
|
else
|
||||||
"[#{s}][#{term[1]}]{:.auto-link}"
|
"[#{s}][#{term[1]}]{:.auto-link}"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
output.gsub!(/<!--.*?-->/m,'') ## Remove all HTML comments
|
output.gsub!(/<!--.*?-->/m, '') ## Remove all HTML comments
|
||||||
|
|
||||||
output
|
output
|
||||||
end
|
end
|
||||||
@ -115,11 +109,9 @@ require 'yaml'
|
|||||||
end
|
end
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
require 'yaml'
|
||||||
require 'yaml'
|
|
||||||
|
|
||||||
class AutoCrossRefBlockDisabled < Liquid::Block
|
class AutoCrossRefBlockDisabled < Liquid::Block
|
||||||
|
|
||||||
def initialize(tag_name, text, tokens)
|
def initialize(tag_name, text, tokens)
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
@ -132,9 +124,7 @@ require 'yaml'
|
|||||||
end
|
end
|
||||||
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?
|
if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index('autocrossref').nil?
|
||||||
print 'Autocrossref disabled' + "\n"
|
print 'Autocrossref disabled' + "\n"
|
||||||
Liquid::Template.register_tag('autocrossref', Jekyll::AutoCrossRefBlockDisabled)
|
Liquid::Template.register_tag('autocrossref', Jekyll::AutoCrossRefBlockDisabled)
|
||||||
|
|||||||
@ -1,17 +1,15 @@
|
|||||||
# This file is licensed under the MIT License (MIT) available on
|
# This file is licensed under the MIT License (MIT) available on
|
||||||
# http://opensource.org/licenses/MIT.
|
# http://opensource.org/licenses/MIT.
|
||||||
|
|
||||||
#contributors.rb fetches Bitcoin Core contributors list and set
|
# contributors.rb fetches Bitcoin Core contributors list and set
|
||||||
#site.contributors array. This is later used to display the
|
# site.contributors array. This is later used to display the
|
||||||
#list of contributors on the "Development" page.
|
# list of contributors on the "Development" page.
|
||||||
|
|
||||||
require 'open-uri'
|
require 'open-uri'
|
||||||
require 'json'
|
require 'json'
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class CategoryGenerator < Generator
|
class CategoryGenerator < Generator
|
||||||
|
|
||||||
def contributors(repo, aliases)
|
def contributors(repo, aliases)
|
||||||
contributors = []
|
contributors = []
|
||||||
# Call GitHub API with 100 results per page
|
# Call GitHub API with 100 results per page
|
||||||
@ -19,7 +17,7 @@ module Jekyll
|
|||||||
data = []
|
data = []
|
||||||
while page < 10 do
|
while page < 10 do
|
||||||
begin
|
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
|
# Prevent any error to stop the build process, return an empty array instead
|
||||||
rescue
|
rescue
|
||||||
print 'GitHub API Call Failed!'
|
print 'GitHub API Call Failed!'
|
||||||
@ -35,6 +33,7 @@ module Jekyll
|
|||||||
end
|
end
|
||||||
# Stop calling GitHub API when no new results are returned
|
# Stop calling GitHub API when no new results are returned
|
||||||
break if (ar.length == 0)
|
break if (ar.length == 0)
|
||||||
|
|
||||||
# Merge contributors into a single array
|
# Merge contributors into a single array
|
||||||
data.push(*ar)
|
data.push(*ar)
|
||||||
page += 1
|
page += 1
|
||||||
@ -45,6 +44,7 @@ module Jekyll
|
|||||||
# Skip incomplete / invalid data and set contributor's name
|
# Skip incomplete / invalid data and set contributor's name
|
||||||
next if !c.is_a?(Hash)
|
next if !c.is_a?(Hash)
|
||||||
next if !c.has_key?('contributions') or !c['contributions'].is_a?(Integer) or c['contributions'] > 1000000
|
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'])
|
if c.has_key?('name') and c['name'].is_a?(String) and /^[A-Za-z0-9\-]{1,150}$/.match(c['name'])
|
||||||
name = 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'])
|
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
|
||||||
end
|
end
|
||||||
# Generate final ordered contributors array
|
# Generate final ordered contributors array
|
||||||
result.each do |key, value|
|
result.each do |_key, value|
|
||||||
contributors.push(value)
|
contributors.push(value)
|
||||||
end
|
end
|
||||||
contributors.sort_by{|c| - c['contributions']}
|
contributors.sort_by { |commits| - commits['contributions'] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate(site)
|
def generate(site)
|
||||||
# Set site.contributors global variables for liquid/jekyll
|
# Set site.contributors global variables for liquid/jekyll
|
||||||
if ! site.respond_to?('corecontributors')
|
if !site.respond_to?('corecontributors')
|
||||||
class << site
|
class << site
|
||||||
attr_accessor :corecontributors
|
attr_accessor :corecontributors
|
||||||
attr_accessor :sitecontributors
|
attr_accessor :sitecontributors
|
||||||
@ -98,14 +98,14 @@ module Jekyll
|
|||||||
site.corecontributors = {}
|
site.corecontributors = {}
|
||||||
site.sitecontributors = {}
|
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?
|
if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index('contributors').nil?
|
||||||
print 'Contributors disabled' + "\n"
|
print 'Contributors disabled' + "\n"
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
## Create cache directory if it doesn't exist
|
## Create cache directory if it doesn't exist
|
||||||
if !File.exists?('_cache')
|
if !File.exist?('_cache')
|
||||||
Dir.mkdir('_cache')
|
Dir.mkdir('_cache')
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ module Jekyll
|
|||||||
# file has to be updated, they both get updated.
|
# file has to be updated, they both get updated.
|
||||||
corecontributors_cache = '_cache/corecontributors.marshall'
|
corecontributors_cache = '_cache/corecontributors.marshall'
|
||||||
sitecontributors_cache = '_cache/sitecontributors.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
|
corecontributors_cache_age = (Time.now - File.stat(corecontributors_cache).mtime).to_i
|
||||||
sitecontributors_cache_age = (Time.now - File.stat(sitecontributors_cache).mtime).to_i
|
sitecontributors_cache_age = (Time.now - File.stat(sitecontributors_cache).mtime).to_i
|
||||||
else
|
else
|
||||||
@ -126,25 +126,22 @@ module Jekyll
|
|||||||
end
|
end
|
||||||
|
|
||||||
if corecontributors_cache_age > 86400 || sitecontributors_cache_age > 86400
|
if corecontributors_cache_age > 86400 || sitecontributors_cache_age > 86400
|
||||||
site.corecontributors = contributors('bitcoin/bitcoin',site.config['aliases'])
|
site.corecontributors = contributors('bitcoin/bitcoin', site.config['aliases'])
|
||||||
File.open(corecontributors_cache,'w') do |file|
|
File.open(corecontributors_cache, 'w') do |file|
|
||||||
Marshal.dump(site.corecontributors, file)
|
Marshal.dump(site.corecontributors, file)
|
||||||
end
|
end
|
||||||
site.sitecontributors = contributors('bitcoin-dot-org/bitcoin.org',site.config['aliases'])
|
site.sitecontributors = contributors('bitcoin-dot-org/bitcoin.org', site.config['aliases'])
|
||||||
File.open(sitecontributors_cache,'w') do |file|
|
File.open(sitecontributors_cache, 'w') do |file|
|
||||||
Marshal.dump(site.sitecontributors, file)
|
Marshal.dump(site.sitecontributors, file)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
File.open(corecontributors_cache,'r') do |file|
|
File.open(corecontributors_cache, 'r') do |file|
|
||||||
site.corecontributors = Marshal.load(file)
|
site.corecontributors = Marshal.load(file)
|
||||||
end
|
end
|
||||||
File.open(sitecontributors_cache,'r') do |file|
|
File.open(sitecontributors_cache, 'r') do |file|
|
||||||
site.sitecontributors = Marshal.load(file)
|
site.sitecontributors = Marshal.load(file)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -12,7 +12,7 @@ module Jekyll
|
|||||||
site.config["env"] = site.config["env"] ? site.config["env"] : {}
|
site.config["env"] = site.config["env"] ? site.config["env"] : {}
|
||||||
|
|
||||||
## Load matching environmental variables in to array
|
## 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] })
|
site.config['env'].merge!({ key => ENV[key] })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
# This file is licensed under the MIT License (MIT) available on
|
# This file is licensed under the MIT License (MIT) available on
|
||||||
# http://opensource.org/licenses/MIT.
|
# http://opensource.org/licenses/MIT.
|
||||||
|
|
||||||
#events.rb sets the site.conferences array based
|
# events.rb sets the site.conferences array based
|
||||||
#on events in _events/
|
# on events in _events/
|
||||||
#This is later used to populate the events map and display the
|
# This is later used to populate the events map and display the
|
||||||
#list in chronological order, in the RSS file and events pages.
|
# list in chronological order, in the RSS file and events pages.
|
||||||
|
|
||||||
require 'open-uri'
|
require 'open-uri'
|
||||||
require 'json'
|
require 'json'
|
||||||
@ -13,22 +13,22 @@ require 'yaml'
|
|||||||
require 'cgi'
|
require 'cgi'
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class EventPageGenerator < Generator
|
class EventPageGenerator < Generator
|
||||||
|
|
||||||
def conferences
|
def conferences
|
||||||
conferences = []
|
conferences = []
|
||||||
# Loop in _events.yml
|
# Loop in _events.yml
|
||||||
YAML.load_file('_events.yml').each do |data|
|
YAML.load_file('_events.yml').each do |data|
|
||||||
# Skip event if it has started more than five days ago
|
# Skip event if it has started more than five days ago
|
||||||
date = data['date'].to_s.split('-')
|
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
|
# Get geolocalisation data from Google Maps
|
||||||
if data.has_key?('address')
|
if data.has_key?('address')
|
||||||
begin
|
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'
|
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
|
end
|
||||||
rescue
|
rescue
|
||||||
print 'Google Maps API Call Failed!'
|
print 'Google Maps API Call Failed!'
|
||||||
@ -42,7 +42,7 @@ module Jekyll
|
|||||||
|
|
||||||
def generate(site)
|
def generate(site)
|
||||||
# Set site.meetups and site.conferences global variables for liquid/jekyll
|
# Set site.meetups and site.conferences global variables for liquid/jekyll
|
||||||
if ! site.respond_to?('conferences')
|
if !site.respond_to?('conferences')
|
||||||
class << site
|
class << site
|
||||||
attr_accessor :meetups, :conferences
|
attr_accessor :meetups, :conferences
|
||||||
alias event_site_payload site_payload
|
alias event_site_payload site_payload
|
||||||
@ -59,14 +59,14 @@ module Jekyll
|
|||||||
# Set site.conferences array
|
# Set site.conferences array
|
||||||
site.conferences = {}
|
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?
|
if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index('events').nil?
|
||||||
print 'Events disabled' + "\n"
|
print 'Events disabled' + "\n"
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
## Create cache directory if it doesn't exist
|
## Create cache directory if it doesn't exist
|
||||||
if !File.exists?('_cache')
|
if !File.exist?('_cache')
|
||||||
Dir.mkdir('_cache')
|
Dir.mkdir('_cache')
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ module Jekyll
|
|||||||
events_file = '_events.yml'
|
events_file = '_events.yml'
|
||||||
|
|
||||||
events_file_unix_time = File.stat(events_file).mtime.to_i
|
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
|
conferences_cache_unix_time = File.stat(conferences_cache).mtime.to_i
|
||||||
else
|
else
|
||||||
conferences_cache_unix_time = 0
|
conferences_cache_unix_time = 0
|
||||||
@ -86,17 +86,14 @@ module Jekyll
|
|||||||
|
|
||||||
if events_file_unix_time >= conferences_cache_unix_time
|
if events_file_unix_time >= conferences_cache_unix_time
|
||||||
site.conferences = conferences()
|
site.conferences = conferences()
|
||||||
File.open(conferences_cache,'w') do |file|
|
File.open(conferences_cache, 'w') do |file|
|
||||||
Marshal.dump(site.conferences, file)
|
Marshal.dump(site.conferences, file)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
File.open(conferences_cache,'r') do |file|
|
File.open(conferences_cache, 'r') do |file|
|
||||||
site.conferences = Marshal.load(file)
|
site.conferences = Marshal.load(file)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -10,11 +10,9 @@
|
|||||||
## {% endgithubify %}
|
## {% endgithubify %}
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
require 'yaml'
|
||||||
require 'yaml'
|
|
||||||
|
|
||||||
class GitHubifyBlock < Liquid::Block
|
class GitHubifyBlock < Liquid::Block
|
||||||
|
|
||||||
def initialize(tag_name, text, tokens)
|
def initialize(tag_name, text, tokens)
|
||||||
super
|
super
|
||||||
@repository_url = text.strip()
|
@repository_url = text.strip()
|
||||||
@ -27,14 +25,14 @@ require 'yaml'
|
|||||||
## If #1234 links to an issue, GitHub automatically redirects
|
## If #1234 links to an issue, GitHub automatically redirects
|
||||||
#
|
#
|
||||||
## Require at least two digits to reduce false positive matches
|
## 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>'
|
'<a href="' + @repository_url + '/pull/' + $1 + '">' + s + '</a>'
|
||||||
}
|
}
|
||||||
|
|
||||||
## Convert `123abcd` into URL for the commit
|
## Convert `123abcd` into URL for the commit
|
||||||
#
|
#
|
||||||
## Only operate on 7 to 10 chars to reduce false positive matches
|
## 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>'
|
'<a href="' + @repository_url + '/commit/' + $1 + '">' + s + '</a>'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,14 +41,11 @@ require 'yaml'
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
## Code to run if plugin is disabled
|
## Code to run if plugin is disabled
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
require 'yaml'
|
||||||
require 'yaml'
|
|
||||||
|
|
||||||
class GitHubifyBlockDisabled < Liquid::Block
|
class GitHubifyBlockDisabled < Liquid::Block
|
||||||
|
|
||||||
def initialize(tag_name, text, tokens)
|
def initialize(tag_name, text, tokens)
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
@ -63,7 +58,7 @@ require 'yaml'
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#Do nothing if plugin is disabled
|
# Do nothing if plugin is disabled
|
||||||
plugin_name = "githubify"
|
plugin_name = "githubify"
|
||||||
if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index(plugin_name).nil?
|
if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index(plugin_name).nil?
|
||||||
print plugin_name + ' disabled' + "\n"
|
print plugin_name + ' disabled' + "\n"
|
||||||
|
|||||||
@ -5,9 +5,7 @@ require 'yaml'
|
|||||||
require 'json'
|
require 'json'
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class GlossaryPage < Page
|
class GlossaryPage < Page
|
||||||
|
|
||||||
def initialize(site, base, lang, srcdir, src, output_directory)
|
def initialize(site, base, lang, srcdir, src, output_directory)
|
||||||
@site = site
|
@site = site
|
||||||
@base = base
|
@base = base
|
||||||
@ -44,8 +42,8 @@ module Jekyll
|
|||||||
if self.data["optional"]["synonyms_and_pluralizations_not_shown_in_glossary"].nil?
|
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"]
|
mixed_case_terms = self.data["required"]["synonyms_shown_in_glossary_capitalize_first_letter"]
|
||||||
else
|
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"]
|
self.data["optional"]["synonyms_and_pluralizations_not_shown_in_glossary"]
|
||||||
end
|
end
|
||||||
|
|
||||||
## Downcase all terms so we can easily detect when we create
|
## Downcase all terms so we can easily detect when we create
|
||||||
@ -58,14 +56,12 @@ module Jekyll
|
|||||||
## Add all synonyms to the autocrossref hash table for automatic linking
|
## Add all synonyms to the autocrossref hash table for automatic linking
|
||||||
site.config["crossref"] = site.config["crossref"] ? site.config["crossref"] : {}
|
site.config["crossref"] = site.config["crossref"] ? site.config["crossref"] : {}
|
||||||
for term in terms do
|
for term in terms do
|
||||||
site.config["crossref"].merge!({ term => output_full_path }) {
|
site.config["crossref"].merge!({ term => output_full_path }) { |key, old_value, new_value|
|
||||||
|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
|
||||||
|
|
||||||
if old_value != new_value
|
new_value
|
||||||
abort("Error: autocrossref key '#{key}' wants to point to both '#{old_value}' and '#{new_value}'")
|
|
||||||
end
|
|
||||||
|
|
||||||
new_value
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -88,9 +84,9 @@ module Jekyll
|
|||||||
## Add only shown synonyms to the glossary hash-tables-inside-sorted-array
|
## Add only shown synonyms to the glossary hash-tables-inside-sorted-array
|
||||||
## for use in the search box and on the master listing page
|
## for use in the search box and on the master listing page
|
||||||
site.config["devsearches"]["Glossary"] =
|
site.config["devsearches"]["Glossary"] =
|
||||||
site.config["devsearches"]["Glossary"] ? site.config["devsearches"]["Glossary"] : {}
|
site.config["devsearches"]["Glossary"] ? site.config["devsearches"]["Glossary"] : {}
|
||||||
site.config["devsearches"]["Glossary"][lang] =
|
site.config["devsearches"]["Glossary"][lang] =
|
||||||
site.config["devsearches"]["Glossary"][lang] ? site.config["devsearches"]["Glossary"][lang] : []
|
site.config["devsearches"]["Glossary"][lang] ? site.config["devsearches"]["Glossary"][lang] : []
|
||||||
for term in self.data["required"]["synonyms_shown_in_glossary_capitalize_first_letter"] do
|
for term in self.data["required"]["synonyms_shown_in_glossary_capitalize_first_letter"] do
|
||||||
site.config["devsearches"]["Glossary"][lang].unshift({ term => output_full_path })
|
site.config["devsearches"]["Glossary"][lang].unshift({ term => output_full_path })
|
||||||
end
|
end
|
||||||
@ -102,68 +98,65 @@ module Jekyll
|
|||||||
## do support this feature, so if we upgrade to Jekyll 2.2 or
|
## 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
|
## higher, look at doing this at template time to save CPU cycles
|
||||||
## and increase flexibility
|
## and increase flexibility
|
||||||
site.config["devsearches"]["Glossary"][lang].sort_by!{|hash|
|
site.config["devsearches"]["Glossary"][lang].sort_by! { |hash|
|
||||||
hash.to_s.downcase.gsub(/"=>.*/,'')
|
hash.to_s.downcase.gsub(/"=>.*/, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class GlossaryPageGenerator < Generator
|
class GlossaryPageGenerator < Generator
|
||||||
def generate(site)
|
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?
|
if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index('glossary').nil?
|
||||||
print 'Glossary disabled' + "\n"
|
print 'Glossary disabled' + "\n"
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
main_dir='_data/glossary/'
|
main_dir = '_data/glossary/'
|
||||||
|
|
||||||
Dir.foreach(main_dir) do |dir|
|
Dir.foreach(main_dir) do |dir|
|
||||||
next if dir == '.' or 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|
|
Dir.foreach(glossary_dir) do |file|
|
||||||
next if file == '.' or file == '..'
|
next if file == '.' or file == '..'
|
||||||
|
|
||||||
src = file
|
src = file
|
||||||
output_directory = lang + '/glossary/'
|
output_directory = lang + '/glossary/'
|
||||||
site.pages << GlossaryPage.new(site, site.source, lang, glossary_dir, src, output_directory)
|
site.pages << GlossaryPage.new(site, site.source, lang, glossary_dir, src, output_directory)
|
||||||
end
|
end
|
||||||
|
|
||||||
devsearches_json = []
|
devsearches_json = []
|
||||||
site.config["devsearches"].each {| cat, items |
|
site.config["devsearches"].each { |cat, items|
|
||||||
devsearches_data_item = {}
|
if cat == "Glossary"
|
||||||
|
items.each { |language, list|
|
||||||
if cat == "Glossary"
|
list.each { |el|
|
||||||
items.each {| lang, list |
|
flat = el.flatten
|
||||||
|
devsearches_json.push({
|
||||||
list.each {| el |
|
"label" => flat[0],
|
||||||
flat = el.flatten
|
"uri" => flat[1],
|
||||||
devsearches_json.push({
|
"category" => cat,
|
||||||
"label" => flat[0],
|
"language" => language
|
||||||
"uri" => flat[1],
|
})
|
||||||
"category" => cat,
|
}
|
||||||
"lang" => lang
|
# puts list
|
||||||
})
|
}
|
||||||
}
|
else
|
||||||
# puts list
|
items.each { |el|
|
||||||
}
|
flat = el.flatten
|
||||||
else
|
devsearches_json.push({
|
||||||
items.each {| el |
|
"label" => flat[0],
|
||||||
flat = el.flatten
|
"uri" => flat[1],
|
||||||
devsearches_json.push({
|
"category" => cat,
|
||||||
"label" => flat[0],
|
"lang" => "en"
|
||||||
"uri" => flat[1],
|
})
|
||||||
"category" => cat,
|
}
|
||||||
"lang" => "en"
|
end
|
||||||
})
|
# devsearches_json.unshift({ term => output_full_path })
|
||||||
}
|
# puts items
|
||||||
end
|
|
||||||
# devsearches_json.unshift({ term => output_full_path })
|
|
||||||
# puts items
|
|
||||||
}
|
}
|
||||||
|
|
||||||
site.config["devsearches_json"] = devsearches_json.to_json
|
site.config["devsearches_json"] = devsearches_json.to_json
|
||||||
@ -174,5 +167,4 @@ module Jekyll
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,19 +1,17 @@
|
|||||||
# This file is licensed under the MIT License (MIT) available on
|
# This file is licensed under the MIT License (MIT) available on
|
||||||
# http://opensource.org/licenses/MIT.
|
# http://opensource.org/licenses/MIT.
|
||||||
|
|
||||||
#htmlescape espaces special html characters. This is a replacement for
|
# htmlescape espaces special html characters. This is a replacement for
|
||||||
#CGI::escapeHTML, which has an inconsistent behavior with single quotes
|
# CGI::escapeHTML, which has an inconsistent behavior with single quotes
|
||||||
#on different ruby versions ( 1.9 and 2.0 ).
|
# on different ruby versions ( 1.9 and 2.0 ).
|
||||||
|
|
||||||
#Example:
|
# Example:
|
||||||
# {{ page.title | htmlescape }}
|
# {{ page.title | htmlescape }}
|
||||||
|
|
||||||
module Entities
|
module Entities
|
||||||
|
|
||||||
def htmlescape(input)
|
def htmlescape(input)
|
||||||
input.gsub(/['&\"<>]/, { "'" => ''', '&' => '&', '"' => '"', '<' => '<', '>' => '>' })
|
input.gsub(/['&\"<>]/, { "'" => ''', '&' => '&', '"' => '"', '<' => '<', '>' => '>' })
|
||||||
end
|
end
|
||||||
|
|
||||||
Liquid::Template.register_filter self
|
Liquid::Template.register_filter self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,82 +1,82 @@
|
|||||||
module Jekyll
|
module Jekyll
|
||||||
class IncludeTagError < StandardError
|
class IncludeTagError < StandardError
|
||||||
attr_accessor :path
|
attr_accessor :path
|
||||||
|
|
||||||
def initialize(msg, path)
|
def initialize(msg, path)
|
||||||
super(msg)
|
super(msg)
|
||||||
@path = path
|
@path = path
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class IncludeAbsoluteTag < Liquid::Tag
|
||||||
|
VARIABLE_SYNTAX = %r!
|
||||||
|
(?<variable>[^{]*(\{\{\s*[\w\-\.]+\s*(\|.*)?\}\}[^\s{}]*)+)
|
||||||
|
(?<params>.*)
|
||||||
|
!x
|
||||||
|
|
||||||
|
def initialize(tag_name, markup, tokens)
|
||||||
|
super
|
||||||
|
|
||||||
|
path = markup.strip.split(' ')
|
||||||
|
|
||||||
|
@file = path[0].strip
|
||||||
|
|
||||||
|
if !path[1].nil?
|
||||||
|
@file_fallback = path[1].strip
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class IncludeAbsoluteTag < Liquid::Tag
|
# Render the variable if required (@see https://goo.gl/N5sMV3)
|
||||||
VARIABLE_SYNTAX = %r!
|
def render_variable(context)
|
||||||
(?<variable>[^{]*(\{\{\s*[\w\-\.]+\s*(\|.*)?\}\}[^\s{}]*)+)
|
if @file.match(VARIABLE_SYNTAX)
|
||||||
(?<params>.*)
|
partial = context.registers[:site]
|
||||||
!x
|
.liquid_renderer
|
||||||
|
.file("(variable)")
|
||||||
def initialize(tag_name, markup, tokens)
|
.parse(@file)
|
||||||
super
|
partial.render!(context)
|
||||||
|
end
|
||||||
path = markup.strip.split(' ')
|
|
||||||
|
|
||||||
@file = path[0].strip
|
|
||||||
|
|
||||||
if !path[1].nil?
|
|
||||||
@file_fallback = path[1].strip
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Render the variable if required (@see https://goo.gl/N5sMV3)
|
|
||||||
def render_variable(context)
|
|
||||||
if @file.match(VARIABLE_SYNTAX)
|
|
||||||
partial = context.registers[:site]
|
|
||||||
.liquid_renderer
|
|
||||||
.file("(variable)")
|
|
||||||
.parse(@file)
|
|
||||||
partial.render!(context)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def render(context)
|
|
||||||
file = render_variable(context) || @file
|
|
||||||
source = File.expand_path(context.registers[:site].config['source']).freeze
|
|
||||||
path = File.join(source, file)
|
|
||||||
|
|
||||||
begin
|
|
||||||
partial = Liquid::Template.parse(read_file(path, context))
|
|
||||||
|
|
||||||
context.stack do
|
|
||||||
context['include'] = parse_params(context) if @params
|
|
||||||
partial.render!(context)
|
|
||||||
end
|
|
||||||
rescue => e
|
|
||||||
if !@file_fallback.nil?
|
|
||||||
begin
|
|
||||||
path_fallback = File.join(source, @file_fallback)
|
|
||||||
|
|
||||||
partial = Liquid::Template.parse(read_file(path_fallback, context))
|
|
||||||
|
|
||||||
context.stack do
|
|
||||||
context['include'] = parse_params(context) if @params
|
|
||||||
partial.render!(context)
|
|
||||||
end
|
|
||||||
rescue => e
|
|
||||||
raise IncludeTagError.new e.message, path_fallback
|
|
||||||
end
|
|
||||||
else
|
|
||||||
raise IncludeTagError.new e.message, path
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def read_file(file, context)
|
|
||||||
File.read(file, file_read_opts(context))
|
|
||||||
end
|
|
||||||
|
|
||||||
def file_read_opts(context)
|
|
||||||
context.registers[:site].file_read_opts
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def render(context)
|
||||||
|
file = render_variable(context) || @file
|
||||||
|
source = File.expand_path(context.registers[:site].config['source']).freeze
|
||||||
|
path = File.join(source, file)
|
||||||
|
|
||||||
|
begin
|
||||||
|
partial = Liquid::Template.parse(read_file(path, context))
|
||||||
|
|
||||||
|
context.stack do
|
||||||
|
context['include'] = parse_params(context) if @params
|
||||||
|
partial.render!(context)
|
||||||
|
end
|
||||||
|
rescue => e
|
||||||
|
if !@file_fallback.nil?
|
||||||
|
begin
|
||||||
|
path_fallback = File.join(source, @file_fallback)
|
||||||
|
|
||||||
|
partial = Liquid::Template.parse(read_file(path_fallback, context))
|
||||||
|
|
||||||
|
context.stack do
|
||||||
|
context['include'] = parse_params(context) if @params
|
||||||
|
partial.render!(context)
|
||||||
|
end
|
||||||
|
rescue => e
|
||||||
|
raise IncludeTagError.new e.message, path_fallback
|
||||||
|
end
|
||||||
|
else
|
||||||
|
raise IncludeTagError.new e.message, path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def read_file(file, context)
|
||||||
|
File.read(file, file_read_opts(context))
|
||||||
|
end
|
||||||
|
|
||||||
|
def file_read_opts(context)
|
||||||
|
context.registers[:site].file_read_opts
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Liquid::Template.register_tag('include_absolute', Jekyll::IncludeAbsoluteTag)
|
Liquid::Template.register_tag('include_absolute', Jekyll::IncludeAbsoluteTag)
|
||||||
|
|||||||
@ -10,21 +10,19 @@
|
|||||||
## {% enditemplate %}
|
## {% enditemplate %}
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
require 'yaml'
|
||||||
require 'yaml'
|
|
||||||
|
|
||||||
class InlineTemplateBlock < Liquid::Block
|
class InlineTemplateBlock < Liquid::Block
|
||||||
|
|
||||||
def initialize(tag_name, text, tokens)
|
def initialize(tag_name, text, tokens)
|
||||||
super
|
super
|
||||||
@template_name = '_templates/' + text.gsub(' ','') + '.inline'
|
@template_name = '_templates/' + text.gsub(' ', '') + '.inline'
|
||||||
end
|
end
|
||||||
|
|
||||||
def render(context)
|
def render(context)
|
||||||
output = super
|
output = super
|
||||||
|
|
||||||
data = YAML.load(output)
|
data = YAML.load(output)
|
||||||
template = File.open(@template_name, mode="r")
|
template = File.open(@template_name)
|
||||||
@mytemplate = Liquid::Template.parse(template.read())
|
@mytemplate = Liquid::Template.parse(template.read())
|
||||||
@mytemplate.render('entry' => data)
|
@mytemplate.render('entry' => data)
|
||||||
end
|
end
|
||||||
@ -32,11 +30,9 @@ require 'yaml'
|
|||||||
end
|
end
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
require 'yaml'
|
||||||
require 'yaml'
|
|
||||||
|
|
||||||
class InlineTemplateBlockDisabled < Liquid::Block
|
class InlineTemplateBlockDisabled < Liquid::Block
|
||||||
|
|
||||||
def initialize(tag_name, text, tokens)
|
def initialize(tag_name, text, tokens)
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
@ -45,19 +41,7 @@ require 'yaml'
|
|||||||
output = super
|
output = super
|
||||||
|
|
||||||
output
|
output
|
||||||
#return('Inline Template (itemplate) disabled' + "\n")
|
# return('Inline Template (itemplate) disabled' + "\n")
|
||||||
end
|
end
|
||||||
end
|
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 %}
|
## {% endif %}
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class LiquidDie < Liquid::Tag
|
class LiquidDie < Liquid::Tag
|
||||||
|
|
||||||
def initialize(tag_name, text, tokens)
|
def initialize(tag_name, text, tokens)
|
||||||
super
|
super
|
||||||
@error = text
|
@error = text
|
||||||
end
|
end
|
||||||
|
|
||||||
def render(context)
|
def render(_context)
|
||||||
## Produces: Liquid die tag called. [<Error.>] -- Error creating output [in <output file name>]
|
## 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
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
Liquid::Template.register_tag('die', Jekyll::LiquidDie)
|
Liquid::Template.register_tag('die', Jekyll::LiquidDie)
|
||||||
|
|||||||
@ -12,18 +12,16 @@
|
|||||||
## {% endif %}
|
## {% endif %}
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class LiquidWarn < Liquid::Tag
|
class LiquidWarn < Liquid::Tag
|
||||||
|
|
||||||
def initialize(tag_name, text, tokens)
|
def initialize(tag_name, text, tokens)
|
||||||
super
|
super
|
||||||
@warning = text
|
@warning = text
|
||||||
end
|
end
|
||||||
|
|
||||||
def render(context)
|
def render(_context)
|
||||||
## Use "notice" instead of "warning" because we use grep to
|
## Use "notice" instead of "warning" because we use grep to
|
||||||
## treat some Jekyll warnings as errors
|
## treat some Jekyll warnings as errors
|
||||||
print "Notice: " + @warning + "\n"
|
print "Notice: " + @warning + "\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,14 +1,13 @@
|
|||||||
# This file is licensed under the MIT License (MIT) available on
|
# This file is licensed under the MIT License (MIT) available on
|
||||||
# http://opensource.org/licenses/MIT.
|
# http://opensource.org/licenses/MIT.
|
||||||
|
|
||||||
#redirects.rb generates all redirection pages
|
# redirects.rb generates all redirection pages
|
||||||
#from _config.yml .
|
# from _config.yml .
|
||||||
|
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'cgi'
|
require 'cgi'
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class PageRedirect < Page
|
class PageRedirect < Page
|
||||||
def initialize(site, base, srcdir, src, dst)
|
def initialize(site, base, srcdir, src, dst)
|
||||||
@site = site
|
@site = site
|
||||||
@ -25,20 +24,19 @@ module Jekyll
|
|||||||
|
|
||||||
class RedirectPageGenerator < Generator
|
class RedirectPageGenerator < Generator
|
||||||
def generate(site)
|
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?
|
if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index('redirects').nil?
|
||||||
print 'Redirects disabled' + "\n"
|
print 'Redirects disabled' + "\n"
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
#Load redirections
|
# Load redirections
|
||||||
redirects = YAML.load_file("_config.yml")['redirects']
|
redirects = YAML.load_file("_config.yml")['redirects']
|
||||||
#Generate each redirection page
|
# Generate each redirection page
|
||||||
if !File.directory?(site.dest)
|
if !File.directory?(site.dest)
|
||||||
Dir.mkdir(site.dest)
|
Dir.mkdir(site.dest)
|
||||||
end
|
end
|
||||||
redirects.each do |src,dst|
|
redirects.each do |src, dst|
|
||||||
srcar = src.split('/')
|
srcar = src.split('/')
|
||||||
src = srcar.pop + '.html'
|
src = srcar.pop + '.html'
|
||||||
srcdir = srcar.join('/')
|
srcdir = srcar.join('/')
|
||||||
@ -46,5 +44,4 @@ module Jekyll
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
# This file is licensed under the MIT License (MIT) available on
|
# This file is licensed under the MIT License (MIT) available on
|
||||||
# http://opensource.org/licenses/MIT.
|
# http://opensource.org/licenses/MIT.
|
||||||
|
|
||||||
#releases.rb generates release pages using files in _releases
|
# releases.rb generates release pages using files in _releases
|
||||||
#and assign them the 'release' category.
|
# and assign them the 'release' category.
|
||||||
|
|
||||||
#This is later used to loop through site.pages in order
|
# This is later used to loop through site.pages in order
|
||||||
#to display the release's list in version order, both
|
# to display the release's list in version order, both
|
||||||
#on the "Version history" page and RSS file.
|
# on the "Version history" page and RSS file.
|
||||||
|
|
||||||
# This plugin also finds the highest required_version of
|
# This plugin also finds the highest required_version of
|
||||||
# Bitcoin Core and populates the Download page with variables set in
|
# Bitcoin Core and populates the Download page with variables set in
|
||||||
@ -15,9 +15,7 @@
|
|||||||
require 'yaml'
|
require 'yaml'
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class ReleasePage < Page
|
class ReleasePage < Page
|
||||||
|
|
||||||
def initialize(site, base, lang, srcdir, src, output_directory)
|
def initialize(site, base, lang, srcdir, src, output_directory)
|
||||||
@site = site
|
@site = site
|
||||||
@base = base
|
@base = base
|
||||||
@ -62,37 +60,34 @@ module Jekyll
|
|||||||
|
|
||||||
def versiontoint(v)
|
def versiontoint(v)
|
||||||
x = 0
|
x = 0
|
||||||
ar = v.split('.').map{|s| s.to_i}
|
ar = v.split('.').map { |s| s.to_i }
|
||||||
ar.each_index do |k|
|
ar.each_index do |k|
|
||||||
x += ar[k] * (1000 ** (5 - k))
|
x += ar[k] * (1000**(5 - k))
|
||||||
end
|
end
|
||||||
return x
|
return x
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class ReleasePageGenerator < Generator
|
class ReleasePageGenerator < Generator
|
||||||
def generate(site)
|
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?
|
if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index('releases').nil?
|
||||||
print 'Releases disabled' + "\n"
|
print 'Releases disabled' + "\n"
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
#generate each release based on templates
|
# generate each release based on templates
|
||||||
Dir.foreach('_releases') do |file|
|
Dir.foreach('_releases') do |file|
|
||||||
next if file == '.' or file == '..'
|
next if file == '.' or file == '..'
|
||||||
|
|
||||||
lang = 'en'
|
lang = 'en'
|
||||||
src = file
|
src = file
|
||||||
srcdir = '_releases'
|
|
||||||
output_directory = lang + '/release'
|
output_directory = lang + '/release'
|
||||||
site.pages << ReleasePage.new(site, site.source, lang, '_releases', src, output_directory)
|
site.pages << ReleasePage.new(site, site.source, lang, '_releases', src, output_directory)
|
||||||
end
|
end
|
||||||
#TODO releases are only generated for english language,
|
# TODO releases are only generated for english language,
|
||||||
#but they could also be translated at some point. They would however
|
# but they could also be translated at some point. They would however
|
||||||
#need to fallback to english when no translation is available.
|
# need to fallback to english when no translation is available.
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,14 +1,13 @@
|
|||||||
# This file is licensed under the MIT License (MIT) available on
|
# This file is licensed under the MIT License (MIT) available on
|
||||||
# http://opensource.org/licenses/MIT.
|
# http://opensource.org/licenses/MIT.
|
||||||
|
|
||||||
#sitemap.rb generates a sitemap.xml file, which also includes
|
# sitemap.rb generates a sitemap.xml file, which also includes
|
||||||
#alternate hreflang for each translated version of each page.
|
# alternate hreflang for each translated version of each page.
|
||||||
|
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'cgi'
|
require 'cgi'
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class SitemapFile < StaticFile
|
class SitemapFile < StaticFile
|
||||||
def write(dest)
|
def write(dest)
|
||||||
# do nothing
|
# do nothing
|
||||||
@ -17,85 +16,93 @@ module Jekyll
|
|||||||
|
|
||||||
class SitemapGenerator < Generator
|
class SitemapGenerator < Generator
|
||||||
def generate(site)
|
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?
|
if !ENV['ENABLED_PLUGINS'].nil? and ENV['ENABLED_PLUGINS'].index('sitemap').nil?
|
||||||
print 'Sitemap disabled' + "\n"
|
print 'Sitemap disabled' + "\n"
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
#Load translations
|
# Load translations
|
||||||
locs = {}
|
locs = {}
|
||||||
enabled = ENV['ENABLED_LANGS'];
|
enabled = ENV['ENABLED_LANGS'];
|
||||||
enabled = enabled.split(' ') if !enabled.nil?
|
enabled = enabled.split(' ') if !enabled.nil?
|
||||||
Dir.foreach('_translations') do |file|
|
Dir.foreach('_translations') do |file|
|
||||||
next if file == '.' or file == '..' or file == 'COPYING'
|
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)
|
if lang != 'en' and !enabled.nil? and !enabled.include?(lang)
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
locs[lang] = YAML.load_file('_translations/'+file)[lang]
|
|
||||||
|
locs[lang] = YAML.load_file('_translations/' + file)[lang]
|
||||||
end
|
end
|
||||||
#Create destination directory if does not exists
|
# Create destination directory if does not exists
|
||||||
if !File.directory?(site.dest)
|
if !File.directory?(site.dest)
|
||||||
Dir.mkdir(site.dest)
|
Dir.mkdir(site.dest)
|
||||||
end
|
end
|
||||||
File.open(File.join(site.dest, 'sitemap.xml'), 'w+') do |sitemap|
|
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 '<?xml version="1.0" encoding="UTF-8"?>'
|
||||||
sitemap.puts '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"'
|
sitemap.puts '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"'
|
||||||
sitemap.puts ' xmlns:xhtml="http://www.w3.org/1999/xhtml">'
|
sitemap.puts ' xmlns:xhtml="http://www.w3.org/1999/xhtml">'
|
||||||
#Add translated pages with their alternative in each languages
|
# Add translated pages with their alternative in each languages
|
||||||
locs['en']['url'].each do |id,value|
|
locs['en']['url'].each do |id, _value|
|
||||||
locs.each do |lang,value|
|
locs.each do |lang, _var|
|
||||||
#Don't add a page if their url is not translated
|
# Don't add a page if their url is not translated
|
||||||
next if locs[lang]['url'][id].nil? or locs[lang]['url'][id] == ''
|
next if locs[lang]['url'][id].nil? or locs[lang]['url'][id] == ''
|
||||||
|
|
||||||
sitemap.puts '<url>'
|
sitemap.puts '<url>'
|
||||||
sitemap.puts ' <loc>https://bitcoin.org/'+lang+'/'+CGI::escape(locs[lang]['url'][id])+'</loc>'
|
sitemap.puts ' <loc>https://bitcoin.org/' + lang + '/' + CGI::escape(locs[lang]['url'][id]) + '</loc>'
|
||||||
locs.each do |altlang,value|
|
locs.each do |altlang, _altvar|
|
||||||
next if locs[altlang]['url'][id].nil? or locs[altlang]['url'][id] == '' or altlang == lang
|
next if locs[altlang]['url'][id].nil? or locs[altlang]['url'][id] == '' or altlang == lang
|
||||||
|
|
||||||
sitemap.puts ' <xhtml:link'
|
sitemap.puts ' <xhtml:link'
|
||||||
sitemap.puts ' rel="alternate"'
|
sitemap.puts ' rel="alternate"'
|
||||||
sitemap.puts ' hreflang="'+altlang+'"'
|
sitemap.puts ' hreflang="' + altlang + '"'
|
||||||
sitemap.puts ' href="https://bitcoin.org/'+altlang+'/'+CGI::escape(locs[altlang]['url'][id])+'" />'
|
sitemap.puts ' href="https://bitcoin.org/' + altlang + '/' + CGI::escape(locs[altlang]['url'][id]) + '" />'
|
||||||
end
|
end
|
||||||
sitemap.puts '</url>'
|
sitemap.puts '</url>'
|
||||||
end
|
end
|
||||||
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|
|
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'
|
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)
|
data = File.read(file)
|
||||||
next if !data.index('google-site-verification:').nil?
|
next if !data.index('google-site-verification:').nil?
|
||||||
|
|
||||||
sitemap.puts '<url>'
|
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>'
|
sitemap.puts '</url>'
|
||||||
end
|
end
|
||||||
#Add alerts pages
|
# Add alerts pages
|
||||||
Dir.foreach('_alerts') do |file|
|
Dir.foreach('_alerts') do |file|
|
||||||
next if file == '.' or file == '..'
|
next if file == '.' or file == '..'
|
||||||
|
|
||||||
sitemap.puts '<url>'
|
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>'
|
sitemap.puts '</url>'
|
||||||
end
|
end
|
||||||
#Add releases pages
|
# Add releases pages
|
||||||
Dir.foreach('_releases') do |file|
|
Dir.foreach('_releases') do |file|
|
||||||
next if file == '.' or file == '..'
|
next if file == '.' or file == '..'
|
||||||
|
|
||||||
file = file.split('-')
|
file = file.split('-')
|
||||||
next if file.length < 4
|
next if file.length < 4
|
||||||
|
|
||||||
file.shift()
|
file.shift()
|
||||||
file.shift()
|
file.shift()
|
||||||
file.shift()
|
file.shift()
|
||||||
file = file.join('-')
|
file = file.join('-')
|
||||||
sitemap.puts '<url>'
|
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>'
|
sitemap.puts '</url>'
|
||||||
end
|
end
|
||||||
#Close sitemap
|
# Close sitemap
|
||||||
sitemap.puts '</urlset>'
|
sitemap.puts '</urlset>'
|
||||||
end
|
end
|
||||||
site.static_files << SitemapFile.new(site, site.source, '', 'sitemap.xml')
|
site.static_files << SitemapFile.new(site, site.source, '', 'sitemap.xml')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,20 +1,19 @@
|
|||||||
# This file is licensed under the MIT License (MIT) available on
|
# This file is licensed under the MIT License (MIT) available on
|
||||||
# http://opensource.org/licenses/MIT.
|
# http://opensource.org/licenses/MIT.
|
||||||
|
|
||||||
#templates.rb generates all translated pages using templates in
|
# templates.rb generates all translated pages using templates in
|
||||||
#_templates. The final file name of each page is defined in
|
# _templates. The final file name of each page is defined in
|
||||||
#the url section of each translations in _translations.
|
# the url section of each translations in _translations.
|
||||||
|
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'cgi'
|
require 'cgi'
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class TranslatePage < Page
|
class TranslatePage < Page
|
||||||
def initialize(site, base, lang, srcdir, src, dstdir, dst)
|
def initialize(site, base, lang, srcdir, src, dstdir, dst)
|
||||||
@site = site
|
@site = site
|
||||||
@base = base
|
@base = base
|
||||||
@dir = '/'+dstdir
|
@dir = '/' + dstdir
|
||||||
@name = dst
|
@name = dst
|
||||||
self.process(dst)
|
self.process(dst)
|
||||||
self.read_yaml(File.join(base, srcdir), src)
|
self.read_yaml(File.join(base, srcdir), src)
|
||||||
@ -23,41 +22,43 @@ module Jekyll
|
|||||||
end
|
end
|
||||||
class TranslatePageGenerator < Generator
|
class TranslatePageGenerator < Generator
|
||||||
def generate(site)
|
def generate(site)
|
||||||
#load translations files
|
# load translations files
|
||||||
locs = {}
|
locs = {}
|
||||||
enabled = ENV['ENABLED_LANGS'];
|
enabled = ENV['ENABLED_LANGS'];
|
||||||
enabled = enabled.split(' ') if !enabled.nil?
|
enabled = enabled.split(' ') if !enabled.nil?
|
||||||
Dir.foreach('_translations') do |file|
|
Dir.foreach('_translations') do |file|
|
||||||
next if file == '.' or file == '..' or file == 'COPYING'
|
next if file == '.' or file == '..' or file == 'COPYING'
|
||||||
|
|
||||||
lang = file.split('.')[0]
|
lang = file.split('.')[0]
|
||||||
#Ignore lang if disabled
|
# Ignore lang if disabled
|
||||||
if lang != 'en' and !enabled.nil? and !enabled.include?(lang)
|
if lang != 'en' and !enabled.nil? and !enabled.include?(lang)
|
||||||
print 'Lang ' + lang + ' disabled' + "\n"
|
print 'Lang ' + lang + ' disabled' + "\n"
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
locs[lang] = YAML.load_file("_translations/"+file)[lang]
|
locs[lang] = YAML.load_file("_translations/" + file)[lang]
|
||||||
end
|
end
|
||||||
#Generate each translated page based on templates
|
# Generate each translated page based on templates
|
||||||
if !File.directory?(site.dest)
|
if !File.directory?(site.dest)
|
||||||
Dir.mkdir(site.dest)
|
Dir.mkdir(site.dest)
|
||||||
end
|
end
|
||||||
locs.each do |lang,value|
|
locs.each do |lang, _value|
|
||||||
Dir.foreach('_templates') do |file|
|
Dir.foreach('_templates') do |file|
|
||||||
next if file == '.' or file == '..'
|
next if file == '.' or file == '..'
|
||||||
|
|
||||||
id = file.split('.')[0]
|
id = file.split('.')[0]
|
||||||
dst = locs[lang]['url'][id]
|
dst = locs[lang]['url'][id]
|
||||||
next if dst.nil? or dst == ''
|
next if dst.nil? or dst == ''
|
||||||
|
|
||||||
src = file
|
src = file
|
||||||
## For files ending in a slash, such as path/to/dir/, give them
|
## For files ending in a slash, such as path/to/dir/, give them
|
||||||
## the index.html file name
|
## the index.html file name
|
||||||
dst.gsub!(/\/$/, '/index')
|
dst.gsub!(/\/$/, '/index')
|
||||||
|
|
||||||
dst = dst+'.html'
|
dst = dst + '.html'
|
||||||
site.pages << TranslatePage.new(site, site.source, lang, '_templates', src, lang, dst)
|
site.pages << TranslatePage.new(site, site.source, lang, '_templates', src, lang, dst)
|
||||||
end
|
end
|
||||||
site.pages << TranslatePage.new(site, site.source, lang, '_templates', 'index.html', lang, 'index.html')
|
site.pages << TranslatePage.new(site, site.source, lang, '_templates', 'index.html', lang, 'index.html')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,50 +1,49 @@
|
|||||||
# This file is licensed under the MIT License (MIT) available on
|
# This file is licensed under the MIT License (MIT) available on
|
||||||
# http://opensource.org/licenses/MIT.
|
# http://opensource.org/licenses/MIT.
|
||||||
|
|
||||||
#translate( id [,category ,lang] )
|
# translate( id [,category ,lang] )
|
||||||
#Return translated string using translations files
|
# Return translated string using translations files
|
||||||
|
|
||||||
#category and lang are set to current page.id and page.lang, but they can
|
# 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.
|
# also be set manually to get translations for global layout and urls.
|
||||||
#Example: {% translate button-wallet layout %} will return the
|
# Example: {% translate button-wallet layout %} will return the
|
||||||
#translated button-wallet string for the global layout file
|
# translated button-wallet string for the global layout file
|
||||||
|
|
||||||
#dynamic variables can be used as arguments
|
# dynamic variables can be used as arguments
|
||||||
#Example: {% translate menu-{{id}} %}
|
# Example: {% translate menu-{{id}} %}
|
||||||
|
|
||||||
#urls and anchors are automatically replaced and translated.
|
# urls and anchors are automatically replaced and translated.
|
||||||
#Example: #vocabulary##[vocabulary.wallet] is replaced by
|
# Example: #vocabulary##[vocabulary.wallet] is replaced by
|
||||||
#/en/vocabulary#wallet when the page is in english or
|
# /en/vocabulary#wallet when the page is in english or
|
||||||
#/fr/vocabulaire#porte-monnaie when the page is in french.
|
# /fr/vocabulaire#porte-monnaie when the page is in french.
|
||||||
|
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'cgi'
|
require 'cgi'
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class TranslateTag < Liquid::Tag
|
class TranslateTag < Liquid::Tag
|
||||||
|
|
||||||
def initialize(tag_name, id, tokens)
|
def initialize(tag_name, id, tokens)
|
||||||
super
|
super
|
||||||
@id = id
|
@id = id
|
||||||
end
|
end
|
||||||
|
|
||||||
def render(context)
|
def render(context)
|
||||||
#Load translations
|
# Load translations
|
||||||
site = context.registers[:site].config
|
site = context.registers[:site].config
|
||||||
if !site.has_key?("loc")
|
if !site.has_key?("loc")
|
||||||
site['loc'] = {}
|
site['loc'] = {}
|
||||||
Dir.foreach('_translations') do |file|
|
Dir.foreach('_translations') do |file|
|
||||||
next if file == '.' or 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
|
||||||
end
|
end
|
||||||
#define id, category and lang
|
# define id, category and lang
|
||||||
defaulten = true
|
defaulten = true
|
||||||
lang = Liquid::Template.parse("{{page.lang}}").render context
|
lang = Liquid::Template.parse("{{page.lang}}").render context
|
||||||
cat = Liquid::Template.parse("{{page.id}}").render context
|
cat = Liquid::Template.parse("{{page.id}}").render context
|
||||||
id=@id.split(' ')
|
id = @id.split(' ')
|
||||||
if !id[1].nil?
|
if !id[1].nil?
|
||||||
cat = Liquid::Template.parse(id[1]).render context
|
cat = Liquid::Template.parse(id[1]).render context
|
||||||
end
|
end
|
||||||
@ -52,62 +51,63 @@ module Jekyll
|
|||||||
lang = Liquid::Template.parse(id[2]).render context
|
lang = Liquid::Template.parse(id[2]).render context
|
||||||
defaulten = false
|
defaulten = false
|
||||||
end
|
end
|
||||||
id=Liquid::Template.parse(id[0]).render context
|
id = Liquid::Template.parse(id[0]).render context
|
||||||
if lang == ''
|
if lang == ''
|
||||||
lang = 'en'
|
lang = 'en'
|
||||||
end
|
end
|
||||||
#get translated string
|
# get translated string
|
||||||
text = ''
|
text = ''
|
||||||
keys = cat.split('.')
|
keys = cat.split('.')
|
||||||
ar = site['loc'][lang]
|
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
|
for key in keys do
|
||||||
break if !ar.is_a?(Hash) || !ar.has_key?(key) || !ar[key].is_a?(Hash)
|
break if !ar.is_a?(Hash) || !ar.has_key?(key) || !ar[key].is_a?(Hash)
|
||||||
|
|
||||||
ar = ar[key]
|
ar = ar[key]
|
||||||
end
|
end
|
||||||
if ar.has_key?(id) && ar[id].is_a?(String)
|
if ar.has_key?(id) && ar[id].is_a?(String)
|
||||||
text = ar[id]
|
text = ar[id]
|
||||||
end
|
end
|
||||||
#fallback to English if string is empty
|
# fallback to English if string is empty
|
||||||
if text == '' and defaulten == true
|
if text == '' and defaulten == true
|
||||||
lang = 'en'
|
lang = 'en'
|
||||||
ar = site['loc'][lang]
|
ar = site['loc'][lang]
|
||||||
for key in keys do
|
for key in keys do
|
||||||
break if !ar.is_a?(Hash) || !ar.has_key?(key) || !ar[key].is_a?(Hash)
|
break if !ar.is_a?(Hash) || !ar.has_key?(key) || !ar[key].is_a?(Hash)
|
||||||
|
|
||||||
ar = ar[key]
|
ar = ar[key]
|
||||||
end
|
end
|
||||||
if ar.has_key?(id) && ar[id].is_a?(String)
|
if ar.has_key?(id) && ar[id].is_a?(String)
|
||||||
text = ar[id]
|
text = ar[id]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
#interpret Liquid templating in string
|
# interpret Liquid templating in string
|
||||||
text = Liquid::Template.parse(text).render context
|
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 = site['loc'][lang]['url']
|
||||||
url.each do |key,value|
|
url.each do |k, v|
|
||||||
if !value.nil?
|
if !value.nil?
|
||||||
text.gsub!("#"+key+"#",'/'+lang+'/'+CGI::escape(value))
|
text.gsub!("#" + k + "#", '/' + lang + '/' + CGI::escape(v))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
## Hack for renaming links to the Bitcoin paper. Safe to remove
|
## Hack for renaming links to the Bitcoin paper. Safe to remove
|
||||||
## when all languages have "bitcoin-paper:" defined in the "url:"
|
## when all languages have "bitcoin-paper:" defined in the "url:"
|
||||||
## section of their '_translations' YAML file.
|
## section of their '_translations' YAML file.
|
||||||
text.gsub!('#bitcoin-paper#','/bitcoin.pdf')
|
text.gsub!('#bitcoin-paper#', '/bitcoin.pdf')
|
||||||
|
|
||||||
anc = site['loc'][lang]['anchor']
|
anc = site['loc'][lang]['anchor']
|
||||||
anc.each do |page,anch|
|
anc.each do |page, anch|
|
||||||
anch.each do |key,value|
|
anch.each do |k, v|
|
||||||
if !value.nil?
|
if !value.nil?
|
||||||
text.gsub!("["+page+'.'+key+"]",CGI::escape(value))
|
text.gsub!("[" + page + '.' + k + "]", CGI::escape(v))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
text
|
text
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Liquid::Template.register_tag('translate', Jekyll::TranslateTag)
|
Liquid::Template.register_tag('translate', Jekyll::TranslateTag)
|
||||||
|
|||||||
@ -4,7 +4,6 @@
|
|||||||
require 'yaml'
|
require 'yaml'
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class WalletPage < Page
|
class WalletPage < Page
|
||||||
def initialize(site, base, dir, wallet, platform, os, title, lang)
|
def initialize(site, base, dir, wallet, platform, os, title, lang)
|
||||||
@site = site
|
@site = site
|
||||||
@ -61,17 +60,18 @@ module Jekyll
|
|||||||
enabled = enabled.split(' ') if !enabled.nil?
|
enabled = enabled.split(' ') if !enabled.nil?
|
||||||
Dir.foreach('_translations') do |file|
|
Dir.foreach('_translations') do |file|
|
||||||
next if file == '.' or file == '..' or file == 'COPYING'
|
next if file == '.' or file == '..' or file == 'COPYING'
|
||||||
|
|
||||||
lang = file.split('.')[0]
|
lang = file.split('.')[0]
|
||||||
# Ignore language if it's disabled
|
# Ignore language if it's disabled
|
||||||
if lang != 'en' and !enabled.nil? and !enabled.include?(lang)
|
if lang != 'en' and !enabled.nil? and !enabled.include?(lang)
|
||||||
puts('Lang ' + lang + ' disabled')
|
puts('Lang ' + lang + ' disabled')
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
locs[lang] = YAML.load_file("_translations/"+file)[lang]
|
locs[lang] = YAML.load_file("_translations/" + file)[lang]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Getting information about each found wallet
|
# Getting information about each found wallet
|
||||||
locs.each do |lang,value|
|
locs.each do |lang, _value|
|
||||||
title = locs[lang]['choose-your-wallet']['title']
|
title = locs[lang]['choose-your-wallet']['title']
|
||||||
|
|
||||||
platformsCol.docs.each do |doc|
|
platformsCol.docs.each do |doc|
|
||||||
@ -104,7 +104,6 @@ module Jekyll
|
|||||||
# platforms and OSes
|
# platforms and OSes
|
||||||
walletPlatforms.each do |platform|
|
walletPlatforms.each do |platform|
|
||||||
platform['os'].each do |os|
|
platform['os'].each do |os|
|
||||||
|
|
||||||
# This allows generation only of valid wallet pages
|
# This allows generation only of valid wallet pages
|
||||||
if platform['name']
|
if platform['name']
|
||||||
if platform['name'] == os['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)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user