Restructured partials

This commit is contained in:
squidfunk 2017-01-13 00:31:37 +01:00
parent f850641437
commit 364309d47a
18 changed files with 86 additions and 130 deletions

View File

@ -98,16 +98,14 @@ The directory layout of the Material theme is as follows:
│ ├─ javascripts/ # JavaScript │ ├─ javascripts/ # JavaScript
│ └─ stylesheets/ # Stylesheets │ └─ stylesheets/ # Stylesheets
├─ partials/ ├─ partials/
│ ├─ fonts.html # Webfont definitions
│ ├─ footer.html # Footer bar │ ├─ footer.html # Footer bar
│ ├─ header.html # Header bar │ ├─ header.html # Header bar
│ ├─ i18n.html # Localized labels │ ├─ language.html # Localized labels
│ ├─ nav-item.html # Main navigation item │ ├─ nav-item.html # Main navigation item
│ ├─ nav.html # Main navigation │ ├─ nav.html # Main navigation
│ ├─ search.html # Search box │ ├─ search.html # Search box
│ ├─ social.html # Social links │ ├─ social.html # Social links
│ ├─ source.html # Repository information │ ├─ source.html # Repository information
│ ├─ svgs.html # Inline SVG definitions
│ ├─ toc-item.html # Table of contents item │ ├─ toc-item.html # Table of contents item
│ └─ toc.html # Table of contents │ └─ toc.html # Table of contents
├─ 404.html # 404 error page ├─ 404.html # 404 error page

View File

