Skip to content

Commit

Permalink
Fix #3 Add a custom template
Browse files Browse the repository at this point in the history
  • Loading branch information
2xyo committed Nov 19, 2013
1 parent 0f3a9a0 commit 8e6eb82
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pelican_delicious/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

delicious_regex = re.compile(r'\[delicious ([\s0-9a-zA-Z]+)\]')

delicious_template = """<div class="delicious">
delicious_default_template = """<div class="delicious">
{% for bookmark in bookmarks %}
<dl>
<dt>Title</dt>
Expand Down Expand Up @@ -74,14 +74,18 @@ def setup_delicious(pelican):

delicious_username = pelican.settings.get('DELICIOUS_USERNAME')
delicious_password = pelican.settings.get('DELICIOUS_PASSWORD')
pelican.settings['DELICIOUS_BOOKMARKS'] = fetch_delicious(
delicious_username, delicious_password)

pelican.settings['DELICIOUS_TEMPLATE'] = \
pelican.settings.get('DELICIOUS_TEMPLATE', delicious_default_template)

pelican.settings['DELICIOUS_BOOKMARKS'] = \
fetch_delicious(delicious_username, delicious_password)


def replace_delicious_tags(generator):
"""Replace delicious tags in the article content."""
from jinja2 import Template
template = Template(delicious_template)
template = Template(generator.context.get('DELICIOUS_TEMPLATE'))

for page in generator.pages:
for match in delicious_regex.findall(page._content):
Expand Down

0 comments on commit 8e6eb82

Please sign in to comment.