‘ AjaxEditSupport ’
Version: 1.0
Published: 23/02/2011
License: GPL-3
File: ajaxeditsupport-1.0a.tar.gz
This is a PmWiki recipe.
It allows the author of a page to quickly browse existing pages (in the same group, or others), existing attachments and existing categories. It also allows the user to find parts of the current pages quickly, and also allows the creation of template pages, with snippets of text to add them to the current page.
The information is retrieved on-line with an Ajax-powered interface, and the author just has to click on any item to insert it in the current page.
If you want to try it out, just go to edit this test page.
Features & limitations
Features:
- Lists wiki pages, attachments and categories.
New in 1.0:
- Retrieves parts of the current page (links, attachments, tables…) and offers them as a list. The user just clicks and the text is highlighted.
- The administrator can define template pages (site-wide, group-wide and one in the profile page of the user, for example). The user can easily insert the snippets found there.
- Click anywhere outside a list to close it.
- A lot of new config options (see below).
- Updated (better, I hope) interface.
Current limitations:
- Page and attachment lists are cached, so new pages do not appear until the user edits again the page.
- Require PHP 5.0 .
- The attach-list considers that you’re working with per-page attachments. Other configurations are currently not supported.
- The “Current page” browser is server based. The text is sent to the server each time (though the recipe tries to be smart and just send data when it has changed).
I’m using RegExps and I’ve found they’re handled differently by different browsers…
How to install
Download, unpack, and copy the files into your current installation of PmWiki.
Now edit “config/local.php” and add:
include_once("$FarmD/cookbook/ajaxeditsupport.php");
…at the end.
You can then set some config variables, to control some aspects of the recipe:
- $AjaxEditSupportPageBrowser (0|1): Enables the pages browser. Defaults to 1 (enabled).
- $AjaxEditSupportAttachmentBrowser (0|1): Enables the attachments browser. Defaults to 1 (enabled).
- $AjaxEditSupportCategoryBrowser (0|1): Enables the categories browser. Defaults to 1 (enabled).
- $AjaxEditSupportEditBrowser (0|1): Enables the “current page” browser. Defaults to 1 (enabled).
- $AjaxEditSupportTemplatesBrowser (0|1): Enables the templates browser. Defaults to 1 (enabled).
- $AjaxEditSupportBrowserWidth: Sets the width in pixels of the browsers. Defaults to 450.
- $AjaxEditSupportBrowserHeight: Sets the height in pixels of the browsers. Defaults to 300.
- $AjaxEditSupportHidePages: Sets a RegExp of pages the pages browser will ignore. Defaults to “/(.*(GroupHeader|GroupFooter|RecentChanges)|Site.*)/” (it won’t list GroupHeader, GroupFooter, RecentChanges and anything that starts with “Site”).
Finally, you have to edit your edit form (usually “Site/EditForm”). You have to add “(:ajaxeditsupport:)
” whereever you want the buttons to appear.
There you go !
Defining templates
The template browser scans a page (we’ll see which one) for anchors named “[[#aesWhatEver]]
” and “[[#aesWhatEverend]]
”. The user will see a list of the text between every defined section.
By default, there is a site-wide templates page (Site.AESTemplates), and group-wide templates page ($Group.AESTemplate
), and the templages defined in the Profile page of the current user (if any, at $AuthorGroup.$AuthId
).
The administrator may define more (or less) template pages by editing the $AjaxEditSupportTemplates variable in the config file.
The “current page” browser
This browser lists significant parts of the current page, so that the user may locate them easily in the text.
When you enable the current page browser, the recipe sets the text form so that it doesn’t wrap. Without this, is impossible (well, very hard) to jump to a given line in the text.
The admin may easily add new entries to the RegExps being searched by the recipe, by editing the $AjaxEditSupportEditOptions array. Take a look at the source to see how it’s defined.
Future plans:
- Include support for per-group or site-wide attachments, if anyone really needs it.