]> git.zarvox.org Git - shortlog.git/commitdiff
Attempt to update shortlog for web.py
authorDrew Fisher <drew.m.fisher@gmail.com>
Sun, 2 Oct 2022 03:20:00 +0000 (20:20 -0700)
committerDrew Fisher <drew.m.fisher@gmail.com>
Sun, 2 Oct 2022 03:20:00 +0000 (20:20 -0700)
shortlog.py [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 3eeb6df..f7b62b3
@@ -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())