* Add sidebar

* Fix style issues
* Import stuff from my private design
This commit is contained in:
Stefan Ritter 2012-01-21 17:52:57 +01:00
parent fdc2d7efc0
commit 9aec5ab42e
3 changed files with 88 additions and 55 deletions

View File

@ -26,6 +26,7 @@ from glob import glob
from random import randint from random import randint
from codecs import getwriter from codecs import getwriter
from optparse import OptionParser from optparse import OptionParser
from operator import itemgetter
# print() will output ascii, but we want utf-8 (python3) # print() will output ascii, but we want utf-8 (python3)
try: try:
@ -121,6 +122,8 @@ try:
comments = configuration.get("look", "comments") comments = configuration.get("look", "comments")
newest_first = configuration.get("look", "newest_first") newest_first = configuration.get("look", "newest_first")
tags = configuration.get("look", "tags") tags = configuration.get("look", "tags")
taglist = configuration.get("look", "taglist")
tags_max = configuration.get("look", "tags_max")
new_comment_mail = configuration.get("smtp", "new_comment_mail") new_comment_mail = configuration.get("smtp", "new_comment_mail")
mail_to = configuration.get("smtp", "mail_to") mail_to = configuration.get("smtp", "mail_to")
smtp_host = configuration.get("smtp", "smtp_host") smtp_host = configuration.get("smtp", "smtp_host")
@ -161,7 +164,8 @@ if language == "de":
"Text", "Text",
"Absenden", "Absenden",
"Neuer Kommentar zu", "Neuer Kommentar zu",
"Jemand hat einen Kommentar zu diesem Beitrag verfasst:" "Jemand hat einen Kommentar zu diesem Beitrag verfasst:",
"Tags"
) )
locales_de = ("de_DE.UTF-8", "de_DE.@euro", "de_DE") locales_de = ("de_DE.UTF-8", "de_DE.@euro", "de_DE")
for i in locales_de: for i in locales_de:
@ -183,7 +187,8 @@ else:
"View all entries...", "View all entries...",
"name", "text", "name", "text",
"commit", "New comment on", "commit", "New comment on",
"Someone wrote a comment to this entry:" "Someone wrote a comment to this entry:",
"tags"
) )
locales_en = ("en_US.UTF-8", "en_US.ISO-8859-15", "en_US") locales_en = ("en_US.UTF-8", "en_US.ISO-8859-15", "en_US")
for i in locales_en: for i in locales_en:
@ -477,7 +482,6 @@ else:
print(ind + "</head>") print(ind + "</head>")
print(ind + "<body>") print(ind + "<body>")
print("")
# Plugins # Plugins
sys.path.append(plugins_dir) sys.path.append(plugins_dir)
@ -534,35 +538,18 @@ else:
print(ind*5 + "<li class=\"pages_list_entry\"><a href=\"%s\" class=\"pages_list_entry\">%s</a></li>" % (link, title)) print(ind*5 + "<li class=\"pages_list_entry\"><a href=\"%s\" class=\"pages_list_entry\">%s</a></li>" % (link, title))
print(ind*4 + "</ul>") print(ind*4 + "</ul>")
print(ind*3 + "</div>") print(ind*3 + "</div>")
print(ind*3 + "<div class=\"pages_footer\"></div>")
print(ind*2 + "</div>") print(ind*2 + "</div>")
print("") print("")
# Monthlist # Sidebar starts here
if monthlist == "True": print(ind*2 + "<div class=\"sidebar\">")
olddate = ""
print(ind*2 + "<div class=\"months\">")
print(ind*3 + "<div class=\"months_title\">%s</div>" % blog_locale[1])
print(ind*3 + "<div class=\"months_list\">")
print(ind*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(ind*5 + "<li class=\"months_list_entry\"><a href=\"?m=%s\" class=\"months_list_entry\">%s</a></li>" % (date, date_display))
olddate = date
print(ind*4 + "</ul>")
print(ind*3 + "</div>")
print(ind*3 + "<div class=\"months_footer\"></div>")
print(ind*2 + "</div>")
print("")
# Linklist # Linklist
if linklist == "True": if linklist == "True":
print(ind*2 + "<div class=\"linklist\">") print(ind*3 + "<div class=\"linklist\">")
print(ind*3 + "<div class=\"linklist_title\">%s</div>" % blog_locale[2]) print(ind*4 + "<div class=\"linklist_title\">%s</div>" % blog_locale[2])
print(ind*3 + "<div class=\"linklist_list\">") print(ind*4 + "<div class=\"linklist_list\">")
print(ind*4 + "<ul class=\"linklist_list\">") print(ind*5 + "<ul class=\"linklist_list\">")
try: try:
if utf8: if utf8:
content = open("linklist", "r", encoding="utf8") content = open("linklist", "r", encoding="utf8")
@ -572,19 +559,65 @@ else:
if line.strip() is "": if line.strip() is "":
print("<br />") print("<br />")
else: else:
print(ind*5 + "<li class=\"linklist_list_entry\"><a href=\"%s\" class=\"months_list_entry\">%s</a></li>" % (line.split(" ")[0], line.split(" ", 1)[1].strip())) print(ind*6 + "<li class=\"linklist_list_entry\"><a href=\"%s\" class=\"linklist_list_entry\">%s</a></li>" % (line.split(" ")[0], line.split(" ", 1)[1].strip()))
content.close() content.close()
except: except:
print("") print("")
print(ind*4 + "</ul>") print(ind*5 + "</ul>")
print(ind*4 + "</div>")
print(ind*3 + "</div>") print(ind*3 + "</div>")
print(ind*3 + "<div class=\"linklist_footer\"></div>")
print(ind*2 + "</div>")
print("") print("")
print(ind*2 + "<div class=\"entries\">") # Taglist
if taglist == "True":
print(ind*3 + "<div class=\"taglist\">")
print(ind*4 + "<div class=\"taglist_title\">%s</div>" % blog_locale[11])
print(ind*4 + "<div class=\"taglist_list\">")
print(ind*5 + "<ul class=\"taglist_list\">")
tagfile = open(os.path.join(entries_dir, "tags"), "r")
content = pickle.load(tagfile)
tagfile.close()
taglist = []
for item in content:
taglist.append(item[0])
tagcloud = {}
for item in taglist:
tagcloud.setdefault(item, taglist.count(item))
tagcloud = sorted(tagcloud.items(), key=itemgetter(1), reverse=True)
count = 0
for item, value in tagcloud:
print(ind*6 + "<li class=\"taglist_list_entry\"><a href=\"?t=%s\" class=\"taglist_list_entry\">%s</a> <small>(%s)</small></li>" % (item, item, value))
count += 1
if count > int(tags_max):
break
print(ind*5 + "</ul>")
print(ind*4 + "</div>")
print(ind*3 + "</div>")
# Monthlist
if monthlist == "True":
olddate = ""
print(ind*3 + "<div class=\"monthlist\">")
print(ind*4 + "<div class=\"monthlist_title\">%s</div>" % blog_locale[1])
print(ind*4 + "<div class=\"monthlist_list\">")
print(ind*5 + "<ul class=\"monthlist_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(ind*6 + "<li class=\"monthlist_list_entry\"><a href=\"?m=%s\" class=\"monthlist_list_entry\">%s</a></li>" % (date, date_display))
olddate = date
print(ind*5 + "</ul>")
print(ind*4 + "</div>")
print(ind*3 + "</div>")
print("") print("")
# Sidebar ends here
print(ind*2 + "</div>")
print(ind*2 + "")
print(ind*2 + "<div class=\"entries\">")
# Staticpage # Staticpage
if static_display != "": if static_display != "":
if utf8: if utf8:

View File

@ -7,10 +7,9 @@ body, html {
background: white; background: white;
width: 700px; width: 700px;
margin: auto; margin: auto;
font-family: sans-serif; font-family: "PT Sans Narrow", sans-serif;
font-size: 0.9em; font-size: 12pt;
color: #000; color: #000;
letter-spacing: 0.05em;
} }
img { img {
@ -18,7 +17,7 @@ img {
} }
a { a {
color: #999; color: #666;
text-decoration: none; text-decoration: none;
} }
@ -30,13 +29,13 @@ a {
.rss { .rss {
position: absolute; position: absolute;
top: 72px; top: 82px;
width: 700px; width: 700px;
} }
.atom { .atom {
position: absolute; position: absolute;
top: 72px; top: 82px;
margin-left: 20px; margin-left: 20px;
width: 700px; width: 700px;
} }
@ -88,25 +87,21 @@ a {
color: black; color: black;
} }
.sidebar {
.months {
width: 700px;
}
.months_list_entry {
list-style-type: none;
display: inline;
text-decoration: none;
font-size: 0.8em;
color: #666;
}
.linklist {
position: absolute; position: absolute;
right: 0px; right: 100px;
padding-right: 10px; top: 84px;
} }
.linklist_title, .taglist_title, .monthlist_title {
padding-top: 30px;
}
.linklist_list, .taglist_list, .monthlist_list {
padding-top: 5px;
}
.entries { .entries {
padding-top: 20px; padding-top: 20px;
width: 700px; width: 700px;
@ -118,11 +113,15 @@ a {
.entry_title, .entry_title a, .comment_author { .entry_title, .entry_title a, .comment_author {
font-weight: bold; font-weight: bold;
font-style: italic;
color: black; color: black;
} }
.entry_date, .comment_date, .tags { .entry_date, .comment_date {
font-size: 0.8em;
color: #666;
}
.tags {
font-size: 0.8em; font-size: 0.8em;
color: #666; color: #666;
} }

View File

@ -0,0 +1 @@
<link href="http://fonts.googleapis.com/css?family=PT+Sans+Narrow:400,700" rel="stylesheet" type="text/css" />