On Jan 3, 7:14 pm, jarble <
jar...@gmail.com> wrote:
> I'm not familiar with TiddlyWiki's API, and I'm trying to create an
> extension that redirects pages that match a regular expression. If a link
> matches a regular expression, it should be redirected to a specific page.
http://www.TiddlyTools.com/#MissingTiddlersPlugin
uses regular expressions to match titles of "missing" tiddlers and
provide alternative, fallback content. After installing the plugin,
you can then simply create a tiddler called [[MissingTiddlers]]
containing sections, where the section headings are regexp patterns to
match and the section content is the fallback content to use when
matched.
You can use any content as a fallback, including static text, TW
macros, etc. For your purposes ("redirecting" to another tiddler),
you could use a <<tiddler>> macro to display the desired 'redirected'
content. You can also embed a special marker sequence, "$1" (without
quotes) within the fallback content to display the actual name of the
tiddler used in the link.
For example, suppose [[MissingTiddlers]] contains:
!(web|online)( )(pages|sites)( that| )( I )(like|like to(read|
browse|explore))
$1
<<tiddler MyFavoriteSites>>
and [[MyFavoriteSites]] contains:
http://www.TiddlyWiki.com/
http://www.TiddlyTools.com/
Then, when you click on a link like: [[web sites that I like to
read]], MissingTiddlersPlugin will find the matching regexp in the
MissingTiddlers list, and display:
web sites that I like to read:
http://www.TiddlyWiki.com/
http://www.TiddlyTools.com/
Note: if you actually want to *redirect* to another tiddler (rather
than just showing the fallback content), you can install
http://www.TiddlyTools.com/#SlideshowTimer
The SlideshowTimer transclusion automatically opens the specified
tiddler (e.g., [[MyFavoriteSites]]) after an indicated delay
(0=immediate) and, with the optional "close" keyword, automatically
closes the current tiddler that was being displayed (i.e. it
'redirects' from one tiddler to another).
This would allow to you write something like this in
[[MissingTiddlers]]:
!(web|online)( )(pages|sites)( that| )( I )(like|like to(read|
browse|explore))
<<tiddler SlideshowTimer with: MyFavoriteSites 0 close>>
The net result is that any link that matches your desired regexp
pattern(s) in [[MissingTiddlers]] would redirect to
[[MyFavoriteSites]] instead. Q.E.D.
enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
----
TiddlyTools needs YOUR financial support...
Help ME to continue to help YOU...
make a generous donation today:
http://www.TiddlyTools.com/#Donations
Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:
http://www.TiddlyTools.com/#Contact