{# NotePaper v1.5.5 http://notepaper.mayamcdougall.me https://github.com/mayamcdougall/NotePaper #} {# Metadata #} {% if meta.title and not ((is_front_page and config.NotePaper.front_page.enabled) or TwigGetUrl.search or TwigGetUrl.tag) %}{{ meta.title }} | {% endif %}{{ site_title }} {% if meta.description %}{% endif %} {% if meta.robots %}{% endif %} {# Styles #} {# Google Fonts #} {# Custom Fonts #} {% if config.NotePaper.css.fonts %} {% for url in config.NotePaper.css.fonts %} {% endfor %} {% endif %} {# Main Stylesheet #} {% if config.NotePaper.css.animations %}{% endif %} {# Custom NotePaper Themes #} {% if config.NotePaper.css.theme and not meta.theme %} {% if config.NotePaper.css.animations %}{% endif %} {% elseif meta.theme and meta.theme != "Default" %} {% if config.NotePaper.css.animations %}{% endif %} {% endif %} {# User Style Overrides #} {% if config.NotePaper.css.override %} {% endif %} {% if meta.css_override %} {% endif %} {# Modernizr #} {# Description Length #} {% if config.NotePaper.description_length %} {% set description_length = config.NotePaper.description_length %} {% else %} {% set description_length = 255 %} {% endif %} {# Open Graph #} {% if meta.title and not ((is_front_page and config.NotePaper.front_page.enabled) or TwigGetUrl.search or TwigGetUrl.tag) %}{% endif %} {% if meta.description %} {% elseif not ((is_front_page and config.NotePaper.front_page.enabled) or TwigGetUrl.search or TwigGetUrl.tag) %} {% if content|striptags|length > description_length %} {% else %} {% endif %} {% endif %} {% if config.NotePaper.og_image %}{% endif %} {# Facebook Coments Administration #} {% if config.NotePaper.comments.type == "facebook" %} {% if config.NotePaper.comments.admin_type == "user" %} {% for users in config.NotePaper.comments.admin_id %} {% endfor %} {% elseif config.NotePaper.comments.admin_type == "app" %} {% endif %} {% endif %} {# Show YAML Errors #} {% for page in pages if page.meta.YAML_ParseError %}

Header Error in {{ page.id }}, {{ page.meta.YAML_ParseError }}

{% endfor %} {# Header #}

{% if config.NotePaper.site_logo %} {{ site_title }} {% else %} {{ site_title }} {% endif %}

{# NotePaper Pages #} {% set np_pages = [] %} {% for page in pages if not page.meta.widget and not (config.NotePaper.front_page.enabled and page.id == "index") %} {% set np_pages = np_pages|merge([page]) %} {% endfor %} {# Experimental Folder Navigation - First Level Calculation #} {% if config.NotePaper.toc.folder %} {% set first_level = [] %} {% for page in np_pages if not page.meta.blog %} {% if '/' in page.id and (page.id|split('/')|first) not in first_level %} {% set first_level = first_level|merge([page.id|split('/')|first]) %} {% endif %} {% endfor %} {% endif %} {# Macros #} {# Recursive Navigation #} {% import _self as macros %} {% macro rnav(toc,is_child) %} {% import _self as macros %} {% endmacro %} {# Experimental Recursive Folder Navigation #} {% macro rfol(ToC,np_pages,sticky_num,config) %} {% import _self as macros %} {% set sticky_num = sticky_num + 1 %} {% set next_level = [] %} {% set current_level = [] %} {% for page in np_pages if not page.meta.blog and page.id starts with ToC %} {% set current_level = current_level|merge([page.id|slice(ToC|length + 1)]) %} {% endfor %} {% for page in current_level %} {% if '/' in page and (ToC ~ '/' ~ page|split('/')|first) not in next_level %} {% set next_level = next_level|merge([ToC ~ '/' ~ page|split('/')|first]) %} {% endif %} {% endfor %} {% for nToC in next_level %} {% endfor %} {% for page in np_pages if not page.meta.blog and page.id starts with ToC %} {% if next_level %} {% set pass = true %} {% for nToC in next_level %} {% if (page.id starts with nToC) %}{% set pass = false %}{% endif %} {% endfor %} {% if pass == true %}
  • {{ page.title }}
  • {% endif %} {% else %}
  • {{ page.title }}
  • {% endif %} {% endfor %} {% endmacro %} {# Widgets Sidebar #} {# Navigation #}
    {% if config.NotePaper.css.mirrorwidgets %} {% set sticky_num = 1 %} {% endif %} {% if not config.NotePaper.disable.toc %} {% endif %} {# Experimental Folder Navigation #} {% if config.NotePaper.toc.folder %} {% for ToC in first_level %} {% endfor %} {% endif %} {# Tag Data #} {% if config.NotePaper.tags.list or config.NotePaper.tags.cloud %} {% set tag_cloud = {} %} {% for page in np_pages if page.meta.tags %} {% for tag in page.meta.tags|split(',') %} {% set tag_cloud = tag_cloud|merge({(tag): (tag_cloud[tag] + 1)}) %} {% endfor %} {# Alphabetical Order #} {% if config.NotePaper.tags.sort.method == 'alphabetical' %} {% set tag_cloud_alphabetical = {} %} {% for tag in tag_cloud|keys|sort %} {% set tag_cloud_alphabetical = tag_cloud_alphabetical|merge({(tag): tag_cloud[tag] }) %} {% if loop.last %} {% if not config.NotePaper.tags.sort.reverse %} {% set tag_cloud = tag_cloud_alphabetical %} {% else %} {% set tag_cloud = tag_cloud_alphabetical|reverse %} {% endif %} {% endif %} {% endfor %} {% endif %} {# Numerical Order #} {% if config.NotePaper.tags.sort.method == 'numerical' %} {% set tag_cloud_numerical = {} %} {% for tag,total in tag_cloud|sort %} {% set tag_cloud_numerical = tag_cloud_numerical|merge({(tag): total }) %} {% if loop.last %} {% if config.NotePaper.tags.sort.reverse %} {% set tag_cloud = tag_cloud_numerical %} {% else %} {% set tag_cloud = tag_cloud_numerical|reverse %} {% endif %} {% endif %} {% endfor %} {% endif %} {% endfor %} {% endif %} {# Tag List #} {% if config.NotePaper.tags.list.enabled and tag_cloud %} {% endif %} {# Tag Cloud #} {% if config.NotePaper.tags.cloud.enabled and tag_cloud %} {# Levels Validation #} {% if config.NotePaper.tags.cloud.levels < 1 %} {% set levels = 5 %} {% else %} {% set levels = config.NotePaper.tags.cloud.levels %} {% endif %} {% if max(tag_cloud) < levels %} {% set levels = max(tag_cloud) %} {% endif %} {% set level_range = (max(tag_cloud) / levels)|round(0,'ceil') %} {# Render Tag Cloud #} {% endif %} {# Widgets #} {% for page in pages if page.meta.widget and page.meta.widget != "Disabled" %} {% endfor %}
    {# Content Rendering #} {# Pagination Math #} {% if is_front_page and (config.NotePaper.front_page.enabled or TwigGetUrl.search or TwigGetUrl.tag) %} {# Page Count #} {% set total_pages = '' %} {% for page in np_pages if (not TwigGetUrl.search or TwigGetUrl.search and (TwigGetUrl.search|lower in page.title|lower or TwigGetUrl.search|lower in page.description|lower or TwigGetUrl.search|lower in page.id|content|lower)) and (not TwigGetUrl.tag or TwigGetUrl.tag in page.meta.tags|split(',')) %} {% set total_pages = (loop.index / config.NotePaper.front_page.limit)|round(0,'ceil') %} {% endfor %} {# Out of Bounds Check #} {% if TwigGetUrl and TwigGetUrl.page not in range(2, total_pages) %} {% set TwigGetUrl = TwigGetUrl|merge({page: '0'}) %} {% endif %} {# Page Offset #} {% if TwigGetUrl.page > 0 %} {% set offset = config.NotePaper.front_page.limit * (TwigGetUrl.page - 1) %} {% else %} {% set offset = 0 %} {% endif %} {% endif %} {# Search and Tag - Number of Results #} {% if TwigGetUrl.search or TwigGetUrl.tag %} {% set numresults = '' %} {% for page in np_pages if (not TwigGetUrl.search or TwigGetUrl.search|lower in page.title|lower or TwigGetUrl.search|lower in page.description|lower or TwigGetUrl.search|lower in page.id|content|lower) and (not TwigGetUrl.tag or TwigGetUrl.tag in page.meta.tags|split(',')) %} {% set numresults = loop.index %} {% endfor %} {% endif %} {# Loop #} {% set regularpage = '' %} {% for page in np_pages if not regularpage and (not is_front_page or (not TwigGetUrl.search or TwigGetUrl.search and (TwigGetUrl.search|lower in page.title|lower or TwigGetUrl.search|lower in page.description|lower or TwigGetUrl.search|lower in page.id|content|lower)) and (not TwigGetUrl.tag or TwigGetUrl.tag in page.meta.tags|split(','))) %} {% if loop.index > offset and count < config.NotePaper.front_page.limit %} {% set count = count + 1 %} {% if not is_front_page or is_front_page and not (config.NotePaper.front_page.enabled or TwigGetUrl.search or TwigGetUrl.tag) %} {% set pagetype = 'meta' %} {% set regularpage = true %} {% else %} {% set pagetype = 'page' %} {% endif %}
    {% if loop.index > offset + 1 %}
    {% endif %} {% if not config.NotePaper.disable.header and ((_context[pagetype].date and not config.NotePaper.disable.date) or (_context[pagetype].title))%}
    {% if _context[pagetype].date and not config.NotePaper.disable.date %}

    {{ _context[pagetype].date|date("F") }}
    {{ _context[pagetype].date|date("jS") }}

    {% endif %} {% if _context[pagetype].title %}

    {{ _context[pagetype].title }}

    {% if _context[pagetype].author %}

    by: {{ _context[pagetype].author }}

    {% endif %} {% endif %}
    {% if _context[pagetype].title %}
    {% endif %} {% endif %} {% if pagetype == "page" and not TwigGetUrl.search and not TwigGetUrl.tag %} {{ page.id|content }} {% elseif is_front_page and (TwigGetUrl.search or TwigGetUrl.tag) %} {% if page.description %} {{ page.description }} {% else %} {% if page.id|content|striptags|length > description_length %} {{ page.id|content|striptags|slice(0,description_length)|split(' ',-1)|join(' ') ~ "..." }} {% else %} {{ page.id|content|striptags }} {% endif %} {% endif %} {% else %} {{ content }} {% endif %}
    {% endif %} {% endfor %} {# Bottom Links #} {% if ((config.NotePaper.bottom_links.enabled and config.NotePaper.bottom_links.enabled ~ '' != "blog") or (config.NotePaper.bottom_links.enabled ~ '' == "blog" and meta.blog)) and regularpage and not (is_front_page and config.NotePaper.disable.front_page_buttons) or is_front_page and ((config.NotePaper.front_page.enabled and TwigGetUrlEnabled and not config.NotePaper.disable.front_page_buttons) or TwigGetUrl.search or TwigGetUrl.tag) %} {% set url = "" %} {% for page in np_pages if config.NotePaper.bottom_links.enabled ~ '' != "blog" or (config.NotePaper.bottom_links.enabled ~ '' == "blog" and meta.blog and page.meta.blog) or is_front_page %} {% if loop.index == 1 %} {% set first_url = page.url %} {% elseif page.id == current_page.id %} {% set prev_url = buffer.url %} {% elseif buffer.id == current_page.id %} {% set next_url = page.url %} {% endif %} {% set last_url = page.url %} {% set buffer = {id: page.id, url: page.url} %} {% set url = { first: { url: first_url, text: config.NotePaper.bottom_links.first.text, image: config.NotePaper.bottom_links.first.image }, prev: { url: prev_url, text: config.NotePaper.bottom_links.prev.text, image: config.NotePaper.bottom_links.prev.image }, top: { url: "#", text: config.NotePaper.bottom_links.top.text, image: config.NotePaper.bottom_links.top.image }, next: { url: next_url, text: config.NotePaper.bottom_links.next.text, image: config.NotePaper.bottom_links.next.image }, last: { url: last_url, text: config.NotePaper.bottom_links.last.text, image: config.NotePaper.bottom_links.last.image }, separator: { text: config.NotePaper.bottom_links.separator.text, image: config.NotePaper.bottom_links.separator.image } } %} {% endfor %} {# Load Default Images #} {% for key,link in url if link.image == "default" %} {% set url = url|merge({(key): link|merge({image: theme_url|slice(base_url|length) ~ "/images/buttons/button_" ~ key ~ ".png"})}) %} {% endfor %} {# Front Page URLs #} {% if is_front_page and (config.NotePaper.front_page.enabled or TwigGetUrl.search or TwigGetUrl.tag) %} {# Search Query #} {% if TwigGetUrl.search %} {% set search = 'search=' ~ TwigGetUrl.search %} {% endif %} {# Tag Query #} {% if TwigGetUrl.tag %} {% set tag = 'tag=' ~ TwigGetUrl.tag %} {% endif %} {# Page Math #} {% if TwigGetUrl.page > 2 %} {% set prev_url = 'page=' ~ (TwigGetUrl.page - 1) %} {% endif %} {% if (TwigGetUrl.page + 1) < total_pages %} {% if TwigGetUrl.page < 2 %} {% set next_url = 'page=' ~ (TwigGetUrl.page + 2) %} {% else %} {% set next_url = 'page=' ~ (TwigGetUrl.page + 1) %} {% endif %} {% else %} {% set next_url = 'page=' ~ total_pages %} {% endif %} {% set last_url = 'page=' ~ total_pages %} {# Set URLs #} {% for key,link in url if key != "separator" and key != "top" %} {% if _context[key ~ '_url'] or search or tag %} {% set operand = '?' %} {% endif %} {% if _context[key ~ '_url'] and search %} {% set ampersand = '&' %} {% endif %} {% if _context[key ~ '_url'] and tag %} {% set ampersand2 = '&' %}{# Kind of awful #} {% endif %} {% set url = url|merge({(key): url[key]|merge({url: (base_url ~ operand ~ _context[key ~ '_url'] ~ ampersand ~ search ~ ampersand2 ~ tag) })}) %} {% endfor %} {% endif %} {# Search Result And Tag Math #} {% if TwigGetUrl.search or TwigGetUrl.tag %} {% if TwigGetUrl.page < 2 %} {% set firstresult = 1 %} {% set secondresult = config.NotePaper.front_page.limit %} {% else %} {% set firstresult = config.NotePaper.front_page.limit * (TwigGetUrl.page - 1)+ 1 %} {% set secondresult = config.NotePaper.front_page.limit * (TwigGetUrl.page - 1) + config.NotePaper.front_page.limit %} {% endif %} {% if secondresult > numresults %} {% set secondresult = numresults %} {% endif %} {% endif %} {# Render Bottom Links #} {% endif %}
    {# Disqus Comments #} {% if config.NotePaper.comments.type == "disqus" and (not is_front_page or config.NotePaper.comments.front) %}
    {# Facebook Comments #} {% elseif config.NotePaper.comments.type == "facebook" and (not is_front_page or config.NotePaper.comments.front) %}
    {% endif %} {# Footer #}