Following guidelines from http://www.python.org/dev/peps/pep-0008/
This commit is contained in:
parent
b48033faca
commit
b76a97c26a
184
blogthon.cgi
184
blogthon.cgi
@ -81,41 +81,63 @@ for config in ["../blogthonrc", "../.blogthonrc", "configuration"]:
|
|||||||
if not config:
|
if not config:
|
||||||
errorpage("No suitable configuration found!")
|
errorpage("No suitable configuration found!")
|
||||||
|
|
||||||
try: blog_title = configuration.get("personal", "blog_title")
|
try:
|
||||||
except: errorpage("\"blog_title\" is missing in configuration!")
|
blog_title = configuration.get("personal", "blog_title")
|
||||||
|
except:
|
||||||
|
errorpage("\"blog_title\" is missing in configuration!")
|
||||||
|
|
||||||
try: blog_subtitle = configuration.get("personal", "blog_subtitle")
|
try:
|
||||||
except: errorpage("\"blog_subtitle\" is missing in configuration!")
|
blog_subtitle = configuration.get("personal", "blog_subtitle")
|
||||||
|
except:
|
||||||
|
errorpage("\"blog_subtitle\" is missing in configuration!")
|
||||||
|
|
||||||
try: blog_url = configuration.get("personal", "blog_url")
|
try:
|
||||||
except: errorpage("\"blog_url\" is missing in configuration!")
|
blog_url = configuration.get("personal", "blog_url")
|
||||||
|
except:
|
||||||
|
errorpage("\"blog_url\" is missing in configuration!")
|
||||||
|
|
||||||
try: keywords = configuration.get("personal", "keywords")
|
try:
|
||||||
except: errorpage("\"keywords\" is missing in configuration!")
|
keywords = configuration.get("personal", "keywords")
|
||||||
|
except:
|
||||||
|
errorpage("\"keywords\" is missing in configuration!")
|
||||||
|
|
||||||
|
try:
|
||||||
|
entries_dir = configuration.get("personal", "entries_dir")
|
||||||
|
except:
|
||||||
|
errorpage("\"entries_dir\" is missing in configuration!")
|
||||||
|
|
||||||
try: entries_dir = configuration.get("personal", "entries_dir")
|
|
||||||
except: errorpage("\"entries_dir\" is missing in configuration!")
|
|
||||||
if not os.path.exists(entries_dir):
|
if not os.path.exists(entries_dir):
|
||||||
errorpage("\"entries_dir\" does not exist!")
|
errorpage("\"entries_dir\" does not exist!")
|
||||||
|
|
||||||
try: entries_suffix = configuration.get("personal", "entries_suffix")
|
try:
|
||||||
except: errorpage("\"entries_suffix\" is missing in configuration!")
|
entries_suffix = configuration.get("personal", "entries_suffix")
|
||||||
|
except:
|
||||||
|
errorpage("\"entries_suffix\" is missing in configuration!")
|
||||||
|
|
||||||
try: staticpages_dir = configuration.get("personal", "staticpages_dir")
|
try:
|
||||||
except: errorpage("\"staticpages_dir\" is missing in configuration!")
|
staticpages_dir = configuration.get("personal", "staticpages_dir")
|
||||||
|
except:
|
||||||
|
errorpage("\"staticpages_dir\" is missing in configuration!")
|
||||||
if not os.path.exists(staticpages_dir):
|
if not os.path.exists(staticpages_dir):
|
||||||
errorpage("\"staticpages_dir\" does not exist!")
|
errorpage("\"staticpages_dir\" does not exist!")
|
||||||
|
|
||||||
try: plugins_dir = configuration.get("personal", "plugins_dir")
|
try:
|
||||||
except: errorpage("\"plugins_dir\" is missing in configuration!")
|
plugins_dir = configuration.get("personal", "plugins_dir")
|
||||||
|
except:
|
||||||
|
errorpage("\"plugins_dir\" is missing in configuration!")
|
||||||
if not os.path.exists(plugins_dir):
|
if not os.path.exists(plugins_dir):
|
||||||
errorpage("\"plugins_dir\" does not exist!")
|
errorpage("\"plugins_dir\" does not exist!")
|
||||||
|
|
||||||
try: style = configuration.get("look", "style")
|
try:
|
||||||
except: errorpage("\"style\" is missing in configuration!")
|
style = configuration.get("look", "style")
|
||||||
|
except:
|
||||||
|
errorpage("\"style\" is missing in configuration!")
|
||||||
|
|
||||||
|
try:
|
||||||
|
language = configuration.get("look", "language")
|
||||||
|
except:
|
||||||
|
errorpage("\"language\" is missing in configuration!")
|
||||||
|
|
||||||
try: language = configuration.get("look", "language")
|
|
||||||
except: errorpage("\"language\" is missing in configuration!")
|
|
||||||
if language == "de":
|
if language == "de":
|
||||||
blog_locale = ("Seiten", "Monate", "Links", "Keine Kommentare", "Kommentare", "Alle Einträge anzeigen...", "Name", "Text", "Absenden")
|
blog_locale = ("Seiten", "Monate", "Links", "Keine Kommentare", "Kommentare", "Alle Einträge anzeigen...", "Name", "Text", "Absenden")
|
||||||
locales_de = ("de_DE.UTF-8", "de_DE.@euro", "de_DE")
|
locales_de = ("de_DE.UTF-8", "de_DE.@euro", "de_DE")
|
||||||
@ -123,8 +145,10 @@ if language == "de":
|
|||||||
try:
|
try:
|
||||||
locale.setlocale(locale.LC_TIME, i)
|
locale.setlocale(locale.LC_TIME, i)
|
||||||
break
|
break
|
||||||
except: continue
|
except:
|
||||||
else: locale.setlocale(locale.LC_TIME, None)
|
continue
|
||||||
|
else:
|
||||||
|
locale.setlocale(locale.LC_TIME, None)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
blog_locale = ("pages", "months", "links", "no comments", "comments", "View all entries...", "name", "text", "commit")
|
blog_locale = ("pages", "months", "links", "no comments", "comments", "View all entries...", "name", "text", "commit")
|
||||||
@ -133,61 +157,97 @@ else:
|
|||||||
try:
|
try:
|
||||||
locale.setlocale(locale.LC_TIME, i)
|
locale.setlocale(locale.LC_TIME, i)
|
||||||
break
|
break
|
||||||
except: continue
|
except:
|
||||||
else: locale.setlocale(locale.LC_TIME, None)
|
continue
|
||||||
|
else:
|
||||||
|
locale.setlocale(locale.LC_TIME, None)
|
||||||
|
|
||||||
try: entries_per_page = configuration.getint("look", "entries_per_page")
|
try:
|
||||||
except: errorpage("\"entries_per_page\" is missing in configuration!")
|
entries_per_page = configuration.getint("look", "entries_per_page")
|
||||||
|
except:
|
||||||
|
errorpage("\"entries_per_page\" is missing in configuration!")
|
||||||
|
|
||||||
try: monthlist = configuration.get("look", "monthlist")
|
try:
|
||||||
except: errorpage("\"monthlist\" is missing in configuration!")
|
monthlist = configuration.get("look", "monthlist")
|
||||||
|
except:
|
||||||
|
errorpage("\"monthlist\" is missing in configuration!")
|
||||||
|
|
||||||
try: staticpages = configuration.get("look", "staticpages")
|
try:
|
||||||
except: errorpage("\"staticpages\" is missing in configuration!")
|
staticpages = configuration.get("look", "staticpages")
|
||||||
|
except:
|
||||||
|
errorpage("\"staticpages\" is missing in configuration!")
|
||||||
|
|
||||||
try: linklist = configuration.get("look", "linklist")
|
try:
|
||||||
except: errorpage("\"linklist\" is missing in configuration!")
|
linklist = configuration.get("look", "linklist")
|
||||||
|
except:
|
||||||
|
errorpage("\"linklist\" is missing in configuration!")
|
||||||
if not os.path.exists("linklist"):
|
if not os.path.exists("linklist"):
|
||||||
errorpage("\"linklist\" does not exist!")
|
errorpage("\"linklist\" does not exist!")
|
||||||
|
|
||||||
try: permalinks = configuration.get("look", "permalinks")
|
try:
|
||||||
except: errorpage("\"permalinks\" is missing in configuration!")
|
permalinks = configuration.get("look", "permalinks")
|
||||||
|
except:
|
||||||
|
errorpage("\"permalinks\" is missing in configuration!")
|
||||||
|
|
||||||
try: comments = configuration.get("look", "comments")
|
try:
|
||||||
except: errorpage("\"comments\" is missing in configuration!")
|
comments = configuration.get("look", "comments")
|
||||||
|
except:
|
||||||
|
errorpage("\"comments\" is missing in configuration!")
|
||||||
|
|
||||||
try: newest_first = configuration.get("look", "newest_first")
|
try:
|
||||||
except: errorpage("\"newest_first\" is missing in configuration!")
|
newest_first = configuration.get("look", "newest_first")
|
||||||
|
except:
|
||||||
|
errorpage("\"newest_first\" is missing in configuration!")
|
||||||
|
|
||||||
try: new_comment_mail = configuration.get("smtp", "new_comment_mail")
|
try:
|
||||||
except: errorpage("\"new_comment_mail\" is missing in configuration!")
|
new_comment_mail = configuration.get("smtp", "new_comment_mail")
|
||||||
|
except:
|
||||||
|
errorpage("\"new_comment_mail\" is missing in configuration!")
|
||||||
|
|
||||||
try: mail_to = configuration.get("smtp", "mail_to")
|
try:
|
||||||
except: errorpage("\"mail_to\" is missing in configuration!")
|
mail_to = configuration.get("smtp", "mail_to")
|
||||||
|
except:
|
||||||
|
errorpage("\"mail_to\" is missing in configuration!")
|
||||||
|
|
||||||
try: smtp_host = configuration.get("smtp", "smtp_host")
|
try:
|
||||||
except: errorpage("\"smtp_host\" is missing in configuration!")
|
smtp_host = configuration.get("smtp", "smtp_host")
|
||||||
|
except:
|
||||||
|
errorpage("\"smtp_host\" is missing in configuration!")
|
||||||
|
|
||||||
try: feed_preview = configuration.get("feed", "feed_preview")
|
try:
|
||||||
except: errorpage("\"feed_preview\" is missing or empty in configuration!")
|
feed_preview = configuration.get("feed", "feed_preview")
|
||||||
|
except:
|
||||||
|
errorpage("\"feed_preview\" is missing or empty in configuration!")
|
||||||
|
|
||||||
# Read POST Variables
|
# Read POST Variables
|
||||||
action = FieldStorage()
|
action = FieldStorage()
|
||||||
month_display = action.getvalue("m")
|
month_display = action.getvalue("m")
|
||||||
|
|
||||||
static_display = action.getvalue("s")
|
static_display = action.getvalue("s")
|
||||||
if static_display: static_display = static_display.replace("/", "")
|
if static_display:
|
||||||
|
static_display = static_display.replace("/", "")
|
||||||
|
|
||||||
post_display = action.getvalue("p")
|
post_display = action.getvalue("p")
|
||||||
if post_display: post_display = post_display.replace(" ", "-").replace("/", "")
|
if post_display:
|
||||||
|
post_display = post_display.replace(" ", "-").replace("/", "")
|
||||||
|
|
||||||
allentries_display = action.getvalue("a")
|
allentries_display = action.getvalue("a")
|
||||||
feed_display = action.getvalue("feed")
|
feed_display = action.getvalue("feed")
|
||||||
if not month_display: month_display = ""
|
|
||||||
if not post_display: post_display = ""
|
if not month_display:
|
||||||
if not static_display: static_display = ""
|
month_display = ""
|
||||||
if not allentries_display: allentries_display = ""
|
|
||||||
if not feed_display: feed_display = ""
|
if not post_display:
|
||||||
|
post_display = ""
|
||||||
|
|
||||||
|
if not static_display:
|
||||||
|
static_display = ""
|
||||||
|
|
||||||
|
if not allentries_display:
|
||||||
|
allentries_display = ""
|
||||||
|
|
||||||
|
if not feed_display:
|
||||||
|
feed_display = ""
|
||||||
|
|
||||||
# Commentstuff
|
# Commentstuff
|
||||||
ctitle = action.getvalue("ctitle")
|
ctitle = action.getvalue("ctitle")
|
||||||
@ -195,11 +255,17 @@ cname = action.getvalue("cname")
|
|||||||
ctext = action.getvalue("ctext")
|
ctext = action.getvalue("ctext")
|
||||||
cquiz = action.getvalue("cquiz")
|
cquiz = action.getvalue("cquiz")
|
||||||
cquizv = action.getvalue("cquizv")
|
cquizv = action.getvalue("cquizv")
|
||||||
if not ctitle: ctitle = ""
|
|
||||||
if not cname: cname = ""
|
if not ctitle:
|
||||||
if not ctext: ctext = ""
|
ctitle = ""
|
||||||
if not cquiz: cquiz = ""
|
if not cname:
|
||||||
if not cquizv: cquizv = ""
|
cname = ""
|
||||||
|
if not ctext:
|
||||||
|
ctext = ""
|
||||||
|
if not cquiz:
|
||||||
|
cquiz = ""
|
||||||
|
if not cquizv:
|
||||||
|
cquizv = ""
|
||||||
|
|
||||||
# Comment to commit?
|
# Comment to commit?
|
||||||
if cname and ctext and ctitle:
|
if cname and ctext and ctitle:
|
||||||
@ -608,4 +674,4 @@ else:
|
|||||||
print tab + "</body>"
|
print tab + "</body>"
|
||||||
print "</html>"
|
print "</html>"
|
||||||
|
|
||||||
# vim: set tw=0 ts=4:
|
# vim: set sw=4 tw=0 ts=4 expandtab:
|
||||||
|
Loading…
Reference in New Issue
Block a user