mirror of
https://github.com/seigler/dash-docs
synced 2025-07-27 01:36:13 +00:00
Upgrade to Jekyll 3.0
Gemfile: - Upgrade to Jekyll 3.x (3.0.1 tested). This brings several new features I want to use, most notably *collections* which allows us to add blog-like collections. I've converted the `_releases` and `_alerts` pages into collections, although their plugins are maintained to handle the Download and Active Alert features. - Upgrade to latest Kramdown. - Lock Less at 2.4.0. This prevents breaking our Less plugin. Jekyll 3.x provides native support for SCSS, so we may want to switch to that in time. - Lock HTML Proofer at 2.1.0. The most recent version was taking forever to check our pages (I never actually got it to complete). I'll look into it when I get more time. Makefile: - New `make clean` command. Jekyll 3.x by default attempts to do incremental rebuilds. The new `jekyll clean` command cleans up the metadata necessary for than so that a full build is performed, and this new `make clean` command is a wrapper around it so that we automatically do full rebuilds in the relevant cases. Note: our plugins aren't fully compatible with the incremental rebuilds, but I'd like to fix that in the future. - Remove WEBrick hack to enable previewing with default URL paths (/ instead of /index.html). - Filter out compliants from Rouge README.md: - Now that Alerts (_alerts) are part of a collection, the file names are no longer parsed for dates, so instructions on adding the date to the YAML metadata have been added. _alerts/*: - Now that alerts are part of a collection, the file names are no longer parsed to provide dates, so a `date:` field has been added to the YAML metadata. _config.yml: - Some variables renamed per upgrade instructions. - Switched from old default syntax highlighter Pygments to new default Rouge. I tried to use Rouge options to keep new output as similar to old output as possible to making diffing easy, but Rouge adds extra CSS class info. - Move `_alerts` and `_releases` into Jekyll 3.x "collections", which provide the organizational features we were using plugins to manange. I haven't removed the old plugins because we still use some of their features (alerts.rb provides active issue and banner features; releases.rb provides info to Download page) - _layouts/* can no longer provide default global metadata; that is now provided in the new `defaults:` section in _config.yml. _layouts/*: - Default metadata can no longer be provided in the layout files for collections, so I've removed it and left a message to see _config.yml. _plugins/*: - Remove filter_for.rb. It's completely broken on Jekyll 3.x because of changes to Liquid which prevent adding new arguments to the inherited Liquid::For class. Existing uses of filter_for have been migrated to built-in for loops prefaced by sorts. - Remove remove-html-extension.rb: at it said in the comments, this was a temporary hack to get us to Jekyll 3.0. _releases/*: - Rename all the files: prefix a v to the file name so the output html (e.g. v10.0.0.html) is the same as the source filename (e.g. v10.0.0.md). This is necessary to migrate them to a Jekyll collection. - Remove %v from titles: we have to explicitly set the title, like we used to. Again required for migration to collections. _templates/events.html & en/rss/events.rss: - Sort events by date and then loop with regular for loop rather than filter_for en/alerts.html & en/rss/alerts.rss: - Sort alerts by date and then loop with regular for loop rather than filter_for en/bitcoin-core/index.md & en/version-history.html & en/rss/releases.rss: - Sort alerts by date and then loop with regular for loop rather than filter_for
This commit is contained in:
parent
02f72f778c
commit
7d98f798ab
62 changed files with 194 additions and 247 deletions
|
@ -1,64 +0,0 @@
|
|||
# This file is licensed under the MIT License (MIT) available on
|
||||
# http://opensource.org/licenses/MIT.
|
||||
|
||||
#filter_for allows to loop in site.pages sorted and filtered
|
||||
#by custom page variables.
|
||||
|
||||
#Example:
|
||||
#{% filter_for p in site.pages sort_by:date category:release lang:{{page.lang}} %}
|
||||
# ..
|
||||
#{% endfilter_for %}
|
||||
|
||||
module Jekyll
|
||||
|
||||
module SortedForImpl
|
||||
def render(context)
|
||||
sorted_collection = collection_to_sort context
|
||||
return if sorted_collection.empty?
|
||||
sort_attr = @attributes['sort_by']
|
||||
@attributes.delete('sort_by')
|
||||
#filter page by given attributes
|
||||
s = []
|
||||
for x in sorted_collection
|
||||
catch :root do
|
||||
@attributes.each do |at,atval|
|
||||
atval = Liquid::Template.parse(atval).render context
|
||||
throw :root unless x.to_liquid.has_key?(at) and x.to_liquid[at] == atval
|
||||
end
|
||||
s.push(x)
|
||||
end
|
||||
end
|
||||
sorted_collection = s
|
||||
#sort collection by given variable
|
||||
if sorted_collection.length > 1
|
||||
sorted_collection = sorted_collection.sort_by { |i| i.to_liquid[sort_attr] }
|
||||
end
|
||||
#return modified array
|
||||
original_name = @collection_name
|
||||
result = nil
|
||||
context.stack do
|
||||
sorted_collection_name = "#{@collection_name}_sorted".sub('.', '_')
|
||||
context[sorted_collection_name] = sorted_collection
|
||||
@collection_name = sorted_collection_name
|
||||
result = super
|
||||
@collection_name = original_name
|
||||
end
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
class SortedForTag < Liquid::For
|
||||
include SortedForImpl
|
||||
|
||||
def collection_to_sort(context)
|
||||
return context[@collection_name].dup
|
||||
end
|
||||
|
||||
def end_tag
|
||||
'endfilter_for'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Liquid::Template.register_tag('filter_for', Jekyll::SortedForTag)
|
|
@ -1,31 +0,0 @@
|
|||
# This file is licensed under the MIT License (MIT) available on
|
||||
# http://opensource.org/licenses/MIT.
|
||||
|
||||
# remove-html-extensions is a temporary workaround to allow the built-in
|
||||
# Jekyll server to serve files like /foo.html as /foo
|
||||
# This functonality is already part of Jekyll 3.0.0beta and this plugin
|
||||
# can be removed when we upgrade that far
|
||||
|
||||
require 'webrick'
|
||||
include WEBrick
|
||||
|
||||
## Code starting here taken from https://github.com/jekyll/jekyll/commit/e99a9e5821a7ba16ce42a1f5de378012f22acae0 MIT license
|
||||
|
||||
# Custom WEBrick FileHandler servlet for serving "/file.html" at "/file"
|
||||
# when no exact match is found. This mirrors the behavior of GitHub Pages
|
||||
# and many static web server configs.
|
||||
class FileHandler < ::WEBrick::HTTPServlet::FileHandler
|
||||
def search_file(req, res, basename)
|
||||
if file = super
|
||||
file
|
||||
else
|
||||
super(req, res, "#{basename}.html")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
## End copied code
|
||||
|
||||
## Horribly hackish and produces a warning, but it works and avoids us
|
||||
## having to modify Jekyll on every end-user system
|
||||
WEBrick::HTTPServlet::FileHandler = FileHandler
|
Loading…
Add table
Add a link
Reference in a new issue