Permalink
Browse files

Adding subtitle support to articles

  • Loading branch information...
1 parent 634eb12 commit dd2d40b9f11f057fbea86f37d2502d42cfeeda56 @ebidel ebidel committed Feb 21, 2013
@@ -36,7 +36,7 @@
{% if tut.type != 'tutorial' and tut.type != 'article' %}
<li data-pubdate="{{tut.publication_date}}">
<span class="date">{{tut.publication_date.month}}/{{tut.publication_date.day}}</span> <span class="author" data-author_id="{{ tut.author.key.name }}"><img src="/static/images/profiles/75/{{tut.author.key.name}}.75.png" alt="{{ tut.author.given_name }} {{ tut.author.family_name }}" title="{{ tut.author.given_name }} {{ tut.author.family_name }}"></span>
- <span class="title"><a href="{{tut.url}}">{{tut.title|safe}}</a></span>
+ <span class="title"><a href="{{tut.url}}">{{tut.title|safe}}{% if tut.subtitle %}: {{tut.subtitle|safe}}{% endif %}</a></span>
<span class="classes">
{% for tag in tut.classes %}
<span class="class {{tag}}"><span class="class_name">{{tag}}</span></span>
@@ -58,7 +58,7 @@
{% if forloop.counter0 < 10 %}
{% if r.type == 'tutorial' or r.type == 'article' %}
<li>
- <a href="{{r.url}}">{{r.title}}</a><br>
+ <a href="{{r.url}}">{{r.title}}{% if r.subtitle %}: {{r.subtitle|safe}}{% endif %}</a><br>
<span>{{r.description|safe|truncatewords:15}}</span>
</a>
</li>
@@ -37,7 +37,7 @@
{% if tut.type != 'tutorial' and tut.type != 'article' %}
<li data-pubdate="{{tut.publication_date}}">
<span class="date">{{tut.publication_date.month}}/{{tut.publication_date.day}}</span> <span class="author" data-author_id="{{ tut.author.key.name }}"><img src="/static/images/profiles/75/{{tut.author.key.name}}.75.png" alt="{{ tut.author.given_name }} {{ tut.author.family_name }}" title="{{ tut.author.given_name }} {{ tut.author.family_name }}"></span>
- <span class="title"><a href="{{tut.url}}">{{tut.title|safe}}</a></span>
+ <span class="title"><a href="{{tut.url}}">{{tut.title|safe}}{% if tut.subtitle %}: {{tut.subtitle|safe}}{% endif %}</a></span>
<span class="classes">
{% for tag in tut.classes %}
<span class="class {{tag}}"><span class="class_name">{{tag}}</span></span>
@@ -59,7 +59,7 @@
{% if forloop.counter0 < 10 %}
{% if r.type == 'tutorial' or r.type == 'article' %}
<li>
- <a href="{{r.url}}">{{r.title}}</a><br>
+ <a href="{{r.url}}">{{r.title}}{% if r.subtitle %}: {{r.subtitle|safe}}{% endif %}</a><br>
<span>{{r.description|safe|truncatewords:15}}</span>
</a>
</li>
View
@@ -46,7 +46,7 @@
{% if forloop.counter0 < 5 %}
<li data-pubdate="{{tut.publication_date}}">
<span class="date">{{tut.publication_date.month}}/{{tut.publication_date.day}}</span> <span class="author" data-author_id="{{ tut.author.key.name }}"><img src="/static/images/profiles/75/{{tut.author.key.name}}.75.png" alt="{{ tut.author.given_name }} {{ tut.author.family_name }}" title="{{ tut.author.given_name }} {{ tut.author.family_name }}" width="20" height="20"></span>
- <span class="title"><a href="{{tut.url}}">{{tut.title|safe}}</a></span>
+ <span class="title"><a href="{{tut.url}}">{{tut.title|safe}}{% if tut.subtitle %}: {{tut.subtitle|safe}}{% endif %}</a></span>
<span class="classes">
{% for tag in tut.classes %}
<span class="class {{tag}}"><span class="class_name">{{tag}}</span></span>
@@ -33,7 +33,7 @@
{% if tut.type != 'tutorial' and tut.type != 'article' %}
<li data-pubdate="{{tut.publication_date}}">
<span class="date">{{tut.publication_date.month}}/{{tut.publication_date.day}}</span> <span class="author" data-author_id="{{ tut.author.key.name }}"><img src="/static/images/profiles/75/{{tut.author.key.name}}.75.png" alt="{{ tut.author.given_name }} {{ tut.author.family_name }}" title="{{ tut.author.given_name }} {{ tut.author.family_name }}"></span>
- <span class="title"><a href="{{tut.url}}">{{tut.title|safe}}</a></span>
+ <span class="title"><a href="{{tut.url}}">{{tut.title|safe}}{% if tut.subtitle %}: {{tut.subtitle|safe}}{% endif %}</a></span>
<span class="classes">
{% for tag in tut.classes %}
<span class="class {{tag}}"><span class="class_name">{{tag}}</span></span>
@@ -55,7 +55,7 @@
{% if forloop.counter0 < 10 %}
{% if r.type == 'tutorial' or r.type == 'article' %}
<li>
- <a href="{{r.url}}">{{r.title}}</a><br>
+ <a href="{{r.url}}">{{r.title}}{% if r.subtitle %}: {{r.subtitle|safe}}{% endif %}</a><br>
<span>{{r.description|safe|truncatewords:15}}</span>
</a>
</li>
@@ -100,7 +100,7 @@
<article class="tutorial_listing" data-type="{{ tut.type }}" data-classes="{{ tut.classes|join:',' }}"
data-pubdate="{{tut.publication_date.year}}-{{tut.publication_date|date:"m"}}-{{tut.publication_date|date:"d"}}">
<h3 id="{{tut.title|slugify}}" >
- <a href="{{tut.url}}">{{tut.title|safe}}</a>
+ <a href="{{tut.url}}">{{tut.title|safe}}{% if tut.subtitle %}: {{tut.subtitle|safe}}{% endif %}</a>
</h3>
<div>
<span class="date">{{tut.publication_date}}</span>
@@ -65,7 +65,7 @@
<p>Current resources:</p>
<ol>
{% for r in resources %}
- <li><a href="/database/resource/{{r.key.id}}">[Edit]</a> &nbsp; <a href="{{r.url}}" target="_blank">{{r.title}}</a> - {% for tag in r.tags %}{{tag}}{% if not forloop.last %}, {% endif %}{% endfor %} {% if r.draft %}&nbsp; <b>draft</b>{% endif %}</li>
+ <li><a href="/database/resource/{{r.key.id}}">[Edit]</a> &nbsp; <a href="{{r.url}}" target="_blank">{{r.title}}{% if r.subtitle %}: {{r.subtitle|safe}}{% endif %}</a> - {% for tag in r.tags %}{{tag}}{% if not forloop.last %}, {% endif %}{% endfor %} {% if r.draft %}&nbsp; <b>draft</b>{% endif %}</li>
{% endfor %}
</ol>
</section>
View
@@ -33,7 +33,8 @@ tags:
---
-title: "Proper templates in HTML"
+title: "HTML's new template tag"
+subtitle: "standardizing client-side templating"
url: /tutorials/webcomponents/template/
author_id: ericbidelman
publication_date: 2013-02-21
@@ -66,7 +67,7 @@ tags:
---
-title: "Confound Malicious Middlemen with HTTPS and HSTS"
+title: "Confound Malicious Middlemen with HTTPS and HTTP Strict Transport Security"
url: /tutorials/security/transport-layer-security/
author_id: mikewest
publication_date: 2013-02-11
@@ -509,7 +510,7 @@ tags:
- angular
- node
- socketio
-- class:business
+- business
- class:connectivity
- type:tutorial
View
14 main.py
@@ -113,6 +113,8 @@ def get_feed(self, path):
for tut in tutorials:
article = {}
article['title'] = tut.title
+ if hasattr(tut, 'subtitle'):
+ article['subtitle'] = tut.subtitle
article['id'] = '-'.join(tut.title.lower().split())
article['href'] = tut.url
article['description'] = tut.description
@@ -218,8 +220,11 @@ def render_atom_feed(self, template_path, data):
author_name = unicode(tut['author_id'])
if 'second_author' in tut:
author_name += ',' + tut['second_author']
+ title = tut['title']
+ if 'subtitle' in tut and tut['subtitle']:
+ title += ': ' + tut['subtitle']
feed.add_item(
- title=unicode(tut['title']),
+ title=unicode(title),
link=prefix + tut['href'],
description=unicode(tut['description']),
pubdate=tut['pubdate'],
@@ -355,6 +360,8 @@ def get(self, relpath):
if tut:
if tut.title:
tut.title = _(tut.title)
+ if hasattr(tut, 'subtitle') and tut.subtitle:
+ tut.subtitle = _(tut.subtitle)
if tut.description:
tut.description = _(tut.description)
@@ -416,6 +423,8 @@ def get(self, relpath):
if os.path.isfile(filepath):
if r.title:
r.title = _(r.title)
+ if hasattr(r, 'subtitle') and r.subtitle:
+ r.subtitle = _(r.subtitle)
if r.description:
r.description = _(r.description)
# Point the article to the localized version, regardless.
@@ -494,6 +503,7 @@ def _ImportBackupResources(self, file_name):
resource = models.Resource(
title=res['title'],
+ subtitle=res.get('subtitle') or None,
description=res.get('description') or None,
author=author_key,
second_author=author_key2,
@@ -761,6 +771,7 @@ def post(self, relpath):
try:
#TODO: This is also hacky.
tutorial.title = self.request.get('title')
+ tutorial.subtitle = self.request.get('subtitle') or None
tutorial.description = self.request.get('description')
tutorial.author = author_key
tutorial.second_author = author_key2
@@ -779,6 +790,7 @@ def post(self, relpath):
try:
tutorial = models.Resource(
title=self.request.get('title'),
+ subtitle=self.request.get('subtitle') or None,
description=self.request.get('description'),
author=author_key,
second_author=author_key2,
View
@@ -75,6 +75,7 @@ class Resource(DictModel):
"""Container for all kinds of resource."""
title = db.StringProperty(required=True)
+ subtitle = db.StringProperty(required=False)
description = db.StringProperty()
author = db.ReferenceProperty(Author, collection_name='author_one_set')
second_author = db.ReferenceProperty(Author, collection_name='author_two_set')
@@ -139,6 +140,7 @@ class TutorialForm(forms.Form):
import datetime
title = forms.CharField(required=True)
+ subtitle = forms.CharField(required=False)
description = forms.CharField(
widget=forms.Textarea(attrs={'required': 'required', 'rows': 5, 'cols': 20}),
View
@@ -2896,13 +2896,19 @@ header.tutorial aside
margin-left: 0;
}
-header.tutorial section h2,
+header.tutorial section h3,
header.tutorial section
{
color: #333;
font-size: 13px;
text-transform: none;
}
+header.tutorial section h2 {
+ text-transform: uppercase;
+ font-size: 26px;
+ font-weight: 300;
+ margin: 0 0 .25em;
+}
header.tutorial .byline
{
@@ -2955,7 +2961,7 @@ header.tutorial aside a
background: none !important;
}
-header.tutorial .browser_support h2
+header.tutorial .browser_support h3
{
float: left;
font-size: 12px;
View
@@ -19,16 +19,17 @@
<section>
<h1>{{ tut.title|safe }}</h1>
+ {% if tut.subtitle %}<h2>{{tut.subtitle|safe}}</h2>{% endif %}
<section class="byline">
<a href="/profiles/#{{ tut.author.key.name }}"><img src="/static/images/profiles/75/{{ tut.author.key.name }}.75.png" itemprop="photo" alt="{{ tut.author.given_name }} {{ tut.author.family_name }}" title="{{ tut.author.given_name }} {{ tut.author.family_name }}"></a>
<hgroup>
- <h2>
+ <h3>
By <strong><a href="/profiles/#{{ tut.author.key.name }}">{{ tut.author.given_name }} {{ tut.author.family_name }}</a></strong>
{% if tut.second_author %}
&amp; <strong><a href="/profiles/#{{ tut.second_author.key.name }}">{{ tut.second_author.given_name }} {{ tut.second_author.family_name }}</a></strong>
{% endif %}
- </h2>
+ </h3>
</hgroup>
<div class="date">
<time pubdate>{% blocktrans %}Published{% endblocktrans %} <strong>{{ tut.publication_date }}</strong></time>
@@ -47,7 +48,7 @@
{% endif %}
<section class="browser_support">
- <h2>{% trans "Supported browsers:" %}</h2>
+ <h3>{% trans "Supported browsers:" %}</h3>
<span class="browsers">
<span class="browser opera {% if 'opera' in tut.browser_support %}supported{% endif %}">
<span class="browser_name">{% trans "Opera" %}</span>

0 comments on commit dd2d40b

Please sign in to comment.