minor code cleanup

This commit is contained in:
Lorin Werthen 2017-02-08 00:51:46 +01:00
parent 10f89e0c7a
commit 44e9a4f76c
No known key found for this signature in database
GPG key ID: F11FFC921E0E08E0
2 changed files with 6 additions and 13 deletions

View file

@ -1,5 +1,5 @@
<a href="<%= relative_path_to(@article) %>" class="tile is-child box <%= @htmlclass %>"
style="background-image:url('<%=@article[:banner]%>');">
<a href="<%= @article.path %>" class="tile is-child box <%= @htmlclass %>"
style="background-image:url('<%= @article[:banner] %>');">
<div class="content" >
<div class="columns">
<div class="column">
@ -14,7 +14,7 @@
</div>
</div>
<div class="description">
<%= @article[:description] %>
<%= @article[:description] %>
</div>
<div class="teaser">
<%= get_teaser(@article) %>

View file

@ -1,14 +1,7 @@
module TileHelper
def get_teaser(post)
content = strip_html(post.compiled_content)
return truncate(content, 300)
# excerptize is part of the TextHelper, given by nanoc
# https://nanoc.ws/doc/reference/helpers/#text
excerptize(post.reps[:text].compiled_content, length: 300)
end
def truncate(s, max=70, elided = ' ...')
s.match( /(.{1,#{max}})(?:\s|\z)/ )[1].tap do |res|
res << elided unless res.length == s.length
end
end
end