Feature #11104


Proposal for views substitution mechanism for plugins

Added by Vitaly Klimov about 12 years ago. Updated about 12 years ago.

Plugin API
Target version:
Start date:
Due date:
% Done:


Estimated time:


I would like to propose to include to the Redmine as a rake task mechanism which i implemented in my Plugin views revisions plugin.

In short, logic behind it eliminates necessity to create full plugins distribution packages if some of the views which plugin changes, changed in the Redmine itself.

If this method would be de-facto standard for plugin development, it would remove last obstacle in the flexibility - right now it is possible to patch controllers, models and helpers but for the views we have to provide whole file, and every change to this file in the Redmine core causes plugin malfunction.

My proposal goes below:

Rake task

Rake task called redmine:plugins:process_version_change and has following attributes:

plugins List of plugins folders to process, could be skipped. In this case all plugins are processed
log Name of the log file. If not present, stdout is used

How this works

For this task to process plugin, plugin should have folder named rev in its root folder. Folders in this folder mirror folder structure of the plugin folder tree.

Each file in folder has following pattern:


  • revision
    Lowest revision number for which this file should be used. Could be omitted if version presents.
  • version_high.version_low.version_tiny
    Lowest version number in major.minor.tiny format for which this file should be used. Could be omitted if revision presents.
  • (=|!)
    Optional. One of the following symbols:
    = - means that this file should be used only for this exact version/revision
    ! - means that if Redmine version/revision is higher than this, this file should be removed from plugin folder


Let's say we have plugin that has modifications in files app/views/issues/new.html.erb and app/views/messages/_form.html.erb

Redmine has different version of first file starting from revision 7723, also this file changed in version 1.4.1. Second file is changed in version 1.4.1. Also for version 1.3.1 exists another special version of this file. And starting from version 2.0.0 this file is not used at all (renamed, let's say).

In this case we should have following folder and files structure in plugin root folder:


Now lets consider following cases:

  1. Redmine version 1.3.2, revision is 7800
    Files selected: 7723-new.html.erb and 1.4.1-_form.html.erb
  2. Redmine version 1.3.1, revision is unknown but is less than 7723
    Files selected: 0000-new.html.erb and 1.3.1!-_form.html.erb
  3. Redmine version 2.0.0, revision is unknown
    File selected 1.4.1-new.html.erb, file form.html.erb is removed from _app/views/messages folder

For 'real-life' example please check my Board watchers plugin

File selection rules

Files validity check

  1. Filename has revision only
    If revision of Redmine is unknown then revision is taken from redmine_revisions.yml file. File is valid if Redmine revision is higher or equal. If equal sign presents file is valid only if the revision matches redmine revision
  2. Filename has only version
    File is valid if Redmine version is higher or equal. If equal sign presents file is valid only if the version matches Redmine version
  3. Filename has both version and revision
    1. If revision of redmine is known then rules for revision apply
    2. If revision of redmine is unknown then rules for version apply

Selection rules

If there are file that has equal sign it is chosen, otherwise file with highest revision/version is chosen.

Special files

Plugin checks for two special files in Rails root folder:

  1. .version
    If exists used for current version override. Should contain string in format XX.YY.ZZ (major,minor,tiny).
  2. .revision
    If exists used to determine current revision of Redmine. Should contain numeric value which is considered as revision number or word .ignore - in this case revision would be excluded from process.
  3. <plugin_root>/config/redmine_revisions.yml
    This file contains mapping between revisions and versions of the Redmine.

Also available in: Atom PDF