Update of "TH1-Hooks"
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Artifact ID: | 9bb8878d9238afe2dc13515ce8f030a32b658b13 |
---|---|
Page Name: | TH1-Hooks |
Date: | 2015-02-09 02:11:18 |
Original User: | mario |
Mimetype: | text/x-markdown |
Next | 584aac19e14de40976a715a4ab13d563cf47a246 |
Since Fossil 1.30 it's possible to extend both the CLI and web interface with new functionality / or gimicks. Using --with-th1-hooks
for compilation and the th1-hooks
repo setting, custom callbacks can be crafted.
Web hooks
Simply craft a webpage_hook
function in th1-setup.
proc webpage_hook {} {
puts $::web_name;
continue;
}
The global var $::web_name
is populated with the currently requested pagename. It can be one of the built-in functions (wiki, index, home, artifact, etc) or a new custom name. It should preferrably only engage for custom URL paths of course.
An accompanying webpage_notify
can be defined, which would be called after page processing.
webpage_hook
is always invoked first.- Fossils built-in pages thereafter, and if no
break
orTH_ERROR
was created. webpage_notify
runs last, ifcontinue
,return
orTH_OK
were returned from the_hook
callback.
The vars $::web_args
and $::web_flags
are mostly useless, and just inherit fossil server/ui/cgi
startup args. Use set name [getParameter name ""]
instead to get URL params.
Comand hooks
The same process applies to command_hook
(called first) and command_notify
(called after internal command processing). The variable names $::cmd_name
, $::cmd_args
, $::$cmd_flags
are in particular useful to implement new and custom fossil mycmd
stuff.