Pseudo-formatters: one-time generated content


 


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:
--

Long signature
::::
generates:
-- [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()

          // 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 extensible markup, then the solution I propose here is not optimal.

Your thoughts?



CategoryDevelopmentFormatters
Comments
Comment by ig0202.uvt.nl
2005-02-28 12:48:33
A pseudo formatter doing automatic user signatures is a must, esp. for pages in ThreadMode, maybe some integration with the wikiedit UI, like MediaWiki does, would be very nice.
Comment by NilsLindenberg
2005-02-28 15:31:43
When we want to use :: :: for markup, and we already use ::c:: as a single ("non closed") markup, why not use something like ::@:: (which is used by wacko)? Or perhaps ::xxx::?

Just an idea: perhaps something like ::user:: ::usertime:: and ::time:: where "user" "time" and "usertime" would/could be defined in the config (to allow it to be changed in other languages). Should get an entry in WikiEdit, though, so that you could at it without having to know the actuall names.
Comment by IanAndolina
2005-02-28 23:48:40
I find that ::usertime:: is too much to write out, I prefer something shorter.

Also, why not make it a proper preformatter, so use $this->Format and call up a preformat.php routine. It would be really nice that " -- " was converted to — "..." to … &'s were always escaped unless part of entities and other goodies. Calling something like [[http://www.michelf.com/projects/php-smartypants/ SmartyPants]] before saving would be ideal for this and could be part of the preformatting to add typographical sharpness and a cleanly encoded page in the database, along with the user signatures.
Comment by DarTar
2005-03-01 15:04:23
@Nils,
I agree with Ian that using keywords instead of symbols is not a good idea, at least for two reasons:
- replacing keywords with symbols will surely make i18n development easier (we do not assume that Malaysian or Italian users will have to learn the English word for "user" in order to add their signature, nor that the developers will translate one day all the keywords used by the formatters)
- (not in any case, but at least in my case) writing "::user::" takes exactly the same amount of characters as writing "--DarTar", so for me it wouldn't be that interesting ;-)

@Ian,
yes I like very much the idea of a preformatter and I have already seen how other engines do this. It looks pretty easy to implement, and I think it makes sense from the point of view of both typography and semantic correctness, so IMO it's a good candidate for a future release.
Comment by JavaWoman
2005-03-01 21:59:18
If we're going to adopt ::...:: for "extensible markup" then it's probably heplful to use a different symbol than : for these "edit shortcuts". Mediawiki uses ~~~~ (I think) for a signature insertion, and we're not using that for anything, I think? Looks like a good candidate to me.
Using a different symbol would als help to remind the user of the different role of this markup: interpreted *once* and formatted result saved, rather than markup that remains markup and is interpreted each time a page is shown.
Comment by IanAndolina
2005-03-01 22:04:44
I have modified SmartyPants to be wikka-syntax aware. I am testing it now and will let you guys at it once I'm done. The only issue is that entities are saved into the database, on reediting, users may not like seeing entities everywhere. If so, we must convert back for editing - which is easy to do with Smartypants - it can "stupefy" text as well as "educate" it!
Comment by DarTar
2005-06-06 14:53:40
A different approach to educated text using SmartyPants:
- works as an afterburner, so the Wikka source code is not modified;
- requires no modification at all in the SmartyPants engine (which is important for 3rd party plugins)

http://wikka.jsnx.com/SmartyPants

Feedback welcome
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki