|
Cookbook /
PageTopStoreSummary: A PageStore alternative which doesn't mangle page contents when viewed outside PmWiki
Version: 2009-11-27
Prerequisites: PmWiki 2.2.0 (untested on earlier but should work)
Status: beta
Maintainer: Eemeli Aro
Categories: Administration, CustomPageStore
Download: pagetopstore.phpΔ
DescriptionBy default, PmWiki stores wiki pages on disk using PageStore objects, which have each page and its complete history in one file. To make this work, the wiki markup of a page is slightly mangled (eg. line feeds are replaced by the string Moving to PageTopStore and back to PageStore should be completely painless, as both read and use the exact same file format; PageTopStore just has an additional file format that it also uses. Conversions between the formats happen automagically. Mostly this is a matter of pages appearing in the To install this recipe:
ConfigurationThe PageTopStore object is initialised with six parameters:
To use PageTopStore with the default $WikiDir = new PageTopStore( 'wiki.d/{$FullName}', 'wikitop.d/{$FullName}' );
Additionally, setting UsageFor the most part, using PageTopStore should be completely transparent to the user. To help with migrating a site to PageTopStore, an additional action File formatAs stated above, PageTopStore keeps two separate files for each wiki page. The complete history of the page uses the default PageStore format (actually, it uses the exact same functions as PageStore to read and write these files). The "top" copy is slightly different, consisting of a header and a body, separated by a blank line. The header is read similarly to how files are read from PageStore, and consists of the non-text information about the page; the exact same fields that are stored in $PCache. The end of the header is indicated by a blank line (ie. the string "\n\n"), similarly to how HTTP requests are parsed. The rest of the file consists of the page text (or more accurately, markup), stored almost exactly as it's seen within PmWiki. By default, PageTopStore replaces SynchronisationGiven that the same information (the current contents of the page) are stored in two separate locations, the possibility exists that these will differ. This is handled as follows. Here,
if $pagefile doesn't exist :
if $topfile exists :
$pagefile is written from information in $topfile.
else :
the page doesn't exist.
else [ $pagefile exists ] :
if $topfile doesn't exist :
$topfile is written from information in $pagefile.
else [ both $pagefile and $topfile exist ] :
if the full page history is being read (eg. for action=edit or action=diff)
and the filesystem modification time of $topfile is later than that of $pagefile
and there's a difference between the page contents :
$pagefile is updated with the changes made to $topfile.
The only default core actions that will update files in wiki.d are edit, diff, postattr, upgrade, approveurls and approvesites. NotesThis is a work in progress, partly to be treated as a mockup of a possible replacement for PageStore. It needs more testing and comments. Having an easily readable format for pages opens up a whole new set of possibilities, some of which may be included in this recipe or others. For example, searching and pagelist generation could be done using external tools. This could be significantly faster, especially if it's assumed that the Listing pages may currently exclude pages for which only a "top" file exists. I welcome suggestions for a better name than Release Notes
See Also
ContributorsCommentsA few problems
Update all pages from wikitop.d to wiki.dSteP 2010-02-10: Thank you for this recipe! It's very useful to me, and it's working well, so far. Would it be possible to add an action to update all pages in wiki.d from pages in wikitop.d? Reason: I use PageTopStore on my development server only. When I'm ready to move changes to my production server, I need to go through a tedious sequence of manual steps:
Only then I'm ready to upload pages from my development server to my production server.
Use in conjunction with git (Fast Version Control System)See my comment at the User Notes page below. How do i contribute my changes ? LukasDiduch May 14, 2011 06:31 PM User notes +2: 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. |