Feature: allow mods to cut pinned topic excerpts

This commit is contained in:
Sam
2014-07-17 21:32:17 +10:00
parent f2093fb4de
commit de7e6a9545
3 changed files with 15 additions and 1 deletions

View File

@ -10,6 +10,7 @@ class ExcerptParser < Nokogiri::XML::SAX::Document
@strip_links = options[:strip_links] == true
@text_entities = options[:text_entities] == true
@markdown_images = options[:markdown_images] == true
@start_excerpt = false
end
def self.get_excerpt(html, length, options)
@ -54,8 +55,11 @@ class ExcerptParser < Nokogiri::XML::SAX::Document
@in_quote = true
when "div", "span"
if attributes.include?(["class", "excerpt"])
@start_excerpt = true
end
# Preserve spoilers
if attributes.any? {|x| x == ["class", "spoiler"] }
if attributes.include?(["class", "spoiler"])
include_tag("span", attributes)
@in_spoiler = true
end
@ -74,6 +78,7 @@ class ExcerptParser < Nokogiri::XML::SAX::Document
when "aside"
@in_quote = false
when "div", "span"
throw :done if @start_excerpt
characters("</span>", false, false, false) if @in_spoiler
@in_spoiler = false
end