summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunnar Wrobel <wrobel@gentoo.org>2006-05-22 05:51:52 +0000
committerGunnar Wrobel <wrobel@gentoo.org>2006-05-22 05:51:52 +0000
commitbb6b567a66222a2dd2e882217881703651f2f14e (patch)
tree2b133afe8a3872ad4aee0b53e7f88c539a6b129a
parentPicard now has its own overlay (diff)
downloadoverlay-bb6b567a66222a2dd2e882217881703651f2f14e.tar.gz
overlay-bb6b567a66222a2dd2e882217881703651f2f14e.tar.bz2
overlay-bb6b567a66222a2dd2e882217881703651f2f14e.zip
Added pycalendar and pyarchives to the ebuild.
svn path=/stable/; revision=714
-rw-r--r--www-apps/pyblosxom-plugins/Manifest6
-rw-r--r--www-apps/pyblosxom-plugins/files/blocks.py13
-rw-r--r--www-apps/pyblosxom-plugins/files/pyarchives.py101
-rw-r--r--www-apps/pyblosxom-plugins/files/pycalendar.py289
-rw-r--r--www-apps/pyblosxom-plugins/pyblosxom-plugins-1.3.2.ebuild2
5 files changed, 409 insertions, 2 deletions
diff --git a/www-apps/pyblosxom-plugins/Manifest b/www-apps/pyblosxom-plugins/Manifest
index 9b57ca8..79192bf 100644
--- a/www-apps/pyblosxom-plugins/Manifest
+++ b/www-apps/pyblosxom-plugins/Manifest
@@ -1,4 +1,4 @@
-MD5 e56518b49fbff23b7b862fde91e53105 files/blocks.py 6369
+MD5 f67ef44f565d2cfa49ce8e728267081b files/blocks.py 6567
MD5 3d89ed013ed90e7afff11e8e3a57ebf4 files/comments.py 25302
MD5 53cf6af3d39e1d47a4d26d20dbe4338b files/contact.py 11517
MD5 d41d8cd98f00b204e9800998ecf8427e files/digest-pyblosxom-plugins-1.3.2 0
@@ -6,6 +6,8 @@ MD5 ef8b9559c56fe3bff0bf15672c2239e4 files/getstamps.py 1332
MD5 3ae49161534556018d226f514ef68195 files/hardcodedates.py 2036
MD5 13427211867bdf6231ec8d9ab1a585cc files/logrequest.py 2248
MD5 3a489e93c5a569beaff1aeba02b6dc20 files/nospam.py 6364
+MD5 2a797ba4c445b019c86dc4b369d7a0a1 files/pyarchives.py 3695
+MD5 7d5a2778c5204601c56172c3c34109f3 files/pycalendar.py 9856
MD5 d30d5cf286b0a3bfb42f1af7029854fc files/pycategories.py 7740
MD5 dad8289c1e561ffec042f661873e4ed4 files/pyguest.py 10951
MD5 b0462630303ce00d3356062868299bce files/rss2renderer.py 8779
@@ -13,4 +15,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 1f9148f802c100c8fa1d4ac29659417f pyblosxom-plugins-1.3.2.ebuild 989
+MD5 99bf8f8959ffc6e079cf39fd0a9d2d93 pyblosxom-plugins-1.3.2.ebuild 1043
diff --git a/www-apps/pyblosxom-plugins/files/blocks.py b/www-apps/pyblosxom-plugins/files/blocks.py
index 6fac35a..a30f357 100644
--- a/www-apps/pyblosxom-plugins/files/blocks.py
+++ b/www-apps/pyblosxom-plugins/files/blocks.py
@@ -10,6 +10,8 @@ __url__ = "http://www.gunnarwrobel.de"
__description__ = "Shows several categories at the same time."
__license__ = "GPL 2"
+import re
+
# Pyblosxom imports
from Pyblosxom.renderers.blosxom import Renderer, NoSuchFlavourException
from Pyblosxom import tools
@@ -161,6 +163,17 @@ class Blocklist(list):
return default
else:
return result
+ if key == 'timetuple':
+ result = 0
+ for i in self:
+ j = i.get('timetuple', 0)
+ if j > result:
+ result = j
+ if not result:
+ return default
+ else:
+ return result
+
return default
def set_path(self, path):
diff --git a/www-apps/pyblosxom-plugins/files/pyarchives.py b/www-apps/pyblosxom-plugins/files/pyarchives.py
new file mode 100644
index 0000000..ce4ad14
--- /dev/null
+++ b/www-apps/pyblosxom-plugins/files/pyarchives.py
@@ -0,0 +1,101 @@
+# vim: tabstop=4 shiftwidth=4
+"""
+Walks through your blog root figuring out all the available monthly archives in
+your blogs. It generates html with this information and stores it in the
+$archivelinks variable which you can use in your head or foot templates.
+
+You can format the output with the key "archive_template".
+
+A config.py example:
+
+ py['archive_template'] = '<li><a href="%(base_url)s/%(Y)s/%(b)s">%(m)s/%(y)s</a></li>'
+
+Displays the archives as list items, with a month number slash year number, like 06/78.
+
+The vars available with typical example values are:
+ b 'Jun'
+ m '6'
+ Y '1978'
+ y '78'
+
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify,
+merge, publish, distribute, sublicense, and/or sell copies of the
+Software, and to permit persons to whom the Software is furnished
+to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+Copyright 2004, 2005 Wari Wahab
+"""
+__author__ = "Wari Wahab - wari at wari dot per dot sg"
+__version__ = "$Id: pyarchives.py 750 2005-08-01 18:48:38Z willhelm $"
+
+from Pyblosxom import tools
+import time, os
+
+def verify_installation(request):
+ config = request.getConfiguration()
+ if not config.has_key("archive_template"):
+ print "missing optional config property 'archive_template' which "
+ print "allows you to specify how the archive links are created. "
+ print "refer to pyarchive plugin documentation for more details."
+ return 1
+
+class PyblArchives:
+ def __init__(self, request):
+ self._request = request
+ self._archives = None
+
+ def __str__(self):
+ if self._archives == None:
+ self.genLinearArchive()
+ return self._archives
+
+ def genLinearArchive(self):
+ config = self._request.getConfiguration()
+ data = self._request.getData()
+ root = config["datadir"]
+ archives = {}
+ archiveList = tools.Walk(self._request, root)
+ fulldict = {}
+ fulldict.update(config)
+ fulldict.update(data)
+
+ template = config.get('archive_template',
+ '<a href="%(base_url)s/%(Y)s/%(b)s">%(Y)s-%(b)s</a><br />')
+ for mem in archiveList:
+ timetuple = tools.filestat(self._request, mem)
+ timedict = {}
+ for x in ["B", "b", "m", "Y", "y"]:
+ timedict[x] = time.strftime("%" + x, timetuple)
+
+ fulldict.update(timedict)
+ if not archives.has_key(timedict['Y'] + timedict['m']):
+ archives[timedict['Y'] + timedict['m']] = (template % fulldict)
+
+ arcKeys = archives.keys()
+ arcKeys.sort()
+ arcKeys.reverse()
+ result = []
+ for key in arcKeys:
+ result.append(archives[key])
+ self._archives = '\n'.join(result)
+
+def cb_prepare(args):
+ request = args["request"]
+ data = request.getData()
+ data["archivelinks"] = PyblArchives(request)
diff --git a/www-apps/pyblosxom-plugins/files/pycalendar.py b/www-apps/pyblosxom-plugins/files/pycalendar.py
new file mode 100644
index 0000000..e2ed1cc
--- /dev/null
+++ b/www-apps/pyblosxom-plugins/files/pycalendar.py
@@ -0,0 +1,289 @@
+"""
+Generates a calendar along the lines of this one::
+
+ < January 2003 >
+ Mo Tu We Th Fr Sa Su
+ 1 2 3 4 5
+ 6 7 8 9 10 11 12
+ 13 14 15 16 17 18 19
+ 20 21 22 23 24 25 26
+ 27 28 29 30 31
+
+It walks through all your entries and marks the dates that have entries
+so you can click on the date and see entries for that date.
+
+It uses the following CSS classes:
+
+ - blosxomCalendar
+ - for the calendar table
+ - blosxomCalendarHead
+ - for the month year header (January 2003)
+ - blosxomCalendarWeekHeader
+ - for the week header (Su, Mo, Tu, ...)
+ - blosxomCalendarEmpty
+ - for filler days
+ - blosxomCalendarCell
+ - for calendar days that aren't today
+ - blosxomCalendarBlogged
+ - for calendar days that aren't today that
+ have entries
+ - blosxomCalendarSpecificDay
+ - for the specific day we're looking at
+ (if we're looking at a specific day)
+ - blosxomCalendarToday
+ - for today's calendar day
+
+
+To use, place $calendar in your head/foot template.
+
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify,
+merge, publish, distribute, sublicense, and/or sell copies of the
+Software, and to permit persons to whom the Software is furnished
+to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+Copyright 2004, 2005 Will Guaraldi
+"""
+__author__ = "Will Guaraldi - willg at bluesock dot org"
+__version__ = "$Id: pycalendar.py 650 2005-04-04 14:43:49Z willhelm $"
+__url__ = "http://pyblosxom.sourceforge.net/"
+__description__ = "Builds a calendar."
+
+from Pyblosxom import tools
+import time, calendar, string, os, types
+
+def verify_installation(request):
+ # there's no configuration needed for this plugin.
+ return 1
+
+class PyblCalendar:
+ def __init__(self, request):
+ self._request = request
+ self._cal = None
+
+ self._today = None
+ self._view = None
+ self._specificday = None
+
+ self._entries = {}
+
+ def __str__(self):
+ """
+ Returns the on-demand generated string.
+ """
+ if self._cal == None:
+ self.generateCalendar()
+
+ return self._cal
+
+ def generateCalendar(self):
+ """
+ Generates the calendar. We'd like to walk the archives
+ for things that happen in this month and mark the dates
+ accordingly. After doing that we pass it to a formatting
+ method which turns the thing into HTML.
+ """
+ config = self._request.getConfiguration()
+ data = self._request.getData()
+ entry_list = data["entry_list"]
+
+ root = config["datadir"]
+ baseurl = config.get("base_url", "")
+
+ self._today = time.localtime()
+
+ if len(entry_list) == 0:
+ # if there are no entries, we shouldn't even try to
+ # do something fancy.
+ self._cal = ""
+ return
+
+ view = list(entry_list[0].get("timetuple", (time.strftime("%Y", self._today),
+ time.strftime("%m", self._today),
+ time.strftime("%d", self._today))))
+
+ # this comes in as 2001, 2002, 2003, ... so we can convert it
+ # without an issue
+ temp = data.get("pi_yr", time.strftime("%Y", self._today))
+ if temp:
+ view[0] = int(temp)
+
+ # the month is a bit harder since it can come in as "08", "", or
+ # "Aug" (in the example of August).
+ temp = data.get("pi_mo", time.strftime("%m", self._today))
+ if temp.isdigit():
+ temp = int(temp)
+ else:
+ if tools.month2num.has_key(temp):
+ temp = int(tools.month2num[temp])
+ else:
+ temp = view[1]
+ view[1] = temp
+
+ view = tuple(view)
+ self._view = view
+
+ # if we're looking at a specific day, we figure out what it is
+ try:
+ if data["pi_yr"] and data["pi_mo"] and data["pi_da"]:
+ if data["pi_mo"].isdigit():
+ mon = data["pi_mo"]
+ else:
+ mon = tools.month2num[data["pi_mo"]]
+
+ self._specificday = [data["pi_yr"], mon, data["pi_da"]]
+ self._specificday = tuple([int(mem) for mem in self._specificday])
+ except:
+ pass
+
+ archiveList = tools.Walk(self._request, root)
+
+ yearmonth = {}
+
+ for mem in archiveList:
+ timetuple = tools.filestat(self._request, mem)
+
+ # if we already have an entry for this date, we skip to the
+ # next one because we've already done this processing
+ day = str(timetuple[2]).rjust(2)
+ if self._entries.has_key(day):
+ continue
+
+ # add an entry for yyyymm so we can figure out next/previous
+ year = str(timetuple[0])
+ dayzfill = string.zfill(timetuple[1], 2)
+ yearmonth[year + dayzfill] = time.strftime("%b", timetuple)
+
+ # if the entry isn't in the year/month we're looking at with
+ # the calendar, then we skip to the next one
+ if timetuple[0:2] != view[0:2]:
+ continue
+
+ # mark the entry because it's one we want to show
+ datepiece = time.strftime("%Y/%b/%d", timetuple)
+ self._entries[day] = (baseurl + "/" + datepiece, day)
+
+
+ # create the calendar
+ calendar.setfirstweekday(calendar.SUNDAY)
+ cal = calendar.monthcalendar(view[0], view[1])
+
+ # insert the days of the week
+ cal.insert(0, ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"])
+
+ # figure out next and previous links by taking the dict of yyyymm
+ # strings we created, turning it into a list, sorting them,
+ # and then finding "today"'s entry. then the one before it
+ # (index-1) is prev, and the one after (index+1) is next.
+ keys = yearmonth.keys()
+ keys.sort()
+ thismonth = time.strftime("%Y%m", view)
+
+ # do some quick adjustment to make sure we didn't pick
+ # a yearmonth that's outside the yearmonths of the entries we
+ # know about.
+ if thismonth in keys:
+ index = keys.index(thismonth)
+ elif len(keys) == 0 or keys[0] > thismonth:
+ index = 0
+ else:
+ index = len(keys) - 1
+
+ # build the prev link
+ if index == 0:
+ prev = None
+ else:
+ prev = ("%s/%s/%s" % (baseurl, keys[index-1][:4], yearmonth[keys[index-1]]), "&lt;")
+
+ # build the next link
+ if index == len(yearmonth)-1:
+ next = None
+ else:
+ next = ("%s/%s/%s" % (baseurl, keys[index+1][:4], yearmonth[keys[index+1]]), "&gt;")
+
+ # insert the month name and next/previous links
+ cal.insert(0, [prev, time.strftime("%B %Y", view), next])
+
+ self._cal = self.formatWithCSS(cal)
+
+
+ def _fixlink(self, link):
+ if link:
+ return "<a href=\"%s\">%s</a>" % (link[0], link[1])
+ else:
+ return " "
+
+ def _fixday(self, day):
+ if day == 0:
+ return "<td class=\"blosxomCalendarEmpty\">&nbsp;</td>"
+
+ strday = str(day).rjust(2)
+ if self._entries.has_key(strday):
+ entry = self._entries[strday]
+ link = "<a href=\"%s\">%s</a>" % (entry[0], entry[1])
+ else:
+ link = strday
+
+ # if it's today
+ if (self._view[0], self._view[1], day) == self._today[0:3]:
+ return "<td class=\"blosxomCalendarToday\">%s</td>" % link
+
+ if self._specificday:
+ # if it's the day we're viewing
+ if (self._view[0], self._view[1], day) == self._specificday:
+ return "<td class=\"blosxomCalendarSpecificDay\">%s</td>" % link
+
+ # if it's a day that's been blogged
+ if self._entries.has_key(strday):
+ return "<td class=\"blosxomCalendarBlogged\">%s</td>" % link
+
+ return "<td class=\"blosxomCalendarCell\">%s</td>" % strday
+
+ def _fixweek(self, item):
+ return "<td class=\"blosxomCalendarWeekHeader\">%s</td>" % item
+
+
+ def formatWithCSS(self, cal):
+ """
+ This formats the calendar using HTML table and CSS. The output
+ can be made to look prettier.
+ """
+ cal2 = ["<table class=\"blosxomCalendar\">"]
+ cal2.append("<tr>")
+ cal2.append("<td align=\"left\">" + self._fixlink(cal[0][0]) + "</td>")
+ cal2.append("<td colspan=\"5\" align=\"center\" class=\"blosxomCalendarHead\">" + cal[0][1] + "</td>")
+ cal2.append("<td align=\"right\">" + self._fixlink(cal[0][2]) + "</td>")
+ cal2.append("</tr>")
+
+ cal2.append("<tr>%s</tr>" % "".join([self._fixweek(m) for m in cal[1]]))
+
+ for mem in cal[2:]:
+ mem = [self._fixday(m) for m in mem]
+ cal2.append("<tr>" + "".join(mem) + "</tr>")
+
+ cal2.append("</table>")
+
+ return "\n".join(cal2)
+
+def cb_prepare(args):
+ request = args["request"]
+ data = request.getData()
+ if data.has_key("entry_list") and data["entry_list"]:
+ data["calendar"] = PyblCalendar(request)
+
+# vim: tabstop=4 shiftwidth=4
diff --git a/www-apps/pyblosxom-plugins/pyblosxom-plugins-1.3.2.ebuild b/www-apps/pyblosxom-plugins/pyblosxom-plugins-1.3.2.ebuild
index aaf1549..5955d6b 100644
--- a/www-apps/pyblosxom-plugins/pyblosxom-plugins-1.3.2.ebuild
+++ b/www-apps/pyblosxom-plugins/pyblosxom-plugins-1.3.2.ebuild
@@ -32,6 +32,8 @@ src_install() {
getstamps.py
rss2renderer.py
pycategories.py
+ pycalendar.py
+ pyarchives.py
contact.py
logrequest.py
pyguest.py