Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add the import functionality and adjust some remote calls

  • Loading branch information...
commit b4acc0baa49d92f00fcccd95797c24bcb78d26af 1 parent f9e8d0f
@f0086 authored
View
8 app/assets/javascripts/feeds.js.coffee
@@ -5,7 +5,9 @@
$(document).ready ->
$("#feed_list > li > a").bind("ajax:success", (event, data, status, xhr) ->
$("#feed_content").html(data)
- $(".item > a").bind("ajax:success", (event, data, status, xhr) ->
- $(this).parent().append(data)
+ $(".item > a", $("#feed_content")).bind("ajax:success", (event, data, status, xhr) ->
+ item = $(this).parent()
+ $("article", item).html(data)
+ $("a", item).bind()
)
- )
+ )
View
5 app/controllers/feeds_controller.rb
@@ -14,4 +14,9 @@ def create
@feed = Feed.import(params[:feed][:url])
redirect_to :action => :index, :notice => "Add the feed"
end
+
+ def import
+ fh = File.open(Rails.root.join("public", "uploads", params[:importer][:import_file].original_filename))
+ # TODO: Hier gehts weiter
+ end
end
View
11 app/views/feeds/import.html.erb
@@ -0,0 +1,11 @@
+<%= form_for(:importer, :url => import_feeds_path, :multipart => true, :remote => true) do |f| %>
+ <%= file_field_tag :import_file %>
+
+ <%= f.label :regex, "Insert a regular expression:" %>
+ <%= f.text_field :regex %>
+ <%= f.submit, "" %>
+<% end %>
+
+<h2>Preview</h2>
+<ul id="import_preview">
+</ul>
View
1  app/views/feeds/index.html.erb
@@ -1,5 +1,6 @@
<header>
<%= render :partial => "add" %>
+ <%= link_to "Import a list of feeds", import_feeds_path %>
</header>
<aside>
View
3  app/views/feeds/show.html.erb
@@ -3,6 +3,7 @@
<li class="item">
<%= link_to raw(item.title), item_path(item), :remote => true %>
<span class="data_published"><%= time_ago_in_words(item.published_at) %></span> <span class="author">by <%= item.author %></span>
+ <article></article>
</li>
<% end %>
-</ul>
+</ul>
View
8 config/routes.rb
@@ -12,7 +12,13 @@
# Sample resource route (maps HTTP verbs to controller actions automatically):
# resources :products
- resources :feeds, :items
+ resources :feeds do
+ collection do
+ get "import"
+ end
+ end
+
+ resources :items
# Sample resource route with options:
# resources :products do
Please sign in to comment.
Something went wrong with that request. Please try again.