Installing the HighlightJS Plugin in Redmine 3.3

July 19, 2016

We wanted to document VBScript code in a Redmine wiki, which ships with a syntax highlighter called CodeRay. There is no VBScript mode in CodeRay, but it can easily be added by copying an existing Scanner and adding and removing some code 😉

Unfortunately CodeRay seems to have a problem with symbols with leading ampersands, as documented in this Redmine issue, and VBScript uses &H to indicate hex numbers.

Search brought up the HighlightJS Plugin as an alternative, which I downloaded and copied into the plugins directory.

Unfortunately, Redmine would not start up again.

Looking for the log files, hoping for an indication what goes wrong, I found the file process.log with the following data:

Started GET "/redmine/admin/plugins" for 127.0.0.1 at 2016-07-13 11:46:57 +0200
Processing by AdminController#plugins as HTML
Current user: redadmin (id=1)
Rendered admin/plugins.html.erb within layouts/admin (15.6ms)
Rendered admin/_menu.html.erb (15.6ms)
Rendered layouts/base.html.erb (421.9ms)
Completed 500 Internal Server Error in 625ms (ActiveRecord: 62.5ms)

ActionView::Template::Error (uninitialized constant Highlightjs::Hooks::ViewHighlightedHook::UserAgent):
13: <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
14: <%= javascript_heads %>
15: <%= heads_for_theme %>
16: <%= call_hook :view_layouts_base_html_head %>
17: <!-- page specific tags -->
18: <%= yield :header_tags -%>
19: </head>
plugins/redmine_highlightjs/lib/hooks/view_highlighted_hook.rb:15:in `view_layouts_base_html_head'
lib/redmine/hook.rb:61:in `block (2 levels) in call_hook'
lib/redmine/hook.rb:61:in `each'
lib/redmine/hook.rb:61:in `block in call_hook'
lib/redmine/hook.rb:58:in `tap'
lib/redmine/hook.rb:58:in `call_hook'
lib/redmine/hook.rb:96:in `call_hook'
app/views/layouts/base.html.erb:16:in `_app_views_layouts_base_html_erb___698415948_43865832'
app/views/layouts/admin.html.erb:8:in `_app_views_layouts_admin_html_erb___707869534_44477868'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'

Now I have no idea how Ruby works, or Redmine, and how to deal with packages and so on. Experimenting with the gem package manager did not fix the situation either.

What I did find though was the location that raised the error, namely checking whether the browser name and version retrieved from the HTTP UserAgent string was among the “supported” browsers. Since it’s hard to imagine that any current browser does not support the highlighting magic of this plugin, I simply deactivated the check in the file view_highlighted_hook.rb:

#user_agent = UserAgent.parse(request)
user_agent = 'MyBrowser'     # don't retrieve, this var is used for logging later

if true            # SupportedBrowsers.detect { |browser| user_agent >= browser }

 

Advertisements

Installing Bitnami Redmine Stack with Separate Data Directory

July 12, 2016

I downloaded the latest version of the Bitnami Redmine Stack (bitnami-redmine-3.3.0-1-windows-installer.exe) and installed it, which worked without any problems.

However I noticed that the installation does not distinguish between programs/executables and stored data, so I tried to figure out what data is being stored and where.

I found that I only needed to move the MySQL databases to a new data directory. and leave everything else in the installation directory.

First, I created a new location D:\Bitnami-Redmine-data to store Redmine’s data.

MySQL

Next, I started the Bitnami Redmine Stack Manager Tool and stopped the MySQL Database service.

Bitnami Redmine Stack Manager Tool

Bitnami Redmine Stack Manager Tool

I created a new location D:\Bitnami-Redmine-data to store Redmine’s data, and copied the MySQL data directory C:\Bitnami\redmine-3.3.0-1\mysql\data to D:\Bitnami-Redmine-data\mysql\data.

To let MySQL know about the new location of its databases, I edited C:\Bitnami\redmine-3.3.0-1\mysql\my.ini and changed the [mysqld] section to point to the new directory:

[mysqld]
#datadir="C:/Bitnami/redmine-3.3.0-1/mysql/data"
datadir="D:\Bitnami-Redmine-data\mysql\data"

#log-error="C:/Bitnami/redmine-3.3.0-1/mysql/data/mysqld.log"
log-error="D:\Bitnami-Redmine-data\mysql\data\mysqld.log"

The I started up the MySQL Database service again, which did not raise any errors. Be sure to check the Server Events tab and the Windows Event Log for errors or warnings.

SVN

Although the Bitnami Redmine Stack ships with and installs the SVN server svnserve, the installer does not automatically create an SVN repository.

To create an SVN repository, follow the Subversion configuration instructions in the Bitnami wiki:

  • Stop the Subversion Server in the Bitnami Redmine Stack Manager Tool
  • Start the “Use Bitnami Redmine Stack” command prompt
  • Create a repository with the command
svnadmin create "D:\Bitnami-Redmine-data\subversion\repository"
  • Check your settings in “D:\Bitnami-Redmine-data\subversion\repository\conf\svnserve.conf”
  • Add users to “D:\Bitnami-Redmine-data\subversion\repository\conf\passwd” if you do not use SASL
  • Edit the file C:\Bitnami\redmine-3.3.0-1\subversion\scripts\serviceinstall.bat to add the repository root path using “–r param”:
"C:\Bitnami\redmine-3.3.0-1/subversion\scripts\winserv.exe" 
    install redmineSubversion 
    -displayname "redmineSubversion" 
    -start auto "C:\Bitnami\redmine-3.3.0-1/subversion\bin\svnserve.exe" 
    -d 
    --listen-port=3690 
    -r "D:\Bitnami-Redmine-data\subversion\repository"

(note that this is a single command line)

  • Then re-install the SVN service from the Bitnami command prompt
Run serviceinstall.bat
Run serviceinstall.bat INSTALL
  • In the Bitnami Tool, start “Subversion Server”
  • Verify you are able to connect to the SVN repository using your favorite client.