Add the Items controller and make it work
This commit is contained in:
parent
2f41765985
commit
f9e8d0f261
11 changed files with 37 additions and 18 deletions
|
@ -5,9 +5,7 @@
|
||||||
$(document).ready ->
|
$(document).ready ->
|
||||||
$("#feed_list > li > a").bind("ajax:success", (event, data, status, xhr) ->
|
$("#feed_list > li > a").bind("ajax:success", (event, data, status, xhr) ->
|
||||||
$("#feed_content").html(data)
|
$("#feed_content").html(data)
|
||||||
|
$(".item > a").bind("ajax:success", (event, data, status, xhr) ->
|
||||||
|
$(this).parent().append(data)
|
||||||
)
|
)
|
||||||
|
|
||||||
add_event_lister ->
|
|
||||||
$("#item > a").bind("ajax:success", (event, data, status, xhr) ->
|
|
||||||
$(this).append(data)
|
|
||||||
)
|
)
|
3
app/assets/javascripts/items.js.coffee
Normal file
3
app/assets/javascripts/items.js.coffee
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Place all the behaviors and hooks related to the matching controller here.
|
||||||
|
# All this logic will automatically be available in application.js.
|
||||||
|
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
3
app/assets/stylesheets/items.css.scss
Normal file
3
app/assets/stylesheets/items.css.scss
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
// Place all the styles related to the items controller here.
|
||||||
|
// They will automatically be included in application.css.
|
||||||
|
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -7,10 +7,7 @@ class FeedsController < ApplicationController
|
||||||
# Show a single feed
|
# Show a single feed
|
||||||
def show
|
def show
|
||||||
@items = Feed.find(params[:id]).items
|
@items = Feed.find(params[:id]).items
|
||||||
end
|
render :layout => false
|
||||||
|
|
||||||
def load_item
|
|
||||||
@item = Item.find(params[:id])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|
6
app/controllers/items_controller.rb
Normal file
6
app/controllers/items_controller.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
class ItemsController < ApplicationController
|
||||||
|
def show
|
||||||
|
@item = Item.find(params[:id])
|
||||||
|
render :layout => false
|
||||||
|
end
|
||||||
|
end
|
2
app/helpers/items_helper.rb
Normal file
2
app/helpers/items_helper.rb
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
module ItemsHelper
|
||||||
|
end
|
|
@ -1,8 +1,8 @@
|
||||||
<ul>
|
<ul>
|
||||||
<% @items.each do |item| %>
|
<% @items.each do |item| %>
|
||||||
<li class="item">
|
<li class="item">
|
||||||
<%= link_to raw(item.title), load_item_feed_path(item), :remote => true %>
|
<%= link_to raw(item.title), item_path(item), :remote => true %>
|
||||||
<span><%= time_ago_in_words(item.published_at) %> by <%= item.author %></span>
|
<span class="data_published"><%= time_ago_in_words(item.published_at) %></span> <span class="author">by <%= item.author %></span>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
3
app/views/items/show.html.erb
Normal file
3
app/views/items/show.html.erb
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<p>
|
||||||
|
<%= raw @item.content %>
|
||||||
|
</p>
|
|
@ -12,11 +12,7 @@ FeedFu::Application.routes.draw do
|
||||||
|
|
||||||
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
||||||
# resources :products
|
# resources :products
|
||||||
resources :feeds do
|
resources :feeds, :items
|
||||||
member do
|
|
||||||
get "load_item"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Sample resource route with options:
|
# Sample resource route with options:
|
||||||
# resources :products do
|
# resources :products do
|
||||||
|
@ -53,7 +49,7 @@ FeedFu::Application.routes.draw do
|
||||||
|
|
||||||
# You can have the root of your site routed with "root"
|
# You can have the root of your site routed with "root"
|
||||||
# just remember to delete public/index.html.
|
# just remember to delete public/index.html.
|
||||||
# root :to => 'welcome#index'
|
root :to => 'feeds#index'
|
||||||
|
|
||||||
# See how all your routes lay out with "rake routes"
|
# See how all your routes lay out with "rake routes"
|
||||||
|
|
||||||
|
|
7
test/functional/items_controller_test.rb
Normal file
7
test/functional/items_controller_test.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class ItemsControllerTest < ActionController::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
4
test/unit/helpers/items_helper_test.rb
Normal file
4
test/unit/helpers/items_helper_test.rb
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class ItemsHelperTest < ActionView::TestCase
|
||||||
|
end
|
Reference in a new issue