Vote #67665
未完了hook for :view_repositories_show_contextual is incomplete
0%
説明
I wrote a plugin to add new commands in repository views (upload files, create directory and delete file/directory) and I noticed that :view_repositories_show_contextual hook lacks of 2 context parameters:
- path
- revision
As a "workaround", I patched the views (show.rhtml, entry.rhtml, changes.rhtml and annotate.rhtml) to replace:
<%= call_hook(:view_repositories_show_contextual, { :repository => @repository, :project => @project }) %>
with
<%= call_hook(:view_repositories_show_contextual, { :repository => @repository, :project => @project, :path => @path, :revision => @rev }) %>
but it would be better if included in the next release of Redmine...
journals
As you can see in "one of my plugins":http://dev.holgerjust.de/projects/redmine-checkout/repository/entry/trunk/lib/checkout/repository_hooks.rb#L15 (line 15), you can get these variables today without having to patch the hook calls.
--------------------------------------------------------------------------------
Many thanks!!! I didn't know how to do that and I really like your solution: I will undo my patches ASAP!!!
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
I disagree... Many things are accessible through @context[:controller]@ but it's not the right way to go for me. Hooks should provide instance variables directly so plugin developers don't have to do hacky things like @instance_variable_get@. Else, with this argument, we could remove nearly any context variables passed to the hooks ;)
It makes me think of using @.send()@ to bypass object privacy: possible, but not so good in most cases.
Is there a particular reason why we should refuse adding those variables ? Maybe something I missed..
--------------------------------------------------------------------------------