@ -281,8 +281,8 @@ google_analytics:
### Localization <small>L10N</small> ### Localization <small>L10N</small>
In order to localize the labels (e.g. *Previous* and *Next* in the footer), In order to localize the labels (e.g. *Previous* and *Next* in the footer),
you can override the file `partials/i18n.html` to provide your own translations you can override the file `partials/language.html` to provide your own
inside the macro `t`: translations inside the macro `t`:
``` jinja ``` jinja
{% macro t(key) %}{{ { {% macro t(key) %}{{ {

View File

@ -1,4 +1,4 @@
{% import "partials/i18n.html" as i18n %} {% import "partials/language.html" as lang %}
<!DOCTYPE html> <!DOCTYPE html>
<html class="no-js"> <html class="no-js">
<head> <head>
@ -34,7 +34,15 @@
<script src="{{ base_url }}/assets/javascripts/modernizr-facb31f4a3.js"></script> <script src="{{ base_url }}/assets/javascripts/modernizr-facb31f4a3.js"></script>
{% endblock %} {% endblock %}
{% block fonts %} {% block fonts %}
{% include "partials/fonts.html" %} {% if config.extra.font != "none" %}
{% set text = config.extra.get("font", {}).text | default("Roboto") %}
{% set code = config.extra.get("font", {}).code
| default("Roboto Mono") %}
{% set font = text + ':300,400,400i,700|' + code | replace(' ', '+') %}
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family={{ font }}">
<style>body,input{font-family:"{{ text }}","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"{{ code }}","Courier New",Courier,monospace}</style>
{% endif %}
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
{% endblock %} {% endblock %}
{% block styles %} {% block styles %}
<link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-ff220fd69d.css"> <link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-ff220fd69d.css">
@ -55,7 +63,18 @@
{% else %} {% else %}
<body> <body>
{% endif %} {% endif %}
{% include "partials/svgs.html" %} <svg class="md-svg">
<defs>
{% set platform = config.extra.repo_icon or config.repo_url %}
{% if "github" in platform %}
{% include "assets/images/icons/github-1da075986e.svg" %}
{% elif "gitlab" in platform %}
{% include "assets/images/icons/gitlab-5ad3f9f9e5.svg" %}
{% elif "bitbucket" in platform %}
{% include "assets/images/icons/bitbucket-670608a71a.svg" %}
{% endif %}
</defs>
</svg>
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="drawer"> <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="drawer">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="search"> <input class="md-toggle" data-md-toggle="search" type="checkbox" id="search">
<label class="md-overlay" data-md-component="overlay" for="drawer"></label> <label class="md-overlay" data-md-component="overlay" for="drawer"></label>
@ -88,7 +107,7 @@
<div class="md-content"> <div class="md-content">
<article class="md-content__inner md-typeset"> <article class="md-content__inner md-typeset">
{% if config.edit_uri %} {% if config.edit_uri %}
<a href="{{ page.edit_url }}" title="{{ i18n.t('edit.link.title') }}" class="md-icon md-content__edit">edit</a> <a href="{{ page.edit_url }}" title="{{ lang.t('edit.link.title') }}" class="md-icon md-content__edit">edit</a>
{% endif %} {% endif %}
{% block content %} {% block content %}
{% if not "\x3ch1 id=" in page.content %} {% if not "\x3ch1 id=" in page.content %}

View File

@ -1,8 +0,0 @@
{% if config.extra.font != "none" %}
{% set text = config.extra.get("font", {}).text | default("Roboto") %}
{% set code = config.extra.get("font", {}).code | default("Roboto Mono") %}
{% set font = text + ':300,400,400i,700|' + code | replace(' ', '+') %}
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family={{ font }}">
<style>body,input{font-family:"{{ text }}","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"{{ code }}","Courier New",Courier,monospace}</style>
{% endif %}
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">

View File

@ -1,4 +1,4 @@
{% import "partials/i18n.html" as i18n %} {% import "partials/language.html" as lang %}
<footer class="md-footer"> <footer class="md-footer">
{% if page.previous_page or page.next_page %} {% if page.previous_page or page.next_page %}
<div class="md-footer-nav"> <div class="md-footer-nav">
@ -11,7 +11,7 @@
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title"> <div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
<span class="md-flex__ellipsis"> <span class="md-flex__ellipsis">
<span class="md-footer-nav__direction"> <span class="md-footer-nav__direction">
{{ i18n.t('footer.previous') }} {{ lang.t('footer.previous') }}
</span> </span>
{{ page.previous_page.title }} {{ page.previous_page.title }}
</span> </span>
@ -23,7 +23,7 @@
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title"> <div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
<span class="md-flex__ellipsis"> <span class="md-flex__ellipsis">
<span class="md-footer-nav__direction"> <span class="md-footer-nav__direction">
{{ i18n.t('footer.next') }} {{ lang.t('footer.next') }}
</span> </span>
{{ page.next_page.title }} {{ page.next_page.title }}
</span> </span>

View File

@ -1,9 +1,9 @@
{% import "partials/i18n.html" as i18n %} {% import "partials/language.html" as lang %}
<div class="md-search" data-md-component="search"> <div class="md-search" data-md-component="search">
<div class="md-search__overlay"></div> <div class="md-search__overlay"></div>
<div class="md-search__inner"> <div class="md-search__inner">
<form class="md-search__form" name="search"> <form class="md-search__form" name="search">
<input type="text" class="md-search__input" name="query" placeholder="{{ i18n.t('search.placeholder') }}" accesskey="s" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false"> <input type="text" class="md-search__input" name="query" placeholder="{{ lang.t('search.placeholder') }}" accesskey="s" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false">
<label class="md-icon md-search__icon" for="search"></label> <label class="md-icon md-search__icon" for="search"></label>
</form> </form>
<div class="md-search__output"> <div class="md-search__output">

View File

@ -1,4 +1,4 @@
{% import "partials/i18n.html" as i18n %} {% import "partials/language.html" as lang %}
{% set platform = config.extra.repo_icon or config.repo_url %} {% set platform = config.extra.repo_icon or config.repo_url %}
{% if "github" in platform %} {% if "github" in platform %}
{% set repo_type = "github" %} {% set repo_type = "github" %}
@ -10,7 +10,7 @@
{% set repo_type = "" %} {% set repo_type = "" %}
{% endif %} {% endif %}
{% block repo %} {% block repo %}
<a href="{{ config.repo_url }}" title="{{ i18n.t('source.link.title') }}" class="md-source" data-md-source="{{ repo_type }}"> <a href="{{ config.repo_url }}" title="{{ lang.t('source.link.title') }}" class="md-source" data-md-source="{{ repo_type }}">
{% if repo_type %} {% if repo_type %}
<div class="md-source__icon"> <div class="md-source__icon">
<svg viewBox="0 0 24 24" width="24" height="24"> <svg viewBox="0 0 24 24" width="24" height="24">

View File

@ -1,10 +0,0 @@
<div class="md-svg">
{% set platform = config.extra.repo_icon or config.repo_url %}
{% if "github" in platform %}
{% include "assets/images/icons/github-1da075986e.svg" %}
{% elif "gitlab" in platform %}
{% include "assets/images/icons/gitlab-5ad3f9f9e5.svg" %}
{% elif "bitbucket" in platform %}
{% include "assets/images/icons/bitbucket-670608a71a.svg" %}
{% endif %}
</div>

View File

@ -1,11 +1,11 @@
{% import "partials/i18n.html" as i18n %} {% import "partials/language.html" as lang %}
<nav class="md-nav md-nav--secondary"> <nav class="md-nav md-nav--secondary">
{% set toc_ = page.toc %} {% set toc_ = page.toc %}
{% if "\x3ch1 id=" in page.content %} {% if "\x3ch1 id=" in page.content %}
{% set toc_ = (toc_ | first).children %} {% set toc_ = (toc_ | first).children %}
{% endif %} {% endif %}
{% if toc_ and (toc_ | first) %} {% if toc_ and (toc_ | first) %}
<label class="md-nav__title" for="toc">{{ i18n.t('toc.title') }}</label> <label class="md-nav__title" for="toc">{{ lang.t('toc.title') }}</label>
<ul class="md-nav__list" data-md-scrollfix> <ul class="md-nav__list" data-md-scrollfix>
{% for toc_item in toc_ %} {% for toc_item in toc_ %}
{% include "partials/toc-item.html" %} {% include "partials/toc-item.html" %}

View File

@ -20,7 +20,7 @@
IN THE SOFTWARE. IN THE SOFTWARE.
--> -->
{% import "partials/i18n.html" as i18n %} {% import "partials/language.html" as lang %}
<!DOCTYPE html> <!DOCTYPE html>
<html class="no-js"> <html class="no-js">
@ -77,7 +77,28 @@
<!-- Block: webfonts --> <!-- Block: webfonts -->
{% block fonts %} {% block fonts %}
{% include "partials/fonts.html" %} {% if config.extra.font != "none" %}
{% set text = config.extra.get("font", {}).text | default("Roboto") %}
{% set code = config.extra.get("font", {}).code
| default("Roboto Mono") %}
{% set font = text + ':300,400,400i,700|' + code | replace(' ', '+') %}
<link rel="stylesheet" type="text/css"
href="https://fonts.googleapis.com/css?family={{ font }}" />
<style>
body, input {
font-family: "{{ text }}", "Helvetica Neue",
Helvetica, Arial, sans-serif;
}
pre, code, kbd {
font-family: "{{ code }}", "Courier New",
Courier, monospace;
}
</style>
{% endif %}
<!-- Material icons as a default iconset -->
<link rel="stylesheet" type="text/css"
href="https://fonts.googleapis.com/icon?family=Material+Icons" />
{% endblock %} {% endblock %}
<!-- Block: stylesheets --> <!-- Block: stylesheets -->
@ -114,8 +135,24 @@
<body> <body>
{% endif %} {% endif %}
<!-- Inline SVGs --> <!-- Hidden container for inline SVGs -->
{% include "partials/svgs.html" %} <svg class="md-svg">
<defs>
<!--
Check whether the repository is hosted on one of the supported code
hosting platforms (Github, Gitlab or Bitbucket) to show icon.
-->
{% set platform = config.extra.repo_icon or config.repo_url %}
{% if "github" in platform %}
{% include "assets/images/icons/github.svg" %}
{% elif "gitlab" in platform %}
{% include "assets/images/icons/gitlab.svg" %}
{% elif "bitbucket" in platform %}
{% include "assets/images/icons/bitbucket.svg" %}
{% endif %}
</defs>
</svg>
<!-- State toggles --> <!-- State toggles -->
<input class="md-toggle" data-md-toggle="drawer" <input class="md-toggle" data-md-toggle="drawer"
@ -173,7 +210,7 @@
<!-- Edit button, if URL was defined --> <!-- Edit button, if URL was defined -->
{% if config.edit_uri %} {% if config.edit_uri %}
<a href="{{ page.edit_url }}" <a href="{{ page.edit_url }}"
title="{{ i18n.t('edit.link.title') }}" title="{{ lang.t('edit.link.title') }}"
class="md-icon md-content__edit">edit</a> class="md-icon md-content__edit">edit</a>
{% endif %} {% endif %}

View File

@ -1,42 +0,0 @@
<!--
Copyright (c) 2016-2017 Martin Donath <martin.donath@squidfunk.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
-->
<!-- Proportional and monospaced fonts -->
{% if config.extra.font != "none" %}
{% set text = config.extra.get("font", {}).text | default("Roboto") %}
{% set code = config.extra.get("font", {}).code | default("Roboto Mono") %}
{% set font = text + ':300,400,400i,700|' + code | replace(' ', '+') %}
<link rel="stylesheet" type="text/css"
href="https://fonts.googleapis.com/css?family={{ font }}" />
<style>
body, input {
font-family: "{{ text }}", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
pre, code, kbd {
font-family: "{{ code }}", "Courier New", Courier, monospace;
}
</style>
{% endif %}
<!-- Material icons as a default iconset -->
<link rel="stylesheet" type="text/css"
href="https://fonts.googleapis.com/icon?family=Material+Icons" />

View File

@ -20,7 +20,7 @@
IN THE SOFTWARE. IN THE SOFTWARE.
--> -->
{% import "partials/i18n.html" as i18n %} {% import "partials/language.html" as lang %}
<!-- Application footer --> <!-- Application footer -->
<footer class="md-footer"> <footer class="md-footer">
@ -44,7 +44,7 @@
md-footer-nav__title"> md-footer-nav__title">
<span class="md-flex__ellipsis"> <span class="md-flex__ellipsis">
<span class="md-footer-nav__direction"> <span class="md-footer-nav__direction">
{{ i18n.t('footer.previous') }} {{ lang.t('footer.previous') }}
</span> </span>
{{ page.previous_page.title }} {{ page.previous_page.title }}
</span> </span>
@ -61,7 +61,7 @@
md-footer-nav__title"> md-footer-nav__title">
<span class="md-flex__ellipsis"> <span class="md-flex__ellipsis">
<span class="md-footer-nav__direction"> <span class="md-footer-nav__direction">
{{ i18n.t('footer.next') }} {{ lang.t('footer.next') }}
</span> </span>
{{ page.next_page.title }} {{ page.next_page.title }}
</span> </span>

View File

@ -20,7 +20,7 @@
IN THE SOFTWARE. IN THE SOFTWARE.
--> -->
{% import "partials/i18n.html" as i18n %} {% import "partials/language.html" as lang %}
<!-- Search interface --> <!-- Search interface -->
<div class="md-search" data-md-component="search"> <div class="md-search" data-md-component="search">
@ -28,7 +28,7 @@
<div class="md-search__inner"> <div class="md-search__inner">
<form class="md-search__form" name="search"> <form class="md-search__form" name="search">
<input type="text" class="md-search__input" name="query" <input type="text" class="md-search__input" name="query"
placeholder="{{ i18n.t('search.placeholder') }}" placeholder="{{ lang.t('search.placeholder') }}"
accesskey="s" autocapitalize="off" autocorrect="off" accesskey="s" autocapitalize="off" autocorrect="off"
autocomplete="off" spellcheck="false" /> autocomplete="off" spellcheck="false" />
<label class="md-icon md-search__icon" for="search"></label> <label class="md-icon md-search__icon" for="search"></label>

View File

@ -20,7 +20,7 @@
IN THE SOFTWARE. IN THE SOFTWARE.
--> -->
{% import "partials/i18n.html" as i18n %} {% import "partials/language.html" as lang %}
<!-- <!--
Check whether the repository is hosted on one of the supported code hosting Check whether the repository is hosted on one of the supported code hosting
@ -39,7 +39,7 @@
<!-- Repository containing source --> <!-- Repository containing source -->
{% block repo %} {% block repo %}
<a href="{{ config.repo_url }}" title="{{ i18n.t('source.link.title') }}" <a href="{{ config.repo_url }}" title="{{ lang.t('source.link.title') }}"
class="md-source" data-md-source="{{ repo_type }}"> class="md-source" data-md-source="{{ repo_type }}">
{% if repo_type %} {% if repo_type %}
<div class="md-source__icon"> <div class="md-source__icon">

View File

@ -1,38 +0,0 @@
<!--
Copyright (c) 2016-2017 Martin Donath <martin.donath@squidfunk.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
-->
<!-- Hidden container for inline SVGs -->
<div class="md-svg">
<!--
Check whether the repository is hosted on one of the supported code hosting
platforms (Github, Gitlab or Bitbucket) to show icon.
-->
{% set platform = config.extra.repo_icon or config.repo_url %}
{% if "github" in platform %}
{% include "assets/images/icons/github.svg" %}
{% elif "gitlab" in platform %}
{% include "assets/images/icons/gitlab.svg" %}
{% elif "bitbucket" in platform %}
{% include "assets/images/icons/bitbucket.svg" %}
{% endif %}
</div>

View File

@ -20,7 +20,7 @@
IN THE SOFTWARE. IN THE SOFTWARE.
--> -->
{% import "partials/i18n.html" as i18n %} {% import "partials/language.html" as lang %}
<!-- Table of contents --> <!-- Table of contents -->
<nav class="md-nav md-nav--secondary"> <nav class="md-nav md-nav--secondary">
@ -38,7 +38,7 @@
<!-- Render item list --> <!-- Render item list -->
{% if toc_ and (toc_ | first) %} {% if toc_ and (toc_ | first) %}
<label class="md-nav__title" for="toc">{{ i18n.t('toc.title') }}</label> <label class="md-nav__title" for="toc">{{ lang.t('toc.title') }}</label>
<ul class="md-nav__list" data-md-scrollfix> <ul class="md-nav__list" data-md-scrollfix>
{% for toc_item in toc_ %} {% for toc_item in toc_ %}
{% include "partials/toc-item.html" %} {% include "partials/toc-item.html" %}