User:Austin J. Che/Extensions/Dewikify
This script/extension allows making a group of wiki pages look like a static page. For info about this script running on this wiki, see OpenWetWare:Dewikify. Also see the OpenWetWare:Dewikify/Demo page for the dewikify process in action.
The main script is a perl library (Dewikify.pm). To adapt the script to your own wiki or server, download the script and follow the instructions in the comments at the top. Briefly, you will need to create an index.cgi on your web server's root. This cgi file should load the library and set the appropriate variables to run the script. Note that this script does not need to be run on the same machine as the wiki server. In addition, some mod_rewrite rules are necessary to rewrite all paths to the index.cgi script.
An optional step is to install the dewikify.php Mediawiki extension. This does require access to the wiki serer. This extension is required for the wikionly and nonwikionly tags.
The first stage of processing is to obtain the CATEGORY of pages to be dewikified. This can be either hard coded (for a single server) or automatically determined based on the virtual host. See the %MAPPING array for adding your own mappings. The mapping uses the host name as follows. Suppose the host name is foo.domain.com. If foo.domain.com exists in the mapping, then that is used. If that doesn't exist, then domain.com is looked up. Finally, if that fails also, foo is looked up in the mapping array.
The virtual root page will be [[CATEGORY]] on the wiki. All pages that are linked from there that begin with CATEGORY will be stripped from the link and the link will redirect back to the same virtual host. Thus, with an appropriately designed page with only links to pages beginning with CATEGORY, the user browsing the site does not ever need to know the pages are coming from a wiki.
The pages are dewikified by grabbing the page content and inserting it inside a template. The default template is Dewikify:Default on the wiki. The page [[Dewikify:CATEGORY]] will be used if it exists. In the template, insert !BODY! and it will be replaced by the page text. For example, look at Dewikify:Synthetic Biology (try to edit the page to see the content).
Pages are cached for some controllable amount of time. See the $WIKI_CACHE_DIR and $CACHE_LIFE variables. The setup on this wiki contains an extra rewrite rule that allows adding a character to the end of any url to clear the cache and automatically jump to the wiki edit page.
Sometimes it is useful to have different text show up on the wiki and dewikified version. For this, the Mediawiki extension needs to be installed. The extension creates two tags:
<wikionly>This text will only appear on the wiki, and not when being dewikified</wikionly> <nonwikionly>This text will only appear on the dewikified version and not on the wiki</nonwikionly>
These tags are handled similar to a pre-processor. What this means is that you can conditionally include wiki markup. For example, lists work correctly (see the OpenWetWare:Dewikify/Demo page). If a wikionly/nonwikionly brackets an entire line, the entire line (i.e. the newline also) is removed.