Revision [16727]

This is an old revision of IncludeRemote made by Io1Wnj on 2007-05-31 10:42:19.

 

Fetching Remote Wikka Content

Last edited by Io1Wnj
Thu, 31 May 2007 10:42 UTC [diff]


FetchRemote v.0.6 available for testing
Download the source and save it as:
actions/fetchremote.php
Feedback is welcome!

See also:

FetchRemote Action

Version 0.7

Note:
JavaWoman has done a huge work in improving/debugging the link rewrite engine, which now works almost perfectly.
Hope she won't mind if I post here the 0.7 'debugging version' of the code ;)

What it does

How to use it
Simply add {{fetchremote}} in one of your pages.
You can specify a starting page by adding: {{fetchremote page="HomePage"}}

Notes
    1. the fetched content integrates seamlessly with the layout and structure of the Wikka-client;
    1. the user can choose to download locally a fetched page, so as to make it available in its Wikka site.

Long-term development ideas
The potential utility of such a plugin is pretty large. Just think of scenarios in which central Mother-wikis distribute wiki-formatted content to Child-wikis.
Providing up-to-date documentation is only one of the possible uses of this plugin.
And now, for something completely different
<mode sci-fi="on">
Imagine that the set of patterns used by the rewrite engine to format the local version of the fetched page might be user-configurable and extended beyond link formatting. One day, we could have a plugin to retrieve content from remote 'non-wikka-powered' wikis, translate the wiki-content in wikka syntax and seamlessly integrate/save it locally. Sounds exciting, doesn't it? :)
<mode sci-fi="off">

The code (actions/fetchremote.php)

Note I had to modify a line in the code below because it contained two "%" in a row (which broke the code display on this page):

Before testing this code please remove the space I added between the two "%":

original:
define('PATTERN_CODE', '% %.*?% %'); # ignore code block

modified:
define('PATTERN_CODE', '%%.*?%%'); # ignore code block


%%(php)
<?php

pattern defines
NOTE: (initial) REs for URL taken from wakka.php formatter - same potential problems.. - now adapted since there WERE indeed problems!
string to mark a "don't replace me" camel words and other strings with
define('IGNOREMARKER', '!!!');
define('PATTERN_IGNOREMARKER', '!!!'); #
@ PHP function to escape for RE?

patterns to be ignored for rewriting
define('PATTERN_IGNORE', PATTERN_IGNOREMARKER.'.*?'.PATTERN_IGNOREMARKER); # string "marked up" to be ignored
Note: REMOVE spaces between % % in the following line before using the plugin
define('PATTERN_CODE', '% %.*?% %'); # ignore code block
define('PATTERN_LITERAL', '.*?'); # ignore Wikka literal
define('PATTERN_ACTION', 'Unknown action; the action name must not contain special characters.'); # ignore action _except_ image
define('PATTERN_ATTRIB', '\b(\w*?\s*)(=\s?"[^\n]*?"|=\s?\'[^\n]*?\')'); # attributes (HTML, action)
#define('PATTERN_URL', '\b[a-z] :\/\/\S '); # copied from formatter
define('PATTERN_URL', '[a-z] :\/\/\S '); # copied from formatter - adapted
#define('PATTERN_URL2', '^([a-z] :\/\/\S ?)([^[:alnum:]^\/])?$'); # copied from formatter
define('PATTERN_URL2', '\b[a-z] :\/\/:alnum:[-_[:alnum:]\/@:\.,_\?
There are 17 comments on this page. [Show comments]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki