From 7b366758fdc4867d4f5174e924464fffdcda6a72 Mon Sep 17 00:00:00 2001
From: Jean-Philippe Lang <jp_lang@yahoo.fr>
Date: Fri, 17 Aug 2007 11:21:58 +0000
Subject: [PATCH] Textilized project descriptions on project list and home
 page. Added jsToolbar on project form.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@651 e93f8b46-1217-0410-a6f0-8f06a7374b81
---
 app/helpers/application_helper.rb | 10 ++++++----
 app/views/admin/projects.rhtml    |  2 +-
 app/views/projects/_form.rhtml    |  3 ++-
 app/views/projects/list.rhtml     |  2 +-
 app/views/welcome/index.rhtml     |  2 +-
 public/stylesheets/jstoolbar.css  |  2 +-
 6 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 071904482..1a59f5460 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -139,6 +139,8 @@ module ApplicationHelper
       format_wiki_link = Proc.new {|project, title| url_for :controller => 'wiki', :action => 'index', :id => project, :page => title }
     end
     
+    project = options[:project] || @project
+    
     # turn wiki links into html links
     # example:
     #   [[mypage]]
@@ -148,15 +150,15 @@ module ApplicationHelper
     #   [[project:mypage]]
     #   [[project:mypage|mytext]]
     text = text.gsub(/\[\[([^\]\|]+)(\|([^\]\|]+))?\]\]/) do |m|
-      project = @project
+      link_project = project
       page = $1
       title = $3
       if page =~ /^([^\:]+)\:(.*)$/
-        project = Project.find_by_name($1) || Project.find_by_identifier($1)
+        link_project = Project.find_by_name($1) || Project.find_by_identifier($1)
         page = $2
         title = $1 if page.blank?
       end
-      link_to((title || page), format_wiki_link.call(project, Wiki.titleize(page)), :class => 'wiki-page')
+      link_to((title || page), format_wiki_link.call(link_project, Wiki.titleize(page)), :class => 'wiki-page')
     end
 
     # turn issue ids into links
@@ -167,7 +169,7 @@ module ApplicationHelper
     # turn revision ids into links (@project needed)
     # example:
     #   r52 -> <a href="/repositories/revision/6?rev=52">r52</a> (@project.id is 6)
-    text = text.gsub(/(?=\b)r(\d+)(?=\b)/) {|m| link_to "r#{$1}", {:controller => 'repositories', :action => 'revision', :id => @project.id, :rev => $1}, :class => 'changeset' } if @project
+    text = text.gsub(/(?=\b)r(\d+)(?=\b)/) {|m| link_to "r#{$1}", {:controller => 'repositories', :action => 'revision', :id => project.id, :rev => $1}, :class => 'changeset' } if project
     
     # when using an image link, try to use an attachment, if possible
     attachments = options[:attachments]
diff --git a/app/views/admin/projects.rhtml b/app/views/admin/projects.rhtml
index e181f85c5..d231be102 100644
--- a/app/views/admin/projects.rhtml
+++ b/app/views/admin/projects.rhtml
@@ -27,7 +27,7 @@
 <% for project in @projects %>
   <tr class="<%= cycle("odd", "even") %>">
 	<td><%= project.active? ? link_to(project.name, :controller => 'projects', :action => 'settings', :id => project) : h(project.name) %>
-	<td><%=h project.description %>
+	<td><%= textilizable project.description, :project => project %>
 	<td align="center"><%= image_tag 'true.png' if project.is_public? %>
 	<td align="center"><%= project.children.size %>
 	<td align="center"><%= format_date(project.created_on) %>
diff --git a/app/views/projects/_form.rhtml b/app/views/projects/_form.rhtml
index 9eb933035..585217e16 100644
--- a/app/views/projects/_form.rhtml
+++ b/app/views/projects/_form.rhtml
@@ -8,10 +8,11 @@
     <p><%= f.select :parent_id, (@root_projects.collect {|p| [p.name, p.id]}), { :include_blank => true } %></p>
 <% end %>
 
-<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 3 %><br /><em><%= l(:text_caracters_maximum, 255) %></em></p>
+<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 5 %><em><%= l(:text_caracters_maximum, 255) %></em></p>
 <p><%= f.text_field :identifier, :required => true, :size => 15, :disabled => @project.identifier_frozen? %><br /><em><%= l(:text_length_between, 3, 12) %> <%= l(:text_project_identifier_info) unless @project.identifier_frozen? %></em></p>
 <p><%= f.text_field :homepage, :size => 40 %></p>
 <p><%= f.check_box :is_public %></p>
+<%= wikitoolbar_for 'project_description' %>
 
 <% for @custom_value in @custom_values %>
 	<p><%= custom_field_tag_with_label @custom_value %></p>
diff --git a/app/views/projects/list.rhtml b/app/views/projects/list.rhtml
index 54cc78738..24448be48 100644
--- a/app/views/projects/list.rhtml
+++ b/app/views/projects/list.rhtml
@@ -11,7 +11,7 @@
   <tr class="<%= cycle("odd", "even") %>">
 	<td>
 	  <%= link_to project.name, {:action => 'show', :id => project}, :class => (@logged_in_user && @logged_in_user.role_for_project(project) ? "icon icon-fav" : "") %><br />
-	  <%=h project.description %>
+	  <%= textilizable project.description, :project => project %>
 	</td>
 	<td><%= link_to(project.parent.name, :action => 'show', :id => project.parent) unless project.parent.nil? %></td>
 	<td align="center"><%= format_date(project.created_on) %></td>
diff --git a/app/views/welcome/index.rhtml b/app/views/welcome/index.rhtml
index b91efec28..399e444ed 100644
--- a/app/views/welcome/index.rhtml
+++ b/app/views/welcome/index.rhtml
@@ -15,7 +15,7 @@
 		<% for project in @projects %>
 			<li>
 			<%= link_to project.name, :controller => 'projects', :action => 'show', :id => project %> (<%= format_time(project.created_on) %>)<br />
-			<%=h project.description %>
+			<%= textilizable project.description, :project => project %>
 			</li>
 		<% end %>
 		</ul>
diff --git a/public/stylesheets/jstoolbar.css b/public/stylesheets/jstoolbar.css
index 37c3a2510..62976e537 100644
--- a/public/stylesheets/jstoolbar.css
+++ b/public/stylesheets/jstoolbar.css
@@ -6,7 +6,7 @@
 }
 
 .jstHandle {
-	height: 16px;
+	height: 10px;
 	font-size: 0.1em;
 	cursor: s-resize;
 	/*background: transparent url(img/resizer.png) no-repeat 45% 50%;*/
-- 
GitLab