Wiki source for PseudoFormatters


Show raw source

===== Pseudo-formatters: one-time generated content =====

>>**See also:**
~-SmartyPants
~-WantedFormatters
~-WikkaExtensibleMarkup
~-PreFormatter
>>::c::

I'd like to discuss the idea - already suggested in the WakkaWiki community - of adding to Wikka a set of **pseudo-formatters**, taking care of //one-time content generation//. Whereas **actual formatters** interpret Wikka markup stored in the DB, **pseudo-formatters** only interpret some specific markup //when a page is stored//: the content is generated on-the-fly and stored in the database as ordinary Wikka content.

A couple of examples:

**Short signature**
##:::##
//generates://
-- {{user}}

**Long signature**
##::::##
//generates://
-- {{user}} ##[2005-02-28 12:02]##

**Timestamp**
##::t::##
//generates://
##[2005-02-28 12:02]##

etc.

== The code ==

The modifications required for this to work are quite silly. We just need to modify ##""SavePage()""## in ##wikka.php##, before the call to ##Query()##

%%(php)
// one-time formatter: signature
if ($user) {
$longsignature = '-- '.$user.' [##'.date("Y-m-d H:i").'##]';
$shortsignature = '-- '.$user;
$body = preg_replace("/::::/",$longsignature,$body);
$body = preg_replace("/:::/",$shortsignature,$body);
}
// one-time formatter: timestamp
$timestamp = '[##'.date("Y-m-d H:i").'##]';
$body = preg_replace("/::t::/",$timestamp,$body);
%%

A similar hack has to be done in the //preview// section of ##handlers/page/edit.php##.
The timestamp markup is just an example, not something I would implement as such in Wikka (the format should be configurable).

== Issues ==
As usual, what we need is a good markup (easy to remember, distinctive, expressive). If we choose to adopt ##**::**## as a tag for [[WikkaExtensibleMarkup | extensible markup]], then the solution I propose here is not optimal.

Your thoughts?

== Related discussion ==

- MagicWords
----
CategoryDevelopmentFormatters
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki