Create parameterised include for shuffle panel
Also added some liquid extensions
This commit is contained in:
43
docs/_includes/custom/shuffle_panel.html
Normal file
43
docs/_includes/custom/shuffle_panel.html
Normal file
@ -0,0 +1,43 @@
|
||||
<!-- Argument summary: -->
|
||||
|
||||
<!-- tag: tag determining the pages included in the panel -->
|
||||
<!-- title: Display title of the panel -->
|
||||
<!-- description: Description of the panel -->
|
||||
<!-- image (optional) : Name of the image to use, as a css class, eg "fa-list" -->
|
||||
<!-- titlemaker (optional) : name of a variable that's evaluated to determine the displayed title of the page. Default is page.title -->
|
||||
|
||||
|
||||
{% capture titlemaker %} {{ include.titlemaker | or_else: "page.title" }} {% endcapture %}
|
||||
|
||||
|
||||
<div class="col-xs-6 col-sm-4 col-md-4" data-groups='["{{ include.tag }}"]'>
|
||||
<div class="panel panel-default">
|
||||
|
||||
|
||||
{% if include.image != "" and include.image != nil %}
|
||||
<div class="panel-heading text-center">
|
||||
<span class="fa-stack fa-5x">
|
||||
<i class="fa fa-circle fa-stack-2x text-secondary"></i>
|
||||
<i class="fa {{ include.image }} fa-stack-1x fa-inverse"></i>
|
||||
</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="panel-heading text-center">{{ include.title }}</div>
|
||||
<div class="panel-body">
|
||||
|
||||
<p class="landing-page cat-description">
|
||||
{{ include.description }}
|
||||
</p>
|
||||
<ul>
|
||||
{% for page in site.pages %}
|
||||
{% for tag in page.tags %}
|
||||
{% if tag == include.tag %}
|
||||
<li><a href="{{page.url | remove: '/'}}">{% eval titlemaker %}</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
5
docs/_includes/custom/shuffle_panel_filler.html
Normal file
5
docs/_includes/custom/shuffle_panel_filler.html
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
<div class="col-xs-6 col-sm-4 col-md-4 shuffle-panel-filler">
|
||||
|
||||
|
||||
</div>
|
13
docs/_plugins/custom_filters.rb
Normal file
13
docs/_plugins/custom_filters.rb
Normal file
@ -0,0 +1,13 @@
|
||||
module CustomFilters
|
||||
# returns the input if it's a non-blank string, otherwise return default value
|
||||
def or_else(input, default)
|
||||
if input
|
||||
input.strip != "" ? input : default
|
||||
else
|
||||
default
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Liquid::Template.register_filter(CustomFilters)
|
33
docs/_plugins/eval_tag.rb
Normal file
33
docs/_plugins/eval_tag.rb
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
# This tag takes a variable name as an input, and evaluates its value twice
|
||||
# (follows one indirection)
|
||||
# E.g. if the symbol table is E = {"foo" => "bar", "bar" => "baz"},
|
||||
# then {% eval foo %} ~> E[E["foo"]] ~> E["bar"] ~> "baz"
|
||||
|
||||
class EvalTag < Liquid::Tag
|
||||
|
||||
def initialize(tag_name, name_expression, tokens)
|
||||
super
|
||||
@name_expression = name_expression.strip
|
||||
end
|
||||
|
||||
|
||||
# Lookup allows access to the page/post variables through the tag context
|
||||
def lookup(context, name)
|
||||
lookup = context
|
||||
name.split(".").each {|value|
|
||||
lookup = lookup[value]
|
||||
}
|
||||
lookup
|
||||
end
|
||||
|
||||
def render(context)
|
||||
# puts "evaluating: #{@name_expression}"
|
||||
# puts "1: #{lookup(context, @name_expression)}"
|
||||
# puts "2: #{lookup(context, lookup(context, @name_expression).strip)}"
|
||||
lookup(context, lookup(context, @name_expression).strip)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Liquid::Template.register_tag('eval', EvalTag)
|
@ -9,5 +9,5 @@
|
||||
}
|
||||
|
||||
.landing-page.cat-description {
|
||||
margin-bottom: .5cm;
|
||||
margin-top: .4cm;
|
||||
}
|
@ -89,35 +89,22 @@ First time user? Then you may be interested in our [quickstart page](TODO).
|
||||
# More details
|
||||
|
||||
|
||||
<div id="grid" class="row">
|
||||
<div class="col-xs-6 col-sm-4 col-md-4" data-groups='["rule_references"]'>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading text-center">
|
||||
<span class="fa-stack fa-5x">
|
||||
<i class="fa fa-circle fa-stack-2x text-primary"></i>
|
||||
<i class="fa fa-list fa-stack-1x fa-inverse"></i>
|
||||
</span>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="text-center landing-page cat-title">
|
||||
<h4>Rule references</h4>
|
||||
</div>
|
||||
<p class="landing-page cat-description">
|
||||
Pick your language to find out about the rule it supports.
|
||||
</p>
|
||||
<ul>
|
||||
{% for page in site.pages %}
|
||||
{% for tag in page.tags %}
|
||||
{% if tag == "rule_references" %}
|
||||
<li><a href="{{page.url | remove: '/'}}">{{page.language_name}}</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% include custom/shuffle_panel.html
|
||||
tag="getting_started"
|
||||
title="Getting started" %}
|
||||
|
||||
|
||||
{% include custom/shuffle_panel.html
|
||||
tag="rule_references"
|
||||
title="Rule references"
|
||||
description="Pick your language to find out about the rule it supports:"
|
||||
image="fa-database"
|
||||
titlemaker="page.language_name" %}
|
||||
|
||||
{% include custom/shuffle_panel_filler.html %}
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- {% include image.html file="pmd-logo-big.png" alt="PMD Logo" %} -->
|
||||
|
||||
|
Reference in New Issue
Block a user