Re: yeararchives (2)
will kahn-greene <[email protected]> Sat, 08 May 2010 14:55:47 -0400
| Newsgroups | gmane.comp.web.pyblosxom.devel |
|---|---|
| Message-ID | <[email protected]> |
I think this looks good. Feel free to push it. On 05/05/2010 09:34 AM, Sebastian Spaeth wrote: > On 2010-05-04, Sebastian Spaeth wrote: >> 2a) For this to work, the yeararchive plugin would need to understand >> URLS such as /2003.snarfed which it does not now. If the URL is not >> ^/2003$ it won't recognize it. Here is a patch that drops of final >> flavour bits, although I am not sure if that is the correct thing to do >> here or if there are better ways. I have implemented that and can send >> the patch if needed. > > OK, here comes the patch that makes yeararchives understand .flav > extensions to the URL. This patch in combination with the other patch in > this thread make yeararchives nearly perfect for my uses. How does this > look? > > Sebastian > > commit a9113d88e49d512cba89f972bb299304d6a3c4bd > Author: Sebastian Spaeth <[email protected]> > Date: Wed May 5 15:00:18 2010 +0200 > > yeararchives: Make it work with .flavour appended to URL > > There were 2 problems with flavours and the yeararchives plugin: > > 1)the data["flavour"] entry gets only set in the pyblosxom handler for > real files (actually it gets set to either the default or when > useing ?flav=foo but will ignore .flav extensions). > This should arguably be improved there but that is a > separate issue. If we find a flavour appendix split it off before > the date parsing and set the data["flavour"] accordingly. > > 2)When creating the FileEntries for each article we passed > data["root_datadir"] as root dir and the filepath of the article as > filename. > > However for data URLS the pyblosxom handler sets: > data["root_datadir"] = os.path.join(config["datadir"], pi_bl) > which leads to wrong root components for our filenames. > > E.g. the yeararchives URL: > http://sspaeth.de/cgi-bin/pyblosxom.cgi/2010.html > > leads to the root_datadir of: > > /home/spaetz/sspaeth.de/public/data/2010.html > > which we pass a root dir to posts such as: > > /home/spaetz/sspaeth.de/public/data/Private/Oliver-in-der-Notaufnahme.rst. > > This is not the intended combination as the root is supposed to be > identical to the start of the full filename. What we really want to > pass here is our configured datadir. So this is what this patch does. > > With this patch URLS such as > http://sspaeth.de/cgi-bin/pyblosxom.cgi/2010.html > http://sspaeth.de/cgi-bin/pyblosxom.cgi/2010.snarfed > http://sspaeth.de/cgi-bin/pyblosxom.cgi/2010?flav=html > > work with the corresponding templates. > > Signed-off-by: Sebastian Spaeth <[email protected]> > > ---------------------------------------------------------------------------------------------------- > diff --git a/plugins/archives/yeararchives.py b/plugins/archives/yeararchives.py > index 60b9065..5390d62 100644 > --- a/plugins/archives/yeararchives.py > +++ b/plugins/archives/yeararchives.py > @@ -207,6 +207,21 @@ def cb_filelist(args): > if not year: > return > > + # Use current (or default) flavour for permalinks > + # note: for date URLs, data["flavor"] is not set in the pyblosxom handler > + # if it is passed as an extension. > + # If we find a valid date URL, we will therefore set data["flavour"] accordingly > + # a few lines down. > + try: > + flavour = data["flavour"] > + except KeyError: > + flavour = config.get("default_flavour", "html") > + > + > + # if a flavor is appended drop it for the date calculation > + # and save it, so we can set the rendering flavour. > + if os.path.basename(year).find('.') != -1: > + year, flavour = year.rsplit('.',1) > if year.startswith("/"): > year = year[1:] > if year.endswith("/"): > @@ -214,6 +229,8 @@ def cb_filelist(args): > if not year.isdigit() or not len(year) == 4: > return > > + data["flavour"] = flavour > + > data[INIT_KEY] = 1 > > # get all the entries > @@ -227,12 +244,6 @@ def cb_filelist(args): > items.sort() > items.reverse() > > - # Use current (or default) flavour for permalinks > - try: > - flavour = data["flavour"] > - except KeyError: > - flavour = config.get("default_flavour", "html") > - > l = ("(%(path)s) <a href=\"" + baseurl + > "/%(file_path)s." + flavour + "\">%(title)s</a><br>") > e = "<tr>\n<td valign=\"top\" align=\"left\">%s</td>\n<td>%s</td></tr>\n" > @@ -262,7 +273,7 @@ def cb_filelist(args): > d = mem[1] > day = [] > entry = entries.fileentry.FileEntry( > - request, mem[3], data['root_datadir']) > + request, mem[3], config['datadir']) > day.append(l % entry) > > if day: > > > > ------------------------------------------------------------------------------ > > > > _______________________________________________ > Pyblosxom-devel mailing list > Pyblosxom-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org > https://lists.sourceforge.net/lists/listinfo/pyblosxom-devel ------------------------------------------------------------------------------