mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-04 04:04:36 +08:00
remove redcarpet gem - markdown
This commit is contained in:
parent
456c6d1ad6
commit
3e162b3a93
12 changed files with 35 additions and 99 deletions
1
Gemfile
1
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'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
<% markdown = markdown ||= nil %>
|
||||
<div class="result">
|
||||
<div class="badge-num">
|
||||
<span class="badge bg-primary icon">
|
||||
|
@ -39,7 +38,7 @@
|
|||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<%= render partial: 'my_modules/result_user_generated.html.erb',
|
||||
locals: { result: result, markdown: markdown } %>
|
||||
locals: { result: result } %>
|
||||
</div>
|
||||
</div>
|
||||
<% if can_view_result_comments(@my_module) %>
|
||||
|
|
|
@ -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 %>
|
||||
|
|
|
@ -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 %>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -23,11 +23,7 @@
|
|||
<div class="report-element-body">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 text-container">
|
||||
<% if markdown.present? %>
|
||||
<%= markdown.render(result_text.text).html_safe %>
|
||||
<% else %>
|
||||
<%= result_text.text %>
|
||||
<% end %>
|
||||
<%= result_text.text.html_safe %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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 %>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
<% @markdown ||= nil %>
|
||||
<% results.each do |result| %>
|
||||
<h5>
|
||||
<% 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 } %>
|
||||
</h5>
|
||||
|
||||
<% 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? %>
|
||||
<blockquote class="search-asset-text-data">
|
||||
<p>
|
||||
<%= 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+/)) %>
|
||||
</p>
|
||||
</blockquote>
|
||||
<% end %>
|
||||
|
|
Loading…
Add table
Reference in a new issue