|
|
|
@ -92,10 +92,21 @@ class Course < ActiveRecord::Base
|
|
|
|
|
|
|
|
|
|
# 课程的短描述信息
|
|
|
|
|
def short_description(length = 255)
|
|
|
|
|
description.gsub(/<\/?.*?>/,"").strip if description
|
|
|
|
|
description.gsub(/<\/?.*?>/,"").html_safe if description
|
|
|
|
|
#description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def strip_html(html)
|
|
|
|
|
return html if html.empty? || !html.include?('<')
|
|
|
|
|
output = ""
|
|
|
|
|
tokenizer = HTML::Tokenizer.new(html)
|
|
|
|
|
while token = tokenizer.next
|
|
|
|
|
node = HTML::Node.parse(nil, 0, 0, token, false)
|
|
|
|
|
output += token unless (node.kind_of? HTML::Tag) or (token =~ /^<!/)
|
|
|
|
|
end
|
|
|
|
|
return output
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def extra_frozen?
|
|
|
|
|
errors[:extra].blank? && !(new_record? || extra.blank?)
|
|
|
|
|
end
|
|
|
|
|