Skip to content
Permalink
Browse files

Helpers for blog

  • Loading branch information...
jodosha committed Feb 16, 2015
1 parent 69388cb commit 5d097b03913cc248647b033e6438329a4730bb2d
Showing with 39 additions and 22 deletions.
  1. +22 −5 config.rb
  2. +11 −11 source/blog.html.erb
  3. +3 −3 source/layouts/blog.erb
  4. +3 −3 source/layouts/home.erb
@@ -50,11 +50,28 @@
end

# Methods defined in the helpers block are available in templates
# helpers do
# def some_helper
# "Helping"
# end
# end
helpers do
def articles(limit = 5)
blog.articles[0..limit]
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 :js_dir, 'javascripts'
@@ -5,19 +5,19 @@ title: Lotus - Blog
<h1>Lotus Blog</h1>

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

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

<%= current_page.body %>
@@ -29,7 +29,7 @@
<p class="sub">Lotus brings back Object Oriented Programming to web development,<br />
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 -->
<div class="terminal-window animated bounceInUp">
@@ -175,9 +175,9 @@

<section class="cta">
<div class="wrapper">
<h3>Download</h3>
<h3>Install</h3>
<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">

0 comments on commit 5d097b0

Please sign in to comment.
You can’t perform that action at this time.