mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge pull request #336 from saimn/typogrify
Apply typogrify on the title.
This commit is contained in:
commit
1779b66f10
5 changed files with 58 additions and 45 deletions
|
|
@ -174,5 +174,6 @@ def read_file(filename, fmt=None, settings=None):
|
||||||
if settings and settings['TYPOGRIFY']:
|
if settings and settings['TYPOGRIFY']:
|
||||||
from typogrify import Typogrify
|
from typogrify import Typogrify
|
||||||
content = Typogrify.typogrify(content)
|
content = Typogrify.typogrify(content)
|
||||||
|
metadata['title'] = Typogrify.typogrify(metadata['title'])
|
||||||
|
|
||||||
return content, metadata
|
return content, metadata
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,34 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% block title %}{{ article.title }}{% endblock %}
|
{% block title %}{{ article.title|striptags }}{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<section id="content" class="body">
|
<section id="content" class="body">
|
||||||
<article>
|
<article>
|
||||||
<header> <h1 class="entry-title"><a href="{{ pagename }}"
|
<header>
|
||||||
rel="bookmark" title="Permalink to {{ article.title }}">{{ article.title
|
<h1 class="entry-title">
|
||||||
}}</a></h1> {% include 'twitter.html' %} </header>
|
<a href="{{ article.url }}" rel="bookmark"
|
||||||
<div class="entry-content">
|
title="Permalink to {{ article.title|striptags }}">{{ article.title}}</a></h1>
|
||||||
{% include 'article_infos.html' %}
|
{% include 'twitter.html' %}
|
||||||
{{ article.content }}
|
</header>
|
||||||
</div><!-- /.entry-content -->
|
|
||||||
{% if DISQUS_SITENAME %}
|
|
||||||
<div class="comments">
|
|
||||||
<h2>Comments !</h2>
|
|
||||||
<div id="disqus_thread"></div>
|
|
||||||
<script type="text/javascript">
|
|
||||||
var disqus_identifier = "{{ article.url }}";
|
|
||||||
(function() {
|
|
||||||
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
|
|
||||||
dsq.src = 'http://{{ DISQUS_SITENAME }}.disqus.com/embed.js';
|
|
||||||
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
</article>
|
<div class="entry-content">
|
||||||
|
{% include 'article_infos.html' %}
|
||||||
|
{{ article.content }}
|
||||||
|
</div><!-- /.entry-content -->
|
||||||
|
{% if DISQUS_SITENAME %}
|
||||||
|
<div class="comments">
|
||||||
|
<h2>Comments !</h2>
|
||||||
|
<div id="disqus_thread"></div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var disqus_identifier = "{{ article.url }}";
|
||||||
|
(function() {
|
||||||
|
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
|
||||||
|
dsq.src = 'http://{{ DISQUS_SITENAME }}.disqus.com/embed.js';
|
||||||
|
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</article>
|
||||||
</section>
|
</section>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,23 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<section id="content" class="body">
|
<section id="content" class="body">
|
||||||
<header> <h2 class="entry-title"><a href="{{ pagename }}" rel="bookmark" title="Permalink to {{ article.title}}">{{ article.title }}</a></h2> </header>
|
<header>
|
||||||
<footer class="post-info">
|
<h2 class="entry-title">
|
||||||
<abbr class="published" title="{{ article.date.isoformat() }}">
|
<a href="{{ article.url }}" rel="bookmark"
|
||||||
{{ article.locale_date }}
|
title="Permalink to {{ article.title|striptags }}">{{ article.title }}</a></h2>
|
||||||
</abbr>
|
</header>
|
||||||
{% if article.author %}
|
<footer class="post-info">
|
||||||
<address class="vcard author">
|
<abbr class="published" title="{{ article.date.isoformat() }}">
|
||||||
By <a class="url fn" href="{{ SITEURL }}/{{ article.author.url }}">{{ article.author }}</a>
|
{{ article.locale_date }}
|
||||||
</address>
|
</abbr>
|
||||||
{% endif %}
|
{% if article.author %}
|
||||||
</footer><!-- /.post-info -->
|
<address class="vcard author">
|
||||||
<div class="entry-content">
|
By <a class="url fn" href="{{ SITEURL }}/{{ article.author.url }}">{{ article.author }}</a>
|
||||||
{{ article.content }}
|
</address>
|
||||||
</div><!-- /.entry-content -->
|
{% endif %}
|
||||||
|
</footer><!-- /.post-info -->
|
||||||
|
<div class="entry-content">
|
||||||
|
{{ article.content }}
|
||||||
|
</div><!-- /.entry-content -->
|
||||||
</section>
|
</section>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import logging
|
||||||
from codecs import open as _open
|
from codecs import open as _open
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
|
from jinja2 import Markup
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
@ -44,6 +45,7 @@ def slugify(value):
|
||||||
|
|
||||||
Took from django sources.
|
Took from django sources.
|
||||||
"""
|
"""
|
||||||
|
value = Markup(value).striptags()
|
||||||
if type(value) == unicode:
|
if type(value) == unicode:
|
||||||
import unicodedata
|
import unicodedata
|
||||||
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore')
|
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore')
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ import logging
|
||||||
|
|
||||||
from codecs import open
|
from codecs import open
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from feedgenerator import Atom1Feed, Rss201rev2Feed
|
from feedgenerator import Atom1Feed, Rss201rev2Feed
|
||||||
|
from jinja2 import Markup
|
||||||
from pelican.paginator import Paginator
|
from pelican.paginator import Paginator
|
||||||
from pelican.utils import get_relative_path, set_date_tzinfo
|
from pelican.utils import get_relative_path, set_date_tzinfo
|
||||||
|
|
||||||
|
|
@ -25,8 +25,9 @@ class Writer(object):
|
||||||
|
|
||||||
def _create_new_feed(self, feed_type, context):
|
def _create_new_feed(self, feed_type, context):
|
||||||
feed_class = Rss201rev2Feed if feed_type == 'rss' else Atom1Feed
|
feed_class = Rss201rev2Feed if feed_type == 'rss' else Atom1Feed
|
||||||
|
sitename = Markup(context['SITENAME']).striptags()
|
||||||
feed = feed_class(
|
feed = feed_class(
|
||||||
title=context['SITENAME'],
|
title=sitename,
|
||||||
link=(self.site_url + '/'),
|
link=(self.site_url + '/'),
|
||||||
feed_url=self.feed_url,
|
feed_url=self.feed_url,
|
||||||
description=context.get('SITESUBTITLE', ''))
|
description=context.get('SITESUBTITLE', ''))
|
||||||
|
|
@ -34,8 +35,9 @@ class Writer(object):
|
||||||
|
|
||||||
def _add_item_to_the_feed(self, feed, item):
|
def _add_item_to_the_feed(self, feed, item):
|
||||||
|
|
||||||
|
title = Markup(item.title).striptags()
|
||||||
feed.add_item(
|
feed.add_item(
|
||||||
title=item.title,
|
title=title,
|
||||||
link='%s/%s' % (self.site_url, item.url),
|
link='%s/%s' % (self.site_url, item.url),
|
||||||
unique_id='tag:%s,%s:%s' % (self.site_url.replace('http://', ''),
|
unique_id='tag:%s,%s:%s' % (self.site_url.replace('http://', ''),
|
||||||
item.date.date(), item.url),
|
item.date.date(), item.url),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue