Skip to content

Commit

Permalink
Restructured partials
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Jan 12, 2017
1 parent f850641 commit 364309d
Show file tree
Hide file tree
Showing 18 changed files with 86 additions and 130 deletions.
4 changes: 1 addition & 3 deletions docs/customization.md
Expand Up @@ -98,16 +98,14 @@ The directory layout of the Material theme is as follows:
│ ├─ javascripts/ # JavaScript
│ └─ stylesheets/ # Stylesheets
├─ partials/
│ ├─ fonts.html # Webfont definitions
│ ├─ footer.html # Footer bar
│ ├─ header.html # Header bar
│ ├─ i18n.html # Localized labels
│ ├─ language.html # Localized labels
│ ├─ nav-item.html # Main navigation item
│ ├─ nav.html # Main navigation
│ ├─ search.html # Search box
│ ├─ social.html # Social links
│ ├─ source.html # Repository information
│ ├─ svgs.html # Inline SVG definitions
│ ├─ toc-item.html # Table of contents item
│ └─ toc.html # Table of contents
├─ 404.html # 404 error page
Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started.md
Expand Up @@ -281,8 +281,8 @@ google_analytics:
### Localization <small>L10N</small>

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
inside the macro `t`:
you can override the file `partials/language.html` to provide your own
translations inside the macro `t`:

``` jinja
{% macro t(key) %}{{ {
Expand Down
27 changes: 23 additions & 4 deletions material/base.html
@@ -1,4 +1,4 @@
{% import "partials/i18n.html" as i18n %}
{% import "partials/language.html" as lang %}
<!DOCTYPE html>
<html class="no-js">
<head>
Expand Down Expand Up @@ -34,7 +34,15 @@
<script src="{{ base_url }}/assets/javascripts/modernizr-facb31f4a3.js"></script>
{% endblock %}
{% 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 %}
{% block styles %}
<link rel="stylesheet" href="{{ base_url }}/assets/stylesheets/application-ff220fd69d.css">
Expand All @@ -55,7 +63,18 @@
{% else %}
<body>
{% 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="search" type="checkbox" id="search">
<label class="md-overlay" data-md-component="overlay" for="drawer"></label>
Expand Down Expand Up @@ -88,7 +107,7 @@
<div class="md-content">
<article class="md-content__inner md-typeset">
{% 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 %}
{% block content %}
{% if not "\x3ch1 id=" in page.content %}
Expand Down
8 changes: 0 additions & 8 deletions material/partials/fonts.html

This file was deleted.

6 changes: 3 additions & 3 deletions material/partials/footer.html
@@ -1,4 +1,4 @@
{% import "partials/i18n.html" as i18n %}
{% import "partials/language.html" as lang %}
<footer class="md-footer">
{% if page.previous_page or page.next_page %}
<div class="md-footer-nav">
Expand All @@ -11,7 +11,7 @@
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
<span class="md-flex__ellipsis">
<span class="md-footer-nav__direction">
{{ i18n.t('footer.previous') }}
{{ lang.t('footer.previous') }}
</span>
{{ page.previous_page.title }}
</span>
Expand All @@ -23,7 +23,7 @@
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
<span class="md-flex__ellipsis">
<span class="md-footer-nav__direction">
{{ i18n.t('footer.next') }}
{{ lang.t('footer.next') }}
</span>
{{ page.next_page.title }}
</span>
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions material/partials/search.html
@@ -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__overlay"></div>
<div class="md-search__inner">
<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>
</form>
<div class="md-search__output">
Expand Down
4 changes: 2 additions & 2 deletions material/partials/source.html
@@ -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 %}
{% if "github" in platform %}
{% set repo_type = "github" %}
Expand All @@ -10,7 +10,7 @@
{% set repo_type = "" %}
{% endif %}
{% 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 %}
<div class="md-source__icon">
<svg viewBox="0 0 24 24" width="24" height="24">
Expand Down
10 changes: 0 additions & 10 deletions material/partials/svgs.html

This file was deleted.

4 changes: 2 additions & 2 deletions material/partials/toc.html
@@ -1,11 +1,11 @@
{% import "partials/i18n.html" as i18n %}
{% import "partials/language.html" as lang %}
<nav class="md-nav md-nav--secondary">
{% set toc_ = page.toc %}
{% if "\x3ch1 id=" in page.content %}
{% set toc_ = (toc_ | first).children %}
{% endif %}
{% 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>
{% for toc_item in toc_ %}
{% include "partials/toc-item.html" %}
Expand Down
47 changes: 42 additions & 5 deletions src/base.html
Expand Up @@ -20,7 +20,7 @@
IN THE SOFTWARE.
-->

{% import "partials/i18n.html" as i18n %}
{% import "partials/language.html" as lang %}

<!DOCTYPE html>
<html class="no-js">
Expand Down Expand Up @@ -77,7 +77,28 @@

<!-- Block: webfonts -->
{% 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 %}

<!-- Block: stylesheets -->
Expand Down Expand Up @@ -114,8 +135,24 @@
<body>
{% endif %}

<!-- Inline SVGs -->
{% include "partials/svgs.html" %}
<!-- Hidden container for inline SVGs -->
<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 -->
<input class="md-toggle" data-md-toggle="drawer"
Expand Down Expand Up @@ -173,7 +210,7 @@
<!-- Edit button, if URL was defined -->
{% if config.edit_uri %}
<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>
{% endif %}

Expand Down
42 changes: 0 additions & 42 deletions src/partials/fonts.html

This file was deleted.

6 changes: 3 additions & 3 deletions src/partials/footer.html
Expand Up @@ -20,7 +20,7 @@
IN THE SOFTWARE.
-->

{% import "partials/i18n.html" as i18n %}
{% import "partials/language.html" as lang %}

<!-- Application footer -->
<footer class="md-footer">
Expand All @@ -44,7 +44,7 @@
md-footer-nav__title">
<span class="md-flex__ellipsis">
<span class="md-footer-nav__direction">
{{ i18n.t('footer.previous') }}
{{ lang.t('footer.previous') }}
</span>
{{ page.previous_page.title }}
</span>
Expand All @@ -61,7 +61,7 @@
md-footer-nav__title">
<span class="md-flex__ellipsis">
<span class="md-footer-nav__direction">
{{ i18n.t('footer.next') }}
{{ lang.t('footer.next') }}
</span>
{{ page.next_page.title }}
</span>
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/partials/search.html
Expand Up @@ -20,15 +20,15 @@
IN THE SOFTWARE.
-->

{% import "partials/i18n.html" as i18n %}
{% import "partials/language.html" as lang %}

<!-- Search interface -->
<div class="md-search" data-md-component="search">
<div class="md-search__overlay"></div>
<div class="md-search__inner">
<form class="md-search__form" name="search">
<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"
autocomplete="off" spellcheck="false" />
<label class="md-icon md-search__icon" for="search"></label>
Expand Down
4 changes: 2 additions & 2 deletions src/partials/source.html
Expand Up @@ -20,7 +20,7 @@
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
Expand All @@ -39,7 +39,7 @@

<!-- Repository containing source -->
{% 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 }}">
{% if repo_type %}
<div class="md-source__icon">
Expand Down
38 changes: 0 additions & 38 deletions src/partials/svgs.html

This file was deleted.

0 comments on commit 364309d

Please sign in to comment.