Squeak Class Documentation category index | class index  
 
SwikiAction
  category: Network-Pluggable Web Server
  superclass: ServerAction
  subclasses: AuthorizedSwikiAction CachedSwikiAction ActiveSwikiAction PSwikiAction

SwikiAction is the action to implement a Swiki, a collaborative website.
This is a web server in Squeak. Each page served has an "Edit this Page"
link. The syntax rules for editing pages (from any web browser) are in the
file FormattingRules.

The pages may be viewed from any web browser, and the URL is
http://thisMachine:80/OurOwnArea.1 ('OurOwnArea' is the name of the Swiki
area.) See http://guzdial.cc.gatech.edu:8080/myswiki for an example
focused on discussing Swikis.

Swiki is based on the Wiki Server, designed and implemented by Ward
Cunningham. See the original Wiki at http://c2.com/cgi-bin/wiki, or the
Squeak-focused one at http://c2.com:8080/

See PWS class howToStart.

Modified by Ted Kaehler to have all state on the disk at all times. Do not
snapshot the image during normal server operation. Restart the server by
loading all state from the disk.

Each separate Wiki is a folder inside the Server folder. The name of the
folder is the name of the Wiki. Each page is a file. (Inefficient on Macs
because of large minimum page size, but that's an OS problem.) All
versions of all pages are kept. Each page contains chunks, just like a
changes file. Each chunk is one version of one page:

self name: 'Ted''s Page' date: '1/28/1998' time: '12:47:21' by: 'tk' text:
'Here is the body of the page' back: 116!

The last item is number of bytes in the chunk. It is the number of bytes
from the start of the chunk to just in front of the number. This allows
back-chaining to old versions. On startup, the chunk is executed
explicitly using evaluate:for:logged:. It supplies the page name to a
SwikiPage and installs it in the URLmap. By doing this for all files in
the folder, the map (url->page) is built. During operation, the chunk is
not executed. Instead, take the file directly, look at 'back:' at the end,
jump back to the start of the chunk, scan for 'text:' and read the text.

The looks of the pages served are controlled by templates. They live in
the 'swiki' folder in the 'Server' folder. See page.html for how to change
the look of a served page. Beware that templates are cached by
HTMLformatter. If you change a template, you will not see the effect until
you reload the Swiki.

A symbol *append here* may be added anywhere in the page. Clicking on it
will bring up a page with a text editing form. The what you type will be
inserted just before the *append here* marker. This allows append-only
pages, or multiple questions with places to add to the answer.

instance methods
  URL processing
  browse:from:
edit:from:
inputFrom:
log:
pageURL:
process:
process:MIMEtype:
smtlk:

  accessing
  formatter
formatter:
map
map:
name
name:
path
source
source:
url
urlmap
urlmap:

  formatters
  clearFormatterCache
formatterFor:

  save and restore
  convert
fixAllLineEndings
restore:
restoreFrom:
rollBack:at:
saveTo:

class methods
  initialization
  mapClass
pageClass
restore:from:
setUp
setUp:

instance methods
  URL processing top  
 

browse:from:

Just reply with a page in HTML format


 

edit:from:


 

inputFrom:

Take user's input and respond with a searchresult or store the edit


 

log:


 

pageURL:

make the URL suited to aPage in this Action


 

process:

URLs are of the form:
{swikiname} browse Front Page
{swikiname}.{coreID} browse the page number coreID
{swikiname}.{coreID}.edit request to edit the page
{swikiname}.{coreID}.versions show the last three versions of the page
{swikiname}.{coreID} {with a field named 'text'} store an edited page
{swikiname}.{coreID}.insert.{placeID} request to insert text in a
specific place in a page
{swikiname}.{coreID} {with a field named 'text-placeID'} store
text in a specific place
-------
{swikiname}.{coreID}.all displays the page and all its references
{swikiname}.searchresult conducts the search and displays the result
{swikiname}.recent to bring up the recent changes list
{swikiname}.{coreID}.searchresult returns a search for references
to coreID's key
{swikiname}.{picName}.gif or .jpeg, .jpg, .jpe, .html (upper or
lower case) return
the picture or static page stored in the {swikiname} folder.


 

process:MIMEtype:

See if there is a .gif file on my disk of this name, and send it out.


 

smtlk:

Return Smalltalk sourcecode. URL =
machine:80/myswiki.smtlk.Point|at; included are: Point|at:
Point|Comment Point|Hierarchy Point|Definition Point|class|x;y; NOTE:
use ; instead of : in selector names!!!


  accessing top  
 

formatter


 

formatter:


 

map

Answer the receiver's 'urlmap'.


 

map:

Set the receiver's instance variable 'urlmap' to be anObject.


 

name

Answer the receiver's 'name'.


 

name:

Set the receiver's instance variable 'name' to be anObject.


 

path

A complete file path name to the directory where my page data is stored


 

source

Answer the receiver's 'source'.


 

source:

Set the receiver's instance variable 'source' to be anObject.


 

url

Answer the receiver's 'name'.


 

urlmap

Answer the receiver's 'urlmap'.


 

urlmap:

Set the receiver's instance variable 'urlmap' to be anObject.


  formatters top  
 

clearFormatterCache

remove all formatters


 

formatterFor:

get the formatter for the given name.
uses lazy initialization. Could eventually check whether the on-disk file
has been updated.


  save and restore top  
 

convert

Make all my pages obey the new format -- all versions in one file, file name is just a single number.


 

fixAllLineEndings

for each page in the swiki, fixes line endings to be CR only.
This is used to bring older Swikis up to date with the newer convention.
If a page has no LF's, then it is left alone


 

restore:

Read all files in the directory 'nameOfSwiki'. Reconstruct the
url map.


 

restoreFrom:


 

rollBack:at:

Roll back the entire server to a previous state. This does not erase data, just moves an older page to the end.


 

saveTo:


class methods
  initialization top  
 

mapClass

The class of my pages


 

pageClass

The class of my pages


 

restore:from:

Obsolete. For old format pages only!!! Get all the info about a Swiki from its folder.


 

setUp


 

setUp:

Set up a named Swiki