You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
115 lines
3.6 KiB
115 lines
3.6 KiB
{% macro typeof(thing) %} |
|
{% if thing is iterable %} |
|
{% if thing is object %} |
|
dict |
|
{% else %} |
|
list |
|
{% endif %} |
|
{% else %} |
|
{% if thing is string %} |
|
str |
|
{% elif thing is number %} |
|
num |
|
{% else %} |
|
other |
|
{% endif %} |
|
{% endif %} |
|
{% endmacro typeof %} |
|
|
|
{% macro render_article_summary(page) %} |
|
<h1><a href="{{ page.permalink }}" class="stealth">{{ page.title }}</a></h1> |
|
{% set d = page.date is defined %} |
|
{% set a = page.extra.author is defined %} |
|
{% set r = page.reading_time is defined %} |
|
{% if d or a or r %} |
|
<span class="sidebyside"> |
|
<span> |
|
{% if d %}<time>{{ page.date }}</time>{% if a %}, {% endif %}{% endif %}{% if a %}by {{ page.extra.author }}{% endif %} |
|
</span> |
|
<span>{% if page.reading_time %}{{ page.reading_time }} minute read{% endif %}</span> |
|
</span> |
|
{% endif %} |
|
{% if page.summary %} |
|
{% if config.extra.summary_max_length %} |
|
{{ page.summary | safe | truncate(length=config.extra.summary_max_length) }} |
|
{% else %} |
|
{{ page.summary | safe }} |
|
{% endif %} |
|
{% endif %} |
|
{% endmacro render_article_summary %} |
|
|
|
{% macro toc(page) %} |
|
<ul class="toc"> |
|
<li> |
|
<a class="stealth" href="{{ page.permalink | safe }}#page-title">{{ page.title }}</a> |
|
</li> |
|
{% for h1 in page.toc %} |
|
<li> |
|
<a class="stealth" href="{{ h1.permalink | safe }}">{{ h1.title }}</a> |
|
{% if h1.children %} |
|
<ul> |
|
{% for h2 in h1.children %} |
|
<li> |
|
<a class="stealth" href="{{ h2.permalink | safe }}">{{ h2.title }}</a> |
|
</li> |
|
{% endfor %} |
|
</ul> |
|
{% endif %} |
|
</li> |
|
{% endfor %} |
|
</ul> |
|
{% endmacro toc %} |
|
|
|
{% macro debug(thing, label="", recurse=0) %} |
|
|
|
{% set type = self::typeof(thing=thing) | trim %} |
|
|
|
<span>{% if label %}{{ label }}: {% endif %}<em>{{ type }}</em></span> |
|
|
|
{% set rdepth = recurse - 1 %} |
|
<div class="debug"> |
|
{% if type == "dict" %} |
|
{% for k, v in thing %} |
|
{% if v is iterable and recurse %} |
|
<span>{{ k }}: {{ self::debug(thing=v, recurse=rdepth) }}</span> |
|
{% else %} |
|
<span>{{ k }}: {{ v }}</span><br> |
|
{% endif %} |
|
{% endfor %} |
|
{% elif type == "list" %} |
|
{% for v in thing %} |
|
{% if v is iterable and recurse %} |
|
<span>{{ self::debug(thing=v, recurse=rdepth) }}</span> |
|
{% else %} |
|
<span>{{ v }}</span><br> |
|
{% endif %} |
|
{% endfor %} |
|
{% else %} |
|
{{ thing }} |
|
{% endif %} |
|
</div> |
|
{% endmacro debug %} |
|
|
|
{% macro parent_tree(ancestors) %} |
|
<div class="sections"> |
|
{% for sect in ancestors %} |
|
{% set sect = get_section(path=sect) %} |
|
<span style="padding-left: {{ loop.index0 }}em;"> |
|
<a href="{{ sect.permalink }}" class="stealth"> |
|
{{ sect.title }}/ |
|
</a> |
|
</span> |
|
{% endfor %} |
|
</div> |
|
{% endmacro section_tree %} |
|
|
|
{% macro subsection_tree(subs) %} |
|
<ul> |
|
{% for sub in subs %} |
|
{% set sub = get_section(path=sub) %} |
|
<li><a href="{{ sub.permalink }}" class="stealth"> |
|
{{ sub.title }} |
|
</a></li> |
|
{% endfor %} |
|
</ul> |
|
{% endmacro subsection_tree %} |