Source

tinkerer / tinkerer / themes / tinkerbase / layout.html

Full commit
{#
    tinkerbase/layout.html
    ~~~~~~~~~~~~~~~~~~~~~~

    Master layout template for Tinkerer blog themes.

    :copyright: Copyright 2011-2012 by Vlad Riscutia and contributors (see
    CONTRIBUTORS file)
     :license: FreeBSD, see LICENSE file
#}

{% extends "basic/layout.html" %}

{# Prev/next nav ------------------------------------------------------------ #}

{# characters displayed before/after prev/next links #}
{%- set prevchar = prevchar is not defined and ' « ' or prevchar %}
{%- set nextchar = nextchar is not defined and ' » ' or nextchar %}

{# character displyed before and after "Blog Archive" #}
{%- set archivechar = archivechar is not defined and ' — ' or archivechar %}

{# Page nav ----------------------------------------------------------------- #}

{# page_nav before or after header (default after) #}
{%- set page_nav_first = page_nav_first is defined %}

{# RSS feed ----------------------------------------------------------------- #}

{# RSS feed link #}
{%- if rss_service %}
    {%- set rss_feed_link = rss_service %}
{%- else %}
    {%- set rss_feed_link = rss_feed_link is defined and rss_feed_link or pathto('rss/all') %}
{%- endif %}        

{# include RSS feed link in page_nav (default True) #}
{%- set rss_in_page_nav = rss_in_page_nav is not defined or rss_in_page_nav %}

{# RSS link text (default None) #}
{%- set rss_link_text = rss_link_text is not defined and None or rss_link_text %}

{# RSS symbol in link (default True) #}
{%- set rss_symbol = rss_symbol is not defined or rss_symbol %}

{# Timestamp format --------------------------------------------------------- #}

{# Timestamp format #}
{%- set timestamp_format = timestamp_format is not defined and 
    '<span class="month">%B</span> <span class="day">%d</span>, <span class="year">%Y</day>' 
    or timestamp_format %}
{%- set timestamp_short_format = timestamp_short_format is not defined and 
    '<span class="month">%b</span> <span class="day">%d</span>' or timestamp_short_format %}

{# Macros ------------------------------------------------------------------- #}

{# Blog header #}
{%- macro blog_header() %}
    <div class="header">
        <h1 class="heading">
            <a href="{{ pathto(pages[0][0]) }}">
                <span>{{ shorttitle|e }}</span>
            </a>
        </h1>
        <h2 class="tagline">{{ tagline }}</h2>
    </div>
{%- endmacro %}

{# RSS nav #}
{%- macro rss_nav() %}
    <div class="rss">
        <a href="{{ rss_feed_link }}" title="Subscribe via RSS">
            {%- if rss_symbol %}<span class="webfont">B</span>{%- endif %}
            {% if rss_link_text %}{{ rss_link_text }}{% endif %}
        </a>
    </div>
{%- endmacro %}
 
{# List of blog pages #}
{%- macro page_nav() %}
    <div class="page_nav">
        <ul>
            {% for page in pages %}
            <li>
                <a href="{{ pathto(page[0]) }}">{{ page[1] }}</a>
            </li>
            {% endfor %}
            {%- if rss_in_page_nav %}
            <li class="right">
                {{ rss_nav() }}
            </li>
            {%- endif %}
        </ul>
    </div>
    <div class="clearer"></div>
{%- endmacro %}

{# Navigation #}
{%- macro tinkerer_relbar() %}
    {%- if prev or next %}
    <div class="related">
        <ul>
            {%- if prev %}
            <li>
                {{ prevchar }}<a href="{{ prev.link|e }}">{{ prev.title }}</a>
            </li>
            {%- endif %}
            {%- if next %}
            <li class="right">
                <a href="{{ next.link|e }}">{{ next.title }}</a>{{ nextchar }}
            </li>
            {%- endif %}
        </ul>
    </div>
    {%- endif %}
{%- endmacro %}

{# Timestamp #}
{%- macro timestamp(date, fmt) %}
    {%- if date %}
        <div class="timestamp postmeta">
            <span>{{ date.strftime(fmt) }}</span> 
        </div>
    {%- endif %}
{%- endmacro %}

{# Author #}
{%- macro author(author_name) %}
    {%- if author_name %}
        <div class="author">
            <span>{{ text_posted_by }} {{ author_name }}</span>
        </div>
    {%- endif %}
{%- endmacro %}

{# Categories #}
{%- macro category_list(post_categories) %}
    {%- if post_categories %}
        <div class="categories">
            <span>
                {{ text_filed_under }}:
                {% for link, category in post_categories %}
                    <a href="{{ pathto('categories/' + link + '.html', 1) }}">{{ category }}</a>
                    {%- if not loop.last %}, {%- endif %}
                {% endfor %}
            </span>
        </div>
    {%- endif %}
{%- endmacro %}    

{# Tags #}
{%- macro tag_list(post_tags) %}
    {%- if post_tags %}
        <div class="tags">
            <span>
                {{ text_tags }}:
                {% for link, tag in post_tags %}
                    <a href="{{ pathto('tags/' + link + '.html', 1) }}">{{ tag }}</a>
                    {%- if not loop.last %}, {%- endif %}
                {% endfor %}
            </span>
        </div>
    {%- endif %}
{%- endmacro %}

{# Comment count #}
{%- macro comment_count(code) %}
    {%- if code %}
        <div class="comments">
            {{ code }}
        </div>
    {%- endif %}
{%- endmacro %}

{# Post metadata #}
{%- macro post_meta(metadata, comment_count_code=None) %}
    <div class="postmeta">
        {{ author(metadata.author) }}
        {{ category_list(metadata.filing["categories"]) }}
        {{ tag_list(metadata.filing["tags"]) }}
        {{ comment_count(comment_count_code) }}
    </div>
{%- endmacro %}

{# Blocks ------------------------------------------------------------------- #}

{%- block linktags %}
    {{ super() }}
    <link rel="alternate" type="application/rss+xml" title="RSS" href="{{ rss_feed_link }}" />
{%- endblock %}

{%- block header %}
    {%- if page_nav_first %}{{ page_nav() }}{%- endif %}
    {{ blog_header() }}
    {%- if not page_nav_first%}{{ page_nav() }}{%- endif %}
{%- endblock %}

{%- block relbar1 %}{%- endblock %}
{%- block relbar2 %}{%- endblock %}

{% block sidebar1 %}{{ sidebar() }}{% endblock %}
{% block sidebar2 %}{% endblock %}

{% block separator %}<div class="separator"></div>{% endblock %}

{%- block footer %}
    <div class="footer">
    {%- if show_copyright %}
        {% trans copyright=copyright|e %}&copy; Copyright {{ copyright }}.{% endtrans %}
    {%- endif %}
    {%- if show_sphinx %}
        Powered by <a href="http://www.tinkerer.me/">Tinkerer</a> and <a href="http://sphinx.pocoo.org/">Sphinx</a>.
    {%- endif %}

    {# Comment plug-in can initialize here #}
    {%- if comment_enabler %}{{ comment_enabler }}{%- endif %}
    </div>
{%- endblock %}