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

View file

@ -1,14 +1,7 @@
module TileHelper module TileHelper
def get_teaser(post) def get_teaser(post)
content = strip_html(post.compiled_content) # excerptize is part of the TextHelper, given by nanoc
return truncate(content, 300) # https://nanoc.ws/doc/reference/helpers/#text
excerptize(post.reps[:text].compiled_content, length: 300)
end 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 end