qwiki

  1. qwiki
    1. Description
    2. Author
    3. Repository
    4. Requirements
    5. Documentation
    6. How to set it up
      1. Create a subversion repository
      2. Deploy qwiki
      3. Create a spiffy configuration
      4. Customizing Qwiki
        1. qwiki
        2. qwiki-svn
        3. qwiki-menu
        4. qwiki-install
        5. qwiki-post-commit-hook
    7. Changelog
    8. License

Description

A fast and light-weight wiki.

Author

Ivan Raikov and Peter Bex

Repository

This egg is hosted on the CHICKEN Subversion repository:

https://anonymous@code.call-cc.org/svn/chicken-eggs/release/6/qwiki

If you want to check out the source code repository of this egg and you are not familiar with Subversion, see this page.

Requirements

Note: the following dependency has been dropped, even though the code to run it is still in the repo:

Documentation

qwiki is the "quick wiki". It is a lightweight wiki which uses sxml for internal wiki page representation. This makes it relatively easy to extend.

In the future we also hope to support multiple storage backends but right now subversion is the only implementation of that.

How to set it up

Create a subversion repository

You should first create a subversion repository, if you don't already have one. Then, make a script called post-commit which you put in repo's hooks directory. This script should invoke the qwiki-post-commit-hook! procedure from the qwiki-post-commit-hook module. Here's an example (path/to/your/repo/hooks/post-commit):

#! /usr/bin/csi -s

(import qwiki qwiki-svn qwiki-post-commit-hook)

;; the URI for the subversion repository from where a copy can be
;; checked out
(qwiki-repos-uri "file:///path/to/the/repository/directory")

;; the path to where the checkout of the repository will be stored
(qwiki-source-path "/path/to/the/checkout/directory")

;; the path used by the web server to serve wiki pages
(qwiki-web-path "/path/to/web/server/documents/directory")

;; If you don't want to use these extensions, you can remove these lines
(import qwiki-menu)
(menu-install!)

(qwiki-post-commit-hook!)

If you prefer, you can delay setting up the post-commit hook until after you got the wiki up and running (this is a good idea if people will be committing to the repository while you are setting this up).

You can also call the post-commit scheme script (like the example above) from any other script you want to use as the actual post-commit script. You can also call arbitrary other scripts from the Scheme script, of course.

Don't forget to make the script executable!

Deploy qwiki

Now you are ready to run the qwiki installation procedure which will create an initial checkout and process all files to make a cached HTML file for each wiki page.

The best way to do that is by creating a script which sets the required parameters and calls qwiki-install!. Here's a simple example:

(import qwiki qwiki-install qwiki-svn)

;; the URI for the subversion repository from where a copy can be
;; checked out
(qwiki-repos-uri "file:///path/to/the/repository/directory")

;; the path to where the checkout of the repository will be stored
(qwiki-source-path "/path/to/the/checkout/directory")

;; the path used by the web server to serve wiki pages
(qwiki-web-path "/path/to/web/server/documents/directory")

;; install qwiki
(qwiki-install!)

Here's a more complex example:

(import qwiki qwiki-install qwiki-menu qwiki-svn)
(import (chicken port)) ;; for with-output-to-port

;; Try to read the svnwiki user password
(handle-exceptions
 exn
 (begin
   (with-output-to-port (current-error-port)
     (lambda ()
       (print "Could not read the password file for the SVN user.  Aborting.")))
   (exit 1))
 (qwiki-repos-password
  (with-input-from-file "the-password-file" read-line)))

(menu-install!)
(qwiki-repos-username "the-wiki-user")
(qwiki-css-file "/wiki.css")
(qwiki-title "The wiki")

(qwiki-repos-uri "file:///var/svn/")
(qwiki-source-path "/tmp/qwiki")
(qwiki-web-path "/var/www/spiffy/wiki")

(qwiki-install!)

The values for qwiki-source-path and qwiki-web-path should not overlap.

The exact directory locations are up to you, of course, but they will have to match the locations of the post-commit-hook.

Now, you can run this script to get started.

Create a spiffy configuration

Currently qwiki can only run under Spiffy, so you will either have to run spiffy as your main webserver, or proxy all requests for the wiki to it.

(import spiffy qwiki qwiki-menu qwiki-svn)

;; If you don't want these extensions, remove them from this script
(menu-install!)

(qwiki-repos-uri "file:///path/to/repos")
(qwiki-source-path "/path/to/the/checkout/directory")

;; Ensure this is an absolute path, if you are using Chicken 4.1 or earlier
(root-path "/var/www/html/qwiki")

