diff options
author | Stefan Ritter <xeno@thehappy.de> | 2010-11-15 17:50:11 +0100 |
---|---|---|
committer | Stefan Ritter <xeno@thehappy.de> | 2010-11-15 17:50:11 +0100 |
commit | 6697c761765e45aa8c06a13fddacb15cdb01b9ed (patch) | |
tree | fc56d8d54d93e30c2a5a34a94812b7889f3a86f0 | |
parent | e4b3672547ab03f6e2891cf76f194c971919ada4 (diff) |
Use variable "tab" for tabs for better code style
-rwxr-xr-x | blogthon.cgi | 106 |
1 files changed, 54 insertions, 52 deletions
diff --git a/blogthon.cgi b/blogthon.cgi index 83c9433..6c48081 100755 --- a/blogthon.cgi +++ b/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_plus = re.compile('^\+.*$') +tab = "\t" + def generate_uuid(string): 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])) @@ -44,10 +46,10 @@ def errorpage(string): print ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' print '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">' print '<head>' - print ' <title>Error!</title>' + print tab + '<title>Error!</title>' print '</head>' print '<body>' - print ' ' + string + print tab + string print '</body>' print '</html>' sys.exit() @@ -334,14 +336,14 @@ elif feed_display == "rss": # Generate regular page else: document_header("xhtml-strict") - print ' <head>' - print ' <title>' + blog_title + '</title>' - print ' <meta http-equiv="content-type" content="text/html; charset=utf-8" />' - print ' <meta name="keywords" content="' + keywords + '" />' - print ' <meta name="description" content="' + blog_title + '" />' - print ' <link rel="stylesheet" type="text/css" href="styles/' + style + '/' + style + '.css" />' - print ' </head>' - print ' <body>' + print tab + '<head>' + print tab*2 + '<title>' + blog_title + '</title>' + print tab*2 + '<meta http-equiv="content-type" content="text/html; charset=utf-8" />' + print tab*2 + '<meta name="keywords" content="' + keywords + '" />' + print tab*2 + '<meta name="description" content="' + blog_title + '" />' + print tab*2 + '<link rel="stylesheet" type="text/css" href="styles/' + style + '/' + style + '.css" />' + print tab + '</head>' + print tab + '<body>' print '' # Plugins @@ -350,26 +352,26 @@ else: __import__ (plugin.split('/')[1].replace('.py', '')) # Site header - print ' <div class="header">' - print ' <div class="header_title">' - print ' <a href="?" class="header_link">' + blog_title + '</a>' - print ' </div>' - print ' <div class="header_subtitle">' - print ' <span class="header_subtitle">' + blog_subtitle + '</span>' - print ' </div>' - print ' </div>' + print tab*2 + '<div class="header">' + print tab*3 + '<div class="header_title">' + print tab*4 + '<a href="?" class="header_link">' + blog_title + '</a>' + print tab*3 + '</div>' + print tab*3 + '<div class="header_subtitle">' + print tab*4 + '<span class="header_subtitle">' + blog_subtitle + '</span>' + print tab*3 + '</div>' + print tab*2 + '</div>' print '' # RSS feed - print ' <div class="rss">' - print ' <a href="?feed=rss" class="rss_link">rss</a>' - print ' </div>' + print tab*2 + '<div class="rss">' + print tab*3 + '<a href="?feed=rss" class="rss_link">rss</a>' + print tab*2 + '</div>' print '' # Atom feed - print ' <div class="atom">' - print ' <a href="?feed=atom" class="atom_link">atom</a>' - print ' </div>' + print tab*2 + '<div class="atom">' + print tab*3 + '<a href="?feed=atom" class="atom_link">atom</a>' + print tab*2 + '</div>' print '' # Staticpages @@ -377,10 +379,10 @@ else: staticpages = [] staticpages_list = glob.glob(staticpages_dir + '*') staticpages_list.sort() - print ' <div class="pages">' - print ' <div class="pages_title">' + blog_locale[0] + '</div>' - print ' <div class="pages_list">' - print ' <ul class="pages_list">' + print tab*2 + '<div class="pages">' + print tab*3 + '<div class="pages_title">' + blog_locale[0] + '</div>' + print tab*3 + '<div class="pages_list">' + print tab*4 + '<ul class="pages_list">' for staticpage in staticpages_list: file = open(staticpage, 'r') header = file.readline() @@ -391,55 +393,55 @@ else: link = '?s=' + link file.close() title = re.sub('\w+?\/\d+?-', '', staticpage) - print ' <li class="pages_list_entry"><a href="' + link + '" class="pages_list_entry">' + title + '</a></li>' - print ' </ul>' - print ' </div>' - print ' <div class="pages_footer"></div>' - print ' </div>' + print tab*5 + '<li class="pages_list_entry"><a href="' + link + '" class="pages_list_entry">' + title + '</a></li>' + print tab*4 + '</ul>' + print tab*3 + '</div>' + print tab*3 + '<div class="pages_footer"></div>' + print tab*2 + '</div>' print '' # Monthlist if monthlist == "True": olddate = "" - print ' <div class="months">' - print ' <div class="months_title">' + blog_locale[1] + '</div>' - print ' <div class="months_list">' - print ' <ul class="months_list">' + print tab*2 + '<div class="months">' + print tab*3 + '<div class="months_title">' + blog_locale[1] + '</div>' + print tab*3 + '<div class="months_list">' + print tab*4 + '<ul class="months_list">' for entry in entries: date = time.strftime("%m%Y", entry[0]) date_display = time.strftime("%h %Y", entry[0]) 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 - print ' </ul>' - print ' </div>' - print ' <div class="months_footer"></div>' - print ' </div>' + print tab*4 + '</ul>' + print tab*3 + '</div>' + print tab*3 + '<div class="months_footer"></div>' + print tab*2 + '</div>' print '' # Linklist if linklist == "True": - print ' <div class="linklist">' - print ' <div class="linklist_title">' + blog_locale[2] + '</div>' - print ' <div class="linklist_list">' - print ' <ul class="linklist_list">' + print tab*2 + '<div class="linklist">' + print tab*3 + '<div class="linklist_title">' + blog_locale[2] + '</div>' + print tab*3 + '<div class="linklist_list">' + print tab*4 + '<ul class="linklist_list">' try: content = open("linklist", "r") for line in content: if line.strip() is "": print '<br />' 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() except: print '' - print ' </ul>' - print ' </div>' - print ' <div class="linklist_footer"></div>' - print ' </div>' + print tab*4 + '</ul>' + print tab*3 + '</div>' + print tab*3 + '<div class="linklist_footer"></div>' + print tab*2 + '</div>' print '' - print ' <div class="entries">' + print tab*2 + '<div class="entries">' print '' # Staticpage |