#!/usr/bin/env python #coding: utf8 # blitiri - A single-file blog engine. # Alberto Bertogli (albertito@gmail.com) # # Configuration section # # You can edit these values, or create a file named "config.py" and put them # there to make updating easier. The ones in config.py take precedence. # # 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" # Path where templates are stored. Use an empty string for the built-in # default templates. If they're not found, the built-in ones will be used. templates_path = "/tmp/blog/templates" # URL to the blog, including the name. Can be a full URL or just the path. blog_url = "/blog/blitiri.cgi" # Style sheet (CSS) URL. Can be relative or absolute. To use the built-in # default, set it to blog_url + "/style". css_url = blog_url + "/style" # Blog title title = "I don't like blogs" # Default author 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 # import sys import os import errno import shutil import time import datetime import calendar 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()) # Load the config file, if there is one try: from config import * except: pass # Pimp *_path config variables to support relative paths data_path = os.path.realpath(data_path) templates_path = os.path.realpath(templates_path) # Default template default_main_header = """\
%(contents)s
Comment #%(number)d
by %(linked_author)s on %(year)04d-%(month)02d-%(day)02d %(hour)02d:%(minute)02d