Project

General

Profile

Can I write a plugin that adds to the existing page layout?

Added by Nick Bolton almost 14 years ago

I need to display some information at the bottom of every page. In this case, it's the hostname of the server (we have two mirrors). So since each server uses the same Redmine dir, the code needs to be dynamic. I don't want to hack the Redmine code, since I might want to upgrade it in future.

Also, I'm a Ruby newbie, so if someone could give me advice on reading the contents of a file on a hard drive, that would be nice! In this case, I want to read /etc/hostname and show it at the bottom of all pages.

Nick


Replies (4)

RE: Can I write a plugin that adds to the existing page layout? - Added by Nick Bolton almost 14 years ago

Just a quick reply. I haven't figured out how to make a plugin for this, but I hacked one of the view files...

<div id="footer">
    Powered by <%= link_to Redmine::Info.app_name, Redmine::Info.url %> &copy; \
2006-2010 Jean-Philippe Lang<br />
<%
file = File.new("/etc/hostname", "r")
line = file.gets
%>
    Mirror: <%= line %>
</div>

... if anyone could advise how to move this into a plugin, please let me know!

RE: Can I write a plugin that adds to the existing page layout? - Added by Eric Davis almost 14 years ago

Take a look at using Hooks. For example, my Google Analyics plugin adds some JavaScript to the bottom of every page. You can easily change this to show the hostname.

Eric Davis

RE: Can I write a plugin that adds to the existing page layout? - Added by Holger Just over 13 years ago

Instead of reading /etc/hostname, you should use the appropriate Ruby function which works across systems:

Socket.gethostname

RE: Can I write a plugin that adds to the existing page layout? - Added by Nick Bolton over 13 years ago

Holger Just wrote:

Instead of reading /etc/hostname, you should use the appropriate Ruby function which works across systems:

Socket.gethostname

Worked nicely, thanks.

    (1-4/4)