Skip to content

Commit

Permalink
Helpers for blog
Browse files Browse the repository at this point in the history
  • Loading branch information
jodosha committed Feb 16, 2015
1 parent 69388cb commit 5d097b0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 22 deletions.
27 changes: 22 additions & 5 deletions config.rb
Expand Up @@ -50,11 +50,28 @@
end end


# Methods defined in the helpers block are available in templates # Methods defined in the helpers block are available in templates
# helpers do helpers do
# def some_helper def articles(limit = 5)
# "Helping" blog.articles[0..limit]
# end end
# end
def article_title(article)
article.data.title
end

def article_author(article)
article.data.author
end

def article_date(article)
date = article.date
date.strftime('%B %d, %Y')
end

def article_summary(article)
article.data.excerpt
end
end


set :css_dir, 'stylesheets' set :css_dir, 'stylesheets'
set :js_dir, 'javascripts' set :js_dir, 'javascripts'
Expand Down
22 changes: 11 additions & 11 deletions source/blog.html.erb
Expand Up @@ -5,19 +5,19 @@ title: Lotus - Blog
<h1>Lotus Blog</h1> <h1>Lotus Blog</h1>


<section class="blog wrapper animated fadeIn"> <section class="blog wrapper animated fadeIn">
<div class="container-fluid"> <div class="container-fluid">
<% blog.articles[0...5].each do |article| %> <% articles.each do |article| %>
<div class="col-lg-12 col-md-12 main"> <div class="col-lg-12 col-md-12 main">
<h2 class="page-header"> <h2 class="page-header">
<%= article.title %> <%= article_title(article) %>
<div class="meta">Posted by <strong class="author"><%= article.data.author %></strong> on <%= article.date.strftime("%B %d, %Y") %></div> <div class="meta">Posted by <strong class="author"><%= article_author(article) %></strong> on <%= article_date(article) %></div>
</h2> </h2>


<p class="lead"><%= article.data.excerpt %></p> <p class="lead"><%= article_summary(article) %></p>


<%= link_to 'Read more…', article %> <%= link_to 'Read more…', article %>
</div>
</div> </div>
<% end %>
</div> </div>
<% end %>
</div>
</section> </section>
6 changes: 3 additions & 3 deletions source/layouts/blog.erb
Expand Up @@ -44,11 +44,11 @@
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1 main"> <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1 main">
<!-- <img src="images/sample-photo.jpg" class="img-rounded img-responsive"> --> <!-- <img src="images/sample-photo.jpg" class="img-rounded img-responsive"> -->
<h1 class="page-header"> <h1 class="page-header">
<%= current_page.data.title %> <%= article_title(current_page) %>
<div class="meta">Posted by <strong><%= current_page.data.author %></strong> on <%= current_page.date.strftime("%B %d, %Y") %></div> <div class="meta">Posted by <strong><%= article_author(current_page) %></strong> on <%= article_date(current_page) %></div>
</h1> </h1>


<p class="lead"><%= current_page.data.excerpt %></p> <p class="lead"><%= article_summary(current_page) %></p>
<hr> <hr>


<%= current_page.body %> <%= current_page.body %>
Expand Down
6 changes: 3 additions & 3 deletions source/layouts/home.erb
Expand Up @@ -29,7 +29,7 @@
<p class="sub">Lotus brings back Object Oriented Programming to web development,<br /> <p class="sub">Lotus brings back Object Oriented Programming to web development,<br />
leveraging a stable API, minimal DSL and plain objects.</p> leveraging a stable API, minimal DSL and plain objects.</p>


<a href="https://rubygems.org/gems/lotusrb" target="_blank" class="btn btn-primary version">Download v{{version}}</a> <a href="https://rubygems.org/gems/lotusrb" target="_blank" class="btn btn-primary version">Install v{{version}}</a>


<!-- terminal-window --> <!-- terminal-window -->
<div class="terminal-window animated bounceInUp"> <div class="terminal-window animated bounceInUp">
Expand Down Expand Up @@ -175,9 +175,9 @@


<section class="cta"> <section class="cta">
<div class="wrapper"> <div class="wrapper">
<h3>Download</h3> <h3>Install</h3>
<h2>Get Started with Lotus</h2> <h2>Get Started with Lotus</h2>
<a href="http://rubygems.org/gems/lotusrb" target="_blank" class="btn btn-primary version">Download v{{version}}</a> <a href="http://rubygems.org/gems/lotusrb" target="_blank" class="btn btn-primary version">Install v{{version}}</a>


<!-- <!--
<article class="case-studies"> <article class="case-studies">
Expand Down

0 comments on commit 5d097b0

Please sign in to comment.