| ... | @@ -7,6 +7,7 @@ |
... | @@ -7,6 +7,7 @@ |
|
|
# cache_markdown_field :foo
|
|
# cache_markdown_field :foo
|
|
|
# cache_markdown_field :bar
|
|
# cache_markdown_field :bar
|
|
|
# cache_markdown_field :baz, pipeline: :single_line
|
|
# cache_markdown_field :baz, pipeline: :single_line
|
|
|
|
# cache_markdown_field :baz, whitelisted: true
|
|
|
#
|
|
#
|
|
|
# Corresponding foo_html, bar_html and baz_html fields should exist.
|
|
# Corresponding foo_html, bar_html and baz_html fields should exist.
|
|
|
module CacheMarkdownField
|
|
module CacheMarkdownField
|
| ... | @@ -39,6 +40,14 @@ module CacheMarkdownField |
... | @@ -39,6 +40,14 @@ module CacheMarkdownField |
|
|
def html_fields
|
|
def html_fields
|
|
|
markdown_fields.map { |field| html_field(field) }
|
|
markdown_fields.map { |field| html_field(field) }
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
def html_fields_whitelisted
|
|
|
|
markdown_fields.each_with_object([]) do |field, fields|
|
|
|
|
if @data[field].fetch(:whitelisted, false)
|
|
|
|
fields << html_field(field)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
def skip_project_check?
|
|
def skip_project_check?
|
| ... | @@ -149,13 +158,18 @@ module CacheMarkdownField |
... | @@ -149,13 +158,18 @@ module CacheMarkdownField |
|
|
alias_method :attributes_before_markdown_cache, :attributes
|
|
alias_method :attributes_before_markdown_cache, :attributes
|
|
|
def attributes
|
|
def attributes
|
|
|
attrs = attributes_before_markdown_cache
|
|
attrs = attributes_before_markdown_cache
|
|
|
|
html_fields = cached_markdown_fields.html_fields
|
|
|
|
whitelisted = cached_markdown_fields.html_fields_whitelisted
|
|
|
|
exclude_fields = html_fields - whitelisted
|
|
|
|
|
|
|
|
attrs.delete('cached_markdown_version')
|
|
exclude_fields.each do |field|
|
|
|
|
|
|
|
|
cached_markdown_fields.html_fields.each do |field|
|
|
|
|
|
attrs.delete(field)
|
|
attrs.delete(field)
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
if whitelisted.empty?
|
|
|
|
attrs.delete('cached_markdown_version')
|
|
|
|
end
|
|
|
|
|
|
|
attrs
|
|
attrs
|
|
|
end
|
|
end
|
|
|
|
|
|
| ... | |
... | |
| ... | | ... | |