Skip to content

Commit

Permalink
Fix #75 -- use a jinjified book.tmpl for jinja themes
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Feb 26, 2017
1 parent 0a1d4df commit 7909257
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 3 deletions.
117 changes: 117 additions & 0 deletions site/book-jinja.tmpl
@@ -0,0 +1,117 @@
{# -*- coding: utf-8 -*- #}
{% import 'post_helper.tmpl' as helper with context %}
{% import 'post_header.tmpl' as pheader with context %}
{% import 'comments_helper.tmpl' as comments with context %}
{% extends 'post.tmpl' %}

{% block extra_head %}
{{ super() }}
<link href='https://fonts.googleapis.com/css?family=Gentium+Book+Basic' rel='stylesheet' type='text/css'>
<style>
.smallcaps {
font-variant: small-caps;
}
.chapter {
width: 100%;
padding: 10px;
-webkit-column-gap: 40px;
-moz-column-gap: 40px;
column-gap: 40px;
-webkit-column-width: 400px;
-moz-column-width: 400px;
column-width: 400px;
-webkit-column-count: 2;
-moz-column-count: 2;
column-count: 2;
-webkit-column-rule: 1px solid #ddd;
-moz-column-rule: 1px solid #ddd;
column-rule: 1px solid #ddd;
height: 90vh;
font-family: 'Gentium Book Basic', serif;
color: #2d2e2e;
font-weight: 500;
}
div.frame {
overflow: hidden;
padding: 0;
margin: 0;
}
div.scrolling-cont {
overflow-x: scroll;
padding: 0;
margin: 0;
}
h1, h2, h3, h4 {
text-align: center;
width: 100%;
font-family: 'Gentium Book Basic', serif;
font-size: 120%;
font-weight: 900;
}
h1 {
font-size: 150%;
}
.subtitle {
text-align: center;
width: 100%;
}
.bookfig {
width: 100%;
height: auto;
max-width: 100%;
max-height: 100%;
}
div.figure {
height: 88vh;
margin: 0;
}
div.topic {
margin: 0;
}
div.section > p {
text-indent: 1em;
margin-bottom: 0;
text-align: justify;
}
</style>
{% endblock %}

{% block content %}
<article class="storypage" itemscope="itemscope" itemtype="http://schema.org/Article">
<div class="frame">
<div class="scrolling-cont" id="scrolling-cont" name="scrolling-cont">
<div class="e-content entry-content chapter" itemprop="articleBody text">
<h1>{{ post.title() }}</h1>
{{ post.text() }}
</div>
</div>
</div>
</article>
{% endblock %}

{% block extra_js %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/Flowtype.js/1.1.0/flowtype.min.js"></script>
<script>
$('#scrolling-cont').flowtype({
minimum: 500,
maximum: 1200,
minFont: 20,
maxFont: 40,
fontRatio: 50
});
$(document).ready(function() {
var elem = $('#scrolling-cont');
elem.click(function(event) {
var x1 = elem.position().left;
var pw = elem.width() + 20;
var x2 = event.pageX;
if (x2 - x1 < pw / 2) {
pw = -pw;
}
elem.animate({
scrollLeft: '+=' + pw
}, 500)
});
});
</script>
{% endblock %}
2 changes: 1 addition & 1 deletion site/pages/jinja.rst
Expand Up @@ -5,6 +5,6 @@
.. post-list::
:sort: slug
:tags: theme, jinja
:tags: jinja
:post_type: pages
:template: theme_list.tmpl
2 changes: 1 addition & 1 deletion site/pages/mako.rst
Expand Up @@ -5,6 +5,6 @@
.. post-list::
:sort: slug
:tags: theme, mako
:tags: mako
:post_type: pages
:template: theme_list.tmpl
Expand Up @@ -63,12 +63,18 @@ def build_demo(theme, themes_dir, demo_source, demo_destination):
os.symlink(os.path.abspath(themes_dir), os.path.abspath("/".join([demo_source, "themes"])))

conf_path = "/".join([demo_source, "conf.py"])
book_path = "/".join([demo_source, "templates", "book.tmpl"])
# Get custom required settings from the theme
themes = utils.get_theme_chain(theme, themes_dirs=[themes_dir, 'themes'])
engine_path = utils.get_asset_path('engine', themes)
extra_conf_path = utils.get_asset_path('conf.py.sample', themes)
extra_conf = ''
if extra_conf_path:
extra_conf = io.open(extra_conf_path, 'r', encoding="utf-8").read()
if engine_path:
engine = io.open(engine_path, 'r', encoding="utf-8").read().strip()
if engine == 'jinja':
shutil.copy('book-jinja.tmpl', book_path)

with io.open(conf_path, "a", encoding="utf-8") as conf:
conf.write(u"\n\n{2}\n\nTHEME = '{0}'\n\nUSE_BUNDLES = False\n\nOUTPUT_FOLDER = '{1}'\n\nSOCIAL_BUTTONS_CODE = ''\nUSE_BASE_TAG = False\n".format(theme, demo_destination, extra_conf))
Expand Down
2 changes: 1 addition & 1 deletion site/state_data.json
@@ -1,3 +1,3 @@
{
"last_deploy": "2017-02-22T16:52:31.760687"
"last_deploy": "2017-02-26T16:36:10.155536"
}

0 comments on commit 7909257

Please sign in to comment.