From 174666059698c2a3bac8e74b0edc64c8c275ab73 Mon Sep 17 00:00:00 2001 From: Thomas Hochstein Date: Sat, 12 Aug 2017 23:08:27 +0200 Subject: [PATCH] Update to nanoc4. Signed-off-by: Thomas Hochstein --- README.md | 8 ++++---- _doc/dejure/CHANGELOG.md | 1 + lib/filters/dejure.rb | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e323c57..cfbf864 100644 --- a/README.md +++ b/README.md @@ -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 `` tags. +Simple *Nanoc* filter to add `` 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, diff --git a/_doc/dejure/CHANGELOG.md b/_doc/dejure/CHANGELOG.md index 7ce7676..aaafbc1 100644 --- a/_doc/dejure/CHANGELOG.md +++ b/_doc/dejure/CHANGELOG.md @@ -5,6 +5,7 @@ ### Version 1.2 (unreleased) * Create links with `https` protocol. +* Nanoc 4.x compatibility ### Version 1.1 (2017-05-27) diff --git a/lib/filters/dejure.rb b/lib/filters/dejure.rb index f50956e..9d450d8 100644 --- a/lib/filters/dejure.rb +++ b/lib/filters/dejure.rb @@ -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 !(/ยง|§|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 '' return input if (// =~ 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?