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' passthrough '/tipuesearch_content.js'
# ERB # ERB
compile '/*.erb' do compile '/cammie.*' do
layout '/generic.*'
layout '/default.*' layout '/default.*'
filter :erb filter :erb
@ -43,10 +42,7 @@ compile '/*.erb' do
end end
compile '/archives/*' do compile '/archives/*' do
posts = items.find_all('/posts/**/*').select do |post| layout '/archive_page.*'
post[:academic_year] == item[:academic_year]
end
layout '/generic.*' layout '/generic.*'
layout '/default.*' layout '/default.*'
filter :erb filter :erb
@ -80,6 +76,14 @@ compile '/posts/**/*', rep: :text do
filter :strip_html filter :strip_html
end end
compile '/*.erb' do
layout '/generic.*'
layout '/default.*'
filter :erb
filter :relativize_paths, type: :html
end
route '/index.*' do route '/index.*' do
'/index.html' '/index.html'
end 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="#"> <a href="#">
About About
</a> </a>
<a href="#"> <a href="/archives">
All posts Archief
</a> </a>
<a href="#"> <a href="#">
Contact Contact
</a> </a>
<a href="/search"> <a href="/search">
Search Zoeken
</a> </a>
<a href="/cammie"> <a href="/cammie">
Cammie Cammie

View file

@ -14,7 +14,13 @@ module ArchiveHelper
academic_years.map { |y| [y, items["/archives/#{y}-#{y + 1}.html"]] }.to_h academic_years.map { |y| [y, items["/archives/#{y}-#{y + 1}.html"]] }.to_h
end end
def pretty_year(y) def pretty_year(year)
"'#{y} - '#{y + 1}" "'#{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
end end