summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunnar Wrobel <wrobel@gentoo.org>2005-07-09 19:08:31 +0000
committerGunnar Wrobel <wrobel@gentoo.org>2005-07-09 19:08:31 +0000
commit934a0bdb4db176443ad154fe4c0690ab384d1875 (patch)
tree68fac43c9c77df41f6f452bdac83f4f47153d606 /www-apps/pyblosxom-plugins/files
parentRemoved jdbm (diff)
downloadoverlay-934a0bdb4db176443ad154fe4c0690ab384d1875.tar.gz
overlay-934a0bdb4db176443ad154fe4c0690ab384d1875.tar.bz2
overlay-934a0bdb4db176443ad154fe4c0690ab384d1875.zip
Starting on pyblosxom plugins
svn path=/; revision=149
Diffstat (limited to 'www-apps/pyblosxom-plugins/files')
-rw-r--r--www-apps/pyblosxom-plugins/files/getstamps.py49
-rw-r--r--www-apps/pyblosxom-plugins/files/hardcodedates.py67
2 files changed, 116 insertions, 0 deletions
diff --git a/www-apps/pyblosxom-plugins/files/getstamps.py b/www-apps/pyblosxom-plugins/files/getstamps.py
new file mode 100644
index 0000000..64ec15a
--- /dev/null
+++ b/www-apps/pyblosxom-plugins/files/getstamps.py
@@ -0,0 +1,49 @@
+"""
+Run this file 'python getstamps.py' from your pyblosxom data-dir.
+
+You may need to make some modification for your situation. This
+assumes your blog entries use a .txt extension.
+
+Hacked on by Michael Olson <http://www.mwolson.org/>.
+"""
+__author__ = 'Nathan Kent Bullock'
+__homepage__ = 'http://bullock.moo.com/nathan/'
+__email__ = 'nathan_kent_bullock -at- yahoo.ca'
+__version__ = '1.0'
+
+import re, sys, os, types
+
+OutFile=None
+
+DateRegexp = re.compile (r'^#date\s+(.+)$')
+
+def getdate(f):
+ for line in f:
+ matched = DateRegexp.search(line)
+ if matched:
+ return matched.group(1)
+
+def recurse(so_far):
+ global OutFile
+
+ for filename in os.listdir(so_far):
+ filepath = so_far + "/" + filename
+
+ # just makes output prettier.
+ if filename == ".svn": continue
+
+ if os.path.isdir(filepath):
+ print "dir %s" % (filepath,)
+ recurse(filepath)
+
+ # You may need to modify the extension test
+ if os.path.isfile(filepath) and filepath != "timestamps":
+ thisfile = open(filepath,'r')
+ thisdate = getdate (thisfile)
+ if thisdate:
+ OutFile.write("%s %s\n" % (thisdate, filepath[2:]))
+ continue
+
+if __name__ == "__main__":
+ OutFile = open("timestamps", "w+")
+ recurse(".")
diff --git a/www-apps/pyblosxom-plugins/files/hardcodedates.py b/www-apps/pyblosxom-plugins/files/hardcodedates.py
new file mode 100644
index 0000000..559421f
--- /dev/null
+++ b/www-apps/pyblosxom-plugins/files/hardcodedates.py
@@ -0,0 +1,67 @@
+"""
+This allows the user to create a file "timestamps" in their datadir,
+that will override the timestamp of any given blog entry. Each line
+in this file should be of the form "YYYY-MM-DD-hh-mm file-name".
+Then for any entry that one of these lines exist the system will use
+that timestamp instead of the actual files modification time.
+
+Note: the filename is relative to your data-dir.
+Example of a line for the file /var/data-dir/school/abc.txt
+ where the datadir is "/var/data-dir/" and the date is Aug 9, 2004.
+
+2004-08-09-00-00 school/abc.txt
+
+Hacked on by Michael Olson <http://www.mwolson.org/>.
+"""
+__author__ = 'Nathan Kent Bullock'
+__homepage__ = 'http://bullock.moo.com/nathan/'
+__email__ = 'nathan_kent_bullock -at- yahoo.ca'
+__version__ = '1.2'
+
+from Pyblosxom import tools
+import os, re, time, sys
+
+FILETIME = re.compile('^([0-9]{4})-([0-1][0-9])-([0-3][0-9])(-([0-2][0-9])-([0-5][0-9]))? +(.*)$')
+
+all_timestamps = None
+
+def get_all_timestamps(datadir):
+ f = open(datadir + "/timestamps")
+ t = []
+ while True:
+ str = f.readline()
+ if str == "": break
+ m = FILETIME.search(str.strip())
+ if m:
+ year = int(m.group(1))
+ mo = int(m.group(2))
+ day = int(m.group(3))
+ if m.group(4):
+ hr = int(m.group(5))
+ minute = int(m.group(6))
+ else:
+ hr = 0
+ minute = 0
+ mtime = time.mktime((year,mo,day,hr,minute,0,0,0,-1))
+
+ t.append( (datadir + "/" + m.group(7) + ".txt", mtime) )
+
+ f.close()
+ return t
+
+def cb_filestat(args):
+ global all_timestamps
+
+ filename = args["filename"]
+ stattuple = args["mtime"]
+
+ for fname,mtime in all_timestamps:
+ if fname == filename:
+ args["mtime"] = tuple(list(stattuple[:8]) + [mtime] + list(stattuple[9:]))
+ break
+
+ return args
+
+def cb_start(args):
+ global all_timestamps
+ all_timestamps = get_all_timestamps(args["request"].getConfiguration()['datadir'])