Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

Commit

Permalink
Add a tip list page
Browse files Browse the repository at this point in the history
  • Loading branch information
yesmeck committed Nov 11, 2012
1 parent 74e0719 commit 30413ce
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/assets/javascripts/tips.js.coffee
Expand Up @@ -2,4 +2,14 @@ jQuery =>
$('#tip_content').charCount(
counterElement: 'div'
)

$('a').tooltip()

$('.tip').hover(
->
$(this).find('.tip-link').show()
->
$(this).find('.tip-link').hide()
)


5 changes: 5 additions & 0 deletions app/controllers/tips_controller.rb
@@ -1,6 +1,11 @@
class TipsController < ApplicationController
# GET /
def index
if params[:page].nil?
params[:page] = 1
end
@tips = Tip.where(:approved => true).order('created_at DESC')
.paginate(:page => params[:page], :per_page=> 10)
end

# GET /tips/1
Expand Down
1 change: 1 addition & 0 deletions app/views/layouts/application.html.erb
Expand Up @@ -32,6 +32,7 @@
<a class="brand" href="/">Vim Tips</a>
<div class="container-fluid nav-collapse">
<ul class="nav">
<li><%= link_to "All Tips", '/tips' %></li>
<li><%= link_to "Post A Tip", '/post' %></li>
<li><%= link_to "Plugin", "/plugin" %></li>
<li><%= link_to "Subscribe", "/feed" %></li>
Expand Down
15 changes: 15 additions & 0 deletions app/views/tips/index.html.erb
@@ -0,0 +1,15 @@
<h1>All Tips</h1>

<ul id="tips">
<% @tips.each do |tip| %>
<li class="tip well">
<%= tip.content %>
<%= render 'via', :tip => tip %>
<%= link_to tip, :class => 'tip-link hide', :title => 'Leave A Comment' do %>
<i class="icon-comment"></i>
<% end %>
</li>
<% end %>
</ul>

<%= will_paginate @tips %>
3 changes: 3 additions & 0 deletions features/step_definitions/tip_list_steps.rb
@@ -0,0 +1,3 @@
When /^I visit All Tips page$/ do
visit tips_path
end
8 changes: 8 additions & 0 deletions features/tip_list.feature
@@ -0,0 +1,8 @@
Feature: Tip list

So that I can see all the tips.

Scenario:
Given a new tip
When I visit All Tips page
Then I should see the tip

0 comments on commit 30413ce

Please sign in to comment.