summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Henrik Mai <lars.mai@kontinui.de>2014-04-09 17:41:17 +0200
committerLars Henrik Mai <lars.mai@kontinui.de>2014-04-09 17:41:17 +0200
commita3995bf898c38ed755a3e1bd60b3b4aaf27670ec (patch)
tree75882cb224243a2e8856371245c698f382a922fb
parent4299ee398c19076ab27451b669d7f726d6e6a45d (diff)
add custom blog article summary generator that truncates to first pararaph
-rw-r--r--config.rb3
-rw-r--r--source/_article_summary.html.erb5
-rw-r--r--source/index.html.erb2
3 files changed, 9 insertions, 1 deletions
diff --git a/config.rb b/config.rb
index 14ca283..93d7cc5 100644
--- a/config.rb
+++ b/config.rb
@@ -15,6 +15,9 @@ activate :blog do |blog|
# blog.layout = "layout"
# blog.summary_separator = /(READMORE)/
# blog.summary_length = 250
+
+ blog.summary_generator = Proc.new {|article, rendered, length, ellipsis| Nokogiri::HTML(rendered).at_xpath("//p[1]").to_s + link_to(ellipsis, article) }
+
# blog.year_link = "{year}.html"
# blog.month_link = "{year}/{month}.html"
# blog.day_link = "{year}/{month}/{day}.html"
diff --git a/source/_article_summary.html.erb b/source/_article_summary.html.erb
new file mode 100644
index 0000000..fbb4cfd
--- /dev/null
+++ b/source/_article_summary.html.erb
@@ -0,0 +1,5 @@
+<% article = article_summary %>
+<div>
+ <h3><%= link_to article.title, article %> <span><%= article.date.strftime('%b %e') %></span></h3>
+ <%= article.summary %>
+</div>
diff --git a/source/index.html.erb b/source/index.html.erb
index 98486b6..dbef3db 100644
--- a/source/index.html.erb
+++ b/source/index.html.erb
@@ -20,7 +20,7 @@ title: sublab - Ein Hackerspace in Leipzig
<h2>[ Neues aus dem sublab]</h2>
- <%= partial "article", collection: blog.articles[0..4] %>
+ <%= partial "article_summary", collection: blog.articles[0..4] %>
<p><%= link_to "Alle News", "/news.html" %></p>