Generate releases notes using releases.rb

Make releases notes layout and urls consistent with the alerts page
Add RSS feed in download and version-history pages
Add a canonical page with a redirect to the new url
Simplify releases notes layouts
This commit is contained in:
Saivann 2013-06-19 14:04:29 -04:00
parent d45b9bbbfc
commit 6ac93df9f2
29 changed files with 118 additions and 98 deletions

51
_plugins/releases.rb Normal file
View file

@ -0,0 +1,51 @@
require 'yaml'
module Jekyll
class ReleasePage < Page
def initialize(site, base, lang, srcdir, src, dstdir, dst, year, month, day)
@site = site
@base = base
@dir = '/'+dstdir
@name = dst.gsub('.md','.html')
self.process(dst)
self.read_yaml(File.join(base, srcdir), src)
self.data['lang'] = lang
self.data['date'] = year + '-' + month + '-' + day
self.data['layout'] = 'release'
if dstdir.index('/releases/') === 0
self.data['redirect'] = dst.gsub('.md','')
else
self.data['category'] = 'release'
site.pages << ReleasePage.new(site, base, lang, srcdir, src, '/releases/' + year + '/' + month + '/' + day, dst, year, month, day)
end
end
end
class ReleasePageGenerator < Generator
def generate(site)
#generate each release based on templates
Dir.foreach('_releases') do |file|
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)
end
#TODO releases are only generated for english language,
#but they could also be translated at some point. They would however
#need to fallback to english when no translation is available.
end
end
end

View file

@ -90,6 +90,19 @@ module Jekyll
sitemap.puts ' <loc>http://bitcoin.org/en/alert/'+file.gsub('.html','')+'</loc>'
sitemap.puts '</url>'
end
#Add english releases pages
Dir.foreach('_releases') do |file|
next if file == '.' or file == '..'
file = file.split('-')
next if file.length < 4
file.shift()
file.shift()
file.shift()
file = file.join('-')
sitemap.puts '<url>'
sitemap.puts ' <loc>http://bitcoin.org/en/release/'+file.gsub('.md','').gsub('.html','')+'</loc>'
sitemap.puts '</url>'
end
#Add posts
site.posts.each do |post|
sitemap.puts '<url>'