genericwiki with PB 1.1?
Matej Cepl <[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.user |
|---|---|
| Organization | Northeastern University, Boston, MA |
| Message-ID | <[email protected]> |
Can anybody explain me two things (using Pyblosxom 1.1, because I cannot
upgrade Python on the server):
1) is it possible to have two entryplugins according to the extension of the
files in datadir? So, that when I would have in one directory files
somethings.wiki and somethingelse.htm, they would be processed by
genericwiki and htmlentryparser respectively.
2) Does genericwiki.py (from pyblosxom.sf.net webpage) work with Pyblosxom
1.1? When I try it, I get this error:
/data/www/ceplovi/pyblosxom/Pyblosxom/tools.py:492: SyntaxWarning: local \
name 'filename' in 'make_logger' shadows use of 'filename' as \
global in nested scope 'log'
def make_logger(filename):
/data/www/ceplovi/pyblosxom/Pyblosxom/tools.py:492: SyntaxWarning: local \
name 'logger' in 'make_logger' shadows use of 'logger' as global \
in nested scope 'log'
def make_logger(filename):
Traceback (most recent call last):
File "/data/cgi-bin/ceplovi/matej", line 49, in ?
p.run()
File "/data/www/ceplovi/pyblosxom/Pyblosxom/pyblosxom.py", line 91, \
in run_blosxom_handler(self._request)
File "/data/www/ceplovi/pyblosxom/Pyblosxom/pyblosxom.py", line 437, \
in blosxom_handler
tools.run_callback("prepare", {"request": request})
File "/data/www/ceplovi/pyblosxom/Pyblosxom/tools.py", line 438, \
in run_callback
output = mem(input)
File "/data/www/ceplovi/pyblosxom/plugins/conditionalhttp.py", line 22, \
in cb_prepare
if entryList and entryList[0].has_key('mtime'):
File "/data/www/ceplovi/pyblosxom/Pyblosxom/entries/base.py", line 271, \
in has_key
value = self.getMetadata(key, DOESNOTEXIST)
File "/data/www/ceplovi/pyblosxom/Pyblosxom/entries/fileentry.py", \
line 80, in getMetadata
self.__populateData()
File "/data/www/ceplovi/pyblosxom/Pyblosxom/entries/fileentry.py", \
line 132, in __populateData
entrydict = eparser(self._filename, self._request)
File "/data/www/ceplovi/pyblosxom/plugins/genericwiki.py", line 62, \
in parse
if wikibaseurl:
TypeError: object of type 'None' is not callable
[Sat Apr 30 22:51:29 2005] [error] [client 65.227.254.182] Premature end of
script headers: /data/cgi-bin/ceplovi/matej
BTW, what about those warnings?
Thanks for any reply,
Matěj
--
Matej Cepl, http://www.ceplovi.cz/matej
GPG Finger: 89EF 4BC6 288A BF43 1BAB 25C3 E09F EF25 D964 84AC
138 Highland Ave. #10, Somerville, Ma 02143, (617) 623-1488
The ratio of literacy to illiteracy is a constant, but nowadays
the illiterates can read.
-- Alberto Moravia
genericwiki.py
(text/plain, 3.4 KB)
# vim: tabstop=4 shiftwidth=4 expandtab """ Generic wiki markup PreFormatter 2002-11-18, for pyblosxom CHANGE wikibaseurl to point to your wiki, & wikinamepattern to yours Bug reports, comments, presents, etc. to John Abbe at [email protected] ToDo: Lists; code/<pre>; InterWiki links; other wikinamepatterns You can configure this as your default preformatter by configuring it in your L{config} file as follows:: py['parser'] = 'genericwiki' or in your blosxom entries, place a C{#parser wiki} line after the title of your blog:: My Little Blog Entry #parser genericwiki This is a text in '''wiki''' format This preformatter also supports WikiWirds, you need to point out where your Wiki site is. This is configured with a new variable in your config.py file, 'genericwiki_baseurl':: py['genericwiki_baseurl'] = 'http://www.google.com/search?q=' The above example would expand 'WikiWord' to http://www.google.com/search?q=WikiWord """ __author__ = 'John Abbe <johnca at ourpla dot net>' __version__ = "$Id: genericwiki.py,v 1.2 2005/04/30 21:50:57 matej Exp matej $" import re,sys def parse(text, wikibaseurl): """ The main workhorse that convert wiki text into html markup @param text: Text for conversion @type text: string """ # WikiName pattern used in your wiki wikinamepattern = r'\b(([A-Z]+[a-z]+){2,})\b' # original mailurlpattern = r'mailto\:[\"\-\_\.\w]+\@[\-\_\.\w]+\w' newsurlpattern = r'news\:(?:\w+\.){1,}\w+' fileurlpattern = r'(?:http|https|file|ftp):[/-_.\w-]+[\/\w][?&+=%\w/-_.#]*' # Turn '[xxx:address label]' into labeled link text = re.sub(r'\[(' + fileurlpattern + '|' + mailurlpattern + '|' + newsurlpattern + ')\s+(.+?)\]', r'<a href="\1">\2</a>', text) # Convert naked URLs into links -- skip ones with a " before text = re.sub(r'(?<!")(' + newsurlpattern + '|' + fileurlpattern + '|' + mailurlpattern + ')', r'<a href="\1">\1</a>', text) # Convert WikiNames into links if wikibaseurl: text = re.sub(r'(?<![\?\/\=])' + wikinamepattern, '<a href="' + wikibaseurl + r'\1">\1</a>', text) # '' for emphasis, ''' for strong, ---- for a horizontal rule text = re.sub(r"'''(.*?)'''", r"<strong>\1</strong>", text) text = re.sub(r"''(.*?)''", r"<em>\1</em>", text) text = re.sub(r"\n(-{4,})\n", "<hr>", text) # Convert two or more newlines into <p> text = re.sub(r'\n{2,}', r'</p>\n<p>', text) return "<p>" + text + "</p>" def cb_entryparser(args): args['wiki'] = parse return args def cb_preformat(args): """ Preformat callback chain looks for this. @param args: a dict with 'parser' string and a list 'story' @type args: dict """ if args['parser'] == 'genericwiki': config = args['request'].getConfiguration() baseurl = config.get('genericwiki_baseurl', None) return parse(''.join(args['story']), baseurl) if __name__ == '__main__': text = """This is a test To test the wiki [http://roughingit.subtlehints.net/pyblosxom?blah=duh#spam A link] news:roughingit.subtlehints.net/pyblosxom/ - no, ''I'' do '''not''' have a news server. mailto:wari@example should go link to an email. WikiWiki is a wiki Keyword """ print parse(text, 'http://wiki.subtlehints.net/moin/')