Mercurial > hg > soundsoftware-site
annotate plugins/redmine_checkout/lib/checkout/repository_hooks.rb @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | b4b72f1eb644 |
children | 12556ba57d17 |
rev | line source |
---|---|
Chris@16 | 1 module Checkout |
Chris@16 | 2 class RepositoryHooks < Redmine::Hook::ViewListener |
Chris@16 | 3 # Renders the checkout URL |
Chris@16 | 4 # |
Chris@16 | 5 # Context: |
Chris@16 | 6 # * :project => Current project |
Chris@16 | 7 # * :repository => Current Repository |
Chris@16 | 8 # |
Chris@16 | 9 def view_repositories_show_contextual(context={}) |
Chris@16 | 10 if context[:repository].present? && Setting.checkout_display_checkout_info? |
Chris@16 | 11 protocols = context[:repository].checkout_protocols.select do |p| |
Chris@16 | 12 p.access_rw(User.current) |
Chris@16 | 13 end |
Chris@16 | 14 |
Chris@16 | 15 path = context[:controller].instance_variable_get("@path") |
Chris@16 | 16 if path && context[:controller].instance_variable_get("@entry") |
Chris@16 | 17 # a single file is showing, so we return only the directory |
Chris@16 | 18 path = File.dirname(path) |
Chris@16 | 19 end |
Chris@16 | 20 |
Chris@16 | 21 default = protocols.find(&:default?) || protocols.first |
Chris@16 | 22 |
Chris@16 | 23 context.merge!({ |
Chris@16 | 24 :protocols => protocols, |
Chris@16 | 25 :default_protocol => default, |
Chris@16 | 26 :checkout_path => path |
Chris@16 | 27 }) |
Chris@16 | 28 |
Chris@16 | 29 options = {:partial => "redmine_checkout_hooks/view_repositories_show_contextual"} |
Chris@16 | 30 context[:controller].send(:render_to_string, {:locals => context}.merge(options)) |
Chris@16 | 31 end |
Chris@16 | 32 end |
Chris@16 | 33 end |
Chris@16 | 34 end |