Skip to content

Instantly share code, notes, and snippets.

@vanakenm

vanakenm/Posts Sample

Last active Dec 19, 2015
Embed
What would you like to do?
<% content_for :header do %>
<%= javascript_include_tag "filters" %>
<% end %>
<h1>Show posts</h1>
<header>
<section id="statistics">
<p>Currently <%= @posts.size %> in <%= @posts.map(&:category).uniq.size %> different categories.</p>
<p>Most recent category: <%= @posts.first.category %>
</section>
<section id="filters">
<div class="btn-group sort">
<a class="btn dropdown-toogle" data-toogle="dropdown" href="#">All categories <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a data-filter-category="all_filter" href="#">All categories</a></li>
<li><a data-filter-category="opinion" href="#">Opinion</a></li>
<li><a data-filter-category="announcement" href="#">Announcement</a></li>
<li><a data-filter-category="debate" href="#">Debate</a></li>
</ul>
</div>
</section>
</header>
<% @posts.each do |post| %>
<article data-category="<%= post.category %>">
<header>
<h1><%= post.title %></h1>
<h2>By <%= post.author %></h2>
</header>
<section class="contents">
<%= post.contents %>
</section>
<footer>
Published on <%= post.publish_date %>
</footer>
</article>
<% end %>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment