Update to nanoc4.

Signed-off-by: Thomas Hochstein <thh@inter.net>
This commit is contained in:
Thomas Hochstein 2017-08-12 23:08:27 +02:00
parent f5aabcf276
commit 1746660596
3 changed files with 8 additions and 5 deletions

View file

@ -1,14 +1,14 @@
# nanoc extensions
*[nanoc](http://nanoc.ws/)* is a popular *static site generator*.
*[Nanoc](http://nanoc.ws/)* is a popular *static site generator*.
I'll add some little extensions for *nanoc* (v3) here.
I'll add some little extensions for *Nanoc* here.
## filters
### abbreviations.rb
Simple *nanoc* filter to add `<abbr>` tags.
Simple *Nanoc* filter to add `<abbr>` tags.
After reading a YAML document from `/content/_data/abbreviations.yam`,
all occurences of each $abbrev are replaced by a
@ -37,7 +37,7 @@ from being rendered and compiled, i.e. like this:
### dejure.rb
*nanoc* filter implementation of the *dejure.org*
*Nanoc* filter implementation of the *dejure.org*
[legal integration service](https://dejure.org/vernetzung.html).
filter :dejure,

View file

@ -5,6 +5,7 @@
### Version 1.2 (unreleased)
* Create links with `https` protocol.
* Nanoc 4.x compatibility
### Version 1.1 (2017-05-27)

View file

@ -46,11 +46,13 @@ module Nanoc::Filters
CACHEDIR = 'tmp/dejure-org'
CACHEDAYS = 7
def run(input, params={})
def run(input, filterparams={})
# return input if there's nothing to replace
return input if !(/§|&sect;|Art\.|\/[0-9][0-9](?![0-9\/])| [0-9][0-9]?[\/\.][0-9][0-9](?![0-9\.])|[0-9][0-9], / =~ input)
# return input if it contains '<!-- no-dejure -->'
return input if (/<!-- ?no-?dejure ?-->/ =~ input)
# copy params (which are now immutable)
params = filterparams.dup
# set cache validity in days from params or set a default
cache_days = params.delete(:cache_days)
cache_days = CACHEDAYS if cache_days.nil?