Re: Re: reST

[email protected]
Newsgroups gmane.comp.web.pyblosxom.user
Message-ID <[email protected]>
hello

On Thu, 3 Apr 2003, Wari Wahab wrote:

> All you need is some mini doc in a docstring that explains to potential
> users of the plugin on where they should download what and how to
> install, etc. How do you do thumbnails in your site? You can read up on
> how Kai did his at
> http://db.cs.helsinki.fi/~hendry/log/pyblosxom.cgi/blogs/textilethumb.html
> with the textile parser. He pretty much uses the python imaging library
> for his thumbnail stuff. I believe that can be converted into a
> postformatter (since that part of the plugin infrastructure is stabilized)

I solved this problem in the simplest manner I could think of: I have an
"images" directory in my public_html directory, and a script that uses
ImageMagick to create thumbnails for all the images in the directory.
Then I just refer to the images by relative url in my posts.

I don't know how to use a postformatter to do thumbnails without mucking
around in reStructuredText stuff, which I really don't want to do.  Maybe
there's a good, easy way and I just don't see it.

Attached is a version of rst.py with a usage docstring.  Let me know if
the instructions are good enough.

regards,
Sean
rst.py (text/plain, 877 B)
"""
A reStructuredText entry formatter for pyblosxom.  reStructuredText is 
part of the docutils project (http://docutils.sourceforge.net/).  To 
use, you need a *recent* version of docutils.  A development snapshot 
(http://docutils.sourceforge.net/#development-snapshots) will work fine.  

Install docutils, copy this file to your pyblosxom libs/plugins
directory, and you're ready to go.  Files with a .rst extension will be
marked up as reStructuredText. 
"""

from docutils.core import publish_string

def cb_entryparser(args):
    args['rst'] = parse
    return args

def parse(filename, request):
    d = file(filename).read()
    title = d.split('\n')[0]
    d = d[len(title):]
    html = publish_string(d, writer_name='html')
    body = html[html.find('<body>') + 6:html.find('</body>')]
    return {'title': title,
            'body': body}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.