'From Squeak2.9alpha of 21 February 2001 [latest update: #2740] on 21 February 2001 at 12:14:57 pm'!

ComancheModule subclass: #SwikiModule
    instanceVariableNames: 'shelf '
    classVariableNames: ''
    poolDictionaries: ''
    category: 'Swiki-Comanche'!


!SwikiModule commentStamp: '<historical>' prior: 0!
SwikiModule

This class gets Comanche to talk to swiki.

In the folder for the swiki, several things are of significants:

    settings.xml        The XML file which contains the settings
    security.xml        The XML file which contains the security
    setup.xml        The XML file which contains the setup
    log.txt            The log file if 'logging' is set to 'local' in the setup file
    addresses        This directory contains the valid addresses
    templates        This directory contains the valid templates
    actions            This directory contains the valid actions
    pages            This directory contains the swiki pages
    uploads            This directory contains the uploads
    rendered        This directory will contain the rendered swiki if the swiki is rendered!


!SwikiModule methodsFor: 'accessing' stamp: 'je77 5/6/2000 13:03'!

shelf
    ^shelf! !

!SwikiModule methodsFor: 'accessing' stamp: 'je77 5/6/2000 13:03'!
shelf: aSwikiShelf
    shelf _ aSwikiShelf! !


!SwikiModule methodsFor: 'processing' stamp: 'je77 5/6/2000 13:19'!

filter: rawRequest
    ^HttpSwikiRequest fromHttpRequest: rawRequest! !

!SwikiModule methodsFor: 'processing' stamp: 'Je77 7/28/2000 12:05'!
process: rawRequest
    | request response |
    request _ self filter: rawRequest.
    response _ Dictionary new.
    shelf process: request response: response.
    ^self responseFrom: response! !

!SwikiModule methodsFor: 'processing' stamp: 'je77 6/6/2000 09:03'!
responseFrom: dict
    | response |
    response _ HttpResponse new.
    "header status"
    response status: (dict at: 'headerStatus' ifAbsent: [#ok]).
    "cacheing"
    (dict at: 'cacheing' ifAbsent: [false]) ifFalse: [
        response fieldAt: 'Pragma' put: 'no-cache';
            fieldAt: 'Expires' put: '0';
            fieldAt: 'Cache-Control' put: 'no cache'].
    "location (in case of redirect)"
    (dict includesKey: 'location') ifTrue: [
        response fieldAt: 'Location' put: (dict at: 'location')].
    "authenticate (in case of unauthorized)"
    (dict includesKey: 'authenticate') ifTrue: [
        response fieldAt: 'WWW-Authenticate' put: (dict at: 'authenticate')].
    "content type"
    response contentType: (dict at: 'contentType' ifAbsent: [MIMEDocument contentTypeHtml]).
    "contents"
    ((dict at: 'content') isKindOf: String)
        ifTrue: [response contents: (ReadStream on: (dict at: 'content'))]
        ifFalse: [response contents: (dict at: 'content')].
    "return the response to be served"
    ^response! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

SwikiModule class
    instanceVariableNames: ''!



!SwikiModule class methodsFor: 'instance creation' stamp: 'je77 5/6/2000 13:13'!

swikiWebServer
    | instance |
    instance _ self newModuleNamed: 'swiki'.
    instance shelf: (SwikiShelf new
        storage: (XmlSwikiStorage fromDir: (FileDirectory default directoryNamed: 'swiki'));
        load;
        yourself).
    ^instance! !