-
Notifications
You must be signed in to change notification settings - Fork 1
/
links.py
37 lines (28 loc) · 1022 Bytes
/
links.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
Copyright 2005 TheCrypto
Copyright 2013 Adam Sampson <[email protected]>
This plugin adds a list of links that you can put into your rawdog template for those sites that you just can't quite RSS yet.
In the config files use lines of the form
link <url> <name>
These will be turned into links.
In your template use the tag __links__ to have replaced with all the links.
Version 0.1
TheCrypto
"""
import rawdoglib.plugins
from rawdoglib.rawdog import string_to_html
def links_config(config, name, value):
if not config.config.has_key('links'):
config['links'] = []
if name == "link":
config['links'].append(value.split(None, 1))
return False
else:
return True
def links_output_bits(rawdog, config, bits):
links = ""
for link in config['links']:
links += '<a href="' + string_to_html(link[0], config) + '">' + string_to_html(link[1], config) + '</a>\n'
bits['links'] = links
rawdoglib.plugins.attach_hook('config_option', links_config)
rawdoglib.plugins.attach_hook('output_bits', links_output_bits)