Re: rememberdates vs. HardCodeDates?
Michael Olson <mwolson-mXXj517/[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.user |
|---|---|
| Message-ID | <[email protected]> |
Ryan Barrett <pyblosxom-6sb6M7qyT/[email protected]> writes: > i'm planning to use one of the plugins that keeps last mod times in > a separate file - either rememberdates or HardCodeDates. is anyone > using either of them? is one more up to date or better supported > than the other? I use a customized version of the hardcodedates.py plugin. I've attached the plugin, as well as an example script. I generate the HTML file for each blog entry from a source file[1] that has an extension of ".muse", which might help to explain my modifications. [1] See http://www.mwolson.org/projects/EmacsMuse.html for information about the generating program I use. -- Michael Olson -- FSF Associate Member #652 -- http://www.mwolson.org/ Interests: Emacs Lisp, text markup, protocols -- Jabber: mwolson_at_hcoop.net /` |\ | | | IRC: freenode.net/mwolson: #emacs, #hcoop, #muse, #PurdueLUG |_] | \| |_| Projects: Emacs, Muse, ERC, EMMS, Planner, ErBot, DVC ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ pyblosxom-users mailing list pyblosxom-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/pyblosxom-users
signature.asc
(application/pgp-signature, 190 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) iD8DBQFE9cU4+1Ho2POo0xkRApb0AKCURRU0xN53S1eo9yAGd8BSYQxaDwCfUsnd XGLHJ25EhGnRRsIkruBXHIk= =tBzX -----END PGP SIGNATURE-----
getstamps.py
(text/x-python, 2.1 KB)
"""
Run 'python getstamps.py' from the directory that contains your
unpublished blog entries.
You may need to make some modification for your situation. This
assumes your blog entries use a .txt extension and that you generate
them from "source" files in a different directory (with an optional
.muse extension).
History:
1.1
* Michael Olson <http://www.mwolson.org/> adapted this for Emacs Muse
and added a few more exluded patterns for other version control
systems.
1.0
* Original version
"""
__author__ = 'Nathan Kent Bullock'
__homepage__ = 'http://bullock.moo.com/nathan/'
__email__ = 'nathan_kent_bullock -at- yahoo.ca'
__version__ = '1.1'
import re, sys, os, types
OutFile=None
# The format of the date line in each blog entry
DateRegexp = re.compile (r'^#date\s+(.+)$')
# The part of the filename of the blog entry to write to the
# timestamps file. Only the first grouping will be used.
FileNameRegexp = re.compile (r'^(.+?)(\.muse)?$')
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 filename == ".arch-ids": continue
if filename == "{arch}": continue
if filename == ".bzr": continue
if filename == "_darcs": 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)
matched = FileNameRegexp.search(filepath[2:])
if thisdate and matched:
thisname = matched.group(1) + ".txt"
OutFile.write("%s %s\n" % (thisdate, thisname))
continue
if __name__ == "__main__":
OutFile = open("timestamps", "w+")
recurse(".")
hardcodedates.py
(text/x-python, 2.2 KB)
"""
This allows the user to create a file "timestamps" in their top-level
blog entries directory, that will override the timestamp of any given
blog entry.
Each line in this file should be in one of the following forms.
"YYYY-MM-DD-hh-mm file-name"
"YYYY-MM-DD 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. An example follows
of a line for the file /var/data-dir/school/abc.txt, where the
top-level blog entries directory is "/var/data-dir/" and the date is
Aug 9, 2004.
2004-08-09-00-00 school/abc.txt
History:
1.3
* Michael Olson <http://www.mwolson.org/> made it optional to include
the hours and minutes.
1.2
* Original version
"""
__author__ = 'Nathan Kent Bullock'
__homepage__ = 'http://bullock.moo.com/nathan/'
__email__ = 'nathan_kent_bullock -at- yahoo.ca'
__version__ = '1.3'
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), 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'])
make-blog
(application/octet-stream, 725 B) - not displayed