;; Pass all requests to non-existent files through qwiki:
(vhost-map `((".*" . ,(lambda (continue)
                        (parameterize ((handle-not-found qwiki-handler)
				       (handle-directory qwiki-handler)
				       (index-files '()))
                           (continue))))))

(start-server)

When you run this, your qwiki installation should be available at http://localhost:8080

Customizing Qwiki

qwiki

These parameters are exported by the qwiki module.

[parameter] (qwiki-css-file [FILE])

Set an optional CSS file to use for styling the wiki. FILE should be a string, which is parsed into an uri-common object by the uri-reference procedure. This URI should be relative to the docroot. Defaults to #f.

[parameter] (qwiki-title [TITLE])

Set an optional global TITLE or "name" for the wiki. This will appear on every page in the browser's titlebar to inform the user that he's on a page of this particular wiki. Defaults to #f.

[parameter] (qwiki-source-path [DIRECTORY])

The directory where qwiki expects a checkout of the repository that holds the wiki pages. When running the installation procedure, it will make this checkout.

The value defaults to the environment variable QWIKI_SOURCE_PATH if set. Otherwise it will default to "/tmp/qwiki".

[parameter] (qwiki-web-path [DIRECTORY])

The directory where qwiki will write its generated and cached HTML files to. Defaults to the environment variable QWIKI_WEB_PATH if set, otherwise will default to "/var/www".

This variable is only for when qwiki is called from the commandline or through the post-commit hook. It is ignored when running qwiki through qwiki-handler inside Spiffy. In that case it will just use Spiffy's root-path.

[parameter] (qwiki-docroot [DIRECTORY])

In case you want qwiki be accessible underneath a subdirectory of spiffy, you can use this. (it's unsure whether this even works and whether it will stay)

[parameter] (qwiki-base-uri [URI])

The URI (an uri-common object) under which this wiki is available. All internal links will use this as their base URI. Defaults to /.

[parameter] (qwiki-output-driver [TRANSFORMATION-RULES])

This defaults to qwiki-html-transformation-rules from the qwiki-sxml module. In principle, this allows you to generate different formats of output (like LaTeX, Texinfo or others), but the alternate implementations that used to exist have bitrotted, so they're no longer shipped.

[parameter] (qwiki-extensions [EXTENSIONS])

This parameter can be extended to add transformation rule extensions to the output driver. Defaults to the empty list.

A transformation rule is simply a ruleset accepted by pre-post-order*.

[parameter] (qwiki-update-handlers [HANDLERS])

This parameter can be extended to add update callbacks which will be invoked when a wiki page was updated. Defaults to the empty list.

An update hook is a procedure that accepts a path to the wiki page (a list of path components) and the sxml which represents the new contents.

[parameter] (qwiki-delete-handlers [HANDLERS])

This parameter can be extended to add update callbacks which will be invoked when a wiki page was removed. Defaults to the empty list.

[parameter] (blocked-ip-addresses-file [PATH])

A path relative to the qwiki checkout which points to a file containing IP addresses to be blocked, one address per line. Useful for combating spam.

Defaults to "edit-deny".

[parameter] (qwiki-current-file [PATH])

Not to be touched in the configuration; this is a run-time parameter used to indicate the current wiki file being processed. Useful for use in transformation rules.

qwiki-svn

These parameters are exported by the qwiki-svn module.

[parameter] (qwiki-repos-uri [URI-STRING])

The URI to the subversion repository. Defaults to #f, so you must configure this!

[parameter] (qwiki-repos-username [USERNAME])

The username for commits done from the wiki interface when the user chooses not to authenticate. Default: "anonymous"

[parameter] (qwiki-repos-password [PASSWORD])

The password for the qwiki-repos-username user. Default: ""

qwiki-menu

These parameters are exported by the qwiki-menu module.

[parameter] (menu-file [PATH])

If not #f, this file will contain (in wiki syntax) the contents of the menu which is rendered on all wiki pages. Should be relative to the wiki checkout directory. Defaults to "/menu".

qwiki-install
[procedure] (qwiki-install!)

Performs the steps for installing qwiki. It uses the parameters qwiki-repos-uri, qwiki-source-path and qwiki-web-path and considers their values are valid ones.

This procedure is to be used by installation scripts.

qwiki-post-commit-hook
[procedure] (qwiki-post-commit-hook!)

Executes the required steps after a commit is performed. It uses the parameters qwiki-repos-uri, qwiki-source-path and considers their values are valid ones.

This procedure is to be used by Subversion post-commit scripts.

Changelog

License

 Copyright (c) 2009-2024, Ivan Raikov and Peter Bex
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are
 met:
 
 Redistributions of source code must retain the above copyright
 notice, this list of conditions and the following disclaimer.
 
 Redistributions in binary form must reproduce the above copyright
 notice, this list of conditions and the following disclaimer in the
 documentation and/or other materials provided with the distribution.
 
 Neither the name of the author nor the names of its contributors may
 be used to endorse or promote products derived from this software
 without specific prior written permission.
 
 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 OF THE POSSIBILITY OF SUCH DAMAGE.