summaryrefslogtreecommitdiff
path: root/_news_colors.py
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-04-16 10:44:33 -0700
committerBen Longbons <b.r.longbons@gmail.com>2014-04-16 10:44:33 -0700
commit9dcbd210f76714e9ccf9426e4c78726a8a3ba76e (patch)
treedd86bc572987923acb6010882b94fd3936f328d2 /_news_colors.py
parent00a5112f81575e1052bf0f8251953e91a265f824 (diff)
downloadtools-9dcbd210f76714e9ccf9426e4c78726a8a3ba76e.tar.gz
tools-9dcbd210f76714e9ccf9426e4c78726a8a3ba76e.tar.bz2
tools-9dcbd210f76714e9ccf9426e4c78726a8a3ba76e.tar.xz
tools-9dcbd210f76714e9ccf9426e4c78726a8a3ba76e.zip
Add a phpbb forum backend to the news generator
Diffstat (limited to '_news_colors.py')
-rw-r--r--_news_colors.py41
1 files changed, 40 insertions, 1 deletions
diff --git a/_news_colors.py b/_news_colors.py
index 329a6b8..3fdf2b2 100644
--- a/_news_colors.py
+++ b/_news_colors.py
@@ -22,7 +22,7 @@
import cgi
-__all__ = ['make_html_colors_dict', 'make_txt_colors_dict']
+__all__ = ['make_html_colors_dict', 'make_txt_colors_dict', 'make_forum_colors_dict']
class Color(object):
__slots__ = ('txt', 'rgb')
@@ -82,6 +82,45 @@ def make_html_colors_dict():
r['/' + k] = '</font>'
return r
+
+class ForumDate(object):
+ __slots__ = ()
+ def __format__(self, date):
+ return '[i]%s[/i]' % date
+
+class ForumLink(object):
+ __slots__ = ()
+ def __format__(self, target):
+ return '[url=%s]%s[/url]' % (target, target)
+
+class ForumSignature(object):
+ __slots__ = ()
+ def __format__(self, author):
+ return '-[i]%s[/i]' % author
+
+class ForumTitle(object):
+ __slots__ = ()
+ def __format__(self, title):
+ # no color here
+ # (we really need someone to do CSS)
+ return 'put this in the post title: %s' % title
+
+def make_forum_colors_dict():
+ r = {
+ 'date': ForumDate(),
+ 'link': ForumLink(),
+ 'author': ForumSignature(),
+ 'title': ForumTitle(),
+ 'ul' : '[list]',
+ '/ul': '[/list]',
+ 'li' : '[*]',
+ '/li': '',
+ }
+ for k, v in color_dict.items():
+ r[k] = '[color=#%06x]' % v.rgb
+ r['/' + k] = '[/color]'
+ return r
+
# Here be dragons
def make_txt_colors_dict():