Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/concerns/cache_markdown_field.rb')
-rw-r--r--app/models/concerns/cache_markdown_field.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/app/models/concerns/cache_markdown_field.rb b/app/models/concerns/cache_markdown_field.rb
index 9713e79f525..cc13f279c4d 100644
--- a/app/models/concerns/cache_markdown_field.rb
+++ b/app/models/concerns/cache_markdown_field.rb
@@ -20,6 +20,10 @@ module CacheMarkdownField
false
end
+ def can_cache_field?(field)
+ true
+ end
+
# Returns the default Banzai render context for the cached markdown field.
def banzai_render_context(field)
raise ArgumentError.new("Unknown field: #{field.inspect}") unless
@@ -38,17 +42,23 @@ module CacheMarkdownField
context
end
- # Update every column in a row if any one is invalidated, as we only store
- # one version per row
- def refresh_markdown_cache
+ def rendered_field_content(markdown_field)
+ return unless can_cache_field?(markdown_field)
+
options = { skip_project_check: skip_project_check? }
+ Banzai::Renderer.cacheless_render_field(self, markdown_field, options)
+ end
+ # Update every applicable column in a row if any one is invalidated, as we only store
+ # one version per row
+ def refresh_markdown_cache
updates = cached_markdown_fields.markdown_fields.map do |markdown_field|
[
cached_markdown_fields.html_field(markdown_field),
- Banzai::Renderer.cacheless_render_field(self, markdown_field, options)
+ rendered_field_content(markdown_field)
]
end.to_h
+
updates['cached_markdown_version'] = latest_cached_markdown_version
updates.each { |field, data| write_markdown_field(field, data) }