Use variable "tab" for tabs for better code style
This commit is contained in:
parent
e4b3672547
commit
6697c76176
106
blogthon.cgi
106
blogthon.cgi
@ -33,6 +33,8 @@ no_break = re.compile('^\s*(<ul|</ul>|<li|</li>|<ol|</ol>|<table|</tabl
|
|||||||
line_start_hyphen = re.compile('^-.*$')
|
line_start_hyphen = re.compile('^-.*$')
|
||||||
line_start_plus = re.compile('^\+.*$')
|
line_start_plus = re.compile('^\+.*$')
|
||||||
|
|
||||||
|
tab = "\t"
|
||||||
|
|
||||||
def generate_uuid(string):
|
def generate_uuid(string):
|
||||||
string_md5sum = md5.new(string).hexdigest()
|
string_md5sum = md5.new(string).hexdigest()
|
||||||
string = str.join('-', (string_md5sum[0:8], string_md5sum[8:12], string_md5sum[12:16], string_md5sum[16:20], string_md5sum[20:32]))
|
string = str.join('-', (string_md5sum[0:8], string_md5sum[8:12], string_md5sum[12:16], string_md5sum[16:20], string_md5sum[20:32]))
|
||||||
@ -44,10 +46,10 @@ def errorpage(string):
|
|||||||
print ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
|
print ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
|
||||||
print '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">'
|
print '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">'
|
||||||
print '<head>'
|
print '<head>'
|
||||||
print ' <title>Error!</title>'
|
print tab + '<title>Error!</title>'
|
||||||
print '</head>'
|
print '</head>'
|
||||||
print '<body>'
|
print '<body>'
|
||||||
print ' ' + string
|
print tab + string
|
||||||
print '</body>'
|
print '</body>'
|
||||||
print '</html>'
|
print '</html>'
|
||||||
sys.exit()
|
sys.exit()
|
||||||
@ -334,14 +336,14 @@ elif feed_display == "rss":
|
|||||||
# Generate regular page
|
# Generate regular page
|
||||||
else:
|
else:
|
||||||
document_header("xhtml-strict")
|
document_header("xhtml-strict")
|
||||||
print ' <head>'
|
print tab + '<head>'
|
||||||
print ' <title>' + blog_title + '</title>'
|
print tab*2 + '<title>' + blog_title + '</title>'
|
||||||
print ' <meta http-equiv="content-type" content="text/html; charset=utf-8" />'
|
print tab*2 + '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'
|
||||||
print ' <meta name="keywords" content="' + keywords + '" />'
|
print tab*2 + '<meta name="keywords" content="' + keywords + '" />'
|
||||||
print ' <meta name="description" content="' + blog_title + '" />'
|
print tab*2 + '<meta name="description" content="' + blog_title + '" />'
|
||||||
print ' <link rel="stylesheet" type="text/css" href="styles/' + style + '/' + style + '.css" />'
|
print tab*2 + '<link rel="stylesheet" type="text/css" href="styles/' + style + '/' + style + '.css" />'
|
||||||
print ' </head>'
|
print tab + '</head>'
|
||||||
print ' <body>'
|
print tab + '<body>'
|
||||||
print ''
|
print ''
|
||||||
|
|
||||||
# Plugins
|
# Plugins
|
||||||
@ -350,26 +352,26 @@ else:
|
|||||||
__import__ (plugin.split('/')[1].replace('.py', ''))
|
__import__ (plugin.split('/')[1].replace('.py', ''))
|
||||||
|
|
||||||
# Site header
|
# Site header
|
||||||
print ' <div class="header">'
|
print tab*2 + '<div class="header">'
|
||||||
print ' <div class="header_title">'
|
print tab*3 + '<div class="header_title">'
|
||||||
print ' <a href="?" class="header_link">' + blog_title + '</a>'
|
print tab*4 + '<a href="?" class="header_link">' + blog_title + '</a>'
|
||||||
print ' </div>'
|
print tab*3 + '</div>'
|
||||||
print ' <div class="header_subtitle">'
|
print tab*3 + '<div class="header_subtitle">'
|
||||||
print ' <span class="header_subtitle">' + blog_subtitle + '</span>'
|
print tab*4 + '<span class="header_subtitle">' + blog_subtitle + '</span>'
|
||||||
print ' </div>'
|
print tab*3 + '</div>'
|
||||||
print ' </div>'
|
print tab*2 + '</div>'
|
||||||
print ''
|
print ''
|
||||||
|
|
||||||
# RSS feed
|
# RSS feed
|
||||||
print ' <div class="rss">'
|
print tab*2 + '<div class="rss">'
|
||||||
print ' <a href="?feed=rss" class="rss_link">rss</a>'
|
print tab*3 + '<a href="?feed=rss" class="rss_link">rss</a>'
|
||||||
print ' </div>'
|
print tab*2 + '</div>'
|
||||||
print ''
|
print ''
|
||||||
|
|
||||||
# Atom feed
|
# Atom feed
|
||||||
print ' <div class="atom">'
|
print tab*2 + '<div class="atom">'
|
||||||
print ' <a href="?feed=atom" class="atom_link">atom</a>'
|
print tab*3 + '<a href="?feed=atom" class="atom_link">atom</a>'
|
||||||
print ' </div>'
|
print tab*2 + '</div>'
|
||||||
print ''
|
print ''
|
||||||
|
|
||||||
# Staticpages
|
# Staticpages
|
||||||
@ -377,10 +379,10 @@ else:
|
|||||||
staticpages = []
|
staticpages = []
|
||||||
staticpages_list = glob.glob(staticpages_dir + '*')
|
staticpages_list = glob.glob(staticpages_dir + '*')
|
||||||
staticpages_list.sort()
|
staticpages_list.sort()
|
||||||
print ' <div class="pages">'
|
print tab*2 + '<div class="pages">'
|
||||||
print ' <div class="pages_title">' + blog_locale[0] + '</div>'
|
print tab*3 + '<div class="pages_title">' + blog_locale[0] + '</div>'
|
||||||
print ' <div class="pages_list">'
|
print tab*3 + '<div class="pages_list">'
|
||||||
print ' <ul class="pages_list">'
|
print tab*4 + '<ul class="pages_list">'
|
||||||
for staticpage in staticpages_list:
|
for staticpage in staticpages_list:
|
||||||
file = open(staticpage, 'r')
|
file = open(staticpage, 'r')
|
||||||
header = file.readline()
|
header = file.readline()
|
||||||
@ -391,55 +393,55 @@ else:
|
|||||||
link = '?s=' + link
|
link = '?s=' + link
|
||||||
file.close()
|
file.close()
|
||||||
title = re.sub('\w+?\/\d+?-', '', staticpage)
|
title = re.sub('\w+?\/\d+?-', '', staticpage)
|
||||||
print ' <li class="pages_list_entry"><a href="' + link + '" class="pages_list_entry">' + title + '</a></li>'
|
print tab*5 + '<li class="pages_list_entry"><a href="' + link + '" class="pages_list_entry">' + title + '</a></li>'
|
||||||
print ' </ul>'
|
print tab*4 + '</ul>'
|
||||||
print ' </div>'
|
print tab*3 + '</div>'
|
||||||
print ' <div class="pages_footer"></div>'
|
print tab*3 + '<div class="pages_footer"></div>'
|
||||||
print ' </div>'
|
print tab*2 + '</div>'
|
||||||
print ''
|
print ''
|
||||||
|
|
||||||
# Monthlist
|
# Monthlist
|
||||||
if monthlist == "True":
|
if monthlist == "True":
|
||||||
olddate = ""
|
olddate = ""
|
||||||
print ' <div class="months">'
|
print tab*2 + '<div class="months">'
|
||||||
print ' <div class="months_title">' + blog_locale[1] + '</div>'
|
print tab*3 + '<div class="months_title">' + blog_locale[1] + '</div>'
|
||||||
print ' <div class="months_list">'
|
print tab*3 + '<div class="months_list">'
|
||||||
print ' <ul class="months_list">'
|
print tab*4 + '<ul class="months_list">'
|
||||||
for entry in entries:
|
for entry in entries:
|
||||||
date = time.strftime("%m%Y", entry[0])
|
date = time.strftime("%m%Y", entry[0])
|
||||||
date_display = time.strftime("%h %Y", entry[0])
|
date_display = time.strftime("%h %Y", entry[0])
|
||||||
if not olddate == date:
|
if not olddate == date:
|
||||||
print ' <li class="months_list_entry"><a href="?m=' + date + '" class="months_list_entry">' + date_display + '</a></li>'
|
print tab*5 + '<li class="months_list_entry"><a href="?m=' + date + '" class="months_list_entry">' + date_display + '</a></li>'
|
||||||
olddate = date
|
olddate = date
|
||||||
print ' </ul>'
|
print tab*4 + '</ul>'
|
||||||
print ' </div>'
|
print tab*3 + '</div>'
|
||||||
print ' <div class="months_footer"></div>'
|
print tab*3 + '<div class="months_footer"></div>'
|
||||||
print ' </div>'
|
print tab*2 + '</div>'
|
||||||
print ''
|
print ''
|
||||||
|
|
||||||
# Linklist
|
# Linklist
|
||||||
if linklist == "True":
|
if linklist == "True":
|
||||||
print ' <div class="linklist">'
|
print tab*2 + '<div class="linklist">'
|
||||||
print ' <div class="linklist_title">' + blog_locale[2] + '</div>'
|
print tab*3 + '<div class="linklist_title">' + blog_locale[2] + '</div>'
|
||||||
print ' <div class="linklist_list">'
|
print tab*3 + '<div class="linklist_list">'
|
||||||
print ' <ul class="linklist_list">'
|
print tab*4 + '<ul class="linklist_list">'
|
||||||
try:
|
try:
|
||||||
content = open("linklist", "r")
|
content = open("linklist", "r")
|
||||||
for line in content:
|
for line in content:
|
||||||
if line.strip() is "":
|
if line.strip() is "":
|
||||||
print '<br />'
|
print '<br />'
|
||||||
else:
|
else:
|
||||||
print ' <li class="linklist_list_entry"><a href="' + line.split(" ")[0] + '" class="months_list_entry">' + line.split(" ", 1)[1].strip() + '</a></li>'
|
print tab*5 + '<li class="linklist_list_entry"><a href="' + line.split(" ")[0] + '" class="months_list_entry">' + line.split(" ", 1)[1].strip() + '</a></li>'
|
||||||
content.close()
|
content.close()
|
||||||
except:
|
except:
|
||||||
print ''
|
print ''
|
||||||
print ' </ul>'
|
print tab*4 + '</ul>'
|
||||||
print ' </div>'
|
print tab*3 + '</div>'
|
||||||
print ' <div class="linklist_footer"></div>'
|
print tab*3 + '<div class="linklist_footer"></div>'
|
||||||
print ' </div>'
|
print tab*2 + '</div>'
|
||||||
print ''
|
print ''
|
||||||
|
|
||||||
print ' <div class="entries">'
|
print tab*2 + '<div class="entries">'
|
||||||
print ''
|
print ''
|
||||||
|
|
||||||
# Staticpage
|
# Staticpage
|
||||||
|
Loading…
Reference in New Issue
Block a user