Mercurial > hg > soundsoftware-site
comparison plugins/redmine_checkout/lib/checkout/repository_hooks.rb @ 1484:51364c0cd58f redmine-2.4-integration
Merge from live branch. Still need to merge manually in files overridden by plugins.
author | Chris Cannam |
---|---|
date | Wed, 15 Jan 2014 09:59:14 +0000 |
parents | 12556ba57d17 |
children |
comparison
equal
deleted
inserted
replaced
1464:261b3d9a4903 | 1484:51364c0cd58f |
---|---|
1 module Checkout | |
2 class RepositoryHooks < Redmine::Hook::ViewListener | |
3 # Renders the checkout URL | |
4 # | |
5 # Context: | |
6 # * :project => Current project | |
7 # * :repository => Current Repository | |
8 # | |
9 def view_repositories_show_contextual(context={}) | |
10 if context[:repository].present? && Setting.checkout_display_checkout_info? | |
11 protocols = context[:repository].checkout_protocols.select do |p| | |
12 p.access_rw(User.current) | |
13 end | |
14 | |
15 path = context[:controller].instance_variable_get("@path") | |
16 if path && context[:controller].instance_variable_get("@entry") | |
17 # a single file is showing, so we return only the directory | |
18 path = File.dirname(path) | |
19 end | |
20 | |
21 default = protocols.find(&:default?) || protocols.first | |
22 | |
23 context.merge!({ | |
24 :protocols => protocols, | |
25 :default_protocol => default, | |
26 :checkout_path => path | |
27 }) | |
28 | |
29 options = {:partial => "redmine_checkout_hooks/view_repositories_show_contextual"} | |
30 | |
31 # cc: cribbed from | |
32 # http://www.redmine.org/projects/redmine/repository/revisions/9785/diff/trunk/lib/redmine/hook.rb | |
33 # for http://www.redmine.org/issues/11105 (formerly used | |
34 # render_to_string on this controller, wasn't working for | |
35 # :header_tags) | |
36 context[:hook_caller].send(:render, {:locals => context}.merge(options)) | |
37 end | |
38 end | |
39 end | |
40 end |