Skip to content

Commit

Permalink
Make bootstrap2 compatible with the new theming.
Browse files Browse the repository at this point in the history
Signed-off-by: Chris “Kwpolska” Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Mar 23, 2014
1 parent 8b79c71 commit 538fb0e
Show file tree
Hide file tree
Showing 23 changed files with 420 additions and 101 deletions.
2 changes: 1 addition & 1 deletion nikola/data/themes/base-jinja/templates/gallery.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
{% endfor %}
</ul>
{% endif %}
{% if enable_comments %}
{% if site_has_comments and enable_comments %}
{{ comments.comment_form(None, permalink, title) }}
{% endif %}
{% endblock %}
2 changes: 1 addition & 1 deletion nikola/data/themes/base-jinja/templates/index.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div class="metadata">
<p class="byline author vcard"><span class="byline-name fn">{{ post.author() }}</span></p>
<p class="dateline"><a href="{{ post.permalink() }}" rel="bookmark"><time class="published dt-published" datetime="{{ post.date.isoformat() }}" itemprop="datePublished" title="{{ messages("Publication date") }}">{{ post.formatted_date(date_format) }}</time></a></p>
{% if not post.meta('nocomments') %}
{% if not post.meta('nocomments') and site_has_comments %}
<p class="commentline">{{ comments.comment_link(post.permalink(), post._base_path) }}
{% endif %}
</div>
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/themes/base-jinja/templates/post.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{{ helper.html_pager(post) }}
</nav>
</aside>
{% if not post.meta('nocomments') %}
{% if not post.meta('nocomments') and site_has_comments %}
<section class="comments">
<h2>{{ messages("Comments") }}</h2>
{{ comments.comment_form(post.permalink(absolute=True), post.title(), post._base_path) }}
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/themes/base-jinja/templates/post_header.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div class="metadata">
<p class="byline author vcard"><span class="byline-name fn">{{ post.author() }}</span></p>
<p class="dateline"><a href="{{ post.permalink() }}" rel="bookmark"><time class="published dt-published" datetime="{{ post.date.isoformat() }}" itemprop="datePublished" title="{{ messages("Publication date") }}">{{ post.formatted_date(date_format) }}</time></a></p>
{% if not post.meta('nocomments') %}
{% if not post.meta('nocomments') and site_has_comments %}
<p class="commentline">{{ comments.comment_link(post.permalink(), post._base_path) }}
{% endif %}
{{ html_sourcelink() }}
Expand Down
2 changes: 1 addition & 1 deletion nikola/data/themes/base-jinja/templates/story.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div itemprop="articleBody text">
{{ post.text() }}
</div>
{% if enable_comments and not post.meta('nocomments') %}
{% 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) }}
Expand Down
23 changes: 9 additions & 14 deletions nikola/data/themes/bootstrap-jinja/templates/base.tmpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{# -*- coding: utf-8 -*- #}
{% import 'base_helper.tmpl' as base with context %}
{% import 'bootstrap_helper.tmpl' as bootstrap with context %}
{% import 'annotation_helper.tmpl' as notes with context %}
{{ set_locale(lang) }}

{{ base.html_headstart() }}
{% block extra_head %}
{# Leave this block alone. #}
{% endblock %}

<body>


<!-- Menubar -->

<div class="navbar navbar-fixed-top" id="navbar">
Expand All @@ -26,7 +29,7 @@
<!-- Everything you want hidden at 940px or less, place within here -->
<div class="nav-collapse collapse">
<ul class="nav">
{{ bootstrap.html_navigation_links() }}
{{ base.html_navigation_links() }}
</ul>
{% if search_form %}
{{ search_form }}
Expand Down Expand Up @@ -59,22 +62,14 @@
<div class="footerbox">
{{ content_footer }}
</div>
{{ bootstrap.late_load_js() }}
{{ base.html_social() }}
<script>jQuery("a.image-reference").colorbox({rel:"gal",maxWidth:"100%",maxHeight:"100%",scalePhotos:true});
$(window).on('hashchange', function(){
if (location.hash && $(location.hash)[0]) {
$('body').animate({scrollTop: $(location.hash).offset().top - $('#navbar').outerHeight(true)*1.2 }, 1);
}
});
$(document).ready(function(){$(window).trigger('hashchange')});
</script>
{{ base.late_load_js() }}
<script>jQuery("a.image-reference").colorbox({rel:"gal",maxWidth:"100%",maxHeight:"100%",scalePhotos:true});</script>
{% block extra_js %}{% endblock %}
{% if annotations and post and not post.meta('noannotations') %}
{{ notes.code() }}
{% elif not annotations and post and post.meta('annotations') %}
{{ notes.code() }}
{% endif %}
{{ body_end }}
{{ body_end }}
</body>
</html>
154 changes: 154 additions & 0 deletions nikola/data/themes/bootstrap-jinja/templates/base_helper.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
{# -*- coding: utf-8 -*- #}

{% macro html_headstart() %}
<!DOCTYPE html>
<html

{% if use_open_graph or (twitter_card and twitter_card['use_twitter_cards']) or (comment_system == 'facebook') %}
prefix='
{% if use_open_graph or (twitter_card and twitter_card['use_twitter_cards']) %}
og: http://ogp.me/ns#
{% endif %}
{% if use_open_graph %}
article: http://ogp.me/ns/article#
{% endif %}
{% if comment_system == 'facebook' %}
fb: http://ogp.me/ns/fb#
{% endif %}
'
{% endif %}

lang="{{ lang }}">
<head>
<meta charset="utf-8">
{% if description %}
<meta name="description" content="{{ description }}">
{% endif %}
<meta name="viewport" content="width=device-width">
<title>{{ title|e }} | {{ blog_title|e }}</title>

{{ html_stylesheets() }}
{{ html_feedlinks() }}
{% if permalink %}
<link rel="canonical" href="{{ abs_link(permalink) }}">
{% endif %}

{% if favicons %}
{% for name, file, size in favicons %}
<link rel="{{ name }}" href="{{ file }}" sizes="{{ size }}"/>
{% endfor %}
{% endif %}

{% if comment_system == 'facebook' %}
<meta property="fb:app_id" content="{{ comment_system_id }}">
{% endif %}

{{ mathjax_config }}
{% if use_cdn %}
<!--[if lt IE 9]><script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
{% else %}
<!--[if lt IE 9]><script src="/assets/js/html5.js"></script><![endif]-->
{% endif %}

{{ extra_head_data }}
{% endmacro %}


{% macro late_load_js() %}
{% if use_bundles %}
{% if use_cdn %}
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/js/bootstrap.min.js"></script>
<script src="/assets/js/all.js"></script>
{% else %}
<script src="/assets/js/all-nocdn.js"></script>
{% endif %}
{% else %}
{% if use_cdn %}
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/js/bootstrap.min.js"></script>
{% else %}
<script src="/assets/js/jquery-1.10.2.min.js"></script>
<script src="/assets/js/bootstrap.min.js"></script>
{% endif %}
<script src="/assets/js/jquery.colorbox-min.js"></script>
{% endif %}
{{ social_buttons_code }}
{% endmacro %}


{% macro html_stylesheets() %}
{% if use_bundles %}
{% if use_cdn %}
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/css/bootstrap-combined.min.css" rel="stylesheet">
<link href="/assets/css/all.css" rel="stylesheet" type="text/css">
{% else %}
<link href="/assets/css/all-nocdn.css" rel="stylesheet" type="text/css">
{% endif %}
{% else %}
{% if use_cdn %}
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/css/bootstrap-combined.min.css" rel="stylesheet">
{% else %}
<link href="/assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="/assets/css/bootstrap-responsive.min.css" rel="stylesheet" type="text/css">
{% endif %}
<link href="/assets/css/rst.css" rel="stylesheet" type="text/css">
<link href="/assets/css/code.css" rel="stylesheet" type="text/css">
<link href="/assets/css/colorbox.css" rel="stylesheet" type="text/css">
<link href="/assets/css/theme.css" rel="stylesheet" type="text/css">
{% if has_custom_css %}
<link href="/assets/css/custom.css" rel="stylesheet" type="text/css">
{% endif %}
{% endif %}
{% if annotations and post and not post.meta('noannotations') %}
{{ notes.css() }}
{% elif not annotations and post and post.meta('annotations') %}
{{ notes.css() }}
{% endif %}
{% endmacro %}


{% macro html_navigation_links() %}
{% for url, text in navigation_links[lang] %}
{% if url is mapping %}
<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ text }}<b class="caret"></b></a>
<ul class="dropdown-menu">
{% for suburl, text in url %}
{% if rel_link(permalink, suburl) == "#" %}
<li class="active"><a href="{{ permalink }}">{{ text }}</a>
{% else %}
<li><a href="{{ suburl }}">{{ text }}</a>
{% endif %}
{% endfor %}
</ul>
{% else %}
{% if rel_link(permalink, url) == "#" %}
<li class="active"><a href="{{ permalink }}">{{ text }}</a>
{% else %}
<li><a href="{{ url }}">{{ text }}</a>
{% endif %}
{% endif %}
{% endfor %}
{% endmacro %}

{% macro html_feedlinks() %}
{% if rss_link %}
{{ rss_link }}
{% else %}
{% if translations|length > 1 %}
{% for language in translations %}
<link rel="alternate" type="application/rss+xml" title="RSS ({{ language }})" href="{{ _link('rss', None, language) }}">
{% endfor %}
{% else %}
<link rel="alternate" type="application/rss+xml" title="RSS" href="{{ _link('rss', None) }}">
{% endif %}
{% endif %}
{% endmacro %}

{% macro html_translations() %}
{% for langname in translations.keys() %}
{% if langname != lang %}
<li><a href="{{ _link("index", None, langname) }}" rel="alternate" hreflang="{{ langname }}">{{ messages("LANGUAGE", langname) }}</a></li>
{% endif %}
{% endfor %}
{% endmacro %}
31 changes: 15 additions & 16 deletions nikola/data/themes/bootstrap-jinja/templates/gallery.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,29 @@
{% if folders %}
<ul>
{% for folder, ftitle in folders %}
<li><a href="{{ folder }}"><i
class="icon-folder-open"></i>&nbsp;{{ ftitle }}</a></li>
<li><a href="{{ folder }}"><i class="icon-folder-open"></i>&nbsp;{{ ftitle }}</a></li>
{% endfor %}
</ul>
{% endif %}

<div id="gallery_container"></div>
{% if photo_array %}
<noscript>
<ul class="thumbnails">
{% for image in photo_array %}
<li><a href="{{ image['url'] }}" class="thumbnail image-reference" title="{{ image['title'] }}">
<img src="{{ image['url_thumb'] }}" alt="{{ image['title'] }}" /></a>
{% endfor %}
</ul>
</noscript>
{% endif %}
{% if enable_comments %}
{{ comments.comment_form(None, permalink, title) }}
<div id="gallery_container"></div>
{% if photo_array %}
<noscript>
<ul class="thumbnails">
{% for image in photo_array %}
<li><a href="{{ image['url'] }}" class="thumbnail image-reference" title="{{ image['title'] }}">
<img src="{{ image['url_thumb'] }}" alt="{{ image['title'] }}" /></a>
{% endfor %}
</ul>
</noscript>
{% endif %}
{% if site_has_comments and enable_comments %}
{{ comments.comment_form(None, permalink, title) }}
{% endif %}
{% endblock %}


{% block extra_head %}
{{ super() }}
<style type="text/css">
.image-block {
display: inline-block;
Expand Down
20 changes: 20 additions & 0 deletions nikola/data/themes/bootstrap-jinja/templates/listing.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{# -*- coding: utf-8 -*- #}
{% extends 'base.tmpl' %}
{% import 'crumbs.tmpl' as ui with context %}

{% block content %}
{{ ui.bar(crumbs) }}
{% if folders or files %}
<ul class="list-unstyled">
{% for name in folders %}
<li><a href="{{ name }}"><i class="icon-folder-open"></i> {{ name }}</a>
{% endfor %}
{% for name in files %}
<li><a href="{{ name }}.html"><i class="icon-file"></i> {{ name }}</a>
{% endfor %}
</ul>
{% endif %}
{% if code %}
{{ code }}
{% endif %}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{{ helper.html_pager(post) }}
</nav>
</aside>
{% if not post.meta('nocomments') %}
{% if not post.meta('nocomments') and site_has_comments %}
<section class="comments">
<h2>{{ messages("Comments") }}</h2>
{{ comments.comment_form(post.permalink(absolute=True), post.title(), post._base_path) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div class="metadata">
<p class="byline author vcard"><span class="byline-name fn">{{ post.author() }}</span></p>
<p class="dateline"><a href="{{ post.permalink() }}" rel="bookmark"><time class="published dt-published" datetime="{{ post.date.isoformat() }}" itemprop="datePublished" title="{{ messages("Publication date") }}">{{ post.formatted_date(date_format) }}</time></a></p>
{% if not post.meta('nocomments') %}
{% if not post.meta('nocomments') and site_has_comments %}
<p class="commentline">{{ comments.comment_link(post.permalink(), post._base_path) }}
{% endif %}
{% if post.meta('link') %}
Expand Down
6 changes: 4 additions & 2 deletions nikola/data/themes/bootstrap-jinja/templates/slides.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% block content %}
<div id="{{ carousel_id }}" class="carousel slide">
<ol class="carousel-indicators">
{% for i in range(content|length) %}
{% for i in range(slides_content|length) %}
{% if i == 0 %}
<li data-target="#{{ carousel_id }}" data-slide-to="{{ i }}" class="active"></li>
{% else %}
Expand All @@ -9,7 +10,7 @@
{% endfor %}
</ol>
<div class="carousel-inner">
{% for i, image in enumerate(content) %}
{% for i, image in enumerate(slides_content) %}
{% if i == 0 %}
<div class="item active"><img src="{{ image }}" alt="" style="margin: 0 auto 0 auto;"></div>
{% else %}
Expand All @@ -20,3 +21,4 @@
<a class="left carousel-control" href="#{{ carousel_id }}" data-slide="prev">&lsaquo;</a>
<a class="right carousel-control" href="#{{ carousel_id }}" data-slide="next">&rsaquo;</a>
</div>
{% endblock %}
Loading

0 comments on commit 538fb0e

Please sign in to comment.