I am puzzled a bit now :)  I think I'm doing exactly what you need. The only 
problem is that it is not a part of some known and used wiki engine. But it 
still could be useful as an example. Here is the code, that does all I need 
from "personal" wiki. Note that it is just 
simplified and reworked for asciidoc.

#!/usr/bin/env python
import web
import os, re, mimetypes

import asciidoc


urls = ('/', 'ADoc',
        '/adoc/([a-zA-Z_]+)', 'ADocPage')


class ADoc: 
  def GET(self): 
    web.header("Content-Type","text/html; charset=utf-8") 
    t = re.compile('^[a-zA-Z_]+$') 
    asciidoc_pages = os.listdir(textdir) 
    print "<html><head><title>Texts</title></head><body>" 
    print "<h2>AsciiDoc Pages:</h2><ul>" 
    for page in asciidoc_pages: 
      if os.path.isfile(os.path.join(textdir, page)) and t.match(page): 
        print "<li><a href=\"%(path)sadoc/%(page)s\">%(page)s</a></li>" \
        % {'path':web.ctx.home+web.ctx.path, 'page':page} 
    print "</ul></body></html>" 
class ADocPage: 
  def GET(self, name): 
    page = os.path.join(textdir,name) 
    web.header("Content-Type","text/html; charset=utf-8") 
    if os.path.exists(page): 
      asciidoc.asciidoc('xhtml11', 'article', (), page, '<stdout>', ())
      web.ctx.status = '404 Not Found' 
      print "<html><head><title>Does not exist: %s</title></head><body>" % 
      print "<p>Page %s does not yet exist - " % name 
      print "<a href=\"%s\">Create</a>" % (web.ctx.home+'/editor/'+name) 

web.internalerror = web.debugerror

if __name__ == '__main__': web.run(urls, web.reloader)


Note that I use asciidoc as a module, and I'm displaying xhtml "on-the-fly" - 
the only files that exist on the disk are the text files in asciidoc format. 
Those text files are exactly what I want to have on the disk and in my 
subversion repository. Xhtml is generated and sent in the moment I open it in 
my browser. The option to edit the files in the browser as is usual in wikis 
is unfinished, but I prefer text editor for such a job anyway.


On Monday 29 January 2007 16:06, Dag Wieers wrote:
> Pavel,
> You're certainly right,, but what we are looking at (and hoping to have
> implemented in asciidoc) is a module that can be loaded (like your
> asciidoc.py).
> But instead of having an interface to write it out, we'd like to be able
> to provide a function the input, and get the output back. So that you
> don't have to write it to disk, but can send it to the web-browser.
> It cannot be hard to have asciidoc provide such an interface by default.
> Kind regards,
> --   dag wieers, [EMAIL PROTECTED],  http://dag.wieers.com/   --
> [all I want is a warm bed and a kind word and unlimited power]

Asciidoc-discuss mailing list

Reply via email to