Skip to content
Snippets Groups Projects
Commit 99205515 authored by Nick Thomas's avatar Nick Thomas
Browse files

Enable CacheMarkdownField for the remaining models

This commit alters views for the following models to use the markdown cache if
present:

* AbuseReport
* Appearance
* ApplicationSetting
* BroadcastMessage
* Group
* Issue
* Label
* MergeRequest
* Milestone
* Project

At the same time, calls to `escape_once` have been moved into the `single_line`
Banzai pipeline, so they can't be missed out by accident and the work is done
at save, rather than render, time.
parent dd159a75
No related branches found
No related tags found
No related merge requests found
Showing
with 34 additions and 45 deletions
Loading
Loading
@@ -37,7 +37,7 @@ class Admin::BroadcastMessagesController < Admin::ApplicationController
end
 
def preview
@message = broadcast_message_params[:message]
@broadcast_message = BroadcastMessage.new(broadcast_message_params)
end
 
protected
Loading
Loading
Loading
Loading
@@ -16,7 +16,7 @@ module AppearancesHelper
end
 
def brand_text
markdown(brand_item.description)
markdown_field(brand_item, :description)
end
 
def brand_item
Loading
Loading
Loading
Loading
@@ -11,18 +11,6 @@ module ApplicationSettingsHelper
current_application_settings.signin_enabled?
end
 
def extra_sign_in_text
current_application_settings.sign_in_text
end
def after_sign_up_text
current_application_settings.after_sign_up_text
end
def shared_runners_text
current_application_settings.shared_runners_text
end
def user_oauth_applications?
current_application_settings.user_oauth_applications
end
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@ module BroadcastMessagesHelper
return unless message.present?
 
content_tag :div, class: 'broadcast-message', style: broadcast_message_style(message) do
icon('bullhorn') << ' ' << render_broadcast_message(message.message)
icon('bullhorn') << ' ' << render_broadcast_message(message)
end
end
 
Loading
Loading
@@ -32,7 +32,7 @@ module BroadcastMessagesHelper
end
end
 
def render_broadcast_message(message)
Banzai.render(message, pipeline: :broadcast_message).html_safe
def render_broadcast_message(broadcast_message)
Banzai.render_field(broadcast_message, :message).html_safe
end
end
Loading
Loading
@@ -13,14 +13,12 @@ module GitlabMarkdownHelper
def link_to_gfm(body, url, html_options = {})
return "" if body.blank?
 
escaped_body = if body.start_with?('<img')
body
else
escape_once(body)
end
user = current_user if defined?(current_user)
gfm_body = Banzai.render(escaped_body, project: @project, current_user: user, pipeline: :single_line)
context = {
project: @project,
current_user: (current_user if defined?(current_user)),
pipeline: :single_line,
}
gfm_body = Banzai.render(body, context)
 
fragment = Nokogiri::HTML::DocumentFragment.parse(gfm_body)
if fragment.children.size == 1 && fragment.children[0].name == 'a'
Loading
Loading
Loading
Loading
@@ -21,7 +21,7 @@
%td
%strong.subheading.visible-xs-block.visible-sm-block Message
.message
= markdown(abuse_report.message.squish!, pipeline: :single_line, author: reporter)
= markdown_field(abuse_report, :message)
%td
- if user
= link_to 'Remove user & report', admin_abuse_report_path(abuse_report, remove_user: true),
Loading
Loading
.broadcast-message-preview{ style: broadcast_message_style(@broadcast_message) }
= icon('bullhorn')
.js-broadcast-message-preview
= render_broadcast_message(@broadcast_message.message.presence || "Your message here")
- if @broadcast_message.message.present?
= render_broadcast_message(@broadcast_message)
- else
= "Your message here"
 
= form_for [:admin, @broadcast_message], html: { class: 'broadcast-message-form form-horizontal js-quick-submit js-requires-input'} do |f|
= form_errors(@broadcast_message)
Loading
Loading
$('.js-broadcast-message-preview').html("#{j(render_broadcast_message(@message))}");
$('.js-broadcast-message-preview').html("#{j(render_broadcast_message(@broadcast_message))}");
Loading
Loading
@@ -23,4 +23,4 @@
 
- if group.description.present?
.description
= markdown(group.description, pipeline: :description)
= markdown_field(group, :description)
%li{id: dom_id(label)}
.label-row
= render_colored_label(label, tooltip: false)
= markdown(label.description, pipeline: :single_line)
= markdown_field(label, :description)
.pull-right
= link_to 'Edit', edit_admin_label_path(label), class: 'btn btn-sm'
= link_to 'Delete', admin_label_path(label), class: 'btn btn-sm btn-remove remove-row', method: :delete, remote: true, data: {confirm: "Delete this label? Are you sure?"}
Loading
Loading
@@ -87,7 +87,7 @@
 
