From e7d313cdc470241866aff742387da6580a4c0a49 Mon Sep 17 00:00:00 2001 From: Stefan Ritter Date: Mon, 7 Dec 2009 00:32:35 +0100 Subject: Added a simple plugin interface --- blogthon.cgi | 13 +++++++++++++ configuration | 1 + plugins/plugin_example.py | 16 ++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 plugins/plugin_example.py diff --git a/blogthon.cgi b/blogthon.cgi index 9752bf9..8354aeb 100755 --- a/blogthon.cgi +++ b/blogthon.cgi @@ -101,6 +101,11 @@ except: errorpage('"staticpages_dir" is missing in configuration!') if not os.path.exists(staticpages_dir): errorpage('"staticpages_dir" does not exist!') +try: plugins_dir = configuration.get('personal', 'plugins_dir') +except: errorpage('"plugins_dir" is missing in configuration!') +if not os.path.exists(plugins_dir): + errorpage('"plugins_dir" does not exist!') + try: style = configuration.get('look', 'style') except: errorpage('"style" is missing in configuration!') @@ -306,6 +311,12 @@ else: print ' ' print ' ' print '' + + # Plugins + sys.path.append(plugins_dir) + for plugin in glob.glob(plugins_dir + '*.py'): + __import__ (plugin.split('/')[1].replace('.py', '')) + # Site header print '
' print '
' @@ -316,6 +327,7 @@ else: print '
' print '
' print '' + # RSS feed print '
' if os.path.exists('styles/' + style.replace('.css', '') + '_img/rss.jpg'): @@ -324,6 +336,7 @@ else: print ' rss' print '
' print '' + # Atom feed print '
' if os.path.exists('styles/' + style.replace('.css', '') + '_img/atom.jpg'): diff --git a/configuration b/configuration index f7949aa..15926c7 100644 --- a/configuration +++ b/configuration @@ -6,6 +6,7 @@ keywords: please,change,me entries_dir: entries/ entries_suffix: txt staticpages_dir: static/ +plugins_dir: plugins/ [look] style: blogthon_noir.css diff --git a/plugins/plugin_example.py b/plugins/plugin_example.py new file mode 100644 index 0000000..98aa805 --- /dev/null +++ b/plugins/plugin_example.py @@ -0,0 +1,16 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# 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. + +# Author: Stefan Ritter +# Description: Example plugin + +print ' ' +print ' This blog is powered by Blogthon! ' +print ' ' +print '' -- cgit v1.2.3