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 ->
|
$(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) ->
|
$(".item > a", $("#feed_content")).bind("ajax:success", (event, data, status, xhr) ->
|
||||||
$(this).parent().append(data)
|
item = $(this).parent()
|
||||||
|
$("article", item).html(data)
|
||||||
|
$("a", item).bind()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -14,4 +14,9 @@ class FeedsController < ApplicationController
|
||||||
@feed = Feed.import(params[:feed][:url])
|
@feed = Feed.import(params[:feed][:url])
|
||||||
redirect_to :action => :index, :notice => "Add the feed"
|
redirect_to :action => :index, :notice => "Add the feed"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def import
|
||||||
|
fh = File.open(Rails.root.join("public", "uploads", params[:importer][:import_file].original_filename))
|
||||||
|
# TODO: Hier gehts weiter
|
||||||
|
end
|
||||||
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>
|
<header>
|
||||||
<%= render :partial => "add" %>
|
<%= render :partial => "add" %>
|
||||||
|
<%= link_to "Import a list of feeds", import_feeds_path %>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<aside>
|
<aside>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
<li class="item">
|
<li class="item">
|
||||||
<%= link_to raw(item.title), item_path(item), :remote => true %>
|
<%= 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>
|
<span class="data_published"><%= time_ago_in_words(item.published_at) %></span> <span class="author">by <%= item.author %></span>
|
||||||
|
<article></article>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -12,7 +12,13 @@ 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, :items
|
resources :feeds do
|
||||||
|
collection do
|
||||||
|
get "import"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
resources :items
|
||||||
|
|
||||||
# Sample resource route with options:
|
# Sample resource route with options:
|
||||||
# resources :products do
|
# resources :products do
|
||||||
|
|
Reference in a new issue