diff --git a/app/assets/javascripts/feeds.js.coffee b/app/assets/javascripts/feeds.js.coffee
index 7615679..3975d34 100644
--- a/app/assets/javascripts/feeds.js.coffee
+++ b/app/assets/javascripts/feeds.js.coffee
@@ -1,3 +1,13 @@
# 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/
+
+$(document).ready ->
+ $("#feed_list > li > a").bind("ajax:success", (event, data, status, xhr) ->
+ $("#feed_content").html(data)
+ )
+
+ add_event_lister ->
+ $("#item > a").bind("ajax:success", (event, data, status, xhr) ->
+ $(this).append(data)
+ )
\ No newline at end of file
diff --git a/app/controllers/feeds_controller.rb b/app/controllers/feeds_controller.rb
index 35bc7bb..bb95761 100644
--- a/app/controllers/feeds_controller.rb
+++ b/app/controllers/feeds_controller.rb
@@ -8,4 +8,13 @@ class FeedsController < ApplicationController
def show
@items = Feed.find(params[:id]).items
end
+
+ def load_item
+ @item = Item.find(params[:id])
+ end
+
+ def create
+ @feed = Feed.import(params[:feed][:url])
+ redirect_to :action => :index, :notice => "Add the feed"
+ end
end
diff --git a/app/views/feeds/_add.html.erb b/app/views/feeds/_add.html.erb
new file mode 100644
index 0000000..dd183a2
--- /dev/null
+++ b/app/views/feeds/_add.html.erb
@@ -0,0 +1,6 @@
+<%= form_for(:feed, :url => feeds_path) do |f| %>
+ <%= f.label :url %>
+ <%= f.text_field :url %>
+
+ <%= f.submit :disable_with => "Adding ..." %>
+<% end %>
diff --git a/app/views/feeds/_navigation.html.erb b/app/views/feeds/_navigation.html.erb
new file mode 100644
index 0000000..f957b51
--- /dev/null
+++ b/app/views/feeds/_navigation.html.erb
@@ -0,0 +1,5 @@
+
+ <% @feeds.each do |feed| %>
+ <%= link_to feed.title, feed_path(feed), :remote => true, :update => "feed_content" %>
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/feeds/index.html.erb b/app/views/feeds/index.html.erb
index d0e11f8..2cda446 100644
--- a/app/views/feeds/index.html.erb
+++ b/app/views/feeds/index.html.erb
@@ -1,5 +1,10 @@
-
- <% @feeds.each do |feed| %>
- <%= link_to feed.title, feed_path(feed) %>
- <% end %>
-
+
+ <%= render :partial => "add" %>
+
+
+
+ <%= render :partial => "navigation" %>
+
+
+
+
diff --git a/app/views/feeds/show.html.erb b/app/views/feeds/show.html.erb
index e115467..96d9982 100644
--- a/app/views/feeds/show.html.erb
+++ b/app/views/feeds/show.html.erb
@@ -1,7 +1,8 @@
+
<% @items.each do |item| %>
-
-
<%= raw(item.title) %>
+
+ <%= link_to raw(item.title), load_item_feed_path(item), :remote => true %>
<%= time_ago_in_words(item.published_at) %> by <%= item.author %>
- <%= raw(item.content) %>
-
+
<% end %>
+
\ No newline at end of file
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 17aeb21..fd9f5f8 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -2,14 +2,12 @@
FeedFu
- <%= stylesheet_link_tag "application", :media => "all" %>
+ <%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
-
-
<%= yield %>
diff --git a/config/routes.rb b/config/routes.rb
index 41181a6..2917d26 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -12,7 +12,11 @@ FeedFu::Application.routes.draw do
# Sample resource route (maps HTTP verbs to controller actions automatically):
# resources :products
- resources :feeds
+ resources :feeds do
+ member do
+ get "load_item"
+ end
+ end
# Sample resource route with options:
# resources :products do