diff --git a/editions/dev/tiddlers/HelloThere.tid b/editions/dev/tiddlers/HelloThere.tid index be8687104..0b9bfaa58 100644 --- a/editions/dev/tiddlers/HelloThere.tid +++ b/editions/dev/tiddlers/HelloThere.tid @@ -1,8 +1,8 @@ -modified: 20140920124011558 +modified: 20141122200310516 tags: TableOfContents title: HelloThere -Welcome to the developer documentation for TiddlyWiki (http://tiddlywiki.com/). It is currently a work in progress as material from two different sources is adapted and merged: +Welcome to the developer documentation for TiddlyWiki (http://tiddlywiki.com/). It is currently a work in progress as material from two different sources is adapted and merged in addition to original content being added: * An assignment by Christian Jurke and Christian Heigele, two students working on their Master's degree in Information Technology at the Gießen University of Applied Sciences (Technische Hochschule Mittelhessen). Their work can be seen in the [[Introduction]] and the tiddlers that link from it. * The original developer documentation from http://tiddlywiki.com: @@ -22,3 +22,5 @@ Welcome to the developer documentation for TiddlyWiki (http://tiddlywiki.com/). ** SyncAdaptorModules ** WidgetModules ** WikiRuleModules +*Original developer documentation +** [[Hook Mechanism]] diff --git a/editions/dev/tiddlers/hooks/HookMechanism.tid b/editions/dev/tiddlers/hooks/HookMechanism.tid new file mode 100644 index 000000000..96d06a27d --- /dev/null +++ b/editions/dev/tiddlers/hooks/HookMechanism.tid @@ -0,0 +1,24 @@ +created: 20141122200310516 +modified: 20141122200310516 +title: Hook Mechanism +type: text/vnd.tiddlywiki + +The Hook Mechanism provides a way for plugins to hook into and modify default functionality. Hooks can be added to the wiki by calling the following from a plugin: + +``$tw.hooks.addHook(name,function definition);`` + +Multiple hooks can be appended to the same name using repeated calls to the above. When a hook is invoked by name all registered functions will be called seqentially in their order of addition. + +Though not essential care should be taken to ensure that hooks are added before they are invoked. For example: [[Hook: tc-opening-default-tiddlers-list]] should ideally be added before the story widget is invoked otherwise any hook specified additions to the default tiddlers will not be seen on the initial loading of the page, though will be visible if the user clicks the home button. + +!!Example + +A working example of addition to a hook that adds "test" to the default tiddlers. + +```javascript +$tw.hooks.addHook("th-opening-default-tiddlers-list",function(list) { + list.push("test"); + return list; +}); +``` + diff --git a/editions/dev/tiddlers/hooks/tc-opening-default-tiddlers-list.tid b/editions/dev/tiddlers/hooks/tc-opening-default-tiddlers-list.tid new file mode 100644 index 000000000..3a7209786 --- /dev/null +++ b/editions/dev/tiddlers/hooks/tc-opening-default-tiddlers-list.tid @@ -0,0 +1,8 @@ +created: 20141122200310516 +modified: 20141122200310516 +title: Hook: tc-opening-default-tiddlers-list +type: text/vnd.tiddlywiki + +This hook allows plugins to add aditional tiddlers to those specified in [[$:/DefaultTiddlers]]. + +The function definition takes a list of tiddlers as it's argument and should return a modified list of tiddlers to display when the wiki is first loaded or the home button is pressed. This hook is invoked after ``$tw.wiki.filterTiddlers`` is called on the contents of [[$:/DefaultTiddlers]] and it is therfore not correct to append additional filters to the list argument as they will not be subsequently applied.