JjsCMS

administrators

Summary: Save wiki pages as html
Version: 1.4beta3
Prerequisites:
Status:
Maintainer: jjs
Categories: CMS
Discussion: JjsCMS-Talk

Question

How can I use PmWiki as a CMS

  • without revealing that the pages come from a wiki
  • although my server is slow - too slow for PmWiki serving to everyone
  • even if I don't fully trust PmWiki s security?

Or

  • How can I create a static copy of all pages of my PmWiki?

Answer

Use jjscms. It saves a modified copy of every page into a specified directory. Since version 1.4beta1 this is done for action=jjscmspublish. Modifications include URL-rewriting (to match the new page location) and removal of "confidential" parts of the template like the edit bar.

How it works

jjscms.php uses php's output buffering feature to capture complete pmwiki pages. An in-memory copy of the captured page is filtered with some regexps and saved to a file. Then the original captured page is presented to the user.

The static pages can be served by a webserver without php, or served by a custom script that could even do further "magic".

Usage

Copy jjscms1_4beta3.phpΔ into your cookbook dir.

Add to local/config.php:

  require_once($FarmD . '/cookbook/jjscms1_4beta3.php');  

add to Site.PageActions:

  * %item rel=nofollow class=edit%[[{$FullName}?action=jjscmspublish | $[Publish] ]]

Since 1.4beta3 no further configuration should be needed to get it working.

Advanced configuration

By default jjscms will save all published pages in the published subdir of your wiki. The $PubDir and $UploadDir folders are shared between public (static) and private (editable) version of the wiki.

Depending on how you plan to separate the cms from its output and restrict pmwiki usage via htaccess, you may have to alter the directory structure of the wiki and set the $JJSCMS.., $UploadDir, $UploadUrlFmt configuration variables accordingly. Finding the correct url and path info can be a bit tricky.

You could also secure the wiki dir by .htaccess and write a script to serve all files from there (Attachments and Skin files).

Configuration Variables

$JJSCMSPublishDir
Directory where the static (public) version of the pages will be written to
Default: 'published'
$JJSCMSPublishUrl
URL prefix to be used in all local links in public version of the page.
Should either point to place where the server is serving $PublishDir, or to a skript that takes <Group>.<Page>.html as parameter
Default: ''
$JJSCMSAttachUrl
Attachment url as used in the wiki
Default: 'uploads/'
$JJSCMSPublishAttachUrl
Point to pmwikis shared upload dir
Default: 'uploads'
$JJSCMSPublishPubDirUrl
Point to pmwikis shared pub dir (mainly needed for skins)
Default: '../pub/'
$JJSCMSPrivateSection
Anything enclosed by <!-- $JJSCMSPrivateSection --> <!-- /$JJSCMSPrivateSection --> in your template will only show up in the private (editable) version of the page.
Default: 'dontpublish'
$JJSCMSPublicSection
Anything enclosed by <!-- $JJSCMSPublicSection --> <!-- /$JJSCMSPublicSection --> in your template will only show up in the public (static) version of the page.
Default: 'dontedit'

Password Protection

Action jjscmspublish can be password protected. Look at the GroupAttributes page. In 1.4beta1 the default password is empty!

Defining what pages may be published

If JJSApprovePage is installed, jjscms will only publish a page if it is in approved state.

Skin / Template changes

You probably have to alter your skins .tmpl file so that the stylesheet-url works from pmwiki as well as in the static version.

To completely remove the edit bar from the static version, add the comment pairs from above around the edit bar section in your skins .tmpl file.

Using a different Skin for publishing

To use the "print" skin for publishing add

$ActionSkin['jjscmspublish'] = 'print';

to your local/config.php

Script

Here's a sample script for serving the static pages. You can name it index.php and put it in the main directory of your site.

It assumes the static pages to reside in ./published

Attachments and skin files must be accessible from their original location.

The $JJSCMSPublishUrl should read index.php?showcmspage=

  
  <?php
  if (isset($_REQUEST['showcmspage'])) 
  {
    $cmspage =   preg_replace('/([[:alnum:]])\.html/s','$1.html',trim($_REQUEST['showcmspage']));
    @readfile('published/' . $cmspage);
    return;
  }
  else
  {
    @readfile('published/Main.HomePage.html');
    return;
  }
  ?>

2006-03-18 Jens Schiffler

Notes

Versions

date of publication : 2005-09-10 : jjscms - version 1.0

date of publication : 2006-01-20 : jjscms - version 1.0

date of publication : 2006-03-18 : jjscms - version 1.4beta1

date of publication : 2006-03-19 : jjscms - version 1.4beta2

date of publication : 2006-03-21 : jjscms - version 1.4beta3

  • This recipe was last tested on PmWiki version: 2.1.3
  • This recipe requires at least PmWiki version: 2.1.beta1

See Also

JJSApprovePage

Contributors

jjs

Comments

See discussion at JjsCMS-Talk

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.