Project

General

Profile

Patch #5897 ยป id-titled.patch

W Snyder, 2010-07-18 14:09

View differences:

app/helpers/application_helper.rb
75 75
        subject = truncate(subject, :length => options[:truncate])
76 76
      end
77 77
    end
78
    s = link_to "#{issue.tracker} ##{issue.id}", {:controller => "issues", :action => "show", :id => issue}, 
78
    s = link_to "#{issue.tracker} ##{issue.id}", {:controller => "issues", :action => "show", :id => issue.id_titled},
79 79
                                                 :class => issue.css_classes,
80 80
                                                 :title => title
81 81
    s << ": #{h subject}" if subject
......
586 600
                                                                :controller => 'messages',
587 601
                                                                :action => 'show',
588 602
                                                                :board_id => message.board,
589
                                                                :id => message.root,
603
                                                                :id => message.id_titled,
590 604
                                                                :anchor => (message.parent ? "message-#{message.id}" : nil)},
591 605
                                                 :class => 'message'
592 606
            end
app/helpers/messages_helper.rb
22 22
    link_to h(truncate(message.subject, :length => 60)), :controller => 'messages',
23 23
                                           :action => 'show',
24 24
                                           :board_id => message.board_id,
25
                                           :id => message.root,
25
                                           :id => message.id_titled,
26 26
                                           :r => (message.parent_id && message.id),
27 27
                                           :anchor => (message.parent_id ? "message-#{message.id}" : nil)
28 28
  end
app/helpers/queries_helper.rb
33 33
    case value.class.name
34 34
    when 'String'
35 35
      if column.name == :subject
36
        link_to(h(value), :controller => 'issues', :action => 'show', :id => issue)
36
        link_to(h(value), :controller => 'issues', :action => 'show', :id => issue.id_titled)
37 37
      else
38 38
        h(value)
39 39
      end
app/models/issue.rb
41 41
                     # sort by id so that limited eager loading doesn't break with postgresql
42 42
                     :order_column => "#{table_name}.id"
43 43
  acts_as_event :title => Proc.new {|o| "#{o.tracker.name} ##{o.id} (#{o.status}): #{o.subject}"},
44
                :url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.id}},
44
                :url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.id_titled }},
45 45
                :type => Proc.new {|o| 'issue' + (o.closed? ? ' closed' : '') }
46 46
  
47 47
  acts_as_activity_provider :find_options => {:include => [:project, :author, :tracker]},
......
541 541
    end
542 542
  end
543 543
  
544
  def id_titled
545
    out = self.id.to_s+"-"+ self.project.name.to_s+"-" +self.subject.gsub(%r{[^0-9a-zA-Z_]+},'-')
546
    out
547
  end
548

  
544 549
  def parent_issue_id
545 550
    if instance_variable_defined? :@parent_issue
546 551
      @parent_issue.nil? ? nil : @parent_issue.id
app/models/journal.rb
29 29
                :description => :notes,
30 30
                :author => :user,
31 31
                :type => Proc.new {|o| (s = o.new_status) ? (s.is_closed? ? 'issue-closed' : 'issue-edit') : 'issue-note' },
32
                :url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.issue.id, :anchor => "change-#{o.id}"}}
32
                :url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.issue.id_titled, :anchor => "change-#{o.id}"}}
33 33

  
34 34
  acts_as_activity_provider :type => 'issues',
35 35
                            :permission => :view_issues,
app/models/message.rb
29 29
  acts_as_event :title => Proc.new {|o| "#{o.board.name}: #{o.subject}"},
30 30
                :description => :content,
31 31
                :type => Proc.new {|o| o.parent_id.nil? ? 'message' : 'reply'},
