From 3e8594a8324f3e1a7ea2586e2c310ce8f04e1d4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Wed, 22 May 2019 13:31:55 +0200 Subject: [PATCH] #1008 Comment --- app/helpers/dmsf_files_helper.rb | 32 ++++++++++++++++++++++++++++++ app/views/dmsf_files/show.html.erb | 12 ++--------- 2 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 app/helpers/dmsf_files_helper.rb diff --git a/app/helpers/dmsf_files_helper.rb b/app/helpers/dmsf_files_helper.rb new file mode 100644 index 00000000..3890996b --- /dev/null +++ b/app/helpers/dmsf_files_helper.rb @@ -0,0 +1,32 @@ +# encoding: utf-8 +# +# Redmine plugin for Document Management System "Features" +# +# Copyright © 2011-19 Karel Pičman +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +module DmsfFilesHelper + + def clean_wiki_text(text) + # If there is

tag, the text is moved one column to the right by Redmin's CSS. A new line causes double new line. + text.gsub! '

', '' + text.gsub! '

', '' + text.gsub! "\n\n", '
' + text.gsub "\n\t", '
' + end + +end + diff --git a/app/views/dmsf_files/show.html.erb b/app/views/dmsf_files/show.html.erb index c4becc54..e3720316 100644 --- a/app/views/dmsf_files/show.html.erb +++ b/app/views/dmsf_files/show.html.erb @@ -112,12 +112,7 @@ <% if revision.description.present? %>
<%= content_tag :div, l(:label_description), :class => 'label' %> - <% text = textilizable(revision.description) %> - <%# If there is

tag, the text is moved one column to the right by Redmin's CSS. A new line causes double new line. %> - <% text.gsub! '

', '' %> - <% text.gsub! '

', '' %> - <% text.gsub! "\n\n", '
' %> - <% text.gsub! "\n\t", '
' %> + <% text = clean_wiki_text(textilizable(revision.description)) %> <%= content_tag :div, text.html_safe, :class => 'value wiki' %>
<% end %> @@ -146,10 +141,7 @@ <% if revision.comment.present? %>
<%= content_tag :div, l(:label_comment), :class => 'label' %> - <% text = textilizable(revision.comment) %> - <% if text =~ /^

(.*)<\/p>$/ %> - <% text = $1 %> - <% end %> + <% text = clean_wiki_text(textilizable(revision.comment)) %> <%= content_tag :div, text.html_safe, :class => 'value wiki' %>

<% end %>