One of the finest universities north of Prospect in Fort Collins

Jack Applin

PmWiki

CS Dept. PmWiki WikiFarm

Definitions

PmWiki:

Farm:

  • A (wiki)farm has many (wiki)fields.
  • The farm contains the pmwiki executables, scripts, and common data such as skins.
  • Our farm is in ~cs000/public_html/pmwiki/.
  • We need only one copy of the pmwiki scripts—easier to keep up-to-date. Also, we only need one copy of the local customization cookbook/ scripts.

Field:

  • Each semester of a class, or each user, has its own field.
  • Mostly just the data pages for this particular wiki.
  • Also CSS style information.
  • Also local cookbook recipes (php extension scripts).
  • One field is ~ct320/public_html/Fall18/pmwiki/
  • Another field is ~applin/public_html/pmwiki/

Directory hierarchies

The directory hierarchy for the wiki farm at ~cs000/public_html/pmwiki:

    pmwiki/		 	 the entire farm
       cookbook/                 farm-wide recipes, one per file
          array.php              defines the recipe (:array:)
          …
          unavailable.php        defines the recipe (:unavailable:)
       local/
          farmconfig.php         customization for this entire farm
       pmwiki.php                the main PmWiki script
       pub/
          skins/                 skins affect how wiki pages apear
             CS3/                Jack’s imitation of CS-Roo
             pmwiki/             default pmwiki skin
             print/              skin for printing
      scripts/                   other parts of the PmWiki implementation
      wikilib.d/                 standard documentation wiki pages

The directory hierarchy for the wiki field at ~ct320/public_html/Fall18:

    .htaccess			 web server control: map all requests to index.php
    index.php			 a “springboard” that transfers control to the farm
    pmwiki/			 the entire field
       cookbook/		 local recipes, for this field only
          bash.php		 define (:bash:) for live bash examples
       local/
          config.php		 customization for this field
       pub/
          css/
             local.css	         CSS styles for this field
             Main.Schedule.css   CSS styles for this particular page
       wiki.d/
          Lecture.Bash	         an actual wiki page
          …
          Main.HomePage	         an actual wiki page
          Main.Schedule	         an actual wiki page
          Main.Syllabus	         an actual wiki page

Execution

  • Our Apache web server uses suPHP, so PHP scripts execute as their owner.
  • We want our field to execute as the field’s owner, not as the farm’s owner.
  • Therefore, we use a “springboard” script in the field that transfers control to the farm.
  • The springboard file is Apache’s starting point, and executes as the field user.

Here is ~ct320/public_html/Fall18/index.php:

    <?php
    # A (Wiki)Farm has many (Wiki)Fields.
    # 
    # Farm: 
    #	The pmwiki executables, scripts, and common data such as skins.
    #	Our farm is in ~cs000/public_html/pmwiki.  We need only one copy
    #	of the pmwiki scripts--easier to keep up-to-date.  Also, we only
    #	need one copy of the local customization cookbook/ scripts.
    #
    # Field:
    #	Essentially only the data pages for this particular wiki.
    #	It also contains css/ customization, and local cookbook/ scripts.
    #	The field for CT320 Fall17 is ~ct320/public_html/Fall17/pmwiki.

    chdir('pmwiki'); # field directory
    require posix_getpwnam('cs000')['dir'] . '/public_html/pmwiki/pmwiki.php';

File/Directory Permissions

The farm is completely open. Everything is owned owned by cs000, Directories are mode 755, plain files are mode 644.

Field files are all owned by the field owner (e.g., ct320). These have tighter permissions, since some wiki pages are secret (quizzes, tests) and we don’t want anyone but us changing the files:

    drwxr-xr-x Fall18
    drwx--x--x Fall18/pmwiki
    drwx------ Fall18/pmwiki/cookbook
    -rw------- Fall18/pmwiki/cookbook/*.php
    drwx------ Fall18/pmwiki/local
    -rwx------ Fall18/pmwiki/local/config.php
    drwx--x--x Fall18/pmwiki/pub
    drwx--x--x Fall18/pmwiki/pub/css
    -rw-r--r-- Fall18/pmwiki/pub/css/*.css
    drwx------ Fall18/pmwiki/wiki.d
    -rw-rw-r-- Fall18/pmwiki/wiki.d/*

pmwiki/pub/css/*.css files are read directly by the web server, so they must be publicly readable, and the directories above it must be executable.

All other plain files (recipes, config.php, and wiki pages) are read only by PHP scripts. Therefore, they can be mode 600.

The permissions of pmwiki/wiki.d/* don’t matter, since pmwiki/wiki.d limits access to them. PmWiki keeps changing their permissions, so I ignore them.

Edit Access

  • Unlike Wikipedia, the wiki pages are not editable by everybody.
  • Here is ~ct320/public_html/Fall18/pmwiki/local/config.php:
    <?php

    $staff = 'id:'.get_current_user()	# the class itself (e.g., ct320)
	  . ',id:applin'		# the instructor, Jack Applin
	  . ',id:TA-NAME-HERE';		# a teaching assistant

    # Only teaching staff may edit pages:
    $DefaultPasswords['edit'] = $staff;

    # Only teaching staff may read tests:
    if (preg_match('/\.(Quiz|Midterm|Final)/', $pagename))
	$DefaultPasswords['read'] = $staff;

    ### # This semester is retired, so only teaching staff may read old homework:
    ### if (preg_match('/\.HW\d+$/', $pagename))
    ###     $DefaultPasswords['read'] = $staff;

    $S5_header_color = 'purple';    # Slide headers/footer color
  • The first assignment to DefaultPasswords says that only user who can edit pages in this field are:
    • ct320 (the class login itself)
    • applin (the instructor)
    • a teaching assistant
  • The second assignment to DefaultPasswords makes the tests readable only by the people who can edit them.

URLs

Wiki URLs look like this:

Wiki pages have a two-level hierarchy, a group and a page. The group defaults to Main.

In all cases, the Apache web server executes the springboard script ~ct320/public_html/Fall18/index.php.