diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2018-09-26 07:27:30 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2018-09-26 07:27:30 +0000 |
commit | b9fa262165601a3b348d22ca1d8da53bda99e55b (patch) | |
tree | 21bd632e051addfee01ab7a568b01f5b6428051a /app | |
parent | c171797673f549e434dd6b94f7262fd31a77b533 (diff) | |
download | redmine-b9fa262165601a3b348d22ca1d8da53bda99e55b.tar.gz redmine-b9fa262165601a3b348d22ca1d8da53bda99e55b.zip |
Adds preview option to the wiki toolbar (#27758).
Patch by Marius BALTEANU.
git-svn-id: http://svn.redmine.org/redmine/trunk@17521 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/messages_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/previews_controller.rb | 23 | ||||
-rw-r--r-- | app/controllers/wiki_controller.rb | 2 | ||||
-rw-r--r-- | app/views/boards/show.html.erb | 3 | ||||
-rw-r--r-- | app/views/common/_preview.html.erb | 8 | ||||
-rw-r--r-- | app/views/issues/_edit.html.erb | 7 | ||||
-rw-r--r-- | app/views/issues/_form.html.erb | 2 | ||||
-rw-r--r-- | app/views/issues/new.html.erb | 3 | ||||
-rw-r--r-- | app/views/journals/_notes_form.html.erb | 7 | ||||
-rw-r--r-- | app/views/messages/_form.html.erb | 2 | ||||
-rw-r--r-- | app/views/messages/edit.html.erb | 2 | ||||
-rw-r--r-- | app/views/messages/new.html.erb | 3 | ||||
-rw-r--r-- | app/views/messages/show.html.erb | 2 | ||||
-rw-r--r-- | app/views/news/_form.html.erb | 2 | ||||
-rw-r--r-- | app/views/news/edit.html.erb | 2 | ||||
-rw-r--r-- | app/views/news/index.html.erb | 2 | ||||
-rw-r--r-- | app/views/news/new.html.erb | 2 | ||||
-rw-r--r-- | app/views/news/show.html.erb | 4 | ||||
-rw-r--r-- | app/views/previews/issue.html.erb | 11 | ||||
-rw-r--r-- | app/views/wiki/edit.html.erb | 7 |
20 files changed, 28 insertions, 68 deletions
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 76bc19cf6..0ba360e9a 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -118,7 +118,7 @@ class MessagesController < ApplicationController def preview message = @board.messages.find_by_id(params[:id]) - @text = (params[:message] || params[:reply])[:content] + @text = params[:text] ? params[:text] : nil @previewed = message render :partial => 'common/preview' end diff --git a/app/controllers/previews_controller.rb b/app/controllers/previews_controller.rb index 37cdc4668..41e6941f9 100644 --- a/app/controllers/previews_controller.rb +++ b/app/controllers/previews_controller.rb @@ -16,31 +16,30 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class PreviewsController < ApplicationController - before_action :find_project, :find_attachments + before_action :find_project, :except => :text + before_action :find_attachments def issue - @issue = Issue.visible.find_by_id(params[:id]) unless params[:id].blank? + @issue = Issue.visible.find_by_id(params[:issue_id]) unless params[:issue_id].blank? if @issue - @description = params[:issue] && params[:issue][:description] - if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n") - @description = nil - end - @notes = params[:journal] ? params[:journal][:notes] : nil - @notes ||= params[:issue] ? params[:issue][:notes] : nil - else - @description = (params[:issue] ? params[:issue][:description] : nil) + @previewed = @issue end - render :layout => false + @text = params[:text] ? params[:text] : nil + render :partial => 'common/preview' end def news if params[:id].present? && news = News.visible.find_by_id(params[:id]) @previewed = news end - @text = (params[:news] ? params[:news][:description] : nil) + @text = params[:text] ? params[:text] : nil render :partial => 'common/preview' end + def text + @text = params[:text] ? params[:text] : nil + render :partial => 'common/preview' + end private def find_project diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index b43b933cd..c5f7cdc0c 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -321,7 +321,7 @@ class WikiController < ApplicationController @attachments += page.attachments @previewed = page.content end - @text = params[:content][:text] + @text = params[:content].present? ? params[:content][:text] : params[:text] render :partial => 'common/preview' end diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb index 4a0a588e9..02dffa278 100644 --- a/app/views/boards/show.html.erb +++ b/app/views/boards/show.html.erb @@ -14,10 +14,8 @@ <%= form_for @message, :url => new_board_message_path(@board), :html => {:multipart => true, :id => 'message-form'} do |f| %> <%= render :partial => 'messages/form', :locals => {:f => f} %> <p><%= submit_tag l(:button_create) %> - <%= preview_link(preview_board_message_path(@board), 'message-form') %> | <%= link_to l(:button_cancel), "#", :onclick => '$("#add-message").hide(); return false;' %></p> <% end %> -<div id="preview" class="wiki"></div> <% end %> </div> @@ -60,7 +58,6 @@ <% end %> <% html_title @board.name %> - <% content_for :header_tags do %> <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@project}: #{@board}") %> <% end %> diff --git a/app/views/common/_preview.html.erb b/app/views/common/_preview.html.erb index 90d83ce8c..ee22288c0 100644 --- a/app/views/common/_preview.html.erb +++ b/app/views/common/_preview.html.erb @@ -1,3 +1,5 @@ -<fieldset class="preview"><legend><%= l(:label_preview) %></legend> -<%= textilizable @text, :attachments => @attachments, :object => @previewed %> -</fieldset> +<% unless @text.blank? %> + <%= textilizable @text, :attachments => @attachments, :object => @previewed %> +<% else %> + <p><%= l(:label_nothing_to_preview) %></p> +<% end %>
\ No newline at end of file diff --git a/app/views/issues/_edit.html.erb b/app/views/issues/_edit.html.erb index fe2119a07..3afaee4ca 100644 --- a/app/views/issues/_edit.html.erb +++ b/app/views/issues/_edit.html.erb @@ -30,7 +30,7 @@ <% if @issue.notes_addable? %> <fieldset><legend><%= l(:field_notes) %></legend> <%= f.text_area :notes, :cols => 60, :rows => 10, :class => 'wiki-edit', :no_label => true %> - <%= wikitoolbar_for 'issue_notes' %> + <%= wikitoolbar_for 'issue_notes', preview_issue_path(:project_id => @project, :issue_id => @issue) %> <% if @issue.safe_attribute? 'private_notes' %> <%= f.check_box :private_notes, :no_label => true %> <label for="issue_private_notes"><%= l(:field_private_notes) %></label> @@ -68,13 +68,12 @@ <%= f.hidden_field :lock_version %> <%= hidden_field_tag 'last_journal_id', params[:last_journal_id] || @issue.last_journal_id %> <%= submit_tag l(:button_submit) %> - <%= preview_link preview_edit_issue_path(:project_id => @project, :id => @issue), 'issue-form' %> - | <%= link_to l(:button_cancel), issue_path(id: @issue.id), :onclick => params[:action] == 'show' ? "$('#update').hide(); return false;" : '' %> + <%= link_to l(:button_cancel), issue_path(id: @issue.id), :onclick => params[:action] == 'show' ? "$('#update').hide(); return false;" : '' %> <%= hidden_field_tag 'prev_issue_id', @prev_issue_id if @prev_issue_id %> <%= hidden_field_tag 'next_issue_id', @next_issue_id if @next_issue_id %> <%= hidden_field_tag 'issue_position', @issue_position if @issue_position %> <%= hidden_field_tag 'issue_count', @issue_count if @issue_count %> + <% end %> -<div id="preview" class="wiki"></div> diff --git a/app/views/issues/_form.html.erb b/app/views/issues/_form.html.erb index f25cb3b2b..c99927d8a 100644 --- a/app/views/issues/_form.html.erb +++ b/app/views/issues/_form.html.erb @@ -37,7 +37,7 @@ :no_label => true %> <% end %> </p> -<%= wikitoolbar_for 'issue_description' %> +<%= wikitoolbar_for 'issue_description', preview_issue_path(:project_id => @issue.project, :issue_id => @issue.id) %> <% end %> <div id="attributes" class="attributes"> diff --git a/app/views/issues/new.html.erb b/app/views/issues/new.html.erb index 1c2c8bac8..22a174a11 100644 --- a/app/views/issues/new.html.erb +++ b/app/views/issues/new.html.erb @@ -39,11 +39,8 @@ <%= submit_tag l(:button_create) %> <%= submit_tag l(:button_create_and_continue), :name => 'continue' %> - <%= preview_link preview_new_issue_path(:project_id => @issue.project), 'issue-form' %> <% end %> -<div id="preview" class="wiki"></div> - <% content_for :header_tags do %> <%= robot_exclusion_tag %> <% end %> diff --git a/app/views/journals/_notes_form.html.erb b/app/views/journals/_notes_form.html.erb index 2ab978769..eecc31da9 100644 --- a/app/views/journals/_notes_form.html.erb +++ b/app/views/journals/_notes_form.html.erb @@ -14,11 +14,6 @@ <% end %> <%= call_hook(:view_journals_notes_form_after_notes, { :journal => @journal}) %> <p><%= submit_tag l(:button_save) %> - <%= preview_link preview_edit_issue_path(:project_id => @project, :id => @journal.issue), - "journal-#{@journal.id}-form", - "journal_#{@journal.id}_preview" %> | <%= link_to l(:button_cancel), '#', :onclick => "$('#journal-#{@journal.id}-form').remove(); $('#journal-#{@journal.id}-notes').show(); return false;" %></p> - - <div id="journal_<%= @journal.id %>_preview" class="wiki"></div> <% end %> -<%= wikitoolbar_for "journal_#{@journal.id}_notes" %> +<%= wikitoolbar_for "journal_#{@journal.id}_notes", preview_issue_path(:project_id => @project, :issue_id => @journal.issue) %> diff --git a/app/views/messages/_form.html.erb b/app/views/messages/_form.html.erb index d9f48af5c..adba05224 100644 --- a/app/views/messages/_form.html.erb +++ b/app/views/messages/_form.html.erb @@ -24,7 +24,7 @@ <p> <%= label_tag "message_content", l(:description_message_content), :class => "hidden-for-sighted" %> <%= f.text_area :content, :cols => 80, :rows => 15, :class => 'wiki-edit', :id => 'message_content' %></p> -<%= wikitoolbar_for 'message_content' %> +<%= wikitoolbar_for 'message_content', preview_board_message_path(:board_id => @board, :id => @message) %> <!--[eoform:message]--> <p><%= l(:label_attachment_plural) %><br /> diff --git a/app/views/messages/edit.html.erb b/app/views/messages/edit.html.erb index 53948e4da..063676197 100644 --- a/app/views/messages/edit.html.erb +++ b/app/views/messages/edit.html.erb @@ -12,6 +12,4 @@ <%= render :partial => 'form', :locals => {:f => f, :replying => !@message.parent.nil?} %> <%= submit_tag l(:button_save) %> - <%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board, :id => @message}, 'message-form') %> <% end %> -<div id="preview" class="wiki"></div> diff --git a/app/views/messages/new.html.erb b/app/views/messages/new.html.erb index f8d840694..be6381413 100644 --- a/app/views/messages/new.html.erb +++ b/app/views/messages/new.html.erb @@ -3,7 +3,4 @@ <%= form_for @message, :url => {:action => 'new'}, :html => {:multipart => true, :id => 'message-form'} do |f| %> <%= render :partial => 'form', :locals => {:f => f} %> <%= submit_tag l(:button_create) %> - <%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form') %> <% end %> - -<div id="preview" class="wiki"></div> diff --git a/app/views/messages/show.html.erb b/app/views/messages/show.html.erb index db41b0cc3..5756a9267 100644 --- a/app/views/messages/show.html.erb +++ b/app/views/messages/show.html.erb @@ -85,9 +85,7 @@ <%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message-form'} do |f| %> <%= render :partial => 'form', :locals => {:f => f, :replying => true} %> <%= submit_tag l(:button_submit) %> - <%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form') %> <% end %> -<div id="preview" class="wiki"></div> </div> <% end %> diff --git a/app/views/news/_form.html.erb b/app/views/news/_form.html.erb index 3f48d21de..dbf21df48 100644 --- a/app/views/news/_form.html.erb +++ b/app/views/news/_form.html.erb @@ -7,4 +7,4 @@ <p id="attachments_form"><label><%= l(:label_attachment_plural) %></label><%= render :partial => 'attachments/form', :locals => {:container => @news} %></p> </div> -<%= wikitoolbar_for 'news_description' %> +<%= wikitoolbar_for 'news_description', preview_news_path(:project_id => @project, :id => @news) %>
\ No newline at end of file diff --git a/app/views/news/edit.html.erb b/app/views/news/edit.html.erb index 4e4cf2e2b..50b897324 100644 --- a/app/views/news/edit.html.erb +++ b/app/views/news/edit.html.erb @@ -3,9 +3,7 @@ <%= labelled_form_for @news, :html => { :id => 'news-form', :multipart => true, :method => :put } do |f| %> <%= render :partial => 'form', :locals => { :f => f } %> <%= submit_tag l(:button_save) %> -<%= preview_link preview_news_path(:project_id => @project, :id => @news), 'news-form' %> <% end %> -<div id="preview" class="wiki"></div> <% content_for :header_tags do %> <%= stylesheet_link_tag 'scm' %> diff --git a/app/views/news/index.html.erb b/app/views/news/index.html.erb index 2ff5a1c8c..cd51aa950 100644 --- a/app/views/news/index.html.erb +++ b/app/views/news/index.html.erb @@ -12,10 +12,8 @@ :html => { :id => 'news-form', :multipart => true } do |f| %> <%= render :partial => 'news/form', :locals => { :f => f } %> <%= submit_tag l(:button_create) %> -<%= preview_link preview_news_path(:project_id => @project), 'news-form' %> | <%= link_to l(:button_cancel), "#", :onclick => '$("#add-news").hide()' %> <% end if @project %> -<div id="preview" class="wiki"></div> </div> <h2><%=l(:label_news_plural)%></h2> diff --git a/app/views/news/new.html.erb b/app/views/news/new.html.erb index f96dd5c52..cf57140b8 100644 --- a/app/views/news/new.html.erb +++ b/app/views/news/new.html.erb @@ -4,6 +4,4 @@ :html => { :id => 'news-form', :multipart => true } do |f| %> <%= render :partial => 'news/form', :locals => { :f => f } %> <%= submit_tag l(:button_create) %> - <%= preview_link preview_news_path(:project_id => @project), 'news-form' %> <% end %> -<div id="preview" class="wiki"></div> diff --git a/app/views/news/show.html.erb b/app/views/news/show.html.erb index 72c94a9c7..d8d098cce 100644 --- a/app/views/news/show.html.erb +++ b/app/views/news/show.html.erb @@ -16,10 +16,8 @@ :html => { :id => 'news-form', :multipart => true, :method => :put } do |f| %> <%= render :partial => 'form', :locals => { :f => f } %> <%= submit_tag l(:button_save) %> -<%= preview_link preview_news_path(:project_id => @project, :id => @news), 'news-form' %> | <%= link_to l(:button_cancel), "#", :onclick => '$("#edit-news").hide(); return false;' %> <% end %> -<div id="preview" class="wiki"></div> </div> <% end %> @@ -56,7 +54,7 @@ <%= form_tag({:controller => 'comments', :action => 'create', :id => @news}, :id => "add_comment_form", :style => "display:none;") do %> <div class="box"> <%= text_area 'comment', 'comments', :cols => 80, :rows => 15, :class => 'wiki-edit' %> - <%= wikitoolbar_for 'comment_comments' %> + <%= wikitoolbar_for 'comment_comments', preview_news_path(:project_id => @project, :id => @news) %> </div> <p><%= submit_tag l(:button_add) %></p> <% end %> diff --git a/app/views/previews/issue.html.erb b/app/views/previews/issue.html.erb deleted file mode 100644 index a88bec6fc..000000000 --- a/app/views/previews/issue.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -<% if @notes %> - <fieldset class="preview"><legend><%= l(:field_notes) %></legend> - <%= textilizable @notes, :attachments => @attachments, :object => @issue %> - </fieldset> -<% end %> - -<% if @description %> - <fieldset class="preview"><legend><%= l(:field_description) %></legend> - <%= textilizable @description, :attachments => @attachments, :object => @issue %> - </fieldset> -<% end %> diff --git a/app/views/wiki/edit.html.erb b/app/views/wiki/edit.html.erb index 6692cfa6e..60a2f6596 100644 --- a/app/views/wiki/edit.html.erb +++ b/app/views/wiki/edit.html.erb @@ -57,14 +57,11 @@ <p> <%= submit_tag l(:button_save) %> - <%= preview_link({:controller => 'wiki', :action => 'preview', :project_id => @project, :id => @page.title }, 'wiki_form') %> - | <%= link_to l(:button_cancel), wiki_page_edit_cancel_path(@page) %> + <%= link_to l(:button_cancel), wiki_page_edit_cancel_path(@page) %> </p> -<%= wikitoolbar_for 'content_text' %> +<%= wikitoolbar_for 'content_text', preview_project_wiki_page_path(:project_id => @project, :id => @page.title) %> <% end %> -<div id="preview" class="wiki"></div> - <% content_for :header_tags do %> <%= robot_exclusion_tag %> <% end %> |