mirror of
https://github.com/seigler/dash-docs
synced 2025-07-27 01:36:13 +00:00
Releases: Variablize Release Notes
Add additional variables to the release note files to allow setting the version number and date. The version number is required, and can be used to automatically set the release notes title. The date is optional and can be set hours/days after the release. Additionally, a Makefile test is added that checks whether the download files exist on the Bitcoin.org server. This can help prevent creating a broken Download page. * Set variables for all previous releases * Document variables in README.md * Update code and templates to use variables * Add the Download page links to the "dl" CSS class. Also add newlines to make the HTML a bit easier to parse using sed * Add a new Liquid plugin to print warnings. This is used to print a non-error warning if any release is created without the optional date
This commit is contained in:
parent
4e80dc13f8
commit
cbebe461ff
40 changed files with 314 additions and 94 deletions
|
@ -17,10 +17,12 @@ module Jekyll
|
|||
|
||||
def initialize(tag_name, text, tokens)
|
||||
super
|
||||
@error = text
|
||||
end
|
||||
|
||||
def render(context)
|
||||
abort("Liquid die tag called. Dying...")
|
||||
## Produces: Liquid die tag called. [<Error.>] -- Error creating output [in <output file name>]
|
||||
abort("Liquid die tag called. " + @error + " -- Error creating output" )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
31
_plugins/liquid-warn.rb
Normal file
31
_plugins/liquid-warn.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
# This file is licensed under the MIT License (MIT) available on
|
||||
# http://opensource.org/licenses/MIT.
|
||||
|
||||
## liquid-warn.rb prints a warning to stdout (not stderr). This can allow
|
||||
## someone manually building the site (or reviewing logs) to detect a problem
|
||||
|
||||
## Example:
|
||||
## {% if some_variable_is_set %}
|
||||
## ...content...
|
||||
## {% else %}
|
||||
## {% warn "Optional message" %}
|
||||
## {% endif %}
|
||||
|
||||
module Jekyll
|
||||
|
||||
class LiquidWarn < Liquid::Tag
|
||||
|
||||
def initialize(tag_name, text, tokens)
|
||||
super
|
||||
@warning = text
|
||||
end
|
||||
|
||||
def render(context)
|
||||
## Use "notice" instead of "warning" because we use grep to
|
||||
## treat some Jekyll warnings as errors
|
||||
print "Notice: " + @warning + "\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Liquid::Template.register_tag('warn', Jekyll::LiquidWarn)
|
|
@ -5,46 +5,58 @@
|
|||
#and assign them the 'release' category.
|
||||
|
||||
#This is later used to loop through site.pages in order
|
||||
#to display the release's list in chronological order, both
|
||||
#to display the release's list in version order, both
|
||||
#on the "Version history" page and RSS file.
|
||||
|
||||
#This plugin also set site.DOWNLOAD_VERSION to the latest
|
||||
#available version of Bitcoin Core, which is used everywhere
|
||||
#in the download page.
|
||||
|
||||
#Alias redirection pages are generated in /releases to avoid
|
||||
#breaking previous links in various websites.
|
||||
# This plugin also finds the highest required_version of
|
||||
# Bitcoin Core and populates the Download page with variables set in
|
||||
# that release file
|
||||
|
||||
require 'yaml'
|
||||
|
||||
module Jekyll
|
||||
|
||||
|
||||
class ReleasePage < Page
|
||||
|
||||
def initialize(site, base, lang, srcdir, src, dstdir, dst, year, month, day)
|
||||
def initialize(site, base, lang, srcdir, src, output_directory)
|
||||
@site = site
|
||||
@base = base
|
||||
@dir = '/'+dstdir
|
||||
@name = dst.gsub('.md','.html')
|
||||
self.process(dst)
|
||||
@dir = '/' + output_directory
|
||||
|
||||
## Read in the file's YAML header
|
||||
self.read_yaml(File.join(base, srcdir), src)
|
||||
self.data['lang'] = lang
|
||||
self.data['date'] = year + '-' + month + '-' + day
|
||||
self.data['version'] = dst.gsub('.md','').gsub(/[a-z]/,'')
|
||||
self.data['versionint'] = versiontoint(self.data['version'])
|
||||
self.data['layout'] = 'release'
|
||||
if dstdir.index('/releases/') === 0
|
||||
self.data['redirect'] = '/en/release/' + dst.gsub('.md','')
|
||||
self.data['layout'] = 'redirect'
|
||||
|
||||
## Die if required_ variables aren't set
|
||||
if self.data['required_version']
|
||||
version = self.data['required_version']
|
||||
else
|
||||
self.data['category'] = 'release'
|
||||
if !site.config.has_key?('DOWNLOAD_VERSION') or site.config['DOWNLOAD_VERSIONINT'] < self.data['versionint']
|
||||
site.config['DOWNLOAD_VERSIONINT'] = self.data['versionint']
|
||||
site.config['DOWNLOAD_VERSION'] = self.data['version']
|
||||
site.config.delete('DOWNLOAD_MAGNETLINK') if site.config.has_key?('DOWNLOAD_MAGNETLINK')
|
||||
site.config['DOWNLOAD_MAGNETLINK'] = self.data['magnetlink'] if self.data.has_key?('magnetlink')
|
||||
end
|
||||
site.pages << ReleasePage.new(site, base, lang, srcdir, src, '/releases/' + year + '/' + month + '/' + day, dst, year, month, day)
|
||||
abort("Error: Variable required_version not set when processing " + src)
|
||||
end
|
||||
|
||||
## Output file is v<version>.md (converted later to HTML)
|
||||
output_file = "v" + version + ".md"
|
||||
@name = output_file
|
||||
self.process(output_file)
|
||||
|
||||
## Title required for <title></title> in _layouts/base.html
|
||||
self.data['title'] = self.data['optional_title'] ? self.data['optional_title'] : "Bitcoin Core version %v released"
|
||||
self.data['title'].gsub!('%v', version)
|
||||
|
||||
## For translation, but currently always set to "en"
|
||||
self.data['lang'] = lang
|
||||
|
||||
## Only processes numeric version numbers with up to five decimals
|
||||
self.data['versionint'] = versiontoint(self.data['required_version'])
|
||||
|
||||
self.data['layout'] = 'release'
|
||||
self.data['category'] = 'release'
|
||||
|
||||
## If this is the highest version we've seen so far...
|
||||
if !site.config.has_key?('DOWNLOAD_VERSION') or site.config['DOWNLOAD_VERSIONINT'] < self.data['versionint']
|
||||
site.config['DOWNLOAD_VERSIONINT'] = self.data['versionint']
|
||||
site.config['DOWNLOAD_VERSION'] = self.data['required_version']
|
||||
|
||||
site.config['DOWNLOAD_MAGNETLINK'] = self.data['optional_magnetlink'] ? self.data['optional_magnetlink'] : nil
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -73,18 +85,9 @@ module Jekyll
|
|||
next if file == '.' or file == '..'
|
||||
lang = 'en'
|
||||
src = file
|
||||
dst = file.split('-')
|
||||
next if dst.length < 4
|
||||
year = dst.shift()
|
||||
month = dst.shift()
|
||||
day = dst.shift()
|
||||
next if !/^[0-9]{4}$/.match(year)
|
||||
next if !/^[0-9]{2}$/.match(month)
|
||||
next if !/^[0-9]{2}$/.match(day)
|
||||
dst = dst.join('-')
|
||||
srcdir = '_releases'
|
||||
dstdir = lang + '/release'
|
||||
site.pages << ReleasePage.new(site, site.source, lang, '_releases', src, dstdir, dst, year, month, day)
|
||||
output_directory = lang + '/release'
|
||||
site.pages << ReleasePage.new(site, site.source, lang, '_releases', src, output_directory)
|
||||
end
|
||||
#TODO releases are only generated for english language,
|
||||
#but they could also be translated at some point. They would however
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue