minor code cleanup
This commit is contained in:
parent
10f89e0c7a
commit
44e9a4f76c
2 changed files with 6 additions and 13 deletions
|
@ -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) %>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue