Skip to content

Commit

Permalink
added atomic link filter to the blog example
Browse files Browse the repository at this point in the history
  • Loading branch information
icebreaker committed Aug 15, 2011
1 parent 49f6a02 commit 8960b77
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions examples/blog/_plugins/metadataprocessor.py
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,10 @@
import os, re, yaml, cgi, doxter import os, re, yaml, cgi, doxter
from datetime import date from datetime import date


def atomic_links(value, root):
regexp = re.compile(r'="\/(.*?)"')
return re.sub(regexp, lambda m: '="%s%s"' % (root, m.group(1)), value)

def date_to_string(value, format='%B %d, %Y'): def date_to_string(value, format='%B %d, %Y'):
return value.strftime(format) return value.strftime(format)


Expand Down Expand Up @@ -33,6 +37,7 @@ def __init__(self):
self.template.register_filter('date_to_xmlschema', date_to_xmlschema) self.template.register_filter('date_to_xmlschema', date_to_xmlschema)
self.template.register_filter('xml_escape', xml_escape) self.template.register_filter('xml_escape', xml_escape)
self.template.register_filter('array_to_sentence_string', array_to_sentence_string) self.template.register_filter('array_to_sentence_string', array_to_sentence_string)
self.template.register_filter('atomic_links', atomic_links)


def priority(self): def priority(self):
return 1 return 1
Expand Down
2 changes: 1 addition & 1 deletion examples/blog/_templates/atom.tpl.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<link href="{{ site.url }}{{ post.path }}"/> <link href="{{ site.url }}{{ post.path }}"/>
<updated>{{ post.date | date_to_xmlschema }}</updated> <updated>{{ post.date | date_to_xmlschema }}</updated>
<id>{{ site.url }}{{ post.path }}</id> <id>{{ site.url }}{{ post.path }}</id>
<content type="html">{{ post.content | xml_escape }}</content> <content type="html">{{ post.content | atomic_links(site.url) | xml_escape }}</content>
{% for tag in post.tags %}<category term="{{tag | xml_escape}}"/>{% endfor %} {% for tag in post.tags %}<category term="{{tag | xml_escape}}"/>{% endfor %}
</entry> </entry>
{% endfor %} {% endfor %}
Expand Down

0 comments on commit 8960b77

Please sign in to comment.