From: Drew Fisher Date: Sun, 2 Oct 2022 03:20:00 +0000 (-0700) Subject: Attempt to update shortlog for web.py X-Git-Url: http://git.zarvox.org/shortlog/static/%7B%7B%20url_for%28%27main.logout_page%27%29%20%7D%7D?a=commitdiff_plain;h=3afd8e37ed8fc4bf1b886cb1412fe94f54fe23b6;p=shortlog.git Attempt to update shortlog for web.py --- diff --git a/shortlog.py b/shortlog.py old mode 100644 new mode 100755 index 3eeb6df..f7b62b3 --- a/shortlog.py +++ b/shortlog.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 import web import os @@ -7,6 +7,7 @@ import re import smtplib import hashlib import sys +from wsgiref.handlers import CGIHandler pwd = os.path.dirname( os.path.realpath( __file__ ) ) sys.path.append(pwd) @@ -114,6 +115,7 @@ class year: entries = [markdoku.markdown(readFile(x)) for x in filelist] commentcounts = map(len, map( getCommentFiles, dates)) render = web.template.render(templatesdir) + web.header("Content-Type","text/html; charset=utf-8") return render.multiday(zip(dates, entries, commentcounts), "Entries from %s" % theyear) class month: @@ -125,11 +127,13 @@ class month: entries = [markdoku.markdown(readFile(x)) for x in filelist] commentcounts = map(len, map( getCommentFiles, dates)) render = web.template.render(templatesdir) + web.header("Content-Type","text/html; charset=utf-8") return render.multiday(zip(dates, entries, commentcounts), "Entries from %s, %s" % (monthnames[themonth], theyear)) class day: def GET(self, year, month, day): filename = os.path.join(entriesdir, "%s-%s-%s.txt" % (year, month, day)) + web.header("Content-Type","text/html; charset=utf-8") if os.path.isfile(filename): entry = markdoku.markdown(readFile(filename)) commentfilelist = os.listdir(commentsdir) @@ -199,6 +203,7 @@ class pastyear: entries = [markdoku.markdown(readFile(x)) for x in filelist] commentcounts = map(len, map( getCommentFiles, dates)) render = web.template.render(templatesdir) + web.header("Content-Type","text/html; charset=utf-8") return render.multiday(zip(dates, entries, commentcounts)) class pastmonth: @@ -209,6 +214,7 @@ class pastmonth: entries = [markdoku.markdown(readFile(x)) for x in filelist] commentcounts = map(len, map( getCommentFiles, dates)) render = web.template.render(templatesdir) + web.header("Content-Type","text/html; charset=utf-8") return render.multiday(zip(dates, entries, commentcounts)) class pastweek: @@ -219,6 +225,7 @@ class pastweek: entries = [markdoku.markdown(readFile(x)) for x in filelist] commentcounts = map(len, map( getCommentFiles, dates)) render = web.template.render(templatesdir) + web.header("Content-Type","text/html; charset=utf-8") return render.multiday(zip(dates, entries, commentcounts)) class redir: @@ -253,8 +260,10 @@ application = web.application(urls, globals()).wsgifunc() #application = web.wsgifunc(web.webpyfunc(urls, globals())) if __name__ == "__main__": - ## The web.py 0.3+ way - app.run() - ## The web.py 0.2 way - #web.run(urls, globals()) + # CGI interface + CGIHandler().run(application) + ## The web.py 0.3+ way + #app.run() + ## The web.py 0.2 way + #web.run(urls, globals())