32
                :url => Proc.new {|o| {:controller => 'messages', :action => 'show', :board_id => o.board_id}.merge(o.parent_id.nil? ? {:id => o.id} : 
32
                :url => Proc.new {|o| {:controller => 'messages', :action => 'show', :board_id => o.board_id}.merge(o.parent_id.nil? ? {:id => o.id_titled} : 
33 33
                                                                                                                                       {:id => o.parent_id, :r => o.id, :anchor => "message-#{o.id}"})}
34 34

  
35 35
  acts_as_activity_provider :find_options => {:include => [{:board => :project}, :author]},
......
90 90
    usr && usr.logged? && (usr.allowed_to?(:delete_messages, project) || (self.author == usr && usr.allowed_to?(:delete_own_messages, project)))
91 91
  end
92 92
  
93
  def id_titled
94
    out = self.id.to_s+"-"+ self.project.name.to_s+"-" +self.subject.gsub(%r{[^0-9a-zA-Z_]+},'-')
95
    out
96
  end
97

  
93 98
  private
94 99
  
95 100
  def add_author_as_watcher
app/models/news.rb
25 25
  validates_length_of :summary, :maximum => 255
26 26

  
27 27
  acts_as_searchable :columns => ['title', 'summary', "#{table_name}.description"], :include => :project
28
  acts_as_event :url => Proc.new {|o| {:controller => 'news', :action => 'show', :id => o.id}}
28
  acts_as_event :url => Proc.new {|o| {:controller => 'news', :action => 'show', :id => o.id_titled}}
29 29
  acts_as_activity_provider :find_options => {:include => [:project, :author]},
30 30
                            :author_key => :author_id
31 31
  
......
37 37
  def self.latest(user = User.current, count = 5)
38 38
    find(:all, :limit => count, :conditions => Project.allowed_to_condition(user, :view_news), :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC")	
39 39
  end
40

  
41
  def id_titled
42
    out = self.id.to_s+"-"+ self.project.name.to_s+"-" +self.title.gsub(%r{[^0-9a-zA-Z_]+},'-')
43
    out
44
  end
40 45
end
app/views/boards/show.rhtml
42 42
  <tbody>
43 43
  <% @topics.each do |topic| %>
44 44
    <tr class="message <%= cycle 'odd', 'even' %> <%= topic.sticky? ? 'sticky' : '' %> <%= topic.locked? ? 'locked' : '' %>">
45
      <td class="subject"><%= link_to h(topic.subject), { :controller => 'messages', :action => 'show', :board_id => @board, :id => topic } %></td>
45
      <td class="subject"><%= link_to h(topic.subject), { :controller => 'messages', :action => 'show', :board_id => @board, :id => topic.id_titled } %></td>
46 46
      <td class="author" align="center"><%= topic.author %></td>
47 47
      <td class="created_on" align="center"><%= format_time(topic.created_on) %></td>
48 48
      <td class="replies" align="center"><%= topic.replies_count %></td>
app/views/issues/_list.rhtml
26 26
  <% end %>
27 27
	<tr id="issue-<%= issue.id %>" class="hascontextmenu <%= cycle('odd', 'even') %> <%= issue.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
28 28
	    <td class="checkbox"><%= check_box_tag("ids[]", issue.id, false, :id => nil) %></td>
29
		<td class="id"><%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue %></td>
29
		<td class="id"><%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue.id_titled %></td>
30 30
        <% query.columns.each do |column| %><%= content_tag 'td', column_content(column, issue), :class => column.name %><% end %>
31 31
	</tr>
32 32
	<% end -%>
app/views/issues/_list_simple.rhtml
12 12
		<tr id="issue-<%= issue.id %>" class="hascontextmenu <%= cycle('odd', 'even') %> <%= issue.css_classes %>">
13 13
			<td class="id">
14 14
			  <%= check_box_tag("ids[]", issue.id, false, :style => 'display:none;') %>
15
				<%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue %>
15
				<%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue.id_titled %>
16 16
			</td>
17 17
			<td class="project"><%= link_to(h(issue.project), :controller => 'projects', :action => 'show', :id => issue.project) %></td>
18 18
			<td class="tracker"><%=h issue.tracker %></td>
19 19
			<td class="subject">
20
        <%= link_to h(truncate(issue.subject, :length => 60)), :controller => 'issues', :action => 'show', :id => issue %> (<%=h issue.status %>)
20
        <%= link_to h(truncate(issue.subject, :length => 60)), :controller => 'issues', :action => 'show', :id => issue.id_titled %> (<%=h issue.status %>)
21 21
      </td>
22 22
		</tr>
23 23
		<% end %>
app/views/issues/changes.rxml
10 10
    issue = change.issue
11 11
    xml.entry do
12 12
      xml.title   "#{issue.project.name} - #{issue.tracker.name} ##{issue.id}: #{issue.subject}"
13
      xml.link    "rel" => "alternate", "href" => url_for(:controller => 'issues' , :action => 'show', :id => issue, :only_path => false)
13
      xml.link    "rel" => "alternate", "href" => url_for(:controller => 'issues' , :action => 'show', :id => issue.id_titled, :only_path => false)
14 14
      xml.id      url_for(:controller => 'issues' , :action => 'show', :id => issue, :journal_id => change, :only_path => false)
15 15
      xml.updated change.created_on.xmlschema
16 16
      xml.author do
app/views/messages/show.rhtml
30 30
    </div>
31 31
  <h4>
32 32
  	<%= avatar(message.author, :size => "24") %>
33
    <%= link_to h(message.subject), { :controller => 'messages', :action => 'show', :board_id => @board, :id => @topic, :anchor => "message-#{message.id}" } %>
33
    <%= link_to h(message.subject), { :controller => 'messages', :action => 'show', :board_id => @board, :id => @topic.id_titled, :anchor => "message-#{message.id}" } %>
34 34
    -
35 35
    <%= authoring message.created_on, message.author %>
36 36
  </h4>
......
44 44
<% if !@topic.locked? && authorize_for('messages', 'reply') %>
45 45
<p><%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %></p>
46 46
<div id="reply" style="display:none;">
47
<% form_for :reply, @reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
47
<% form_for :reply, @reply, :url => {:action => 'reply', :id => @topic.id_titled}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
48 48
  <%= render :partial => 'form', :locals => {:f => f, :replying => true} %>
49 49
  <%= submit_tag l(:button_submit) %>
50 50
  <%= link_to_remote l(:label_preview), 
app/views/news/_news.rhtml
1 1
<p><%= link_to(h(news.project.name), :controller => 'projects', :action => 'show', :id => news.project) + ': ' unless @project %>
2
<%= link_to h(news.title), :controller => 'news', :action => 'show', :id => news %>
2
<%= link_to h(news.title), :controller => 'news', :action => 'show', :id => news.id_titled %>
3 3
<%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %>
4 4
<br />
5 5
<% unless news.summary.blank? %><span class="summary"><%=h news.summary %></span><br /><% end %>
app/views/news/index.rhtml
29 29
<% else %>
30 30
<% @newss.each do |news| %>
31 31
    <h3><%= link_to(h(news.project.name), :controller => 'projects', :action => 'show', :id => news.project) + ': ' unless news.project == @project %>
32
    <%= link_to h(news.title), :controller => 'news', :action => 'show', :id => news %>
32
    <%= link_to h(news.title), :controller => 'news', :action => 'show', :id => news.id_titled %>
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>
35 35
    <div class="wiki">
config/routes.rb
16 16
  
17 17
  map.connect 'time_entries/:id/edit', :action => 'edit', :controller => 'timelog'
18 18
  map.connect 'projects/:project_id/time_entries/new', :action => 'edit', :controller => 'timelog'
19
  map.connect 'projects/:project_id/issues/:issue_id/time_entries/new', :action => 'edit', :controller => 'timelog'
19
  map.connect 'projects/:project_id/issues/:issue_id:ignore/time_entries/new', :action => 'edit', :controller => 'timelog', :issue_id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/
20 20
  
21 21
  map.with_options :controller => 'timelog' do |timelog|
22 22
    timelog.connect 'projects/:project_id/time_entries', :action => 'details'
......
24 24
    timelog.with_options :action => 'details', :conditions => {:method => :get}  do |time_details|
25 25
      time_details.connect 'time_entries'
26 26
      time_details.connect 'time_entries.:format'
27
      time_details.connect 'issues/:issue_id/time_entries'
28
      time_details.connect 'issues/:issue_id/time_entries.:format'
27
      time_details.connect 'issues/:issue_id:ignore/time_entries', :issue_id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/
28
      time_details.connect 'issues/:issue_id:ignore/time_entries.:format', :issue_id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/
29 29
      time_details.connect 'projects/:project_id/time_entries.:format'
30 30
      time_details.connect 'projects/:project_id/issues/:issue_id/time_entries'
31 31
      time_details.connect 'projects/:project_id/issues/:issue_id/time_entries.:format'
......
38 38
    end
39 39

  
40 40
    timelog.with_options :action => 'edit', :conditions => {:method => :get} do |time_edit|
41
      time_edit.connect 'issues/:issue_id/time_entries/new'
41
      time_edit.connect 'issues/:issue_id:ignore/time_entries/new', :issue_id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/
42 42
    end
43 43
      
44 44
    timelog.connect 'time_entries/:id/destroy', :action => 'destroy', :conditions => {:method => :post}
......
66 66
  map.with_options :controller => 'messages' do |messages_routes|
67 67
    messages_routes.with_options :conditions => {:method => :get} do |messages_views|
68 68
      messages_views.connect 'boards/:board_id/topics/new', :action => 'new'
69
      messages_views.connect 'boards/:board_id/topics/:id', :action => 'show'
70
      messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit'
69
      messages_views.connect 'boards/:board_id/topics/:id:ignore', :action => 'show', :id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/
70
      messages_views.connect 'boards/:board_id/topics/:id:ignore/edit', :action => 'edit', :id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/
71 71
    end
72 72
    messages_routes.with_options :conditions => {:method => :post} do |messages_actions|
73 73
      messages_actions.connect 'boards/:board_id/topics/new', :action => 'new'
74
      messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply'
75
      messages_actions.connect 'boards/:board_id/topics/:id/:action', :action => /edit|destroy/
74
      messages_actions.connect 'boards/:board_id/topics/:id:ignore/replies', :action => 'reply', :id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/
75
      messages_actions.connect 'boards/:board_id/topics/:id:ignore/:action', :action => /edit|destroy/, :id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/
76 76
    end
77 77
  end
78 78
  
......
80 80
    board_routes.with_options :conditions => {:method => :get} do |board_views|
81 81
      board_views.connect 'projects/:project_id/boards', :action => 'index'
82 82
      board_views.connect 'projects/:project_id/boards/new', :action => 'new'
83
      board_views.connect 'projects/:project_id/boards/:id', :action => 'show'
84
      board_views.connect 'projects/:project_id/boards/:id.:format', :action => 'show'
85
      board_views.connect 'projects/:project_id/boards/:id/edit', :action => 'edit'
83
      board_views.connect 'projects/:project_id/boards/:id:ignore', :action => 'show', :id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/
84
      board_views.connect 'projects/:project_id/boards/:id:ignore.:format', :action => 'show', :id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/
85
      board_views.connect 'projects/:project_id/boards/:id:ignore/edit', :action => 'edit', :id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/
86 86
    end
87 87
    board_routes.with_options :conditions => {:method => :post} do |board_actions|
88 88
      board_actions.connect 'projects/:project_id/boards', :action => 'new'
89
      board_actions.connect 'projects/:project_id/boards/:id/:action', :action => /edit|destroy/
89
      board_actions.connect 'projects/:project_id/boards/:id:ignore/:action', :action => /edit|destroy/, :id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/
90 90
    end
91 91
  end
92 92
  
......
113 113
      issues_views.connect 'projects/:project_id/issues/gantt', :controller => 'gantts', :action => 'show'
114 114
      issues_views.connect 'projects/:project_id/issues/calendar', :controller => 'calendars', :action => 'show'
115 115
      issues_views.connect 'projects/:project_id/issues/:copy_from/copy', :action => 'new'
116
      issues_views.connect 'issues/:id', :action => 'show', :id => /\d+/
117
      issues_views.connect 'issues/:id.:format', :action => 'show', :id => /\d+/
118
      issues_views.connect 'issues/:id/edit', :action => 'edit', :id => /\d+/
119
      issues_views.connect 'issues/:id/move', :action => 'move', :id => /\d+/
116
      issues_views.connect 'issues/:id:ignore', :action => 'show', :id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/
117
      issues_views.connect 'issues/:id:ignore.:format', :action => 'show', :id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/
118
      issues_views.connect 'issues/:id:ignore/edit', :action => 'edit', :id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/
119
      issues_views.connect 'issues/:id:ignore/move', :action => 'move', :id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/
120 120
    end
121 121
    issues_routes.with_options :conditions => {:method => :post} do |issues_actions|
122 122
      issues_actions.connect 'issues', :action => 'index'
123 123
      issues_actions.connect 'projects/:project_id/issues', :action => 'create'
124 124
      issues_actions.connect 'projects/:project_id/issues/gantt', :controller => 'gantts', :action => 'show'
125 125
      issues_actions.connect 'projects/:project_id/issues/calendar', :controller => 'calendars', :action => 'show'
126
      issues_actions.connect 'issues/:id/quoted', :action => 'reply', :id => /\d+/
127
      issues_actions.connect 'issues/:id/:action', :action => /edit|move|destroy/, :id => /\d+/
126
      issues_actions.connect 'issues/:id/quoted', :action => 'reply', :id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/
127
      issues_actions.connect 'issues/:id/:action', :action => /edit|move|destroy/, :id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/
128 128
      issues_actions.connect 'issues.:format', :action => 'create', :format => /xml/
129 129
    end
130 130
    issues_routes.with_options :conditions => {:method => :put} do |issues_actions|
......
140 140
  end
141 141
  
142 142
  map.with_options  :controller => 'issue_relations', :conditions => {:method => :post} do |relations|
143
    relations.connect 'issues/:issue_id/relations/:id', :action => 'new'
144
    relations.connect 'issues/:issue_id/relations/:id/destroy', :action => 'destroy'
143
    relations.connect 'issues/:issue_id:ignore/relations/:id:ignore2', :action => 'new', :id => /\d+/, :issue_id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/, :ignore2 => /(-[a-zA-Z0-9_]+)?/
144
    relations.connect 'issues/:issue_id:ignore/relations/:id:ignore2/destroy', :action => 'destroy', :id => /\d+/, :issue_id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/, :ignore2 => /(-[a-zA-Z0-9_]+)?/
145 145
  end
146 146
  
147 147
  map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports|
......
156 156
      news_views.connect 'projects/:project_id/news.:format', :action => 'index'
157 157
      news_views.connect 'news.:format', :action => 'index'
158 158
      news_views.connect 'projects/:project_id/news/new', :action => 'new'
159
      news_views.connect 'news/:id', :action => 'show'
160
      news_views.connect 'news/:id/edit', :action => 'edit'
159
      news_views.connect 'news/:id:ignore', :action => 'show', :id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/
160
      news_views.connect 'news/:id:ignore/edit', :action => 'edit', :id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/
161 161
    end
162 162
    news_routes.with_options do |news_actions|
163 163
      news_actions.connect 'projects/:project_id/news', :action => 'new'
164
      news_actions.connect 'news/:id/edit', :action => 'edit'
165
      news_actions.connect 'news/:id/destroy', :action => 'destroy'
164
      news_actions.connect 'news/:id:ignore/edit', :action => 'edit', :id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/
165
      news_actions.connect 'news/:id:ignore/destroy', :action => 'destroy', :id => /\d+/, :ignore => /(-[a-zA-Z0-9_]+)?/
166 166
    end
167 167
  end
168 168
  
    (1-1/1)