News
Two new hooks in Hooks Manager 1.0.1
Since the release of Hooks Manager 1.0.0 Redmine got two new hooks – view_my_account_right_bottom
and view_users_form_right_bottom
– both are related to the user profile. One of these hooks adds content below preferences in the user’s own profile (better known as “My account”), another one – below preferences on the user edit page (in Administration → Users). Both these hooks are now supported by Hooks Manager.
These hooks were suggested for Redmine by Johnny Tide. How do I know this?.. Cause Johnny also suggestes to use them in my Contact Form plugin. Moreover, he did updated the Contact Form plugin and shared the patch (see #2208) with me. It’s astonishing, how such an active contributor to Redmine can also be a contributor to my plugin and suggest changes to Redmine, that get also reflected in my other plugin... By the way, as far as I know, he needed these hooks for some other plugin, he developed or contributed to (check also his Github page).
But these hooks are not the only change in Hooks Manager 1.0.1. Thus, they were added in Redmine 2.4.x and the version 1.0.1 of Hooks Manager will also run under Redmine 1.4.x... So, displaying these two hooks for this older version of Redmine would be, at least, incorrect (as users could get confused, why they did not work). So, exactly for such cases I planned to implement support for the require
property of the placeholder (see #2211). And I did it in 1.0.1! This way under Redmine 1.4.x you just won’t see new (not-yet-available) hooks...
But the version 1.0.1 also comes with bug fixes.
The view_layouts_base_html_head
hook of Redmine, which is known as the only “HTML header” hook (“All pages”) in the Hooks Manager plugin, can be used for loading some additional CSS styles, JavaScript functions, and so on. At the same time Hooks Manager also used it for adding styles! But, while developing it I forgot that a plugin can add only one handler for the hook. So, custom HTML content, that was specified for this hook in Administration → Hooks, did not work...
This issues was noticed by Fabien Crespel. He also investigated this issues, found the reason, fixed it and shared the patch (see #2295)! So, in version 1.0.1 I applied his patch (with some modifications). In other words, this issue is now resolved! Thanks, Fabien!
Another weird issue was found by Christopher Caruk – due to wrong (my) code and Christopher’s specific environment the plugin loaded jQuery functions, but tried to use prototype (older) ones... Now it loads and uses same functions (which exactly – depends on the actual environment and application versions).
Meet the reborn Google Ads plugin named Hooks Manager
To be honest, actually this plugin never was just about Google ads... The name was completely wrong, very confusing and limiting – I understood this soon after the release of the version 0.0.1 of the plugin. In fact the plugin allows much more than just adding ads – using it you can largely customize your Redmine. So I planned to rename this plugin a long time ago. And finally I did this!
Unfortunately the rename implies some minor troubles for users of the previous version of the plugin... Thus, in order to update the plugin you need to remove the folder with its previous version (but, please, don’t run the uninstallation migration) and install the new one as a completely new plugin! Largely this is required because the internal plugin name (which was sense
) has also changed (to hooks_manager
). Luckily the new version comes with the migration script intended for moving data from the previous version to the new one. Check also this section for more details...
Another problem of the previous version was its UI, which displayed the list of hooks as a static drop down list. Adding all available hooks would make this list large and, therefore, less readable. So new version comes with an improved and friendly UI allowing to change the way hooks are displayed (first by pages, then by location, or vice verse) and to hide extra hooks (ones, which are unlikely to be used commonly).
Certainly due to UI improvements the version 1.0.0 comes with all native hooks of Redmine (ones, which can be used to add custom HTML). In total the plugin currently comes with support for 41 hooks (however by default most such hooks are not visible and should be made available by clicking on the “Show all hooks” checkbox).
In addition the plugin can now load hook definitions from other plugins. So, if an other plugin supports the Hooks Manager, its hooks will be available in the list as well.
If you are developer of a Redmine plugin, check this page on how to register your custom hooks in the Hooks Manager.
Version 1.0.0 also comes with its own special hook :view_wiki_inline_content
intended to be used in the Wiki content (e.g., Wiki page) with help of the !{{inline_hook}}
Wiki macro. The design of this hook (and the macro) was greatly influenced by Google ads. Thus, the Wiki macro supports optional arguments in the format name=value
. If specified, such arguments get transparently converted into JavaScript variables and, therefore, become available in the HTML/JS content. See the following page for a sample and cautions.
This version is not yet fully ChiliProject ready while it works fine under it. Thus, the plugin does not check, if the hook can be used by ChiliProject, and the
!{{inline_hook}}
Wiki macro is not compatible with ChiliProject’s Liquid.The above mentioned change of the name introduces another trouble for those of you, who uses the SVN repository of the project, as the repository name has also changed! Anyway you will probably prefer to check it out to a new directory, as the plugin’s directory name also changed. If not, you will need to execute the following command to fix the repository URL:
$ svn switch --relocate http://svn.s-andy.com/redmine-google-ads http://svn.s-andy.com/hooks-manager
Google Ads for Redmine
Some time ago I was looking for a way to place Google Ads on this site... I found that many users use sidebar plugins. Others just modify core RHTML files. I like none of these ways! Why? Google Ads should be placed not only on sidebar to “work”. And changing core files means issues on upgrade...
For things like Google Ads Redmine has... hooks. What is this?.. These are “functions” which you can define in your plugins. These functions can return HTML code and this HTML code will be placed in the certain places on Redmine pages. That’s what any sidebar plugin uses! In addition to sidebar hooks allow adding custom HTML to many other places. Besides theoretically you can suggest your hooks by submitting patches to Redmine1.
That’s how I decided to write this plugin. This plugins provides a nice interface to Redmine hooks (well... some of them). With this interface any user can define his/her own HTML code to be placed on Redmine pages. The interface contains a nice thumbnails showing where the content is to be placed.
1 However seems none of my hooks were included into Redmine...
Also available in: Atom