CreditsBlock

Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.


Goal

To add a block of text to PmWiki pages showing the last editor and all previous editors, as in:

Last edited by AliceFakename. Based on work by BobNotaperson, CharlieDoesntexist and anonymous users of SomeWiki.

Solution

This script creates a variable $CreditsBlock that can be used in PmWiki templates. Configuration variables allow some variation on the text used in the credits block.

Discussion

To install the software, unpack the tarball or zip file, and copy its contents to your pmwiki directory:

 
     tar zxf pmwiki-credits-0.2.tar.gz
     cp -R pmwiki-credits-0.2/* /path/to/pmwiki/

You can use the extension by adding the following line to your local/config.php file:

  
     include_once('cookbook/credits.php');

This will create a variable, $CreditBlock, that you can put into your PmWiki templates however you like. I put mine at the bottom at the page, right after the "last edited" stuff.

The module can be configured with the following variables:

  • $CreditLimit -- Maximum number of credits to list. 0 means leave out the credits block entirely, 1 means just the last author, and -1 (or anything less than 0) means no limit. The default is -1. And, yes, it's a pun.
  • $CreditLastFmt -- A pattern for the credit block, showing the last person to edit the page. Use the substitution variable "$last" to show where to put the name. Defaults to "Last edited by \$last."
  • $CreditOthersFormat -- A pattern for the credit block, showing the other people who've edited the page. Use the substitution variable "$others" to show where to put the list of other contributors. Defaults to "Based on work by \$others."
  • $CreditAnonymous -- A string meaning a single anonymous user. Default is "an anonymous user of $WikiTitle".
  • $CreditAnonymousPlural -- A string meaning a multiple anonymous users. Default is "anonymous users of $WikiTitle".
  • $CreditAnd
  • $CreditComma -- for turning lists into text. Default "and" and "," respectively.

History

  • 2004 May 28 -- 0.1. First version, probably pretty buggy.
  • 2004 July 20 -- 0.2. Change to comply with the ComplexRecipes layout.

Comments & Bugs

  • The ListToText() function is probably too focused on English, and may not work well for other languages.
  • Doesn't create links to the profile pages for each contributor listed.
  • Doesn't space out names ("EvanProdromou" -> "Evan Prodromou").
  • Doesn't actually respect $CreditLimit; more than $CreditLimit names will be listed, if it's a positive integer greater than 1.
  • Should show "overflow" credits on a separate page.
  • Reads the page before any other code gets to it; it would be nice to figure out a way to "hook" into page display, so the file doesn't have to be read twice.
  • If page history expires or is forced to expire, those authors are no longer credited.

Contributors

Copyright

Copyright 2004, Evan Prodromou. Made available to you through the General Public License (GPL), which is in the zip file. pmwiki-2.2.113 -- Last modified by {{EvanProdromou}}

from IP: 85.171.160.186 ip should be disabled by default for security reasons