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