diff --git a/_plugins/catpage_for.rb b/_plugins/filter_for.rb similarity index 56% rename from _plugins/catpage_for.rb rename to _plugins/filter_for.rb index 4bdd7fe6..cd5de188 100644 --- a/_plugins/catpage_for.rb +++ b/_plugins/filter_for.rb @@ -1,6 +1,8 @@ -#catpage_for allows to loop in site.pages sorted by custom page -#variables and filtered by page.category. -#Example : {% catpage_for p in site.pages sort_by:date category:release %} +#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 @@ -8,17 +10,23 @@ module Jekyll sorted_collection = collection_to_sort context return if sorted_collection.empty? sort_attr = @attributes['sort_by'] - category_attr = @attributes['category'] - #filter page by given category + @attributes.delete('sort_by') + #filter page by given attributes s = [] for x in sorted_collection - if x.to_liquid.has_key?('category') && x.to_liquid['category'] == category_attr + 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 - sorted_collection = sorted_collection.sort_by { |i| i.to_liquid[sort_attr] } + 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 @@ -41,9 +49,9 @@ module Jekyll end def end_tag - 'endcatpage_for' + 'endfilter_for' end end end -Liquid::Template.register_tag('catpage_for', Jekyll::SortedForTag) +Liquid::Template.register_tag('filter_for', Jekyll::SortedForTag) diff --git a/en/alerts.html b/en/alerts.html index 30f3c242..2a57e13f 100644 --- a/en/alerts.html +++ b/en/alerts.html @@ -7,25 +7,25 @@ title: Network status and alerts - Bitcoin

Network status and alertsrss

- {% assign active = false %}{% catpage_for p in site.pages reversed sort_by:date category:alert %}{% if p.active == true %}{% assign active = true %}{% endif %}{% endcatpage_for %} + {% assign active = false %}{% filter_for p in site.pages reversed sort_by:date category:alert %}{% if p.active == true %}{% assign active = true %}{% endif %}{% endfilter_for %} {% if active == false %}
There is no ongoing event on the Bitcoin network.
{% else %}
The following network event is ongoing.
{% endif %}

See the complete CVE list.

diff --git a/en/rss/alerts.rss b/en/rss/alerts.rss index 24f54f7e..42351ef0 100644 --- a/en/rss/alerts.rss +++ b/en/rss/alerts.rss @@ -10,12 +10,12 @@ http://bitcoin.org/img/logo_rss.png http://bitcoin.org/en/alerts - {% catpage_for p in site.pages reversed sort_by:date category:alert %} + {% filter_for p in site.pages reversed sort_by:date category:alert %} {{ p.title }} http://bitcoin.org{{ p.url | replace:'.html','' }} {{ p.date | date: "%a, %d %b %Y" }} - {% endcatpage_for %} + {% endfilter_for %} diff --git a/en/rss/releases.rss b/en/rss/releases.rss index 6595060c..d6c67a3e 100644 --- a/en/rss/releases.rss +++ b/en/rss/releases.rss @@ -10,12 +10,12 @@ http://bitcoin.org/img/logo_rss.png http://bitcoin.org/en/version-history - {% catpage_for p in site.pages reversed sort_by:date category:release %} + {% filter_for p in site.pages reversed sort_by:date category:release %} {{ p.title }} http://bitcoin.org{{ p.url | replace:'.html','' }} {{ p.date | date: "%a, %d %b %Y" }} - {% endcatpage_for %} + {% endfilter_for %} diff --git a/en/version-history.html b/en/version-history.html index 5915b711..d9761118 100644 --- a/en/version-history.html +++ b/en/version-history.html @@ -8,10 +8,10 @@ title: Bitcoin-Qt version history

Bitcoin-Qt version historyrss