Add the import functionality and adjust some remote calls
This commit is contained in:
parent
f9e8d0f261
commit
b4acc0baa4
6 changed files with 31 additions and 5 deletions
|
@ -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()
|
||||
)
|
||||
)
|
|
@ -14,4 +14,9 @@ class FeedsController < ApplicationController
|
|||
@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
|
||||
|
|
11
app/views/feeds/import.html.erb
Normal file
11
app/views/feeds/import.html.erb
Normal file
|
@ -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>
|
|
@ -1,5 +1,6 @@
|
|||
<header>
|
||||
<%= render :partial => "add" %>
|
||||
<%= link_to "Import a list of feeds", import_feeds_path %>
|
||||
</header>
|
||||
|
||||
<aside>
|
||||
|
|
|
@ -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>
|
|
@ -12,7 +12,13 @@ FeedFu::Application.routes.draw do
|
|||
|
||||
# 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
|
||||
|
|
Reference in a new issue