diff --git a/layouts/article_body.html b/layouts/article_body.html
index f03d6d7a..37287e99 100644
--- a/layouts/article_body.html
+++ b/layouts/article_body.html
@@ -1,15 +1,3 @@
-<%
-def sanitize_path(path)
- result = path
- if (!path.start_with?('/'))
- result = '/' + result
- end
- if (!path.end_with?('/'))
- result = result + '/'
- end
- result
-end
-%>
diff --git a/layouts/project_body.html b/layouts/project_body.html
index 164876d9..8039e3b0 100644
--- a/layouts/project_body.html
+++ b/layouts/project_body.html
@@ -2,15 +2,16 @@
-
<%= item[:title] %>
- <%= yield %>
-
-
-
Ein Projektartikel
-
-
-
Noch ein Projektartikel
-
+
<%= item[:title] %>
+ <%= yield %>
+
+ <% latest_articles_referred_to(item.identifier,5).each do |item| %>
+
+ <%= render 'article_intro', :article => item, :extended => true %>
+
+ Zum Artikel
+
+ <% end %>
diff --git a/lib/articlehelpers.rb b/lib/articlehelpers.rb
index 14745c3e..e8a829ba 100644
--- a/lib/articlehelpers.rb
+++ b/lib/articlehelpers.rb
@@ -19,6 +19,16 @@ def pathname_of_article(item)
time.strftime('%Y-%m-%d') + '-' + slug
end
+def sanitize_path(path)
+ result = path
+ if (!path.start_with?('/'))
+ result = '/' + result
+ end
+ if (!path.end_with?('/'))
+ result = result + '/'
+ end
+ result
+end
def latest_articles(max=nil)
@cache_latest_art ||= @site.items.select do |p|
@@ -29,3 +39,12 @@ def latest_articles(max=nil)
@cache_latest_art[0..(max ? max-1 : @cache_latest_art.length-1)]
end
+def latest_articles_referred_to(refers_to, max=nil)
+ refers_to = sanitize_path(refers_to)
+ @site.items.select do |p|
+ p.attributes[:kind]=='article' && p.attributes[:refers_to] && sanitize_path(p.attributes[:refers_to])==refers_to
+ end.sort do |a, b|
+ a.attributes[:created_at] <=> b.attributes[:created_at]
+ end.reverse[0..(max ? max-1 : @cache_latest_art.length-1)]
+end
+