Project overview page

This commit is contained in:
Stefan Schlott 2013-08-23 19:45:19 +02:00
parent 01b8494f18
commit 0e6b0d7e43
8 changed files with 80 additions and 1 deletions

16
lib/articlesummary.rb Normal file
View file

@ -0,0 +1,16 @@
require 'nokogiri'
def article_summary(item, separator=/<!-- *more *-->/)
# Has intro attribute? Use this
if (item[:intro] && item[:intro].length>0)
return parse_markdown(item[:intro])
end
# Try to extract marked teaser from article
summary,body = item.compiled_content.split(separator)
if (body)
return summary
end
# Else: Extract first top level html element
doc = Nokogiri::Slop(item.compiled_content)
return doc.children[0].to_html
end