Skip to content
Permalink
Browse files
Do useful stuff with new theme metadata
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed May 20, 2017
1 parent ac73f54 commit ee972e81191591b73ee42e4e2252b48cb932608f
@@ -10,3 +10,19 @@
.post-list-item h3 {
text-align: center;
}

.theme-versions-index {
text-align: center;
}

.demo-thumbnail {
width: 500px;
margin: 10px auto;
}

.demo-thumbnail-link {
font-style: italic;
padding: 10px;
margin: 0;
text-align: center;
}
@@ -180,14 +180,24 @@ def parse_theme_info(post, pkg_dir, config):
data['family'] = c.get('Family', 'family', fallback=theme)
data['family_head'] = data['family'] == theme
if data['engine'] == 'mako':
data['family_mako_variant'] = theme
data['family_jinja_variant'] = c.get('Family', 'jinja_variant', fallback=None)
data['family_mako_version'] = theme
_other = c.get('Family', 'jinja_version', fallback=None)
data['family_jinja_version'] = _other
data['show_family_data'] = bool(_other)
else:
data['family_mako_variant'] = c.get('Family', 'mako_variant', fallback=None)
data['family_jinja_variant'] = theme
data['family_jinja_version'] = theme
_other = c.get('Family', 'mako_version', fallback=None)
data['family_mako_version'] = _other
data['show_family_data'] = bool(_other)

data['family_variants'] = [i.strip() for i in c.get('Family', 'variants', fallback='').split(',')]
data['family_variants'] = [i for i in data['family_variants'] if i] # remove empty strings
_variants_count = len(data['family_variants'])
data['family_variants_text'] = '1 variant' if _variants_count == 1 else '{0} variants'.format(_variants_count)

data['show_family_data'] = data['show_family_data'] or bool(data['family_variants'])
data['bootswatch'] = c.getboolean('Nikola', 'bootswatch', fallback=False)
data['tags'] = 'theme,' + data['engine']
data['tags'] = 'newmeta,theme,' + data['engine']
data['license'] = c.get('Theme', 'license', fallback=None)
data['author'] = c.get('Theme', 'author', fallback=None)
data['author_url'] = c.get('Theme', 'author_url', fallback=None)
@@ -213,6 +223,7 @@ def parse_theme_info(post, pkg_dir, config):
if data['parent'] is None and theme != 'base':
raise ValueError("Theme {0} has no parent.".format(theme))
else:
# Old-style metadata
if os.path.exists(engine):
post.add_dependency(engine)
with io.open(engine, 'r', encoding='utf-8') as f:
@@ -234,6 +245,9 @@ def parse_theme_info(post, pkg_dir, config):
'bootstrap3' in data['chain']) and
'bootstrap3-gradients' not in data['chain'])
data['tags'] = 'theme,' + data['engine']
data['family'] = theme
data['family_head'] = True
data['family_{0}_version'.format(data['engine'])] = theme

return data

@@ -11,40 +11,69 @@
<header>
${pheader.html_title()}
<div class="metadata">
% if post.meta('author'):
% if post.meta('author_url'):
<p class="authorline author">By <a href="${post.meta('author_url')|h}">${post.meta('author')|h}</a></p>
% else:
<p class="authorline author">By ${post.meta('author')|h}</p>
% endif
% endif
% if post.meta('based_on'):
<p class="basedonline basedon">Based on ${post.meta('based_on')}</p>
% endif
% if post.meta('engine') == 'mako':
<p class="engineline engine">Uses <a href="http://www.makotemplates.org/">Mako</a></p>
% else:
<p class="engineline engine">Uses <a href="http://jinja.pocoo.org/docs/">Jinja2</a></p>
% endif
% if post.meta('license'):
<p class="licenseline license">License: ${post.meta('license')}</p>
% endif
% if post.meta('bootswatch'):
<p class="bootswatchline bootswatch">Supports <a href="https://bootswatch.com/">Bootswatch</a></p>
% endif
<p class="demoline demo"><a href="${post.meta('demo_link')}" class="btn btn-primary">See demo</a></p>
</div>
</header>
<div class="e-content entry-content" itemprop="articleBody text">
<div class="well well-sm">To install, run <code>nikola theme -i ${post.meta('slug')}</code></div>
<div><a href="${post.meta('demo_link')}"><img src="${post.meta('previewimage')}" style="width:500px; margin: 10px auto 10px auto; display: block;" class="img-thumbnail"></a></div>
<div class="thumbnail demo-thumbnail">
<a href="${post.meta('demo_link')}"><img src="${post.meta('previewimage')}" alt="Screenshot of ${post.meta('title')}" title="See demo of theme ${post.meta('title')}"><p class="demo-thumbnail-link">See demo</p></a>
</div>
${post.text()}
% if post.meta('confpy'):
<h3>Suggested Configuration:</h3>
${post.meta('confpy')}
% endif
<h3>Issues? Questions?</h3>
<p>You can report issues with this theme and request help via <a href="https://github.com/getnikola/nikola-themes/issues/new?title=[${post.meta('slug')}]">GitHub Issues</a>.</p>
% if post.meta('show_family_data'):
<h3>Related themes</h3>
<div class="metadata">
<p class="familyline family">Theme family: <a href="../${post.meta('family')}/">${post.meta('family')}</a>
</p>
% if post.meta('engine') == 'jinja' and post.meta('family_mako_version'):
<p class="engineversionline engineversion">Mako version: <a href="../${post.meta('family_mako_version')}/">${post.meta('family_mako_version')}</a></p>
% endif
% if post.meta('engine') == 'mako' and post.meta('family_jinja_version'):
<p class="engineversionline engineversion">Jinja2 version: <a href="../${post.meta('family_jinja_version')}/">${post.meta('family_jinja_version')}</a></p>
% endif
</div>
% if post.meta('family_variants'):
<p id="variants">Variants:</p>
<ul>
% for i in post.meta('family_variants'):
<li><a href="../${i}/">${i}</a></li>
% endfor
</ul>
% endif
% endif
<h3>Theme inheritance chain</h3>
<ul class="breadcrumb">
% for i in post.meta('chain'):
<li><a href="../${i}/">${i}</a></li>
% endfor
</ul>
</div>
%if site_has_comments and enable_comments and not post.meta('nocomments'):
<section class="comments">
<h2>${messages("Comments")}</h2>
${comments.comment_form(post.permalink(absolute=True), post.title(), post.base_path)}
</section>
%endif
${helper.mathjax_script(post)}
</article>
</div>
@@ -4,14 +4,27 @@
<div id="${post_list_id}" class="post-list row">
%if posts:
% for post in posts:
% if post.meta('family_head'):
<div class="col-sm-6 col-md-4">
<div class="thumbnail post-list-item">
<a href="${post.permalink(lang)}">
<img src="${post.meta('previewimage_thumbnail')}">
<h2>${post.title(lang)|h}<h2>
<h2>${post.title(lang)|h}</h2>
</a>
<div class="theme-versions-index metadata">
% if post.meta('family_mako_version'):
<p class="makoversionline"><a href="${_link('slug', post.meta('family_mako_version'), lang)}">Mako</a></p>
% endif
% if post.meta('family_jinja_version'):
<p class="jinjaversionline"><a href="${_link('slug', post.meta('family_jinja_version'), lang)}">Jinja2</a></p>
% endif
% if post.meta('family_variants'):
<p class="variantsline"><a href="${post.permalink(lang)}#variants">${post.meta('family_variants_text')}</a></p>
% endif
</div>
</div>
</div>
% endif
% endfor
</ul>
%endif

0 comments on commit ee972e8

Please sign in to comment.