FIX: emoticons stop summary from being updated
This commit is contained in:
parent
e3a12995c8
commit
f4688f74db
|
@ -213,11 +213,11 @@ SQL
|
||||||
end
|
end
|
||||||
|
|
||||||
def description_text
|
def description_text
|
||||||
return nil unless description
|
return nil unless self.description
|
||||||
|
|
||||||
@@cache ||= LruRedux::ThreadSafeCache.new(1000)
|
@@cache ||= LruRedux::ThreadSafeCache.new(1000)
|
||||||
@@cache.getset(self.description) do
|
@@cache.getset(self.description) do
|
||||||
Nokogiri::HTML(self.description).text
|
Nokogiri::HTML.fragment(self.description).text.strip
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -442,18 +442,14 @@ class PostRevisor
|
||||||
def update_category_description
|
def update_category_description
|
||||||
return unless category = Category.find_by(topic_id: @topic.id)
|
return unless category = Category.find_by(topic_id: @topic.id)
|
||||||
|
|
||||||
body = @post.cooked
|
doc = Nokogiri::HTML.fragment(@post.cooked)
|
||||||
matches = body.scan(/\<p\>(.*)\<\/p\>/)
|
doc.css("img").remove
|
||||||
|
|
||||||
matches.each do |match|
|
html = doc.css("p").first.inner_html.strip
|
||||||
next if match[0] =~ /\<img(.*)src=/ || match[0].blank?
|
new_description = html unless html.starts_with?(Category.post_template[0..50])
|
||||||
new_description = match[0]
|
|
||||||
# first 50 characters should be fine to test they haven't changed the default description
|
category.update_column(:description, new_description)
|
||||||
new_description = nil if new_description.starts_with?(I18n.t("category.replace_paragraph")[0..50])
|
@category_changed = category
|
||||||
category.update_column(:description, new_description)
|
|
||||||
@category_changed = category
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def advance_draft_sequence
|
def advance_draft_sequence
|
||||||
|
|
Loading…
Reference in New Issue