Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

CMSBundle

Summary: Some scripts that add features useful for a CMS-type installation.
Version: Sprout
Prerequisites: PmWiki 2.1.x
Status: Partial development
Maintainer: Hagan Fox
Categories: CMS

Description

This recipe is an as-yet-incomplete set of scripts that add features useful for a site that is using PmWiki as a Content Management System.

Notes

When I create a new PmWiki site I nearly always install a certain few of my customized recipe scripts. I started a project to bundle those scripts together and publish them, but that project has slowed nearly to a halt. The scripts may be useful individually, so I've uploaded some of them to pmwiki.org (usually accompanying a post to the pmwiki-users list).

CMS Mode script

cmsb-cmsmode.phpΔ - This recipe script adds the following to a PmWiki site:

  • Certain changes to the site's behavior when the visitor isn't permitted to edit pages.
    • Only essential site-related actions are permitted. This way, for example, ?action=diff and ?action=source have no effect.
    • Only your site's pages will appear in search results.
    • Most PmWiki-related pages will be inaccessible.
    • The rel="nofollow" attribute is removed from external links, which will signal search engines to index them.
    • Page modification times are simplified to just a date.
  • (All)RecentChanges pages are modified so they're more appropriate to be used as public web feeds.
    • RecentChanges pages other than $SiteGroup.AllRecentChanges will have a web feed-friendly format, with PmWiki-related pages excluded.
    • A Main.AllRecentChanges page is created that is appropriate to be used as a public site-wide web feed page.

Blocklist Script (Deprecated)

