diff --git a/Gemfile b/Gemfile index 3b638c1c4..a25416052 100644 --- a/Gemfile +++ b/Gemfile @@ -46,7 +46,6 @@ gem 'roo', '~> 2.1.0' # Spreadsheet parser gem 'wicked_pdf' gem 'wkhtmltopdf-heroku' gem 'remotipart', '~> 1.2' # Async file uploads -gem 'redcarpet' # Markdown parser gem 'faker' # Generate fake data gem 'auto_strip_attributes', '~> 2.1' # Removes unnecessary whitespaces from ActiveRecord or ActiveModel attributes gem 'deface', '~> 1.0' diff --git a/LICENSE-3RD-PARTY.txt b/LICENSE-3RD-PARTY.txt index 6459cfd6b..bafe1b73f 100644 --- a/LICENSE-3RD-PARTY.txt +++ b/LICENSE-3RD-PARTY.txt @@ -1516,47 +1516,39 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------------- - RedCarpet Gem + Quill ----------------------------------------------------------------------------- -Copyright (c) 2009, Natacha Porté -Copyright (c) 2015, Vicent Marti - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - ------------------------------------------------------------------------------ - Markdown ------------------------------------------------------------------------------ - -Copyright © 2004, John Gruber -http://daringfireball.net/ +Copyright (c) 2014, Jason Chen +Copyright (c) 2013, salesforce.com All rights reserved. -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: -Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. -Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. -Neither the name “Markdown” nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. +3. Neither the name of the copyright holder nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. -This software is provided by the copyright holders and contributors “as is” and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------------- Faker Gem diff --git a/app/controllers/my_modules_controller.rb b/app/controllers/my_modules_controller.rb index d75b622c4..4707c8f46 100644 --- a/app/controllers/my_modules_controller.rb +++ b/app/controllers/my_modules_controller.rb @@ -9,7 +9,6 @@ class MyModulesController < ApplicationController :assign_samples, :unassign_samples, :delete_samples, :samples_index, :archive] - before_action :load_markdown, only: [ :results ] before_action :load_vars_nested, only: [:new, :create] before_action :check_edit_permissions, only: [ :edit, :update, :description, :due_date @@ -358,16 +357,6 @@ class MyModulesController < ApplicationController end end - # Initialize markdown parser - def load_markdown - @markdown = Redcarpet::Markdown.new( - Redcarpet::Render::HTML.new( - filter_html: true, - no_images: true - ) - ) - end - def check_edit_permissions unless can_edit_module(@my_module) render_403 diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 52a8b8569..4863940e4 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -50,16 +50,6 @@ class ReportsController < ApplicationController layout "fluid" - # Initialize markdown parser - def load_markdown - @markdown = Redcarpet::Markdown.new( - Redcarpet::Render::HTML.new( - filter_html: true, - no_images: true - ) - ) - end - # Index showing all reports of a single project def index end @@ -113,7 +103,6 @@ class ReportsController < ApplicationController # cleans all the deleted report current_organization_switch(@report.project.organization) @report.cleanup_report - load_markdown render 'reports/new.html.erb' end @@ -555,12 +544,11 @@ class ReportsController < ApplicationController end end if in_params? :module_result_texts then - load_markdown (my_module.results.select { |r| r.is_text && r.active? }).each do |result_text| res << generate_new_el(false) el = generate_el( "reports/elements/result_text_element.html.erb", - { result: result_text, markdown: @markdown } + { result: result_text } ) el[:children] = generate_result_contents_json(result_text) res << el diff --git a/app/controllers/result_texts_controller.rb b/app/controllers/result_texts_controller.rb index d1de9c694..e4a82ba34 100644 --- a/app/controllers/result_texts_controller.rb +++ b/app/controllers/result_texts_controller.rb @@ -3,7 +3,6 @@ class ResultTextsController < ApplicationController before_action :load_vars, only: [:edit, :update, :download] before_action :load_vars_nested, only: [:new, :create] - before_action :load_markdown, only: [ :create, :update ] before_action :check_create_permissions, only: [:new, :create] before_action :check_edit_permissions, only: [:edit, :update] @@ -63,8 +62,7 @@ class ResultTextsController < ApplicationController html: render_to_string({ partial: "my_modules/result.html.erb", locals: { - result: @result, - markdown: @markdown + result: @result } }) }, status: :ok @@ -142,8 +140,7 @@ class ResultTextsController < ApplicationController html: render_to_string({ partial: "my_modules/result.html.erb", locals: { - result: @result, - markdown: @markdown + result: @result } }) }, status: :ok @@ -182,16 +179,6 @@ class ResultTextsController < ApplicationController end end - # Initialize markdown parser - def load_markdown - @markdown = Redcarpet::Markdown.new( - Redcarpet::Render::HTML.new( - filter_html: true, - no_images: true - ) - ) - end - def check_create_permissions unless can_create_result_text_in_module(@my_module) render_403 diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 58f43517e..176429936 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,6 +1,5 @@ class SearchController < ApplicationController before_filter :load_vars, only: :index - before_filter :load_markdown, only: :index def index if not @search_query @@ -79,18 +78,6 @@ class SearchController < ApplicationController @search_page = 1 if @search_page < 1 end - # Initialize markdown parser - def load_markdown - if @search_category == :results - @markdown = Redcarpet::Markdown.new( - Redcarpet::Render::HTML.new( - filter_html: true, - no_images: true - ) - ) - end - end - protected def search_by_name(model) diff --git a/app/views/my_modules/_result.html.erb b/app/views/my_modules/_result.html.erb index 069abc134..be137e1ee 100644 --- a/app/views/my_modules/_result.html.erb +++ b/app/views/my_modules/_result.html.erb @@ -1,4 +1,3 @@ -<% markdown = markdown ||= nil %>
@@ -39,7 +38,7 @@
<%= render partial: 'my_modules/result_user_generated.html.erb', - locals: { result: result, markdown: markdown } %> + locals: { result: result } %>
<% if can_view_result_comments(@my_module) %> diff --git a/app/views/my_modules/_result_user_generated.html.erb b/app/views/my_modules/_result_user_generated.html.erb index cf5699424..e991fe56a 100644 --- a/app/views/my_modules/_result_user_generated.html.erb +++ b/app/views/my_modules/_result_user_generated.html.erb @@ -1,5 +1,5 @@ <% if result.is_text %> - <%= render partial: "results/result_text.html.erb", locals: {result: result, markdown: markdown, target: nil} %> + <%= render partial: "results/result_text.html.erb", locals: {result: result, target: nil} %> <% elsif result.is_table %> <%= render partial: "results/result_table.html.erb", locals: {result: result} %> <% elsif result.is_asset %> diff --git a/app/views/my_modules/results.html.erb b/app/views/my_modules/results.html.erb index f2193f5d1..6afe560a2 100644 --- a/app/views/my_modules/results.html.erb +++ b/app/views/my_modules/results.html.erb @@ -43,7 +43,7 @@ data-module-protocols-step-text="<%=t 'tutorial.module_results_html' %>" data-module-protocols-click-samples-step-text="<%=t 'tutorial.module_results_click_samples_html' %>"> <% ordered_result_of(@my_module).each do |result| %> - <%= render partial: "result", locals: {result: result, markdown: @markdown, direct_upload: @direct_upload} %> + <%= render partial: "result", locals: {result: result, direct_upload: @direct_upload} %> <% end %>
diff --git a/app/views/reports/elements/_result_text_element.html.erb b/app/views/reports/elements/_result_text_element.html.erb index d93c74e16..078c522a4 100644 --- a/app/views/reports/elements/_result_text_element.html.erb +++ b/app/views/reports/elements/_result_text_element.html.erb @@ -23,11 +23,7 @@
- <% if markdown.present? %> - <%= markdown.render(result_text.text).html_safe %> - <% else %> - <%= result_text.text %> - <% end %> + <%= result_text.text.html_safe %>
diff --git a/app/views/reports/new.html.erb b/app/views/reports/new.html.erb index 2635a4be8..19a32186a 100644 --- a/app/views/reports/new.html.erb +++ b/app/views/reports/new.html.erb @@ -30,7 +30,7 @@ <% if @report.present? %> <% @report.root_elements.each do |el| %> - <%= render_report_element(el, { markdown: @markdown }) %> + <%= render_report_element(el) %> <%= render_new_element(false) %> <% end %> <% else %> diff --git a/app/views/search/results/_results.html.erb b/app/views/search/results/_results.html.erb index e5632892c..b7d216ffc 100644 --- a/app/views/search/results/_results.html.erb +++ b/app/views/search/results/_results.html.erb @@ -1,4 +1,3 @@ -<% @markdown ||= nil %> <% results.each do |result| %>
<% if result.is_text %> @@ -15,10 +14,10 @@ <%= render partial: "search/results/partials/result_text.html.erb", locals: { result: result, query: search_query, target: nil } %>
- <% if result.is_text && result.result_text.text.present? && !result.result_text.text.empty? && @markdown.present? %> + <% if result.is_text && result.result_text.text.present? && !result.result_text.text.empty? %>

- <%= highlight(@markdown.render(result.result_text.text).html_safe, search_query.strip.split(/\s+/)) %> + <%= highlight(result.result_text.text.html_safe, search_query.strip.split(/\s+/)) %>

<% end %>