summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--www-apps/pyblosxom-plugins/Manifest5
-rw-r--r--www-apps/pyblosxom-plugins/files/blocks.py207
-rw-r--r--www-apps/pyblosxom-plugins/files/digest-pyblosxom-plugins-1.3.2 (renamed from www-apps/pyblosxom-plugins/files/digest-pyblosxom-plugins-1.3)0
-rw-r--r--www-apps/pyblosxom-plugins/pyblosxom-plugins-1.3.2.ebuild (renamed from www-apps/pyblosxom-plugins/pyblosxom-plugins-1.3.ebuild)1
4 files changed, 211 insertions, 2 deletions
diff --git a/www-apps/pyblosxom-plugins/Manifest b/www-apps/pyblosxom-plugins/Manifest
index e11a28f..297f778 100644
--- a/www-apps/pyblosxom-plugins/Manifest
+++ b/www-apps/pyblosxom-plugins/Manifest
@@ -1,6 +1,7 @@
+MD5 68900c82dbdf221d22e8a999b02443d9 files/blocks.py 5866
MD5 3d89ed013ed90e7afff11e8e3a57ebf4 files/comments.py 25302
MD5 cad9589b6b07ac28854f1172a67c51c0 files/contact.py 11817
-MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-pyblosxom-plugins-1.3 0
+MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-pyblosxom-plugins-1.3.2 0
MD5 ef8b9559c56fe3bff0bf15672c2239e4 files/getstamps.py 1332
MD5 3ae49161534556018d226f514ef68195 files/hardcodedates.py 2036
MD5 13427211867bdf6231ec8d9ab1a585cc files/logrequest.py 2248
@@ -12,4 +13,4 @@ MD5 551595972432681869214de6b21dc0aa files/rss2renderer.py.html 41245
MD5 9d08ee37ee648e2e1541b51333db0fe6 files/session.py 11214
MD5 2fcbddb5246ec1f79ec0557cbe56bdad files/wbglast10summary.py 1094
MD5 1bd704ad5a8e5fd621b84a6ab2ec9d32 files/wbglast10summary.py.html 4862
-MD5 de6a2a634cd8474fc643ee50d5cb485b pyblosxom-plugins-1.3.ebuild 966
+MD5 1f9148f802c100c8fa1d4ac29659417f pyblosxom-plugins-1.3.2.ebuild 989
diff --git a/www-apps/pyblosxom-plugins/files/blocks.py b/www-apps/pyblosxom-plugins/files/blocks.py
new file mode 100644
index 0000000..4b583ba
--- /dev/null
+++ b/www-apps/pyblosxom-plugins/files/blocks.py
@@ -0,0 +1,207 @@
+"""
+
+Displays a splitted page with different categories. I use this to
+allow having a german and an english blog at the same time.
+
+"""
+__author__ = "Gunnar Wrobel <wrobel@gentoo.org>"
+__version__ = "$$"
+__url__ = "http://www.gunnarwrobel.de"
+__description__ = "Shows several categories at the same time."
+__license__ = "GPL 2"
+
+# Pyblosxom imports
+from Pyblosxom.renderers.blosxom import Renderer, NoSuchFlavourException
+from Pyblosxom import tools
+from Pyblosxom.entries.fileentry import FileEntry
+
+# Variables
+TRIGGER = "/blocks"
+TRIGGER_KEY = "block_urltrigger"
+INIT_KEY = "block_initiated"
+
+_default_template = """
+<div>
+</div>
+"""
+
+def _update_config(config):
+ if TRIGGER_KEY in config:
+ global TRIGGER
+ TRIGGER = config[TRIGGER_KEY]
+ else:
+ # set this explicitly so it's available in templates
+ config[TRIGGER_KEY] = TRIGGER
+
+class BlocksRenderer(Renderer):
+
+ def _processBlockContent(self):
+ """
+ Processes the content for the story portion of a page.
+
+ @returns: the content string
+ @rtype: string
+ """
+ config = self._request.getConfiguration()
+ data = self._request.getData()
+
+ if isinstance(self._content, list):
+ current_date = ''
+
+ for block in self._content:
+ if self.flavour.has_key('block_head'):
+ self._outputFlavour(parsevars,'block_head')
+ outputbuffer = []
+ for entry in block:
+ output, current_date = self._processEntry(entry, current_date)
+ outputbuffer.append(output)
+ self.write(u"".join(outputbuffer))
+ if self.flavour.has_key('block_foot'):
+ self._outputFlavour(parsevars,'block_foot')
+
+ def render(self, header=1):
+ """
+ Figures out flavours and such and then renders the content according
+ to which flavour we're using.
+
+ @param header: whether (1) or not (0) to render the HTTP headers
+ @type header: boolean
+ """
+ # if we've already rendered, then we don't want to do so again
+ if self.rendered == 1:
+ return
+
+ data = self._request.getData()
+ config = self._request.getConfiguration()
+
+ # FIXME
+ parsevars = tools.VariableDict()
+ parsevars.update(config)
+ parsevars.update(data)
+
+ try:
+ self.flavour = self._getFlavour(data.get("flavour", "html"))
+
+ except NoSuchFlavourException, nsfe:
+ error_msg = nsfe._msg
+ try:
+ self.flavour = self._getFlavour("error")
+ except NoSuchFlavourException, nsfe2:
+ self.flavour = get_included_flavour("error")
+ error_msg = error_msg + "And your error flavour doesn't exist."
+
+ self._content = { "title": "Flavour error",
+ "body": error_msg }
+
+ data['content-type'] = self.flavour['content_type'].strip()
+ if header:
+ if self._needs_content_type and data['content-type'] !="":
+ self.addHeader('Content-type', '%(content-type)s' % data)
+
+ self.showHeaders()
+
+ if self._content:
+ if self.flavour.has_key('head'):
+ self._outputFlavour(parsevars,'head')
+ self._processBlockContent()
+ if self.flavour.has_key('date_foot'):
+ self._outputFlavour(parsevars,'date_foot')
+ if self.flavour.has_key('foot'):
+ self._outputFlavour(parsevars,'foot')
+
+ self.rendered = 1
+
+
+#******************************
+# Callbacks
+#******************************
+
+def cb_start(args):
+ request = args['request']
+ http = request.getHttp()
+ config = request.getConfiguration()
+ _update_config(config)
+
+ if http['PATH_INFO'].startswith(TRIGGER):
+ data = request.getData()
+ data[INIT_KEY] = True
+
+def cb_renderer(args):
+ request = args['request']
+ data = request.getData()
+
+ if INIT_KEY in data:
+ return BlocksRenderer(request, request.getResponse())
+
+def cb_end(args):
+ request = args['request']
+ data = request.getData()
+ if INIT_KEY in data:
+ del data[INIT_KEY]
+
+
+class Blocklist(list):
+
+ def get(self, key, default):
+ if key == 'mtime':
+ result = 0
+ for i in self:
+ j = i.get('mtime', 0)
+ if j > result:
+ result = j
+ if not result:
+ return default
+ else:
+ return result
+ return default
+
+def cb_filelist(args):
+ """
+ """
+ request = args["request"]
+
+ data = request.getData()
+ config = request.getConfiguration()
+
+ if not INIT_KEY in data:
+ return
+
+ blocklist = []
+ for category in config['block_categories']:
+ filelist = tools.Walk(request, config['datadir'] + '/' + category, int(config['depth']))
+
+ entrylist = []
+ for ourfile in filelist:
+ e = FileEntry(request, ourfile, data['root_datadir'])
+ entrylist.append((e._mtime, e))
+
+ # this sorts entries by mtime in reverse order. entries that have
+ # no mtime get sorted to the top.
+ entrylist.sort()
+ entrylist.reverse()
+
+ # Match dates with files if applicable
+ if data['pi_yr']:
+ # This is called when a date has been requested, e.g. /some/category/2004/Sep
+ month = (data['pi_mo'] in tools.month2num.keys() and tools.month2num[data['pi_mo']] or data['pi_mo'])
+ matchstr = "^" + data["pi_yr"] + month + data["pi_da"]
+ valid_list = [x for x in entrylist if re.match(matchstr, x[1]._fulltime)]
+ else:
+ valid_list = entrylist
+
+ # This is the maximum number of entries we can show on the front page
+ # (zero indicates show all entries)
+ max = config.get("block_entries", 0)
+ if max and not data["pi_yr"]:
+ valid_list = valid_list[:max]
+ data["debugme"] = "done"
+
+ valid_list = [x[1] for x in valid_list]
+
+ block = Blocklist()
+ for i in valid_list:
+ block.append(i)
+ blocklist.append(block)
+
+ return blocklist
+
diff --git a/www-apps/pyblosxom-plugins/files/digest-pyblosxom-plugins-1.3 b/www-apps/pyblosxom-plugins/files/digest-pyblosxom-plugins-1.3.2
index e69de29..e69de29 100644
--- a/www-apps/pyblosxom-plugins/files/digest-pyblosxom-plugins-1.3
+++ b/www-apps/pyblosxom-plugins/files/digest-pyblosxom-plugins-1.3.2
diff --git a/www-apps/pyblosxom-plugins/pyblosxom-plugins-1.3.ebuild b/www-apps/pyblosxom-plugins/pyblosxom-plugins-1.3.2.ebuild
index 820a907..aaf1549 100644
--- a/www-apps/pyblosxom-plugins/pyblosxom-plugins-1.3.ebuild
+++ b/www-apps/pyblosxom-plugins/pyblosxom-plugins-1.3.2.ebuild
@@ -35,6 +35,7 @@ src_install() {
contact.py
logrequest.py
pyguest.py
+ blocks.py
wbglast10summary.py"
for plg in ${PLUGINS}