Fossil

TH1 Hooks
Login

** DRAFT **

The TH1 hooks feature allows TH1 scripts to be configured that can monitor, create, alter, or cancel the execution of Fossil commands and web pages.

This feature requires the TH1 hooks feature to be enabled at compile-time. Additionally, the "th1-hooks" repository setting must be enabled at runtime in order to successfully make use of this feature.

TH1 Hook Related User-Defined Procedures

In order to activate TH1 hooks, one or more of the following user-defined procedures should be defined, generally from within the "th1-setup" script (setting) for a repository. The following bullets summarize the available TH1 hooks:

TH1 Hook Related Variables for Commands

TH1 Hook Related Variables for Web Pages

TH1 Hook Related Return Codes for Commands

For commands that are not included in the Fossil binary, allowing their execution will cause the standard "unknown command" error message to be generated, which will typically exit the process. Therefore, adding a new command generally requires using the TH_CONTINUE return code.

TH1 Hook Related Return Codes for Web Pages

For web pages that are not included in the Fossil binary, allowing their rendering will cause the standard "Not Found" error message to be generated, which will cause an HTTP 404 status code to be sent. Therefore, adding a new web page generally requires using the TH_CONTINUE return code.

Triggering TH1 Return Codes from a Script

TH1 command_hook Procedure

This user-defined procedure, if present, is called just before the execution of a command. The name of the command being executed will be stored in the "cmd_name" global variable. The arguments to the command being executed will be stored in the "cmd_args" global variable. The associated CMDFLAG value will be stored in the "cmd_flags" global variable. Before exiting, the procedure should trigger the return code that corresponds to the desired action to take next.

TH1 command_notify Procedure

This user-defined procedure, if present, is called just after the execution of a command. The name of the command being executed will be stored in the "cmd_name" global variable. The arguments to the command being executed will be stored in the "cmd_args" global variable. The associated CMDFLAG value will be stored in the "cmd_flags" global variable. Before exiting, the procedure should trigger the return code that corresponds to the desired action to take next.

TH1 webpage_hook Procedure

This user-defined procedure, if present, is called just before the rendering of a web page. The name of the web page being rendered will be stored in the "web_name" global variable. The arguments to the web page being rendered will be stored in the "web_args" global variable. The associated CMDFLAG value will be stored in the "web_flags" global variable. Before exiting, the procedure should trigger the return code that corresponds to the desired action to take next.

TH1 webpage_notify Procedure

This user-defined procedure, if present, is called just after the rendering of a web page. The name of the web page being rendered will be stored in the "web_name" global variable. The arguments to the web page being rendered will be stored in the "web_args" global variable. The associated CMDFLAG value will be stored in the "web_flags" global variable. Before exiting, the procedure should trigger the return code that corresponds to the desired action to take next.