Project

General

Profile

Improved Repository Plugin - Implementation Help!

Added by ponto andré over 15 years ago

Hi,
i am adding functionality to the redmine's repository feature. changing some of the user interaction workflow.

I've modified some of the views and added some js and css.

What i would like to know, is if i can deploy this as a new plugin/extension, instead of a patch.
I believe i would need to create a new plugin that inherits all the Repository Controllers and Models, using my modified views. Also i think the plugin would need to disable the current Repository feature, enabling my own.

Am i right? How should i do this?


Replies (8)

RE: Improved Repository Plugin - Implementation Help! - Added by Eric Davis over 15 years ago

If all you did was change the views, you can just create a plugin and put your own version of the repositories views in there. These views should be named exactly the same as the ones in the core. If you plugin doesn't provide a view file, Redmine will use the default one in the core.

|-- _dir_list.rhtml
|-- _dir_list_content.rhtml
|-- _navigation.rhtml
|-- _revisions.rhtml
|-- annotate.rhtml
|-- browse.rhtml
|-- changes.rhtml
|-- diff.rhtml
|-- entry.rhtml
|-- revision.rhtml
|-- revisions.rhtml
|-- show.rhtml
`-- stats.rhtml

Issue #2179 talks about this in more detail but using a layout instead of single view files. The implementation would be the same though.

If you need to change the existing Controllers or Models, you will have to monkey patch the core.

Eric

RE: Improved Repository Plugin - Implementation Help! - Added by ponto andré over 15 years ago

this worked : >

it's almost done. i've wrote a little js code using prototype to add the line(s) highlight funcionality (a little like github has) and i need to include one .js and .css. and i don't won't to overwrite the layout just to add these two lines:
<%= stylesheet_link_tag 'pmbase/pmbase-m2.css', :media => 'all' >
<
= javascript_include_tag "pmbase/pmbase-m2.js" %>

is there any way to to these? some hook or something?

RE: Improved Repository Plugin - Implementation Help! - Added by ponto andré over 15 years ago

i think i've found the solution to this. i was lookin' at base.rhtml a hook said said hello to me: <%= call_hook :view_layouts_base_html_head %>

RE: Improved Repository Plugin - Implementation Help! - Added by ponto andré over 15 years ago

i'm new to rails, and ruby too. i officially start to use them last saturday.

is there any documentation that could me explain the use of hooks in detail? i've found the hook's api ( http://www.redmine.org/issues/show/1677 ) on redmine's issues but for a newbie like me examples or so would work better.

RE: Improved Repository Plugin - Implementation Help! - Added by Eric Davis over 15 years ago

ponto andré wrote:

i think i've found the solution to this. i was lookin' at base.rhtml a hook said said hello to me: <%= call_hook :view_layouts_base_html_head %>

Yea, that will work if you only need to add in JavaScript and CSS. Just make sure the JavaScript will not error on non-repository pages, the hooks are run for every page.

Eric

RE: Improved Repository Plugin - Implementation Help! - Added by Eric Davis over 15 years ago

ponto andré wrote:

is there any documentation that could me explain the use of hooks in detail? i've found the hook's api ( http://www.redmine.org/issues/show/1677 ) on redmine's issues but for a newbie like me examples or so would work better.

There really isn't much documentation about them. I've been trying to maintain the Hooks wiki page that lists the hooks but I haven't had a chance to write up any documentation on how to use them. I've implemented some in my Budget plugin, check the lib directory for the two hooks classes I implemented. Soon I'll have another plugin coming out with some more advanced hook examples (e.g. PluginA hooks into PluginB).

Eric

RE: Improved Repository Plugin - Implementation Help! - Added by ponto andré over 15 years ago

so, looking at the code all i've to do is write a object that inherit Redmine::Hook::ViewListener. and add it to init.rb?

RE: Improved Repository Plugin - Implementation Help! - Added by Eric Davis over 15 years ago

ponto andré wrote:

so, looking at the code all i've to do is write a object that inherit Redmine::Hook::ViewListener. and add it to init.rb?

Yes, just name the method of the class after the specific hook (e.g. view_layouts_base_html_head) and make sure it takes a single parameter (a Hash). This parameter will contain all the data the hook exposes.

Eric

    (1-8/8)