X-Git-Url: https://git.llucax.com/software/blitiri.git/blobdiff_plain/a5749f095f091ee8af98d0a92abea8276d1001e4..70a0afa4c3907cd348f4c5699897dfe992150567:/blitiri.cgi
diff --git a/blitiri.cgi b/blitiri.cgi
index 11a7df8..347d27a 100755
--- a/blitiri.cgi
+++ b/blitiri.cgi
@@ -14,6 +14,9 @@
# Directory where entries are stored
data_path = "/tmp/blog/data"
+# Are comments allowed? (if False, comments_path option is not used)
+enable_comments = False
+
# Directory where comments are stored (must be writeable by the web server)
comments_path = "/tmp/blog/comments"
@@ -21,6 +24,12 @@ comments_path = "/tmp/blog/comments"
# default templates. If they're not found, the built-in ones will be used.
templates_path = "/tmp/blog/templates"
+# Path where the cache is stored (must be writeable by the web server);
+# set to None to disable. When enabled, you must take care of cleaning it up
+# every once in a while.
+#cache_path = "/tmp/blog/cache"
+cache_path = None
+
# URL to the blog, including the name. Can be a full URL or just the path.
blog_url = "/blog/blitiri.cgi"
@@ -37,6 +46,34 @@ author = "Hartmut Kegan"
# Article encoding
encoding = "utf8"
+# Captcha class
+class Captcha (object):
+ def __init__(self, article):
+ self.article = article
+ words = article.title.split()
+ self.nword = hash(article.title) % len(words) % 5
+ self.answer = words[self.nword]
+ self.help = 'gotcha, damn spam bot!'
+
+ def get_puzzle(self):
+ nword = self.nword + 1
+ if nword == 1:
+ n = '1st'
+ elif nword == 2:
+ n = '2nd'
+ elif nword == 3:
+ n = '3rd'
+ else:
+ n = str(nword) + 'th'
+ return "enter the %s word of the article's title" % n
+ puzzle = property(fget = get_puzzle)
+
+ def validate(self, form_data):
+ if form_data.captcha.lower() == self.answer.lower():
+ return True
+ return False
+
+
#
# End of configuration
# DO *NOT* EDIT ANYTHING PAST HERE
@@ -45,6 +82,8 @@ encoding = "utf8"
import sys
import os
+import errno
+import shutil
import time
import datetime
import calendar
@@ -52,6 +91,7 @@ import zlib
import urllib
import cgi
from docutils.core import publish_parts
+from docutils.utils import SystemMessage
# Before importing the config, add our cwd to the Python path
sys.path.append(os.getcwd())
@@ -118,7 +158,8 @@ default_article_header = """
%(uday)02d\
%(uhour)02d:%(uminute)02d)
-
- with %(comments)s comment(s)
+ with %(comments)s
+ comment(s)
Comment #%(number)d
-by %(author)s +by %(linked_author)s on %(year)04d-%(month)02d-%(day)02d %(hour)02d:%(minute)02dYour comment
+