strip syntax for meta description tag

This commit is contained in:
r888888888
2016-02-04 13:46:37 -08:00
parent 504674b288
commit 7f9261b0cb
3 changed files with 20 additions and 2 deletions

View File

@@ -323,6 +323,24 @@ class DText
html.join("").html_safe
end
def self.strip(s)
s.gsub!(/[\r\n]+/m, " ")
s.gsub!(/\[\/?(?:b|i|s|u|tn|tr|td|th|thead|tbody|quote|code|spoilers|spoiler|expand|table)\]/, "")
s.gsub!(/\[\[([^\|\]]+)\|([^\]]+)\]\]/m, '\2')
s.gsub!(/\[\[([^\]]+)\]\]/, '\1')
s.gsub!(/\{\{([^\}]+)\}\}/, '\1')
s.gsub!(/("[^"]+":(https?:\/\/|\/)[^\s\r\n<>]+|https?:\/\/[^\s\r\n<>]+|"[^"]+":\[(https?:\/\/|\/)[^\s\r\n<>\]]+\])+/) do |url|
if url =~ /^"([^"]+)":\[(.+)\]$/
$1
elsif url =~ /^"([^"]+)":(.+)$/
$1
else
url
end
end
s
end
def self.sanitize(text)
text.gsub!(/<( |-|3|:|>|\Z)/, "&lt;\\1")

View File

@@ -2,6 +2,6 @@ class WeeklyMaintenance
def run
ActiveRecord::Base.connection.execute("set statement_timeout = 0")
UserPasswordResetNonce.prune!
JanitorPruner.new.prune!
# JanitorPruner.new.prune!
end
end

View File

@@ -10,7 +10,7 @@ class WikiPagePresenter
end
def blurb
excerpt.try(:gsub, /<.+?>/, "")
DText.strip(excerpt.to_s)
end
def consequent_tag_aliases