##// END OF EJS Templates
Merged r3924 from trunk....
Eric Davis -
r3860:c7e719fc4b44
parent child
Show More
@@ -103,6 +103,23 module ApplicationHelper
103 103 link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => revision}, :title => l(:label_revision_id, revision))
104 104 end
105 105
106 # Generates a link to a project if active
107 # Examples:
108 #
109 # link_to_project(project) # => link to the specified project overview
110 # link_to_project(project, :action=>'settings') # => link to project settings
111 # link_to_project(project, {:only_path => false}, :class => "project") # => 3rd arg adds html options
112 # link_to_project(project, {}, :class => "project") # => html options with default url (project overview)
113 #
114 def link_to_project(project, options={}, html_options = nil)
115 if project.active?
116 url = {:controller => 'projects', :action => 'show', :id => project}.merge(options)
117 link_to(h(project), url, html_options)
118 else
119 h(project)
120 end
121 end
122
106 123 def toggle_link(name, id, options={})
107 124 onclick = "Element.toggle('#{id}'); "
108 125 onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ")
@@ -368,12 +385,12 module ApplicationHelper
368 385 ancestors = (@project.root? ? [] : @project.ancestors.visible)
369 386 if ancestors.any?
370 387 root = ancestors.shift
371 b << link_to(h(root), {:controller => 'projects', :action => 'show', :id => root, :jump => current_menu_item}, :class => 'root')
388 b << link_to_project(root, {:jump => current_menu_item}, :class => 'root')
372 389 if ancestors.size > 2
373 390 b << '&#8230;'
374 391 ancestors = ancestors[-2, 2]
375 392 end
376 b += ancestors.collect {|p| link_to(h(p), {:controller => 'projects', :action => 'show', :id => p, :jump => current_menu_item}, :class => 'ancestor') }
393 b += ancestors.collect {|p| link_to_project(p, {:jump => current_menu_item}, :class => 'ancestor') }
377 394 end
378 395 b << h(@project)
379 396 b.join(' &#187; ')
@@ -605,8 +622,7 module ApplicationHelper
605 622 end
606 623 when 'project'
607 624 if p = Project.visible.find_by_id(oid)
608 link = link_to h(p.name), {:only_path => only_path, :controller => 'projects', :action => 'show', :id => p},
609 :class => 'project'
625 link = link_to_project(p, {:only_path => only_path}, :class => 'project')
610 626 end
611 627 end
612 628 elsif sep == ':'
@@ -648,8 +664,7 module ApplicationHelper
648 664 end
649 665 when 'project'
650 666 if p = Project.visible.find(:first, :conditions => ["identifier = :s OR LOWER(name) = :s", {:s => name.downcase}])
651 link = link_to h(p.name), {:only_path => only_path, :controller => 'projects', :action => 'show', :id => p},
652 :class => 'project'
667 link = link_to_project(p, {:only_path => only_path}, :class => 'project')
653 668 end
654 669 end
655 670 end
@@ -72,7 +72,7 module ProjectsHelper
72 72 end
73 73 classes = (ancestors.empty? ? 'root' : 'child')
74 74 s << "<li class='#{classes}'><div class='#{classes}'>" +
75 link_to(h(project), {:controller => 'projects', :action => 'show', :id => project}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}")
75 link_to_project(project, {}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}")
76 76 s << "<div class='wiki description'>#{textilizable(project.short_description, :project => project)}</div>" unless project.description.blank?
77 77 s << "</div>\n"
78 78 ancestors << project
@@ -50,7 +50,7 module QueriesHelper
50 50 when 'User'
51 51 link_to_user value
52 52 when 'Project'
53 link_to(h(value), :controller => 'projects', :action => 'show', :id => value)
53 link_to_project value
54 54 when 'Version'
55 55 link_to(h(value), :controller => 'versions', :action => 'show', :id => value)
56 56 when 'TrueClass'
@@ -27,7 +27,7
27 27 <tbody>
28 28 <% project_tree(@projects) do |project, level| %>
29 29 <tr class="<%= cycle("odd", "even") %> <%= css_project_classes(project) %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
30 <td class="name"><%= project.active? ? link_to(h(project.name), :controller => 'projects', :action => 'settings', :id => project) : h(project.name) %></td>
30 <td class="name"><%= link_to_project(project, :action => 'settings') %></td>
31 31 <td><%= textilizable project.short_description, :project => project %></td>
32 32 <td align="center"><%= checked_image project.is_public? %></td>
33 33 <td align="center"><%= format_date(project.created_on) %></td>
@@ -14,7 +14,7
14 14 <%= check_box_tag("ids[]", issue.id, false, :style => 'display:none;') %>
15 15 <%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue %>
16 16 </td>
17 <td class="project"><%= link_to(h(issue.project), :controller => 'projects', :action => 'show', :id => issue.project) %></td>
17 <td class="project"><%= link_to_project(issue.project) %></td>
18 18 <td class="tracker"><%=h issue.tracker %></td>
19 19 <td class="subject">
20 20 <%= link_to h(truncate(issue.subject, :length => 60)), :controller => 'issues', :action => 'show', :id => issue %> (<%=h issue.status %>)
@@ -1,4 +1,4
1 <p><%= link_to(h(news.project.name), :controller => 'projects', :action => 'show', :id => news.project) + ': ' unless @project %>
1 <p><%= link_to_project(news.project) + ': ' unless @project %>
2 2 <%= link_to h(news.title), :controller => 'news', :action => 'show', :id => news %>
3 3 <%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %>
4 4 <br />
@@ -28,7 +28,7
28 28 <p class="nodata"><%= l(:label_no_data) %></p>
29 29 <% else %>
30 30 <% @newss.each do |news| %>
31 <h3><%= link_to(h(news.project.name), :controller => 'projects', :action => 'show', :id => news.project) + ': ' unless news.project == @project %>
31 <h3><%= link_to_project(news.project) + ': ' unless news.project == @project %>
32 32 <%= link_to h(news.title), :controller => 'news', :action => 'show', :id => news %>
33 33 <%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %></h3>
34 34 <p class="author"><%= authoring news.created_on, news.author %></p>
@@ -15,7 +15,7
15 15 <% next if membership.new_record? %>
16 16 <tr id="member-<%= membership.id %>" class="<%= cycle 'odd', 'even' %> class">
17 17 <td class="project">
18 <%= link_to h(membership.project), {:controller => 'projects', :action => 'show', :id => membership.project} %>
18 <%= link_to_project membership.project %>
19 19 </td>
20 20 <td class="roles">
21 21 <span id="member-<%= membership.id %>-roles"><%=h membership.roles.sort.collect(&:to_s).join(', ') %></span>
@@ -24,7 +24,7
24 24 <h3><%=l(:label_project_plural)%></h3>
25 25 <ul>
26 26 <% for membership in @memberships %>
27 <li><%= link_to(h(membership.project.name), :controller => 'projects', :action => 'show', :id => membership.project) %>
27 <li><%= link_to_project(membership.project) %>
28 28 (<%=h membership.roles.sort.collect(&:to_s).join(', ') %>, <%= format_date(membership.created_on) %>)</li>
29 29 <% end %>
30 30 </ul>
@@ -20,7 +20,7
20 20 <% for project in @projects %>
21 21 <% @project = project %>
22 22 <li>
23 <%= link_to h(project.name), :controller => 'projects', :action => 'show', :id => project %> (<%= format_time(project.created_on) %>)
23 <%= link_to_project project %> (<%= format_time(project.created_on) %>)
24 24 <%= textilizable project.short_description, :project => project %>
25 25 </li>
26 26 <% end %>
@@ -597,4 +597,16 EXPECTED
597 597 t = link_to_user(user)
598 598 assert_equal ::I18n.t(:label_user_anonymous), t
599 599 end
600
601 def test_link_to_project
602 project = Project.find(1)
603 assert_equal %(<a href="/projects/ecookbook">eCookbook</a>),
604 link_to_project(project)
605 assert_equal %(<a href="/projects/ecookbook/settings">eCookbook</a>),
606 link_to_project(project, :action => 'settings')
607 assert_equal %(<a href="http://test.host/projects/ecookbook?jump=blah">eCookbook</a>),
608 link_to_project(project, {:only_path => false, :jump => 'blah'})
609 assert_equal %(<a href="/projects/ecookbook/settings" class="project">eCookbook</a>),
610 link_to_project(project, {:action => 'settings'}, :class => "project")
611 end
600 612 end
General Comments 0
You need to be logged in to leave comments. Login now