2009-06-01 03:36:30 +02:00
|
|
|
#!/usr/bin/python
|
2009-11-01 15:41:17 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2009-06-01 03:36:30 +02:00
|
|
|
|
2009-07-29 20:17:16 +02:00
|
|
|
# This program is free software. It comes without any warranty, to
|
2009-02-28 18:02:23 +01:00
|
|
|
# the extent permitted by applicable law. You can redistribute it
|
|
|
|
# and/or modify it under the terms of the Do What The Fuck You Want
|
|
|
|
# To Public License, Version 2, as published by Sam Hocevar. See
|
|
|
|
# http://sam.zoy.org/wtfpl/COPYING for more details.
|
|
|
|
|
2009-05-17 23:19:07 +02:00
|
|
|
# Authors: Stefan Ritter <xeno@thehappy.de>
|
|
|
|
# Adrian Vondendriesch <disco-stu@disco-stu.de>
|
2009-12-03 22:19:56 +01:00
|
|
|
# Pascal Turbing <pascal@turbing.de>
|
2010-12-14 09:42:38 +01:00
|
|
|
#
|
2009-03-01 13:55:09 +01:00
|
|
|
# Description: A simple blogging software
|
|
|
|
|
2010-02-17 11:16:00 +01:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import time
|
|
|
|
import locale
|
|
|
|
import re
|
2012-01-21 02:17:42 +01:00
|
|
|
import pickle
|
2011-08-25 21:03:52 +02:00
|
|
|
from cgi import FieldStorage
|
|
|
|
from smtplib import SMTP
|
|
|
|
from hashlib import md5
|
|
|
|
from glob import glob
|
|
|
|
from random import randint
|
|
|
|
from codecs import getwriter
|
2012-01-21 00:42:23 +01:00
|
|
|
from optparse import OptionParser
|
2011-05-18 22:56:50 +02:00
|
|
|
|
2011-05-18 23:05:51 +02:00
|
|
|
# print() will output ascii, but we want utf-8 (python3)
|
|
|
|
try:
|
2011-08-25 21:03:52 +02:00
|
|
|
sys.stdout = getwriter('utf8')(sys.stdout.buffer)
|
2011-05-19 11:36:00 +02:00
|
|
|
utf8 = True
|
2011-05-18 23:05:51 +02:00
|
|
|
except:
|
2011-05-19 11:36:00 +02:00
|
|
|
utf8 = False
|
2011-03-23 22:53:59 +01:00
|
|
|
|
|
|
|
# Backward compatibilty to python2
|
|
|
|
try:
|
2011-03-24 13:05:22 +01:00
|
|
|
import configparser as configparser
|
|
|
|
except ImportError:
|
|
|
|
import ConfigParser as configparser
|
2011-03-23 22:53:59 +01:00
|
|
|
|
2009-12-06 21:50:12 +01:00
|
|
|
# A wonderful place for doing some regexp ;)
|
2010-12-14 11:26:21 +01:00
|
|
|
no_break = re.compile("^\s*(<ul|</ul>|<li|</li>|<ol|</ol>|<table|</table>|<tr|</tr>|<td|</td>|<th|</th>|<p|</p>).*$")
|
2010-12-14 09:42:38 +01:00
|
|
|
line_start_hyphen = re.compile("^-.*$")
|
2010-12-14 11:26:21 +01:00
|
|
|
line_start_plus = re.compile("^\+.*$")
|
2009-12-06 21:50:12 +01:00
|
|
|
|
2011-07-14 12:12:43 +02:00
|
|
|
# HTML indention
|
2011-07-12 09:11:21 +02:00
|
|
|
ind = "\t"
|
2010-11-15 17:50:11 +01:00
|
|
|
|
2011-07-14 12:12:43 +02:00
|
|
|
# Generate md5sum for feeds
|
2009-03-28 14:30:02 +01:00
|
|
|
def generate_uuid(string):
|
2011-03-23 23:55:14 +01:00
|
|
|
string_md5sum = md5(string.encode("utf-8")).hexdigest()
|
2010-12-14 11:26:21 +01:00
|
|
|
string = str.join("-", (string_md5sum[0:8], string_md5sum[8:12], string_md5sum[12:16], string_md5sum[16:20], string_md5sum[20:32]))
|
|
|
|
return string
|
2009-03-28 14:30:02 +01:00
|
|
|
|
2011-07-14 12:12:43 +02:00
|
|
|
# Custom errorpage
|
2009-04-10 12:05:01 +02:00
|
|
|
def errorpage(string):
|
2011-03-22 22:54:47 +01:00
|
|
|
document_header("html")
|
2011-03-23 14:57:43 +01:00
|
|
|
print("<head>")
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind + "<title>Error!</title>")
|
|
|
|
print(ind + "<link rel=\"stylesheet\" type=\"text/css\" href=\"error.css\" />")
|
2011-03-23 14:57:43 +01:00
|
|
|
print("</head>")
|
|
|
|
print("<body>")
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind + "<div class=\"container\">")
|
|
|
|
print(ind*2 + "<div class=\"title\"><h1>Error!</h1></div>")
|
|
|
|
print(ind*2 + "<div class=\"text\"><h2>" + string + "</h2></div>")
|
|
|
|
print(ind + "</div>")
|
2011-03-23 14:57:43 +01:00
|
|
|
print("</body>")
|
|
|
|
print("</html>")
|
2010-12-14 11:26:21 +01:00
|
|
|
sys.exit()
|
2009-03-28 14:30:02 +01:00
|
|
|
|
2011-07-14 12:12:43 +02:00
|
|
|
# Header for html, atom and rss
|
2009-04-30 10:26:56 +02:00
|
|
|
def document_header(string):
|
2011-03-22 22:54:47 +01:00
|
|
|
if string == "html":
|
2011-03-23 14:57:43 +01:00
|
|
|
print("Content-type: text/html\n")
|
|
|
|
print("<!DOCTYPE html>")
|
2011-03-22 23:18:16 +01:00
|
|
|
try:
|
2011-03-23 14:57:43 +01:00
|
|
|
print("<html lang=\"" + language + "\">")
|
2011-03-22 23:18:16 +01:00
|
|
|
except NameError:
|
2011-03-23 14:57:43 +01:00
|
|
|
print("<html lang=\"en\">")
|
2010-12-14 11:26:21 +01:00
|
|
|
if string == "atom":
|
2011-03-23 14:57:43 +01:00
|
|
|
print("Content-type: application/atom+xml\n")
|
|
|
|
print("<?xml version=\"1.0\" encoding=\"utf-8\"?>")
|
|
|
|
print("<feed xmlns=\"http://www.w3.org/2005/Atom\">")
|
2010-12-14 11:26:21 +01:00
|
|
|
if string == "rss":
|
2011-03-23 14:57:43 +01:00
|
|
|
print("Content-type: application/rss+xml\n")
|
|
|
|
print("<?xml version=\"1.0\" encoding=\"utf-8\"?>")
|
|
|
|
print("<rss version=\"2.0\">")
|
2010-12-14 09:42:38 +01:00
|
|
|
|
2011-03-23 22:53:59 +01:00
|
|
|
# Parse configuration (with backward compatibilty)
|
2011-03-24 13:05:22 +01:00
|
|
|
configuration = configparser.SafeConfigParser()
|
2009-12-06 17:03:28 +01:00
|
|
|
|
2010-12-14 09:42:38 +01:00
|
|
|
for config in ["../blogthonrc", "../.blogthonrc", "configuration"]:
|
2010-12-14 11:26:21 +01:00
|
|
|
if os.path.exists(config):
|
|
|
|
configuration.read(config)
|
|
|
|
config = True
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
config = False
|
2010-12-14 09:42:38 +01:00
|
|
|
|
|
|
|
if not config:
|
2010-12-14 11:26:21 +01:00
|
|
|
errorpage("No suitable configuration found!")
|
2009-02-28 18:02:23 +01:00
|
|
|
|
2010-12-14 11:26:21 +01:00
|
|
|
try:
|
|
|
|
blog_title = configuration.get("personal", "blog_title")
|
|
|
|
blog_subtitle = configuration.get("personal", "blog_subtitle")
|
|
|
|
blog_url = configuration.get("personal", "blog_url")
|
|
|
|
keywords = configuration.get("personal", "keywords")
|
|
|
|
entries_dir = configuration.get("personal", "entries_dir")
|
2010-12-14 16:16:12 +01:00
|
|
|
entries_suffix = configuration.get("personal", "entries_suffix")
|
|
|
|
staticpages_dir = configuration.get("personal", "staticpages_dir")
|
|
|
|
plugins_dir = configuration.get("personal", "plugins_dir")
|
|
|
|
style = configuration.get("look", "style")
|
|
|
|
language = configuration.get("look", "language")
|
|
|
|
entries_per_page = configuration.getint("look", "entries_per_page")
|
|
|
|
monthlist = configuration.get("look", "monthlist")
|
|
|
|
staticpages = configuration.get("look", "staticpages")
|
|
|
|
linklist = configuration.get("look", "linklist")
|
|
|
|
permalinks = configuration.get("look", "permalinks")
|
|
|
|
comments = configuration.get("look", "comments")
|
|
|
|
newest_first = configuration.get("look", "newest_first")
|
2012-01-21 01:44:39 +01:00
|
|
|
tags = configuration.get("look", "tags")
|
2010-12-14 16:16:12 +01:00
|
|
|
new_comment_mail = configuration.get("smtp", "new_comment_mail")
|
|
|
|
mail_to = configuration.get("smtp", "mail_to")
|
|
|
|
smtp_host = configuration.get("smtp", "smtp_host")
|
|
|
|
feed_preview = configuration.get("feed", "feed_preview")
|
2011-03-23 22:48:21 +01:00
|
|
|
except configparser.Error as error:
|
2010-12-14 16:16:12 +01:00
|
|
|
errorpage(str(error))
|
2009-05-22 10:18:04 +02:00
|
|
|
|
2010-12-16 11:11:41 +01:00
|
|
|
if not re.match("^http:\/\/.*$", blog_url):
|
|
|
|
blog_url = "http://" + blog_url
|
|
|
|
|
|
|
|
if not re.match("^.*\/$", blog_url):
|
|
|
|
blog_url = blog_url + "/"
|
|
|
|
|
2009-05-22 10:18:04 +02:00
|
|
|
if not os.path.exists(entries_dir):
|
2010-12-16 11:11:41 +01:00
|
|
|
errorpage("Directory \"%s\" does not exist!" % entries_dir)
|
2009-05-22 10:18:04 +02:00
|
|
|
|
2011-02-07 23:03:23 +01:00
|
|
|
if not os.access(entries_dir, os.W_OK):
|
|
|
|
errorpage("Directory \"%s\" is not writable!" % entries_dir)
|
|
|
|
|
2009-05-22 10:18:04 +02:00
|
|
|
if not os.path.exists(staticpages_dir):
|
2010-12-16 11:11:41 +01:00
|
|
|
errorpage("Directory \"%s\" does not exist!" % staticpages_dir)
|
2009-05-22 10:18:04 +02:00
|
|
|
|
2009-12-07 00:32:35 +01:00
|
|
|
if not os.path.exists(plugins_dir):
|
2010-12-16 11:11:41 +01:00
|
|
|
errorpage("Directory \"%s\" does not exist!" % plugins_dir)
|
2010-12-14 11:26:21 +01:00
|
|
|
|
2010-12-14 16:16:12 +01:00
|
|
|
if not os.path.exists("linklist"):
|
|
|
|
errorpage("File \"linklist\" does not exist!")
|
2009-05-22 10:18:04 +02:00
|
|
|
|
2010-02-17 11:16:00 +01:00
|
|
|
if language == "de":
|
2011-07-14 12:12:43 +02:00
|
|
|
blog_locale = (
|
|
|
|
"Seiten",
|
|
|
|
"Monate",
|
|
|
|
"Links",
|
|
|
|
"Keine Kommentare",
|
|
|
|
"Kommentare",
|
|
|
|
"Alle Einträge anzeigen...",
|
|
|
|
"Name",
|
|
|
|
"Text",
|
|
|
|
"Absenden",
|
|
|
|
"Neuer Kommentar zu",
|
|
|
|
"Jemand hat einen Kommentar zu diesem Beitrag verfasst:"
|
|
|
|
)
|
2010-12-14 11:26:21 +01:00
|
|
|
locales_de = ("de_DE.UTF-8", "de_DE.@euro", "de_DE")
|
|
|
|
for i in locales_de:
|
|
|
|
try:
|
|
|
|
locale.setlocale(locale.LC_TIME, i)
|
|
|
|
break
|
|
|
|
except:
|
|
|
|
continue
|
|
|
|
else:
|
|
|
|
locale.setlocale(locale.LC_TIME, None)
|
2010-02-17 11:16:00 +01:00
|
|
|
|
2010-02-17 09:26:59 +01:00
|
|
|
else:
|
2011-07-14 12:12:43 +02:00
|
|
|
blog_locale = (
|
|
|
|
"pages",
|
|
|
|
"months",
|
|
|
|
"links",
|
|
|
|
"no comments",
|
|
|
|
"comments",
|
|
|
|
"View all entries...",
|
|
|
|
"name", "text",
|
|
|
|
"commit", "New comment on",
|
|
|
|
"Someone wrote a comment to this entry:"
|
|
|
|
)
|
2010-12-14 11:26:21 +01:00
|
|
|
locales_en = ("en_US.UTF-8", "en_US.ISO-8859-15", "en_US")
|
|
|
|
for i in locales_en:
|
|
|
|
try:
|
|
|
|
locale.setlocale(locale.LC_TIME, i)
|
|
|
|
break
|
|
|
|
except:
|
|
|
|
continue
|
|
|
|
else:
|
|
|
|
locale.setlocale(locale.LC_TIME, None)
|
|
|
|
|
2012-01-21 00:42:23 +01:00
|
|
|
# Commandline arguments
|
|
|
|
parser = OptionParser()
|
|
|
|
parser.add_option("-i", "--info", help="show statistics about your blog", action="store_true", dest="info")
|
|
|
|
parser.add_option("-t", "--tags", help="read all tags and create new index", action="store_true", dest="tags")
|
|
|
|
options, args = parser.parse_args()
|
|
|
|
|
|
|
|
if vars(options).values().count(True) > 1:
|
|
|
|
print("Too much arguments, just take one!")
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
if options.info:
|
|
|
|
num_entries = len(glob(os.path.join(entries_dir, "*." + entries_suffix)))
|
|
|
|
num_comments = 0
|
|
|
|
comments = glob(os.path.join(entries_dir, "*.comments"))
|
|
|
|
for file in comments:
|
|
|
|
content = open(file, "r")
|
|
|
|
for line in content:
|
|
|
|
if line.startswith("-"):
|
|
|
|
num_comments += 1
|
|
|
|
content.close()
|
|
|
|
print("Number of entries: %s" % num_entries)
|
|
|
|
print("Number of comments: %s" % num_comments)
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
if options.tags:
|
2012-01-21 02:14:21 +01:00
|
|
|
try:
|
|
|
|
tagindex = []
|
|
|
|
entries = glob(os.path.join(entries_dir, "*." + entries_suffix))
|
|
|
|
for entry in entries:
|
|
|
|
content = open(entry, "r")
|
|
|
|
tagline = content.readline().strip()
|
|
|
|
if re.match(line_start_plus, tagline):
|
|
|
|
taglist = tagline.split("+")[1:]
|
|
|
|
for tag in taglist:
|
|
|
|
tagindex.append([tag.strip(), entry])
|
|
|
|
content.close()
|
|
|
|
tagfile = open(os.path.join(entries_dir, "tags"), "w")
|
2012-01-21 02:17:42 +01:00
|
|
|
pickle.dump(tagindex, tagfile)
|
2012-01-21 02:14:21 +01:00
|
|
|
tagfile.close()
|
|
|
|
print("Index created!")
|
|
|
|
except:
|
|
|
|
print("Error creating index!")
|
2012-01-21 00:42:23 +01:00
|
|
|
sys.exit(0)
|
|
|
|
|
2011-07-14 12:12:43 +02:00
|
|
|
# Read POST variables
|
2010-11-20 20:01:08 +01:00
|
|
|
action = FieldStorage()
|
2010-12-14 09:42:38 +01:00
|
|
|
month_display = action.getvalue("m")
|
2009-07-21 17:27:23 +02:00
|
|
|
|
2010-12-14 09:42:38 +01:00
|
|
|
static_display = action.getvalue("s")
|
2010-12-14 11:26:21 +01:00
|
|
|
if static_display:
|
|
|
|
static_display = static_display.replace("/", "")
|
2009-07-21 17:27:23 +02:00
|
|
|
|
2010-12-14 09:42:38 +01:00
|
|
|
post_display = action.getvalue("p")
|
2010-12-14 11:26:21 +01:00
|
|
|
if post_display:
|
|
|
|
post_display = post_display.replace(" ", "-").replace("/", "")
|
2009-07-21 17:27:23 +02:00
|
|
|
|
2010-12-14 09:42:38 +01:00
|
|
|
allentries_display = action.getvalue("a")
|
|
|
|
feed_display = action.getvalue("feed")
|
2010-12-14 11:26:21 +01:00
|
|
|
|
|
|
|
if not month_display:
|
|
|
|
month_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 = ""
|
2009-02-28 18:02:23 +01:00
|
|
|
|
2010-12-14 09:42:38 +01:00
|
|
|
ctitle = action.getvalue("ctitle")
|
|
|
|
cname = action.getvalue("cname")
|
|
|
|
ctext = action.getvalue("ctext")
|
|
|
|
cquiz = action.getvalue("cquiz")
|
|
|
|
cquizv = action.getvalue("cquizv")
|
2010-12-14 11:26:21 +01:00
|
|
|
|
|
|
|
if not ctitle:
|
|
|
|
ctitle = ""
|
|
|
|
if not cname:
|
|
|
|
cname = ""
|
|
|
|
if not ctext:
|
|
|
|
ctext = ""
|
|
|
|
if not cquiz:
|
|
|
|
cquiz = ""
|
|
|
|
if not cquizv:
|
|
|
|
cquizv = ""
|
2009-03-08 19:17:59 +01:00
|
|
|
|
2011-07-14 12:12:43 +02:00
|
|
|
# Commit comment
|
2009-03-08 19:17:59 +01:00
|
|
|
if cname and ctext and ctitle:
|
2010-12-14 11:26:21 +01:00
|
|
|
# Prevent XSS hacks
|
|
|
|
cname = cname.replace("<", "<").replace(">", ">").replace("\'", """)
|
|
|
|
ctext = ctext.replace("<", "<").replace(">", ">").replace("\'", """)
|
|
|
|
|
|
|
|
if not cquiz == cquizv:
|
2011-07-14 12:12:43 +02:00
|
|
|
errorpage("Brainmode") # Captcha not solved
|
2010-12-14 11:26:21 +01:00
|
|
|
else:
|
|
|
|
comments_file = os.path.join(entries_dir, ctitle + ".comments")
|
|
|
|
if not os.path.exists(comments_file):
|
2011-05-19 11:36:00 +02:00
|
|
|
if utf8:
|
|
|
|
content = open(comments_file, "w", encoding="utf8")
|
|
|
|
else:
|
|
|
|
content = open(comments_file, "w")
|
2010-12-14 11:26:21 +01:00
|
|
|
content.close()
|
|
|
|
|
2011-05-19 11:36:00 +02:00
|
|
|
if utf8:
|
|
|
|
content = open(comments_file, "a", encoding="utf8")
|
|
|
|
else:
|
|
|
|
content = open(comments_file, "a")
|
2011-02-07 23:06:10 +01:00
|
|
|
content.write("-." + cname + "\n")
|
|
|
|
content.write("+." + time.strftime("%c", time.localtime()) + "\n")
|
|
|
|
ctext = ctext.split("\n")
|
|
|
|
for line in ctext:
|
|
|
|
content.write("." + line + "\n")
|
|
|
|
content.close()
|
|
|
|
|
2011-07-14 12:12:43 +02:00
|
|
|
# Send mail
|
2011-02-07 23:06:10 +01:00
|
|
|
if not new_comment_mail == "False":
|
2011-07-14 12:12:43 +02:00
|
|
|
msg = "From: Blogthon\nTo: %s\nSubject: %s %s\n\n%s %s?p=%s" % (mail_to, blog_locale[9], blog_title, blog_locale[10], blog_url, ctitle.replace(" ", "-"))
|
2011-02-07 23:06:10 +01:00
|
|
|
smtp = SMTP(smtp_host)
|
|
|
|
smtp.starttls()
|
|
|
|
smtp.sendmail(blog_title, mail_to, msg)
|
2011-02-07 23:07:33 +01:00
|
|
|
smtp.quit()
|
2009-03-08 19:17:59 +01:00
|
|
|
|
2009-03-24 20:37:21 +01:00
|
|
|
# Read entries and store their title and timestamp
|
2010-12-14 11:26:21 +01:00
|
|
|
entries = []
|
|
|
|
entries_list = glob(os.path.join(entries_dir, "*." + entries_suffix))
|
2009-02-28 18:02:23 +01:00
|
|
|
|
|
|
|
for entry in entries_list:
|
2010-12-14 11:26:21 +01:00
|
|
|
title = entry.replace(entries_dir, "", 1)
|
|
|
|
title = title.replace("." + entries_suffix, "")
|
|
|
|
|
|
|
|
stampfile = os.path.join(entries_dir, title + ".stamp")
|
|
|
|
if os.path.exists(stampfile):
|
|
|
|
timestamp = os.stat(stampfile)
|
|
|
|
else:
|
|
|
|
timestamp = os.stat(entry)
|
|
|
|
stampfile = os.path.join(entries_dir, title + ".stamp")
|
|
|
|
stamp = open(stampfile, "w")
|
|
|
|
stamp.close()
|
|
|
|
utime = os.utime(stampfile, (os.stat(entry)[8], os.stat(entry)[8]))
|
|
|
|
|
|
|
|
timestamp = time.localtime(timestamp[8])
|
|
|
|
entry = timestamp, entry
|
|
|
|
entries.append(entry)
|
2009-02-28 18:02:23 +01:00
|
|
|
|
|
|
|
if newest_first:
|
2010-12-14 11:26:21 +01:00
|
|
|
entries.sort(reverse=True)
|
2009-02-28 18:02:23 +01:00
|
|
|
else:
|
2010-12-14 11:26:21 +01:00
|
|
|
entries.sort()
|
2009-02-28 18:02:23 +01:00
|
|
|
|
2009-03-24 20:37:21 +01:00
|
|
|
# Generate atom feed
|
|
|
|
if feed_display == "atom":
|
2010-12-14 11:26:21 +01:00
|
|
|
date = entries[0][0]
|
|
|
|
blog_title_md5sum = generate_uuid(blog_title)
|
|
|
|
|
|
|
|
# Append 0 to the beginning if len of integer is 1 (value<10)
|
|
|
|
month = "%(#)02d" % {"#": int(date[1])}
|
|
|
|
day = "%(#)02d" % {"#": int(date[2])}
|
|
|
|
hour = "%(#)02d" % {"#":int(date[3])}
|
|
|
|
min = "%(#)02d" % {"#": int(date[4])}
|
|
|
|
sec = "%(#)02d" % {"#": int(date[5])}
|
|
|
|
|
|
|
|
document_header("atom")
|
2011-03-23 14:57:43 +01:00
|
|
|
print("<link href=\"%s?feed=atom\" rel=\"self\" type=\"application/atom+xml\"/>" % blog_url)
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind + "<author>")
|
|
|
|
print(ind*2 + "<name>%s</name>" % blog_title)
|
|
|
|
print(ind + "</author>")
|
|
|
|
print(ind + "<title>%s</title>" % blog_title)
|
|
|
|
print(ind + "<id>urn:uuid:%s</id>" % blog_title_md5sum)
|
|
|
|
print(ind + "<updated>%s-%s-%sT%s:%s:%sZ</updated>" % (str(date[0]), month, day, hour, min, sec))
|
2011-03-23 14:57:43 +01:00
|
|
|
print("")
|
2010-12-14 11:26:21 +01:00
|
|
|
j = len(entries)
|
|
|
|
if j > 10: j = 10
|
2011-03-23 23:55:14 +01:00
|
|
|
for i in range(0, j):
|
2010-12-14 11:26:21 +01:00
|
|
|
title = str(entries[i][1]).replace(entries_dir, "", 1).replace("." + entries_suffix, "")
|
|
|
|
date = entries[i][0]
|
|
|
|
title_md5sum = generate_uuid(title)
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*2 + "<entry>")
|
|
|
|
print(ind*3 + "<title>%s</title>" % title)
|
|
|
|
print(ind*3 + "<link href=\"%s?p=%s\"/>" % (blog_url, title))
|
|
|
|
print(ind*3 + "<id>urn:uuid:%s</id>" % title_md5sum)
|
|
|
|
print(ind*3 + "<updated>%s-%s-%sT%s:%s:%sZ</updated>" % (str(date[0]), month, day, hour, min, sec))
|
|
|
|
print(ind*3 + "<summary>")
|
2011-05-19 11:36:00 +02:00
|
|
|
if utf8:
|
|
|
|
content = open(str(entries[i][1]), "r", encoding="utf8")
|
|
|
|
else:
|
|
|
|
content = open(str(entries[i][1]), "r")
|
2011-03-23 23:55:14 +01:00
|
|
|
for h in range(0, int(feed_preview)):
|
2010-12-14 11:26:21 +01:00
|
|
|
rss_line = content.readline().strip()
|
|
|
|
if rss_line != "":
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*4 + rss_line)
|
2010-12-14 11:26:21 +01:00
|
|
|
content.close()
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*3 + "</summary>")
|
|
|
|
print(ind*2 + "</entry>")
|
2011-03-23 14:57:43 +01:00
|
|
|
print("</feed>")
|
2009-03-24 20:37:21 +01:00
|
|
|
|
2009-06-05 10:56:00 +02:00
|
|
|
# Generate rss 2.0 feed
|
2009-06-05 20:36:39 +02:00
|
|
|
elif feed_display == "rss":
|
2010-12-14 11:26:21 +01:00
|
|
|
document_header("rss")
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind + "<channel>")
|
|
|
|
print(ind*2 + "<title>%s</title>" % blog_title)
|
|
|
|
print(ind*2 + "<link>%s</link>" % blog_url)
|
|
|
|
print(ind*2 + "<description>%s</description>" % blog_subtitle)
|
2010-12-14 11:26:21 +01:00
|
|
|
date = time.strftime("%a, %d %b %Y %H:%M:%S", time.gmtime(time.mktime(entries[0][0])))
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*2 + "<pubDate>%s</pubDate>" % date)
|
2011-03-23 14:57:43 +01:00
|
|
|
print("")
|
2010-12-14 11:26:21 +01:00
|
|
|
j = len(entries)
|
|
|
|
if j > 10: j = 10
|
2011-03-23 23:55:14 +01:00
|
|
|
for i in range(0, j):
|
2010-12-14 11:26:21 +01:00
|
|
|
title = str(entries[i][1]).replace(entries_dir, "", 1).replace("." + entries_suffix, "")
|
|
|
|
date = time.strftime("%a, %d %b %Y %H:%M:%S %z", time.gmtime(time.mktime(entries[i][0])))
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*2 + "<item>")
|
|
|
|
print(ind*3 + "<title>%s</title>" % title)
|
|
|
|
print(ind*3 + "<link>%s?p=%s</link>" % (blog_url, title))
|
|
|
|
print(ind*3 + "<guid>%s?p=%s</guid>" % (blog_url, title))
|
|
|
|
print(ind*3 + "<pubDate>%s</pubDate>" % date)
|
2011-05-19 11:36:00 +02:00
|
|
|
if utf8:
|
|
|
|
content = open(str(entries[i][1]), "r", encoding="utf8")
|
|
|
|
else:
|
|
|
|
content = open(str(entries[i][1]), "r")
|
2010-12-14 11:26:21 +01:00
|
|
|
rss_description= ""
|
2011-03-23 23:55:14 +01:00
|
|
|
for h in range(0, int(feed_preview)):
|
2010-12-14 11:26:21 +01:00
|
|
|
line = content.readline().strip()
|
|
|
|
if line:
|
2010-12-16 11:11:41 +01:00
|
|
|
rss_description = "%s%s<br />" % (rss_description, line)
|
2010-12-14 11:26:21 +01:00
|
|
|
content.close()
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*3 + "<description><![CDATA[%s]]></description>" % rss_description)
|
|
|
|
print(ind*2 + "</item>")
|
|
|
|
print(ind + "</channel>")
|
2011-03-23 14:57:43 +01:00
|
|
|
print("</rss>")
|
2009-06-05 10:56:00 +02:00
|
|
|
|
2009-03-24 20:37:21 +01:00
|
|
|
# Generate regular page
|
|
|
|
else:
|
2011-03-22 22:54:47 +01:00
|
|
|
document_header("html")
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind + "<head>")
|
|
|
|
print(ind*2 + "<title>%s</title>" % blog_title)
|
2012-01-19 04:59:13 +01:00
|
|
|
print(ind*2 + "<meta charset=\"utf-8\" />")
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*2 + "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />")
|
|
|
|
print(ind*2 + "<meta name=\"keywords\" content=\"%s\" />" % keywords)
|
|
|
|
print(ind*2 + "<meta name=\"description\" content=\"%s\" />" % blog_title)
|
|
|
|
print(ind*2 + "<link rel=\"stylesheet\" type=\"text/css\" href=\"styles/%s/%s.css\" />" % (style, style))
|
2012-01-18 20:07:23 +01:00
|
|
|
|
|
|
|
if os.path.exists("styles/" + style + "/favicon.png"):
|
|
|
|
icon_suffix = "png"
|
|
|
|
icon_type = "image/png"
|
|
|
|
elif os.path.exists("styles/" + style + "/favicon.gif"):
|
|
|
|
icon_suffix = "gif"
|
|
|
|
icon_type = "image/gif"
|
|
|
|
elif os.path.exists("styles/" + style + "/favicon.ico"):
|
|
|
|
icon_suffix = "ico"
|
|
|
|
icon_type = "image/x-icon"
|
|
|
|
else:
|
|
|
|
icon_type = None;
|
|
|
|
if icon_type:
|
|
|
|
print(ind*2 + "<link rel=\"icon\" href=\"styles/%s/favicon.%s\" type=\"%s\" />" % (style, icon_suffix, icon_type))
|
|
|
|
|
2012-01-19 04:59:13 +01:00
|
|
|
# Load additional header lines from style
|
|
|
|
if os.path.exists("styles/" + style + "/header.txt"):
|
|
|
|
content = open("styles/" + style + "/header.txt", "r")
|
|
|
|
for line in content:
|
|
|
|
print(ind*2 + line.strip())
|
|
|
|
content.close()
|
|
|
|
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind + "</head>")
|
|
|
|
print(ind + "<body>")
|
2011-03-24 00:02:41 +01:00
|
|
|
print("")
|
2010-12-14 11:26:21 +01:00
|
|
|
|
|
|
|
# Plugins
|
|
|
|
sys.path.append(plugins_dir)
|
|
|
|
for plugin in glob(plugins_dir + "*.py"):
|
|
|
|
__import__ (plugin.split("/")[1].replace(".py", ""))
|
|
|
|
|
|
|
|
# Site header
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*2 + "<div class=\"header\">")
|
|
|
|
print(ind*3 + "<div class=\"header_title\">")
|
|
|
|
print(ind*4 + "<a href=\"?\" class=\"header_link\">%s</a>" % blog_title)
|
|
|
|
print(ind*3 + "</div>")
|
|
|
|
print(ind*3 + "<div class=\"header_subtitle\">")
|
|
|
|
print(ind*4 + "<span class=\"header_subtitle\">%s</span>" % blog_subtitle)
|
|
|
|
print(ind*3 + "</div>")
|
|
|
|
print(ind*2 + "</div>")
|
2011-03-23 14:57:43 +01:00
|
|
|
print("")
|
2010-12-14 11:26:21 +01:00
|
|
|
|
|
|
|
# RSS feed
|
2011-07-12 09:15:38 +02:00
|
|
|
print(ind*2 + "<div class=\"feeds\">")
|
|
|
|
print(ind*3 + "<div class=\"rss\">")
|
|
|
|
print(ind*4 + "<a href=\"?feed=rss\" class=\"rss_link\">rss</a>")
|
|
|
|
print(ind*3 + "</div>")
|
2011-03-23 14:57:43 +01:00
|
|
|
print("")
|
2010-12-14 11:26:21 +01:00
|
|
|
|
|
|
|
# Atom feed
|
2011-07-12 09:15:38 +02:00
|
|
|
print(ind*3 + "<div class=\"atom\">")
|
|
|
|
print(ind*4 + "<a href=\"?feed=atom\" class=\"atom_link\">atom</a>")
|
|
|
|
print(ind*3 + "</div>")
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*2 + "</div>")
|
2011-03-23 14:57:43 +01:00
|
|
|
print("")
|
2010-12-14 11:26:21 +01:00
|
|
|
|
|
|
|
# Staticpages
|
|
|
|
if staticpages == "True":
|
|
|
|
staticpages = []
|
|
|
|
staticpages_list = glob(os.path.join(staticpages_dir, "*"))
|
|
|
|
staticpages_list.sort()
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*2 + "<div class=\"pages\">")
|
|
|
|
print(ind*3 + "<div class=\"pages_title\">%s</div>" % blog_locale[0])
|
|
|
|
print(ind*3 + "<div class=\"pages_list\">")
|
|
|
|
print(ind*4 + "<ul class=\"pages_list\">")
|
2010-12-14 11:26:21 +01:00
|
|
|
for staticpage in staticpages_list:
|
2011-05-19 11:36:00 +02:00
|
|
|
if utf8:
|
|
|
|
file = open(staticpage, "r", encoding="utf8")
|
|
|
|
else:
|
|
|
|
file = open(staticpage, "r")
|
2010-12-14 11:26:21 +01:00
|
|
|
header = file.readline()
|
|
|
|
if header.split(":", 1)[0] == "extern_link":
|
|
|
|
link = header.split(":", 1)[1].strip()
|
|
|
|
else:
|
|
|
|
link = re.sub("\w+?\/", "", staticpage)
|
2010-12-16 11:11:41 +01:00
|
|
|
link = "?s=%s" % link
|
2010-12-14 11:26:21 +01:00
|
|
|
file.close()
|
|
|
|
title = re.sub("\w+?\/\d+?-", "", staticpage)
|
2011-03-24 09:42:08 +01:00
|
|
|
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*3 + "</div>")
|
|
|
|
print(ind*3 + "<div class=\"pages_footer\"></div>")
|
|
|
|
print(ind*2 + "</div>")
|
2011-03-23 14:57:43 +01:00
|
|
|
print("")
|
2010-12-14 11:26:21 +01:00
|
|
|
|
|
|
|
# Monthlist
|
|
|
|
if monthlist == "True":
|
|
|
|
olddate = ""
|
2011-03-24 09:42:08 +01:00
|
|
|
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\">")
|
2010-12-14 11:26:21 +01:00
|
|
|
for entry in entries:
|
2010-12-16 11:11:41 +01:00
|
|
|
date = time.strftime("%m%Y", entry[0])
|
2010-12-14 11:26:21 +01:00
|
|
|
date_display = time.strftime("%h %Y", entry[0])
|
|
|
|
if not olddate == date:
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*5 + "<li class=\"months_list_entry\"><a href=\"?m=%s\" class=\"months_list_entry\">%s</a></li>" % (date, date_display))
|
2010-12-14 11:26:21 +01:00
|
|
|
olddate = date
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*4 + "</ul>")
|
|
|
|
print(ind*3 + "</div>")
|
|
|
|
print(ind*3 + "<div class=\"months_footer\"></div>")
|
|
|
|
print(ind*2 + "</div>")
|
2011-03-23 14:57:43 +01:00
|
|
|
print("")
|
2010-12-14 11:26:21 +01:00
|
|
|
|
|
|
|
# Linklist
|
|
|
|
if linklist == "True":
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*2 + "<div class=\"linklist\">")
|
|
|
|
print(ind*3 + "<div class=\"linklist_title\">%s</div>" % blog_locale[2])
|
|
|
|
print(ind*3 + "<div class=\"linklist_list\">")
|
|
|
|
print(ind*4 + "<ul class=\"linklist_list\">")
|
2010-12-14 11:26:21 +01:00
|
|
|
try:
|
2011-05-19 11:36:00 +02:00
|
|
|
if utf8:
|
|
|
|
content = open("linklist", "r", encoding="utf8")
|
|
|
|
else:
|
|
|
|
content = open("linklist", "r")
|
2010-12-14 11:26:21 +01:00
|
|
|
for line in content:
|
|
|
|
if line.strip() is "":
|
2011-03-23 14:57:43 +01:00
|
|
|
print("<br />")
|
2010-12-14 11:26:21 +01:00
|
|
|
else:
|
2011-03-24 09:42:08 +01:00
|
|
|
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()))
|
2010-12-14 11:26:21 +01:00
|
|
|
content.close()
|
|
|
|
except:
|
2011-03-23 14:57:43 +01:00
|
|
|
print("")
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*4 + "</ul>")
|
|
|
|
print(ind*3 + "</div>")
|
|
|
|
print(ind*3 + "<div class=\"linklist_footer\"></div>")
|
|
|
|
print(ind*2 + "</div>")
|
2011-03-23 14:57:43 +01:00
|
|
|
print("")
|
2010-12-14 11:26:21 +01:00
|
|
|
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*2 + "<div class=\"entries\">")
|
2011-03-23 14:57:43 +01:00
|
|
|
print("")
|
2010-12-14 11:26:21 +01:00
|
|
|
|
|
|
|
# Staticpage
|
|
|
|
if static_display != "":
|
2011-05-19 11:36:00 +02:00
|
|
|
if utf8:
|
|
|
|
content = open(os.path.join(staticpages_dir, static_display), "r", encoding="utf-8")
|
|
|
|
else:
|
|
|
|
content = open(os.path.join(staticpages_dir, static_display), "r")
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*3 + "<div class=\"entry\">")
|
|
|
|
print(ind*4 + "<div class=\"entry_title\">%s</div>" % re.sub("^\.", "", re.sub("\d+?-", "", static_display)))
|
|
|
|
print(ind*4 + "<div class=\"entry_content\">")
|
|
|
|
print(ind*5 + "<p>")
|
2010-12-14 11:26:21 +01:00
|
|
|
for line in content:
|
|
|
|
if no_break.match(line):
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*5 + line.strip())
|
2010-12-14 11:26:21 +01:00
|
|
|
else:
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*5 + line.strip() + "<br />")
|
|
|
|
print(ind*5 + "</p>")
|
|
|
|
print(ind*4 + "</div>")
|
|
|
|
print(ind*3 + "</div>")
|
2011-03-23 14:57:43 +01:00
|
|
|
print("")
|
2010-12-14 11:26:21 +01:00
|
|
|
content.close()
|
|
|
|
|
|
|
|
# Entry
|
|
|
|
else:
|
|
|
|
entry_counter = 0
|
|
|
|
for entry in entries:
|
|
|
|
date = time.strftime("%c", entry[0])
|
|
|
|
date_to_compare = time.strftime("%m%Y", entry[0]) # Needed for permalinks
|
|
|
|
entry = entry[1]
|
|
|
|
title = entry.replace(entries_dir, "", 1)
|
|
|
|
title = title.replace("." + entries_suffix, "")
|
|
|
|
|
|
|
|
stampfile = os.path.join(entries_dir, title + ".stamp")
|
|
|
|
if os.path.exists(stampfile):
|
|
|
|
date = time.localtime(os.stat(stampfile)[8])
|
|
|
|
date = time.strftime("%c", date)
|
|
|
|
|
|
|
|
if month_display == date_to_compare or not month_display:
|
|
|
|
if post_display == title.replace(" ", "-") or not post_display:
|
|
|
|
if allentries_display == "1" or entry_counter < entries_per_page:
|
2011-05-19 11:36:00 +02:00
|
|
|
if utf8:
|
|
|
|
content = open(entry, "r", encoding="utf8")
|
|
|
|
else:
|
|
|
|
content = open(entry, "r")
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*3 + "<div class=\"entry\">")
|
2010-12-14 11:26:21 +01:00
|
|
|
if permalinks:
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*4 + "<div class=\"entry_title\"><a href=\"?p=%s\" class=\"entry_title\">%s</a></div>" % (title.replace(" ", "-"), title))
|
2010-12-14 11:26:21 +01:00
|
|
|
else:
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*4 + "<div class=\"entry_title\">%s</div>" % title)
|
|
|
|
print(ind*4 + "<div class=\"entry_date\">%s</div>" % date)
|
2012-01-20 22:59:11 +01:00
|
|
|
|
|
|
|
# Read tags
|
2012-01-21 01:44:39 +01:00
|
|
|
tagline = content.readline().strip()
|
|
|
|
if re.match(line_start_plus, tagline):
|
|
|
|
tagline = tagline.replace("+", "")
|
|
|
|
if tags == "True":
|
|
|
|
print(ind*4 + "<div class=\"tags\"><b>Tags:</b> %s</div>" % tagline)
|
2012-01-20 22:59:11 +01:00
|
|
|
else:
|
|
|
|
content.seek(0)
|
|
|
|
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*4 + "<div class=\"entry_content\">")
|
2012-01-20 22:59:11 +01:00
|
|
|
|
2010-12-14 11:26:21 +01:00
|
|
|
for line in content:
|
|
|
|
if no_break.match(line):
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*5 + line.strip())
|
2010-12-14 11:26:21 +01:00
|
|
|
else:
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*5 + line.strip() + "<br />")
|
|
|
|
print(ind*4 + "</div>")
|
2010-12-14 11:26:21 +01:00
|
|
|
|
|
|
|
# Comments...
|
|
|
|
# ... are shown when post_display and comments_file isn't false
|
|
|
|
comments_file = glob(os.path.join(entries_dir, title + ".comments"))
|
|
|
|
if post_display:
|
|
|
|
if comments_file:
|
2011-05-19 11:36:00 +02:00
|
|
|
if utf8:
|
|
|
|
comments_content = open(comments_file[0], "r", encoding="utf8")
|
|
|
|
else:
|
|
|
|
comments_content = open(comments_file[0], "r")
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*3 + "</div>")
|
|
|
|
print(ind*2 + "</div>")
|
2011-03-23 14:57:43 +01:00
|
|
|
print("")
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*2 + "<div class=\"comments\">")
|
2010-12-14 11:26:21 +01:00
|
|
|
|
|
|
|
notfirstline = 0 # Ugly fix for closing comment containers
|
|
|
|
label_count = 0
|
|
|
|
|
|
|
|
for line in comments_content:
|
|
|
|
if line_start_hyphen.match(line):
|
|
|
|
if notfirstline == 1:
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*4 + "</div>")
|
|
|
|
print(ind*3 + "</div>")
|
2010-12-14 11:26:21 +01:00
|
|
|
notfirstline = 0
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*3 + "<div class=\"comment\">")
|
2010-12-14 11:26:21 +01:00
|
|
|
|
|
|
|
# Label for each comment
|
|
|
|
label_count += 1
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*4 + "<a name=\"%s\"></a>" % str(label_count))
|
2010-12-14 11:26:21 +01:00
|
|
|
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*4 + "<div class=\"comment_author\">%s</div>" % line.split(".", 1)[1].strip())
|
2010-12-14 11:26:21 +01:00
|
|
|
elif line_start_plus.match(line):
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*4 + "<div class=\"comment_date\">%s</div>" % line.split(".", 1)[1].strip())
|
|
|
|
print(ind*4 + "<div class=\"comment_content\">")
|
2010-12-14 11:26:21 +01:00
|
|
|
else:
|
|
|
|
notfirstline = 1
|
|
|
|
line = line.split(".", 1)[1]
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*5 + line.strip() + "<br />")
|
2011-03-23 14:57:43 +01:00
|
|
|
print("")
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*4 + "</div>")
|
|
|
|
print(ind*3 + "</div>")
|
2010-12-14 11:26:21 +01:00
|
|
|
comments_content.close()
|
|
|
|
else:
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*3 + "</div>")
|
|
|
|
print(ind*2 + "</div>")
|
|
|
|
print(ind*2 + "<div class=\"comments\">")
|
2010-12-14 11:26:21 +01:00
|
|
|
|
|
|
|
# Form for adding comments
|
|
|
|
if comments == "True":
|
|
|
|
random_int_a = randint(1,9)
|
|
|
|
random_int_b = randint(1,9)
|
|
|
|
cquizv = random_int_a + random_int_b
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*3 + "<div class=\"submit_comment\">")
|
|
|
|
print(ind*4 + "<form action=\"\" method=\"post\">")
|
|
|
|
print(ind*5 + "<input type=\"hidden\" name=\"ctitle\" value=\"%s\" />" % title)
|
|
|
|
print(ind*5 + "<input type=\"hidden\" name=\"cquizv\" value=\"%s\" />" % str(cquizv))
|
|
|
|
print(ind*5 + "<label class=\"submit_comment_name\">%s:</label><input class=\"submit_comment_name_input\" type=\"text\" id=\"cname\" name=\"cname\" />" % blog_locale[6])
|
|
|
|
print(ind*5 + "<br /><label class=\"submit_comment_text\">%s:</label><textarea class=\"submit_comment_textarea\" id=\"ctext\" name=\"ctext\"></textarea>" % blog_locale[7])
|
|
|
|
print(ind*5 + "<br /><label class=\"submit_comment_quiz\">%s+%s=</label><input class=\"submit_comment_quiz_input\" type=\"text\" id=\"cquiz\" name=\"cquiz\" />" % (str(random_int_a), str(random_int_b)))
|
|
|
|
print(ind*5 + "<br /><input class=\"submit_comment_button\" type=\"submit\" id=\"submit\" value=\"%s\" />" % blog_locale[8])
|
|
|
|
print(ind*4 + "</form>")
|
|
|
|
print(ind*3 + "</div>")
|
2010-12-14 11:26:21 +01:00
|
|
|
|
|
|
|
if comments == "True":
|
|
|
|
comments_file = glob(os.path.join(entries_dir, title + ".comments"))
|
|
|
|
if not comments_file and not post_display:
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*4 + "<div class=\"entry_comment\">")
|
|
|
|
print(ind*5 + "<a href=\"?p=%s\" class=\"entry_comment\">%s</a>" % (title.replace(" ", "-"), blog_locale[3]))
|
|
|
|
print(ind*4 + "</div>")
|
|
|
|
print(ind*3 + "</div>")
|
2011-03-23 14:57:43 +01:00
|
|
|
print("")
|
2010-12-14 11:26:21 +01:00
|
|
|
elif comments_file and not post_display:
|
2011-05-19 11:36:00 +02:00
|
|
|
if utf8:
|
|
|
|
comments_content = open(comments_file[0], "r", encoding="utf8")
|
|
|
|
else:
|
|
|
|
comments_content = open(comments_file[0], "r")
|
2010-12-14 11:26:21 +01:00
|
|
|
comments_counter = 0
|
|
|
|
for line in comments_content:
|
|
|
|
if line.split(".", 1)[0] == "-": comments_counter += 1
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*4 + "<div class=\"entry_comment\">")
|
|
|
|
print(ind*5 + "<a href=\"?p=%s\" class=\"entry_comment\">%s (%s)</a>" % (title.replace(" ", "-"), blog_locale[4], str(comments_counter)))
|
|
|
|
print(ind*4 + "</div>")
|
|
|
|
print(ind*3 + "</div>")
|
2011-03-23 14:57:43 +01:00
|
|
|
print("")
|
2010-12-14 11:26:21 +01:00
|
|
|
comments_content.close()
|
|
|
|
|
|
|
|
content.close()
|
|
|
|
entry_counter += 1
|
|
|
|
|
|
|
|
if not month_display and not post_display and not allentries_display and entry_counter == entries_per_page: # Display pagelist
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*3 + "<div class=\"show_all\"><a href=\"?a=1\">%s</a></div>" % blog_locale[5])
|
2010-12-14 11:26:21 +01:00
|
|
|
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind*2 + "</div>")
|
2011-03-23 14:57:43 +01:00
|
|
|
print("")
|
2011-03-24 09:42:08 +01:00
|
|
|
print(ind + "</body>")
|
2011-03-23 14:57:43 +01:00
|
|
|
print("</html>")
|
2010-12-14 11:26:21 +01:00
|
|
|
|
|
|
|
# vim: set sw=4 tw=0 ts=4 expandtab:
|