To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / plugins / redmine_checkout / lib / checkout / repository_hooks.rb @ 1315:12556ba57d17
History | View | Annotate | Download (1.42 KB)
| 1 | 16:020926a36823 | Chris | 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 | 1315:12556ba57d17 | chris | |
| 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 | 16:020926a36823 | Chris | end
|
| 38 | end
|
||
| 39 | end
|
||
| 40 | 1315:12556ba57d17 | chris | end |