finish up archive page somewhat

This commit is contained in:
Lorin Werthen 2016-07-23 22:06:06 +02:00
parent 14ffd7a1ff
commit a22209d485
No known key found for this signature in database
GPG key ID: F11FFC921E0E08E0
4 changed files with 31 additions and 11 deletions

16
Rules
View file

@ -34,8 +34,7 @@ end
passthrough '/tipuesearch_content.js'
# ERB
compile '/*.erb' do
layout '/generic.*'
compile '/cammie.*' do
layout '/default.*'
filter :erb
@ -43,10 +42,7 @@ compile '/*.erb' do
end
compile '/archives/*' do
posts = items.find_all('/posts/**/*').select do |post|
post[:academic_year] == item[:academic_year]
end
layout '/archive_page.*'
layout '/generic.*'
layout '/default.*'
filter :erb
@ -80,6 +76,14 @@ compile '/posts/**/*', rep: :text do
filter :strip_html
end
compile '/*.erb' do
layout '/generic.*'
layout '/default.*'
filter :erb
filter :relativize_paths, type: :html
end
route '/index.*' do
'/index.html'
end

10
layouts/archive_page.erb Normal file
View file

@ -0,0 +1,10 @@
<% posts_in_year(item[:academic_year]).each do |post| %>
<a href="<%= relative_path_to(post) %>">
<div class="tipue_search_content_title">
<%= post[:title] %>
</div>
<div class="tipue_search_content_text">
<%= excerptize(post.reps[:text].compiled_content, length: 200) %>
</div>
</a>
<% end %>

View file

@ -2,14 +2,14 @@
<a href="#">
About
</a>
<a href="#">
All posts
<a href="/archives">
Archief
</a>
<a href="#">
Contact
</a>
<a href="/search">
Search
Zoeken
</a>
<a href="/cammie">
Cammie

View file

@ -14,7 +14,13 @@ module ArchiveHelper
academic_years.map { |y| [y, items["/archives/#{y}-#{y + 1}.html"]] }.to_h
end
def pretty_year(y)
"'#{y} - '#{y + 1}"
def pretty_year(year)
"'#{year} - '#{year + 1}"
end
def posts_in_year(academic_year)
items.find_all('/posts/**/*').select do |post|
post[:academic_year] == academic_year
end
end
end