cmsb-blocklist.phpΔ - This script is a fork of the Blocklist2 script. At this point it's significantly different from the original. Some of the more noticeable differences:

  • There's no regex matching.
  • The default blocklist pages are $SiteGroup.FarmBlocklist, $SiteGroup.Blocklist, and Main.Blocklist.
  • You can do whole-string matching by double-quoting a string (so block:"urge" doesn't match the word "burger").
  • There's Unblocklist capability so a wiki in a farm can override items in the farm-wide blocklist.
  • The script is capable of logging to a wiki page ($SiteGroup.Blocklog by default).

As of PmWiki 2.2.0-beta7 a blocklist feature has been added to the PmWiki core. You should probably use PmWiki's bundled blocklist capability instead of cmsb-blocklist.php. That said, if cmsb-blocklist is installed and working there's no compelling reason to switch over -- at least not in a hurry.

Addlink Bookmarklet script

cmsb-addlink.phpΔ - This is a fork of an old version of the AddLinkBookmarklet recipe, which at the time seemed unmaintained and overlooked. At this point it's significantly different from the original.

This recipe creates an "add link" bookmarklet that makes it easy save web site links in your wiki. It works like this:

  • Insert (:addlink:) in a page.
  • Add the link as a bookmark in your browser.
  • Optionally delete the (:addlink:) markup from the page.
  • Surf the web and find a page you want to bookmark.
  • Highlight some descriptive text in the page.
  • Use the bookmark.

Your browser will be taken to your site in edit mode. By default the page's title will become a definition term and the text you highlighted will become the definition for the term. A bookmark for pmwiki.org has markup that looks like this

:[[http://www.pmwiki.org/wiki/Cookbook/CMSBundle|PmWiki | Cookbook / CMSBundle]]:Some scripts that add features useful for a CMS-type installation.

and renders like this

PmWiki | Cookbook / CMSBundle
Some scripts that add features useful for a CMS-type installation.

Optionally you can have the recipe create "heading style" (a.k.a. Herber style) markup that looks like this

!!!PmWiki | Cookbook / CMSBundle

http://www.pmwiki.org/wiki/Cookbook/CMSBundle

Some scripts that add features useful for a CMS-type installation.

and renders like this

PmWiki | Cookbook / CMSBundle

http://www.pmwiki.org/wiki/Cookbook/CMSBundle

Some scripts that add features useful for a CMS-type installation.

Local configuration file

Adding the following to the end your configuration file (config.php) will turn PmWiki 2.1.10 or newer into a nice little CMS. (Global edit password required.)

/**
* Recipes
*/

## Put the wiki in "CMS Mode".
$pagename = ResolvePageName($pagename);
include_once("$FarmD/cookbook/cmsb-cmsmode.php");

## Enable the IP- and content-banning recipe.
if ($action == 'edit' || $action == 'comment' || $action == 'diff') {
  include_once("$FarmD/cookbook/cmsb-blocklist.php"); }

## Enable the AddLink Bookmarklet recipe.
if ($action == 'edit' || $action == 'browse' || $action == 'addlink') {
  include_once("$FarmD/cookbook/cmsb-addlink.php"); }

## Apply a CMS Look for non-authors (ver. 2.1.10 or newer PmWiki default skin).
if (! @$page['=auth']['edit']) {
  $HTMLStylesFmt[CMSLook] = '
 .headnav, #wikicmds, .pagegroup, .footnav { display:none }
 .pagetitle { margin-top:8px; } div.lastmod { color:#cccccc; } ';
}

This will cause the PmWiki-related content on the sidebar to disappear unless you are an author

Customize the sidebar

First, let's hide Wiki-related content from non-authors. Underneath the top link, add an (:if auth edit:) directive, as in

* [[Main/HomePage]]
(:if auth edit:)
* [[Main/WikiSandbox]]
[<...the rest of the sidebar content...>]

Next, let's add a Logout link. At the bottom of the sidebar page, add a "Log out" link. When you are done, it will look like this:

[<...the rest of the sidebar content...>]
%right% [-[[Site.SideBar?action=edit | edit SideBar]]-][[<<]]
%right% [-[[Main.HomePage?action=logout | Log out]]-]

Customize the Page Actions

  1. Add a Login link.
  2. Remove the Print link.
  3. Add an AllRecentChanges link.

When you are an editor and want to become an administrator or an "uploader", it helps to have a link to take you to the login page. Also, I don't like the anachronistic Print link and often find a sitewide AllRecentChanges link handy. To that end, the $SiteGroup.PageActions page gets this content:

(Wide content should be narrowed.)

* %item class=browse accesskey='$[ak_view]'%[[{$FullName} | $[View] ]]
* %item rel=nofollow class=edit accesskey='$[ak_edit]'%[[{$FullName}?action=edit | $[Edit] ]]
* %item rel=nofollow class=diff accesskey='$[ak_history]'%[[{$FullName}?action=diff | $[History] ]]
(:if auth upload:)
* %item rel=nofollow class=upload accesskey='$[ak_attach]'%[[{$FullName}?action=upload | $[Attach] ]]
(:if:)
* %item rel=nofollow class=login accesskey='$[ak_login]'%[[{$FullName}?action=login | $[Log in] ]]
* %item rel=nofollow class=allrecent accesskey='$[ak_arc]'%[[{$SiteGroup}.AllRecentChanges | $[A.R.C.] ]]

When you are done, set new edit password of " @_site_edit " on your $SiteGroup.PageActions page.

Customize the logo

Go to this site and create a logo. The background color is 247/247/247. A font with a slim upper margin looks best. Rename the file to something that makes sense, like site_logo.png, and configure PmWiki to use it by adding this line to your config.php file:

$PageLogoUrl = "$PubDirUrl/skins/pmwiki/site_logo.png";

You can adjust the position of the searchbox and make the "Search" link text text match the links in the sidebar with this:

$HTMLStylesFmt['site_searchbox'] = '
 #wikihead { margin-top:10px; }
 #wikihead a { text-decoration:none; color:black; }
 #wikihead a:hover { text-decoration:underline; color:blue; }
 ';

Comments

This will break some cookbook scripts that rely on forms like mailform and commentbox.

How specifically does it break them? If you will provide some more helpful information about it, I'll see if I can figure out how to improve compatibility with those recipes. --Hagan
In order to, for example, post a comment using commentboxstyled, you need to be logged in. Otherwise, it will just say (:commentbox:).
Which of the scripts (if any) causes it to happen? --Hagan
I'm sorry, I forgot to mention it's the cmsb-cmsmode.phpΔ script.
You need to add the 'comment' action to the array of allowed actions. Put in config.php:
$CMSAllowedActions = array(
     'browse','print','search','edit','login','rss','atom','addlink','comment');
-- HansB August 14, 2006, at 01:38 PM
Thanks Hans. It's added by default in the latest release. Hagan
14-Nov-2006 RussFink: I installed the cms script per instructions above. I created some users via AuthUser. If I log in as one of the AuthUser users, it works great. If I log out, the edit bars go away, super. However, if enabled, the cms script does not recognize user 'admin.' It says, "name/password not recognized." Is there a workaround? Here are some lines from my config.php, below. Other side effects:
  • If I comment out the "prevent groups w/o password" section, it allows me to view other groups; if I leave it in as recorded below, the non-auth'd user can only see pages in group Main.
  • However, if I move that "prevent groups" section below the CMSBundle section, then I can see the other groups, but then another problem: the edit links show up on pages in those other groups. For instance, leave PmWiki groups in your sidebar; unauth'd users can click on them, and will see edit bars.
  • Taking out the other sections besides AuthUser and CMSBundle does not fix the 'admin' not recognized problem.
  • I took out the "if (1)" block (removed the "if" and the final "}" in case it needs a global variable; no change.
# RAF * use AuthUser; force logged in user to prepopulate in change form
include_once("$FarmD/scripts/authuser.php");
$Author = $AuthId;

# RAF * prevent groups w/o password; see Cookbook:LimitWikiGroups, opt 2
$rc = FmtPageName('$Group.RecentChanges', $pagename);
  if (!PageExists($rc))
    $DefaultPasswords['edit'] = $DefaultPasswords['admin'];

# RAF * add CMS mode per CMSBundle recipe (fetched 14-Nov-2006)
## Put the wiki in "CMS Mode".
if (1) {
        $pagename = ResolvePageName($pagename);
        include_once("$FarmD/cookbook/cmsb-cmsmode.php");
        ## Apply a CMS Look for non-authors (ver>=2.1.10 PmWiki default skin).
        if (! @$page['=auth']['edit']) {
          $HTMLStylesFmt[CMSLook] = '
         .headnav, #wikicmds, .pagegroup, .footnav { display:none }
         .pagetitle { margin-top:8px; } div.lastmod { color:#cccccc; } ';
        }
}

The recipe seems to break the upload ability on my site. I'm using pmwiki 2.1.27 with UserAuth2 and CMSB-CMSmode installed. I'm logged in as admin but can't upload files (I've set $EnableUpload=1 in config.php). After disabling the inclusion of the CMSmode recipe and login as admin I can upload files to all pages. What's wrong with my installation?

Contributors

  • NeilHerber has donned his programmer's hat and provided helpful feedback and advice about the blocklist and addlink scripts.
Edit - History - Print - Recent Changes - Search
Page last modified on December 29, 2007, at 12:51 PM