- if project.description.present?
.description
= markdown(project.description, pipeline: :description)
= markdown_field(project, :description)
 
= paginate @projects, theme: 'gitlab'
- else
Loading
Loading
Loading
Loading
@@ -3,9 +3,9 @@
Almost there...
%p.lead
Please check your email to confirm your account
- if after_sign_up_text.present?
- if current_application_settings.after_sign_up_text.present?
.well-confirmation.text-center
= markdown(after_sign_up_text)
= markdown_field(current_application_settings, :after_sign_up_text)
%p.confirmation-content.text-center
No confirmation email received? Please check your spam folder or
.append-bottom-20.prepend-top-20.text-center
Loading
Loading
Loading
Loading
@@ -21,7 +21,7 @@
 
- if @group.description.present?
.cover-desc.description
= markdown(@group.description, pipeline: :description)
= markdown_field(@group, :description)
 
%div.groups-header{ class: container_class }
.top-area
Loading
Loading
Loading
Loading
@@ -20,7 +20,7 @@
Read more about GitLab at #{link_to promo_host, promo_url, target: '_blank'}.
- if current_application_settings.help_page_text.present?
%hr
= markdown(current_application_settings.help_page_text)
= markdown_field(current_application_settings, :help_page_text)
 
%hr
 
Loading
Loading
Loading
Loading
@@ -25,8 +25,8 @@
Perform code reviews and enhance collaboration with merge requests.
Each project can also have an issue tracker and a wiki.
 
- if extra_sign_in_text.present?
= markdown(extra_sign_in_text)
- if current_application_settings.sign_in_text.present?
= markdown_field(current_application_settings, :sign_in_text)
 
%hr
.container
Loading
Loading
Loading
Loading
@@ -9,7 +9,7 @@
 
.project-home-desc
- if @project.description.present?
= markdown(@project.description, pipeline: :description)
= markdown_field(@project, :description)
 
- if forked_from_project = @project.forked_from_project
%p
Loading
Loading
Loading
Loading
@@ -65,10 +65,10 @@
 
.commit-box.content-block
%h3.commit-title
= markdown escape_once(@commit.title), pipeline: :single_line, author: @commit.author
= markdown(@commit.title, pipeline: :single_line, author: @commit.author)
- if @commit.description.present?
%pre.commit-description
= preserve(markdown(escape_once(@commit.description), pipeline: :single_line, author: @commit.author))
= preserve(markdown(@commit.description, pipeline: :single_line, author: @commit.author))
 
:javascript
$(".commit-info.branches").load("#{branches_namespace_project_commit_path(@project.namespace, @project, @commit.id)}");
Loading
Loading
@@ -33,7 +33,7 @@
 
- if commit.description?
%pre.commit-row-description.js-toggle-content
= preserve(markdown(escape_once(commit.description), pipeline: :single_line, author: commit.author))
= preserve(markdown(commit.description, pipeline: :single_line, author: commit.author))
 
.commit-row-info
= commit_author_link(commit, avatar: false, size: 24)
Loading
Loading
Loading
Loading
@@ -55,12 +55,12 @@
.issue-details.issuable-details
.detail-page-description.content-block
%h2.title
= markdown escape_once(@issue.title), pipeline: :single_line, author: @issue.author
= markdown_field(@issue, :title)
- if @issue.description.present?
.description{ class: can?(current_user, :update_issue, @issue) ? 'js-task-list-container' : '' }
.wiki
= preserve do
= markdown(@issue.description, cache_key: [@issue, "description"], author: @issue.author)
= markdown_field(@issue, :description)
%textarea.hidden.js-task-list-field
= @issue.description
= edited_time_ago_with_tooltip(@issue, placement: 'bottom', html_class: 'issue_edited_ago')
Loading
Loading
.detail-page-description.content-block
%h2.title
= markdown escape_once(@merge_request.title), pipeline: :single_line, author: @merge_request.author
= markdown_field(@merge_request, :title)
 
%div
- if @merge_request.description.present?
.description{class: can?(current_user, :update_merge_request, @merge_request) ? 'js-task-list-container' : ''}
.wiki
= preserve do
= markdown(@merge_request.description, cache_key: [@merge_request, "description"], author: @merge_request.author)
= markdown_field(@merge_request, :description)
%textarea.hidden.js-task-list-field
= @merge_request.description
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment