From fc1b6997235fe0249b1f5fdf0e47d58734cee8f3 Mon Sep 17 00:00:00 2001 From: Stefan Ritter Date: Sat, 28 Feb 2009 18:02:23 +0100 Subject: Initial release --- blogthon.cgi | 137 +++++++++++++++++++++++++++++++ configuration | 14 ++++ entries/Demo.txt | 5 ++ static/01-Support | 1 + styles/blogthon.css | 81 ++++++++++++++++++ styles/blogthon_img/title_background.png | Bin 0 -> 327 bytes 6 files changed, 238 insertions(+) create mode 100755 blogthon.cgi create mode 100644 configuration create mode 100644 entries/Demo.txt create mode 100644 static/01-Support create mode 100644 styles/blogthon.css create mode 100644 styles/blogthon_img/title_background.png diff --git a/blogthon.cgi b/blogthon.cgi new file mode 100755 index 0000000..f85eb01 --- /dev/null +++ b/blogthon.cgi @@ -0,0 +1,137 @@ +#!/usr/bin/python + +# This program is free software. It comes without any warranty, to +# 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. + +import cgi +import os +import time +import glob +import re +import ConfigParser + +configuration = ConfigParser.ConfigParser() +configuration.read('configuration') + +blog_title = configuration.get('personal', 'blog_title') +keywords = configuration.get('personal', 'keywords') +entries_dir = configuration.get('personal', 'entries_dir') +entries_suffix = configuration.get('personal', 'entries_suffix') +staticpages_dir = configuration.get('personal', 'staticpages_dir') +style = configuration.get('look', 'style') +entries_per_page = configuration.getint('look', 'entries_per_page') +monthlist = configuration.get('look', 'monthlist') +staticpages = configuration.get('look', 'staticpages') +permalinks = configuration.get('look', 'permalinks') +newest_first = configuration.get('look', 'newest_first') + +action = cgi.FieldStorage() +month_display = action.getvalue('m') +post_display = action.getvalue('p') +static_display = action.getvalue('s') +site_display = action.getvalue('i') +if not month_display: month_display = "" +if not post_display: post_display = "" +if not static_display: static_display = "" +if not site_display: site_display = "" + +print 'Content-type: text/html\n' +print '' +print '' +print ' ' +print ' ' + blog_title + '' +print ' ' +print ' ' +print ' ' +print ' ' +print ' ' +print ' ' +print '
' + blog_title + '
' + +entries = [] +entries_list = glob.glob(entries_dir + '*.' + entries_suffix) + +for entry in entries_list: + timestamp = os.stat(entry) + timestamp = time.localtime(timestamp[8]) + entry = timestamp, entry + entries.append(entry) + +if newest_first: + entries.sort(reverse=True) +else: + entries.sort() + +print ' ' +print '
' + +if static_display != "": # Show Staticpage + content = open(staticpages_dir + static_display, "r") + print '
' + re.sub('\d+?-', '', static_display) + '
' + print '

' + for line in content: + print ' ' + line.strip() + '
' + print '

' + content.close() +else: # Show regular entry + 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/', '', 1) + title = title.replace('.txt', '') + entry_counter += 1 + + if month_display == date_to_compare or not month_display: + if post_display == title or not post_display: + if entry_counter <= entries_per_page: + content = open(entry, "r") + if permalinks: + print ' ' + else: + print '
' + title + ' (' + date + ')
' + print '

' + for line in content: + print ' ' + line.strip() + '
' + print '

' + print '

' + content.close() + + if entry_counter > entries_per_page: # Display pagelist + print '
[previous page] [next page]
' + +print '
' +print ' ' +print '' + +# vim: set tw=0 ts=4: diff --git a/configuration b/configuration new file mode 100644 index 0000000..68c0285 --- /dev/null +++ b/configuration @@ -0,0 +1,14 @@ +[personal] +blog_title: A BlogThon Blog +keywords: please,change,me +entries_dir: entries/ +entries_suffix: txt +staticpages_dir: static/ + +[look] +style: blogthon.css +entries_per_page: 20 +monthlist: True +staticpages: True +permalinks: True +newest_first: True diff --git a/entries/Demo.txt b/entries/Demo.txt new file mode 100644 index 0000000..5c4e70f --- /dev/null +++ b/entries/Demo.txt @@ -0,0 +1,5 @@ +Welcome to your new BlogThon Blog. + +You can add new entries by just put it into a textfile under the "entries" folder with the suffix ".txt". They are sorted by using the Unix timestamp. Staticpages are the same as entries, but without a suffix and with a leading number and a - (like 35-foo). They are stored under the folder "static". + +Have fun with your new Blog. diff --git a/static/01-Support b/static/01-Support new file mode 100644 index 0000000..147f272 --- /dev/null +++ b/static/01-Support @@ -0,0 +1 @@ +If you have any questions regarding BlogThon, you can join our IRC channel on irc.thehappy.de #thehappy.de . You can also write a mail to xeno@thehappy.de. diff --git a/styles/blogthon.css b/styles/blogthon.css new file mode 100644 index 0000000..7d7568f --- /dev/null +++ b/styles/blogthon.css @@ -0,0 +1,81 @@ +.html, body { + background: #000; + color: #FFF; + margin: 0px; + overflow-x: hidden; +} + +img { + border: 0; +} + +a:link, a:active, a:visited, a:hover { + font-family: Verdana; + font-size: 12px; + color: #FC3; + text-decoration: none; +} + +a.title:link, a.title:hover, a.title:active, a.title:visited { + position: absolute; + text-align: center; + width: 100%; + height: 25px; + background-image: url(blogthon_img/title_background.png); + font-family: Verdana; + font-weight: bold; + font-size: 18px; + color: #FC3; +} + +.content { /* Container for entrytitle and entry */ + position: absolute; + top: 30px; + left: 6px; + width: 600px; +} + +.entrytitle { + font-family: Verdana; + font-weight: bold; + font-size: 16px; + color: #335599; + text-decoration: underline; +} +a.entrytitle:link, a.entrytitle:hover, a.entrytitle:visited, a.entrytitle:active { + font-family: Verdana; + font-weight: bold; + font-size: 16px; + color: #335599; + text-decoration: underline; +} + +.entry { + font-family: Verdana; + font-size: 12px; + color: #FFF; + margin-left: 15px; +} + +.sidebar { + position: absolute; + right: 6px; + top: 30px; + background: #0F0; +} + +.monthlist { + font-family: Verdana; + font-size: 12px; + color: #5577BB; + text-align: center; + background: #111; +} + +.staticpages { + font-family: Verdana; + font-size: 12px; + color: #5577BB; + text-align: center; + background: #111; +} diff --git a/styles/blogthon_img/title_background.png b/styles/blogthon_img/title_background.png new file mode 100644 index 0000000..961d0fe Binary files /dev/null and b/styles/blogthon_img/title_background.png differ -- cgit v1.2.3