FIX: emoticons stop summary from being updated

This commit is contained in:
Régis Hanol 2016-12-07 23:05:14 +01:00
parent e3a12995c8
commit f4688f74db
2 changed files with 9 additions and 13 deletions

View File

@ -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

View File

@ -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
html = doc.css("p").first.inner_html.strip
new_description = html unless html.starts_with?(Category.post_template[0..50])
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
end
def advance_draft_sequence