X-Git-Url: https://git.llucax.com/software/blitiri.git/blobdiff_plain/958d21141796b86d79fc95c86f679d08652ef78e..f874dc7a70fd66a320882bcc1fd71e8324918f2c:/blitiri.cgi?ds=inline diff --git a/blitiri.cgi b/blitiri.cgi index dd87387..f13e59a 100755 --- a/blitiri.cgi +++ b/blitiri.cgi @@ -50,6 +50,9 @@ import urllib import cgi from docutils.core import publish_parts +# Before importing the config, add our cwd to the Python path +sys.path.append(os.getcwd()) + # Load the config file, if there is one try: from config import * @@ -57,6 +60,10 @@ except: pass +# Pimp *_path config variables to support relative paths +data_path = os.path.realpath(data_path) +templates_path = os.path.realpath(templates_path) + # Default template default_main_header = """ @@ -85,6 +92,7 @@ default_main_footer = """ %(showyear)s: %(monthlinks)s
years: %(yearlinks)s
subscribe: atom
+ views: blog list
@@ -357,6 +365,10 @@ class Article (object): return -1 return 1 + def title_cmp(self, other): + return cmp(self.title, other.title) + + def load(self): try: raw = open(data_path + '/' + self.path).readlines() @@ -503,6 +515,20 @@ def render_html(articles, db, actyear = None): print template.get_article_footer(a) print template.get_main_footer() +def render_artlist(articles, db, actyear = None): + template = Templates(templates_path, db, actyear) + print 'Content-type: text/html; charset=utf-8\n' + print template.get_main_header() + print '

Articles

' + for a in articles: + print '
  • %(title)s
  • ' \ + % { 'url': blog_url, + 'uuid': a.uuid, + 'title': a.title, + 'author': a.author, + } + print template.get_main_footer() + def render_atom(articles): if len(articles) > 0: updated = articles[0].updated.isoformat() @@ -570,6 +596,7 @@ def handle_cgi(): atom = False style = False post = False + artlist = False if os.environ.has_key('PATH_INFO'): path_info = os.environ['PATH_INFO'] @@ -577,7 +604,9 @@ def handle_cgi(): atom = path_info == '/atom' tag = path_info.startswith('/tag/') post = path_info.startswith('/post/') - if not style and not atom and not post and not tag: + artlist = path_info.startswith('/list') + if not style and not atom and not post and not tag \ + and not artlist: date = path_info.split('/')[1:] try: if len(date) > 1 and date[0]: @@ -605,7 +634,11 @@ def handle_cgi(): elif style: render_style() elif post: - render_html( [db.get_article(uuid)], year ) + render_html( [db.get_article(uuid)], db, year ) + elif artlist: + articles = db.get_articles() + articles.sort(cmp = Article.title_cmp) + render_artlist(articles, db) else: articles = db.get_articles(year, month, day, tags) articles.sort(reverse = True)