From fdf842a4c458b9f40c233bda221ff241df8eb108 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 7 Sep 2007 20:07:54 +0000 Subject: [PATCH] Improved Redmine links: * issue and changeset links generated only if the object exists * issue subject and status appear in the link title * strike issue link if issue is closed * red wiki page link if page doesn't exist * new icon for external links Wiki page cache had to be disabled. git-svn-id: http://redmine.rubyforge.org/svn/trunk@714 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/application_helper.rb | 22 ++++++++++++++++--- app/models/project.rb | 1 + app/views/projects/_form.rhtml | 2 +- app/views/wiki/_content.rhtml | 4 +--- public/images/external.png | Bin 323 -> 194 bytes public/stylesheets/application.css | 6 ++++- test/unit/helpers/application_helper_test.rb | 13 ++++++----- 7 files changed, 35 insertions(+), 13 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 135d61627..91594529b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -157,7 +157,16 @@ module ApplicationHelper page = title || $2 title = $1 if page.blank? end - link_to((title || page), format_wiki_link.call(link_project, Wiki.titleize(page)), :class => 'wiki-page') + + if link_project && link_project.wiki + # check if page exists + wiki_page = link_project.wiki.find_page(page) + link_to((title || page), format_wiki_link.call(link_project, Wiki.titleize(page)), + :class => ('wiki-page' + (wiki_page ? '' : ' new'))) + else + # project or wiki doesn't exist + title || page + end end # turn issue and revision ids into links @@ -168,9 +177,16 @@ module ApplicationHelper leading, otype, oid = $1, $2, $3 link = nil if otype == 'r' - link = link_to("r#{oid}", {:controller => 'repositories', :action => 'revision', :id => project.id, :rev => oid}, :class => 'changeset') if project + if project && (changeset = project.changesets.find_by_revision(oid)) + link = link_to("r#{oid}", {:controller => 'repositories', :action => 'revision', :id => project.id, :rev => oid}, :class => 'changeset', + :title => truncate(changeset.comments, 100)) + end else - link = link_to("##{oid}", {:controller => 'issues', :action => 'show', :id => oid}, :class => 'issue') + if issue = Issue.find_by_id(oid.to_i, :include => [:project, :status], :conditions => Project.visible_by(User.current)) + link = link_to("##{oid}", {:controller => 'issues', :action => 'show', :id => oid}, :class => 'issue', + :title => "#{truncate(issue.subject, 100)} (#{issue.status.name})") + link = content_tag('del', link) if issue.closed? + end end leading + (link || "#{otype}#{oid}") end diff --git a/app/models/project.rb b/app/models/project.rb index 2eaa0f733..fa975c435 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -33,6 +33,7 @@ class Project < ActiveRecord::Base has_many :issue_categories, :dependent => :delete_all, :order => "#{IssueCategory.table_name}.name" has_many :boards, :order => "position ASC" has_one :repository, :dependent => :destroy + has_many :changesets, :through => :repository has_one :wiki, :dependent => :destroy has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}", :association_foreign_key => 'custom_field_id' acts_as_tree :order => "name", :counter_cache => true diff --git a/app/views/projects/_form.rhtml b/app/views/projects/_form.rhtml index 55527e080..7edf17e30 100644 --- a/app/views/projects/_form.rhtml +++ b/app/views/projects/_form.rhtml @@ -45,7 +45,7 @@ <%= hidden_field_tag "wiki_enabled", 0 %>
<% fields_for :wiki, @project.wiki, { :builder => TabularFormBuilder, :lang => current_language} do |wiki| %> -

<%= wiki.text_field :start_page, :size => 60, :required => true %>
<%= l(:text_unallowed_characters) %>: , . / ? ; |

+

<%= wiki.text_field :start_page, :size => 60, :required => true %>
<%= l(:text_unallowed_characters) %>: , . / ? ; : |

