Added some filtering to make descriptions more consistent

This commit is contained in:
Godwin 2014-07-13 13:15:05 -06:00
parent 44a6bce08c
commit 14792c14f3
2 changed files with 20 additions and 3 deletions

View File

@ -303,7 +303,7 @@ main {
#banner {
position: relative;
background-size: cover;
background-position: center 66.6667%;
background-position: 25% 66.6667%;
//padding-top: 4em;
color: $white;
overflow: visible;
@ -457,7 +457,7 @@ main {
figure {
img {
max-height: 100%;
max-height: 75%;
}
}

View File

@ -1,3 +1,4 @@
module ApplicationHelper
@@keyQueue = nil
@@translationsOnThisPage = nil
@ -363,7 +364,23 @@ module ApplicationHelper
end
def p(object, attribute)
('<p>' + object.send(attribute.to_s).strip.gsub(/\s*\n+\s*/, '</p><p>') + '</p>').html_safe
content = object.send(attribute.to_s)
result = ''
if content =~ /<(p|span|h\d|div)[^>]*>/
result = content.gsub(/\s*(style|class|id|width|height|font)=\".*?\"/, '')
.gsub(/&nbsp;/, ' ')
.gsub(/<(\/)?\s*h\d\s*>/, '<\1h3>')
.gsub(/<p>(.*?)<br\s\/?>\s*(<br\s\/?>)+/, '<p>\1</p><p>')
.gsub(/<span[^>]*>\s*(.*?)\s*<\/span>/, '\1')
.gsub(/<p>\s*<\/p>/, '')
.gsub(/<(\/)?div>/, '<\1p>')
if !(result =~ /<p[^>]*>/)
result = '<p>' + result + '</p>'
end
else
result = '<p>' + content.strip.gsub(/\s*\n+\s*/, '</p><p>') + '</p>'
end
result.html_safe
end
def form_field(f, response = nil)