<% # content_tag("div", "", :id => "wiki_start_page_auto_complete", :class => "auto_complete") + # auto_complete_field("wiki_start_page", { :url => { :controller => 'wiki', :action => 'auto_complete_for_wiki_page', :id => @project } }) %> diff --git a/app/views/wiki/_content.rhtml b/app/views/wiki/_content.rhtml index 3f7c14201..0c6f4d648 100644 --- a/app/views/wiki/_content.rhtml +++ b/app/views/wiki/_content.rhtml @@ -1,5 +1,3 @@
- <% cache "wiki/show/#{content.page.id}/#{content.version}" do %> - <%= textilizable content.text, :attachments => content.page.attachments %> - <% end %> + <%= textilizable content.text, :attachments => content.page.attachments %>
diff --git a/public/images/external.png b/public/images/external.png index 0561752f47bb733c0840af2d9e713b4dc465f638..45df6404f655f9a30436d8828a2cb9e24f637b3b 100644 GIT binary patch delta 163 zcmX@ibcoTUGr-TCmrII^fq{Y7)59eQNOOWP2Q!eo?*B~*NU@iA`ns}T=VTX>R|?ti zWcI{djWnJBpAc7|+_`JVw(i|JXX%`pe3@TBK4VFcUoeBivm0qZj*h2`V@Sm<-=0QJ z1_Pc$L7)Ghf6XQvIzd4xATZeB!Bdle$G%PNHo9{9=GyJd0y7w*QkgdQ0rfF>y85}S Ib4q9e0P5~G6aWAK delta 311 zcmX@ac$lfaGr-TCmrII^fq{Y7)59eQNQ2m1985rxDInq%kkT!2jVN(0N=+=u%+FH@ z$;?e<$W1NMQ!rFW%>P}YU}Rumu3%(nWo%|;VxgdIU}#_vbBt{wP$PSZr>`sfbq+>h zHFl1l3vGcyoCO|{#S9GGLLkg|X`-80{Y+06$B>F!$$$R;w`b|NyVpRc18n2i1%KCmct zvVw}R%l(ay+3(D0R*-6FJDA&e>+DH2E|Jz~mXNH372I1mv~shvxdRn7by>h2 zH|SrPp8uYwcdMe%`T6^rclQXsVA*k6v9H~liG$(ptPnx>EDd3x!x=nX{an^LB{Ts5 D061sy diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index bb1812025..8f4a3ecdb 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -615,7 +615,7 @@ div.wiki table, div.wiki td, div.wiki th { div.wiki a { background-position: 0% 60%; background-repeat: no-repeat; - padding-left: 14px; + padding-left: 12px; background-image: url(../images/external.png); } @@ -624,6 +624,10 @@ div.wiki a.wiki-page, div.wiki a.issue, div.wiki a.changeset, div.wiki a.email { background-image: none; } +div.wiki a.new { + color: #b73535; +} + div.wiki code { font-size: 1.2em; } diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index c618cec09..10372fb74 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -19,7 +19,8 @@ require File.dirname(__FILE__) + '/../../test_helper' class ApplicationHelperTest < HelperTestCase include ApplicationHelper - fixtures :projects + include ActionView::Helpers::TextHelper + fixtures :projects, :repositories, :changesets, :trackers, :issue_statuses, :issues def setup super @@ -53,12 +54,14 @@ class ApplicationHelperTest < HelperTestCase end def test_redmine_links - issue_link = link_to('#52', {:controller => 'issues', :action => 'show', :id => 52}, :class => 'issue') - changeset_link = link_to('r19', {:controller => 'repositories', :action => 'revision', :id => 1, :rev => 19}, :class => 'changeset') + issue_link = link_to('#3', {:controller => 'issues', :action => 'show', :id => 3}, + :class => 'issue', :title => 'Error 281 when updating a recipe (New)') + changeset_link = link_to('r1', {:controller => 'repositories', :action => 'revision', :id => 1, :rev => 1}, + :class => 'changeset', :title => 'My very first commit') to_test = { - '#52, #52 and #52.' => "#{issue_link}, #{issue_link} and #{issue_link}.", - 'r19' => changeset_link + '#3, #3 and #3.' => "#{issue_link}, #{issue_link} and #{issue_link}.", + 'r1' => changeset_link } @project = Project.find(1) to_test.each { |text, result| assert_equal "

#{result}

", textilizable(text) } -- 2.39.5