From 18f0f15ea809c7d057d0ba12ad90b96470a089a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20B=C3=A4ume?= Date: Fri, 12 Oct 2012 02:04:32 +0200 Subject: [PATCH 01/11] fix get wikipedia images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should be all that is needed for the wikipedia integration. It’s now possible to search for new images and add them as FileAsset records. This is mostly a rewrite of the old code and is IMHO much more clean and more tested. --- .../javascripts/fassets_resources/index.js | 1 + .../fassets_resources/wikipedia_search.js | 19 +++++++++++++++++++ .../file_assets_controller.rb | 13 +++---------- .../file_assets/_wiki_img_form.html.haml | 15 +++++++-------- ....html.haml => _wikipedia_images.html.haml} | 0 config/routes.rb | 7 +------ .../file_assets_controller_spec.rb | 12 ++++++++++++ 7 files changed, 43 insertions(+), 24 deletions(-) create mode 100644 app/assets/javascripts/fassets_resources/wikipedia_search.js rename app/views/fassets_resources/file_assets/{_search_wiki_imgs.html.haml => _wikipedia_images.html.haml} (100%) diff --git a/app/assets/javascripts/fassets_resources/index.js b/app/assets/javascripts/fassets_resources/index.js index 6bbd557..565cb8a 100644 --- a/app/assets/javascripts/fassets_resources/index.js +++ b/app/assets/javascripts/fassets_resources/index.js @@ -4,3 +4,4 @@ //= require jquery.fileupload-ui //= require_self //= require ./add_asset_box +//= require ./wikipedia_search diff --git a/app/assets/javascripts/fassets_resources/wikipedia_search.js b/app/assets/javascripts/fassets_resources/wikipedia_search.js new file mode 100644 index 0000000..427b655 --- /dev/null +++ b/app/assets/javascripts/fassets_resources/wikipedia_search.js @@ -0,0 +1,19 @@ +$(document).ready(function(){ + var performWikiSearch = function() { + var wiki_qry_path = $("input.wiki_submit").data("wiki-qry-path"); + var search_key = $("input#file_asset_search_key").val(); + $("#wiki_search_result").load(wiki_qry_path,{'search_key': search_key}); + }; + $(document).ajaxComplete(function() { + $("input.wiki_submit").one("click", function(event){ + event.preventDefault(); + performWikiSearch(); + }); + $("input#file_asset_search_key").one("keydown", function(event){ + if (event.which == 13) { + event.preventDefault(); + performWikiSearch(); + }; + }); + }); +}); diff --git a/app/controllers/fassets_resources/file_assets_controller.rb b/app/controllers/fassets_resources/file_assets_controller.rb index 27148d2..07e38e2 100644 --- a/app/controllers/fassets_resources/file_assets_controller.rb +++ b/app/controllers/fassets_resources/file_assets_controller.rb @@ -3,6 +3,7 @@ module FassetsResources class FileAssetsController < AssetsController skip_before_filter :authenticate_user!, :only => [:thumb, :preview, :original] + skip_before_filter :find_content, :only => [:wikipedia_images] def thumb redirect_to "/public/uploads/#{@content.id}/thumb.#{params[:format]}" @@ -20,11 +21,7 @@ def original def content_model return FileAsset end - def new_remote_file - @content = FileAsset.new - render :template => 'file_assets/new_remote_file' - end - def search_wiki_imgs + def wikipedia_images @content = FileAsset.new Wikipedia.Configure { domain 'en.wikipedia.org' @@ -33,11 +30,7 @@ def search_wiki_imgs } page = Wikipedia.find(params[:search_key]) image_urls = page.image_urls - render :partial => 'file_assets/search_wiki_imgs', :locals => {:search_key => params[:search_key], :image_urls => image_urls} - end - def get_wiki_imgs - @content = FileAsset.new - render :template => "file_assets/new_wiki_img" + render :partial => 'wikipedia_images', :locals => {:search_key => params[:search_key], :image_urls => image_urls} end end end diff --git a/app/views/fassets_resources/file_assets/_wiki_img_form.html.haml b/app/views/fassets_resources/file_assets/_wiki_img_form.html.haml index c4a9951..94baa41 100644 --- a/app/views/fassets_resources/file_assets/_wiki_img_form.html.haml +++ b/app/views/fassets_resources/file_assets/_wiki_img_form.html.haml @@ -4,11 +4,10 @@ #name New -#main.fassets_core - =form_for @content, :url => "/search_wiki_imgs",:html => {:multipart => true} do |f| - =render :partial => "shared/error", :locals => {:target => @content} - %p - %label{:for => 'search_key'} Search for Images from: - =text_field :file_asset, :search_key - =submit_tag "Search", :class => "wiki_submit" - +#search_wiki_images + =render :partial => "shared/error", :locals => {:target => @content} + %p + %label{:for => 'search_key'} Search for Images from: + =text_field :file_asset, :search_key + =submit_tag "Search", :class => "wiki_submit", :data => {:wiki_qry_path => fassets_resources.wikipedia_search_path} + #wiki_search_result diff --git a/app/views/fassets_resources/file_assets/_search_wiki_imgs.html.haml b/app/views/fassets_resources/file_assets/_wikipedia_images.html.haml similarity index 100% rename from app/views/fassets_resources/file_assets/_search_wiki_imgs.html.haml rename to app/views/fassets_resources/file_assets/_wikipedia_images.html.haml diff --git a/config/routes.rb b/config/routes.rb index ca3836b..aa8295d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,10 +9,5 @@ end end - match 'file_assets/:id' => 'FileAssets#update' - match 'urls/:id' => 'Urls#update' - match 'new_remote_file' => 'FileAssets#new_remote_file' - match 'get_wiki_imgs' => 'FileAssets#get_wiki_imgs' - match 'search_wiki_imgs' => 'FileAssets#search_wiki_imgs' - match 'add_wiki_img' => 'FileAssets#add_wiki_image' + post '/wikipedia_search', :as => 'wikipedia_search', :action => 'wikipedia_images', :controller => "file_assets" end diff --git a/spec/controllers/fassets_resources/file_assets_controller_spec.rb b/spec/controllers/fassets_resources/file_assets_controller_spec.rb index 0262b5d..bc9ae39 100644 --- a/spec/controllers/fassets_resources/file_assets_controller_spec.rb +++ b/spec/controllers/fassets_resources/file_assets_controller_spec.rb @@ -46,5 +46,17 @@ module FassetsResources response.should render_template("assets/show") end end + + context "GET wikipedia_images" do + it "should get a list of images" do + page = double("Wikipedia::Page") + page.should_receive(:image_urls) {['http://test.host/test1.png','http://test.host/test2.png']} + Wikipedia.should_receive(:find).with("test search") { page } + get 'wikipedia_images', :use_route => :fassets_resources, :search_key => "test search" + response.should be_success + response.should render_template "wikipedia_images" + response.should_not render_template "layouts/fassets_core/application" + end + end end end From 4aa47689b023fc8d9fd059e14f86395d8bab707e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20B=C3=A4ume?= Date: Fri, 12 Oct 2012 21:11:07 +0200 Subject: [PATCH 02/11] fix wikipedia_search action when result is empty Wikipedia::Page.image_urls returns nil, if no results are found. But we want to assign an empty list in this case. This allows the partials to be rendered properly. --- .../fassets_resources/file_assets_controller.rb | 4 ++-- .../file_assets_controller_spec.rb | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/controllers/fassets_resources/file_assets_controller.rb b/app/controllers/fassets_resources/file_assets_controller.rb index 07e38e2..54381b8 100644 --- a/app/controllers/fassets_resources/file_assets_controller.rb +++ b/app/controllers/fassets_resources/file_assets_controller.rb @@ -29,8 +29,8 @@ def wikipedia_images path 'w/api.php' } page = Wikipedia.find(params[:search_key]) - image_urls = page.image_urls - render :partial => 'wikipedia_images', :locals => {:search_key => params[:search_key], :image_urls => image_urls} + @image_urls = page.image_urls || [] + render :partial => 'wikipedia_images', :locals => {:search_key => params[:search_key], :image_urls => @image_urls} end end end diff --git a/spec/controllers/fassets_resources/file_assets_controller_spec.rb b/spec/controllers/fassets_resources/file_assets_controller_spec.rb index bc9ae39..4d89d5e 100644 --- a/spec/controllers/fassets_resources/file_assets_controller_spec.rb +++ b/spec/controllers/fassets_resources/file_assets_controller_spec.rb @@ -50,12 +50,24 @@ module FassetsResources context "GET wikipedia_images" do it "should get a list of images" do page = double("Wikipedia::Page") - page.should_receive(:image_urls) {['http://test.host/test1.png','http://test.host/test2.png']} + test_urls = ['http://test.host/test1.png','http://test.host/test2.png'] + page.should_receive(:image_urls) { test_urls } Wikipedia.should_receive(:find).with("test search") { page } get 'wikipedia_images', :use_route => :fassets_resources, :search_key => "test search" response.should be_success response.should render_template "wikipedia_images" response.should_not render_template "layouts/fassets_core/application" + assigns(:image_urls).should == test_urls + end + + it "should not assign nil as image list" do + page = double("Wikipedia::Page") + # image_urls returns nil if no images are found + page.should_receive(:image_urls) { nil } + Wikipedia.should_receive(:find).with("test search") { page } + get 'wikipedia_images', :use_route => :fassets_resources, :search_key => "test search" + assigns(:image_urls).should_not be_nil + assigns(:image_urls).should be_empty end end end From 42d58e0bc57761b710a6811ad65e922564d1df0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20B=C3=A4ume?= Date: Fri, 12 Oct 2012 21:51:51 +0200 Subject: [PATCH 03/11] fix crash in wikipedia_search action calling find with an empty string will raise a TypeError, so we need to check for it. --- app/controllers/fassets_resources/file_assets_controller.rb | 5 +++-- .../fassets_resources/file_assets_controller_spec.rb | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/controllers/fassets_resources/file_assets_controller.rb b/app/controllers/fassets_resources/file_assets_controller.rb index 54381b8..38ef9f7 100644 --- a/app/controllers/fassets_resources/file_assets_controller.rb +++ b/app/controllers/fassets_resources/file_assets_controller.rb @@ -28,8 +28,9 @@ def wikipedia_images #domain 'commons.wikimedia.org' path 'w/api.php' } - page = Wikipedia.find(params[:search_key]) - @image_urls = page.image_urls || [] + page = Wikipedia.find(params[:search_key]) unless params[:search_key] == "" + @image_urls = page.image_urls unless page.nil? + @image_urls ||= [] render :partial => 'wikipedia_images', :locals => {:search_key => params[:search_key], :image_urls => @image_urls} end end diff --git a/spec/controllers/fassets_resources/file_assets_controller_spec.rb b/spec/controllers/fassets_resources/file_assets_controller_spec.rb index 4d89d5e..0162505 100644 --- a/spec/controllers/fassets_resources/file_assets_controller_spec.rb +++ b/spec/controllers/fassets_resources/file_assets_controller_spec.rb @@ -69,6 +69,12 @@ module FassetsResources assigns(:image_urls).should_not be_nil assigns(:image_urls).should be_empty end + + it "should not fail with empty search string" do + # find with empty string will raise a type error + Wikipedia.should_not_receive(:find).with("") + get 'wikipedia_images', :use_route => :fassets_resources, :search_key => "" + end end end end From 74aa349d5938f2e3dce1e0a8aa7bcaeb65aa9898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20B=C3=A4ume?= Date: Mon, 12 Nov 2012 12:44:35 +0100 Subject: [PATCH 04/11] include wikipedia.css file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wasn’t loaded in manifest file, before --- app/assets/stylesheets/fassets_resources/index.css | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/stylesheets/fassets_resources/index.css b/app/assets/stylesheets/fassets_resources/index.css index aa4d1d5..6ef6089 100644 --- a/app/assets/stylesheets/fassets_resources/index.css +++ b/app/assets/stylesheets/fassets_resources/index.css @@ -2,4 +2,5 @@ *= require fancybox *= require_self *= require fassets_core + *= require ./wikipedia */ From c01f0ea4d871a447848486f9e358c68cd762cd14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20B=C3=A4ume?= Date: Sun, 28 Oct 2012 20:39:16 +0100 Subject: [PATCH 05/11] require jquery-fileupload-rails There is now a gem for this thing, done by Tors Dalid. Thanks to him for creating it :) See [1](https://github.com/tors/jquery-fileupload-rails) for more information. --- Gemfile.lock | 4 ++++ fassets_resources.gemspec | 1 + 2 files changed, 5 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index c6a9b74..41911c7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,6 +6,7 @@ PATH fancybox-rails fassets_core (~> 0.3.1) haml + jquery-fileupload-rails jquery-rails mime-types mini_magick @@ -85,6 +86,9 @@ GEM haml (3.1.7) hike (1.2.1) i18n (0.6.1) + jquery-fileupload-rails (0.3.5) + actionpack (>= 3.1) + railties (>= 3.1) jquery-rails (2.1.3) railties (>= 3.1.0, < 5.0) thor (~> 0.14) diff --git a/fassets_resources.gemspec b/fassets_resources.gemspec index 23763a2..5531942 100644 --- a/fassets_resources.gemspec +++ b/fassets_resources.gemspec @@ -27,6 +27,7 @@ Gem::Specification.new do |s| s.add_dependency "streamio-ffmpeg" s.add_dependency "fancybox-rails" s.add_dependency "wikipedia-client" + s.add_dependency "jquery-fileupload-rails" s.add_development_dependency "devise" s.add_development_dependency "guard-rspec" From 12819f0268fb348a07449a80b1fc5d3c23f5d3cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20B=C3=A4ume?= Date: Mon, 29 Oct 2012 19:32:59 +0100 Subject: [PATCH 06/11] remove code related to jquery-fileupload Not needed any longer. File upload is horribly broken, so I throw out most things related and implement it more easy from scratch --- .../file_assets/_fileupload_widget.html.erb | 21 ---------- .../file_assets/_template-download.html.erb | 40 ------------------- .../file_assets/_template-upload.html.erb | 21 ---------- 3 files changed, 82 deletions(-) delete mode 100644 app/views/fassets_resources/file_assets/_fileupload_widget.html.erb delete mode 100644 app/views/fassets_resources/file_assets/_template-download.html.erb delete mode 100644 app/views/fassets_resources/file_assets/_template-upload.html.erb diff --git a/app/views/fassets_resources/file_assets/_fileupload_widget.html.erb b/app/views/fassets_resources/file_assets/_fileupload_widget.html.erb deleted file mode 100644 index 09cd08b..0000000 --- a/app/views/fassets_resources/file_assets/_fileupload_widget.html.erb +++ /dev/null @@ -1,21 +0,0 @@ - diff --git a/app/views/fassets_resources/file_assets/_template-download.html.erb b/app/views/fassets_resources/file_assets/_template-download.html.erb deleted file mode 100644 index 72adeef..0000000 --- a/app/views/fassets_resources/file_assets/_template-download.html.erb +++ /dev/null @@ -1,40 +0,0 @@ - diff --git a/app/views/fassets_resources/file_assets/_template-upload.html.erb b/app/views/fassets_resources/file_assets/_template-upload.html.erb deleted file mode 100644 index 1a97956..0000000 --- a/app/views/fassets_resources/file_assets/_template-upload.html.erb +++ /dev/null @@ -1,21 +0,0 @@ - \ No newline at end of file From 488af87ed69013d31c0a8636dfcfb1ec2efc67c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20B=C3=A4ume?= Date: Tue, 30 Oct 2012 00:32:00 +0100 Subject: [PATCH 07/11] simplify forms for different file assets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All this stuff isn’t needed, for now. May be it can be re-added, when we want to support mass-import of files. But I don’t see that feature right now. --- .../file_assets/_form.html.haml | 2 +- .../file_assets/_local_file_form.html.haml | 21 +++---------------- .../file_assets/_remote_file_form.html.haml | 15 +++---------- 3 files changed, 7 insertions(+), 31 deletions(-) diff --git a/app/views/fassets_resources/file_assets/_form.html.haml b/app/views/fassets_resources/file_assets/_form.html.haml index 9b9816f..2cc688b 100644 --- a/app/views/fassets_resources/file_assets/_form.html.haml +++ b/app/views/fassets_resources/file_assets/_form.html.haml @@ -1,5 +1,5 @@ - if controller.action_name == "new" - #file_asset_form + %p#file_asset_form = render :partial => FassetsResources::FileAssetsHelper::partial_for_type(@selected_type) - if controller.action_name == "edit" diff --git a/app/views/fassets_resources/file_assets/_local_file_form.html.haml b/app/views/fassets_resources/file_assets/_local_file_form.html.haml index 0861b71..6321aae 100644 --- a/app/views/fassets_resources/file_assets/_local_file_form.html.haml +++ b/app/views/fassets_resources/file_assets/_local_file_form.html.haml @@ -1,18 +1,3 @@ -#fileupload - =form_for :file_asset, :html => { :multipart => true } do |f| - .fileupload-buttonbar - %label.fileinput-button - %span - Add files... - =f.file_field :file - %br - %button{:type=>"submit",:class=>"start"}Start upload - %button{:type=>"reset",:class=>"cancel"}Cancel upload - %button{:type=>"button",:class=>"delete"}Delete files - .fileupload-content - %table{:class=>"files"} - .fileupload-progressbar - - =render :partial => "fassets_resources/file_assets/template-upload" - =render :partial => "fassets_resources/file_assets/template-download" - =render :partial => "fassets_resources/file_assets/fileupload_widget" +=fields_for :fassets_resources_file_asset do |f| + =f.label :file + =f.file_field :file diff --git a/app/views/fassets_resources/file_assets/_remote_file_form.html.haml b/app/views/fassets_resources/file_assets/_remote_file_form.html.haml index 59969b5..c65ccda 100644 --- a/app/views/fassets_resources/file_assets/_remote_file_form.html.haml +++ b/app/views/fassets_resources/file_assets/_remote_file_form.html.haml @@ -1,12 +1,3 @@ --content_for :h1 do - #type - =@content.class.to_s - #name - New - -#main.fassets_core - =fields_for "fassets_resources_file_asset" do |a| - %p - =a.label :remote_url, "Remote File Url:" - =a.text_field :remote_file_url - =submit_tag "Add", :class => "add_remote_file" +=fields_for "fassets_resources_file_asset" do |a| + =a.label :remote_url, "Remote File Url:" + =a.text_field :remote_file_url From b4f4d2e504886353c665b5aaee538c613dbae2bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20B=C3=A4ume?= Date: Mon, 12 Nov 2012 12:40:59 +0100 Subject: [PATCH 08/11] update fassets_core to 0.4.0 This brings some changes to make file-upload work much better because it uses rails form helpers instead of some self-hacked stuff. Should be a much better approach, now. --- Gemfile.lock | 8 ++++---- fassets_resources.gemspec | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 41911c7..9773e16 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,7 +4,7 @@ PATH fassets_resources (0.1.0) carrierwave fancybox-rails - fassets_core (~> 0.3.1) + fassets_core (~> 0.4.0) haml jquery-fileupload-rails jquery-rails @@ -64,7 +64,7 @@ GEM erubis (2.7.0) fancybox-rails (0.1.4) railties (>= 3.1.0) - fassets_core (0.3.1) + fassets_core (0.4.0) best_in_place fancybox-rails haml @@ -157,10 +157,10 @@ GEM sys-proctable (0.9.1) thor (0.14.6) tilt (1.3.3) - treetop (1.4.11) + treetop (1.4.12) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.34) + tzinfo (0.3.35) warden (1.0.5) rack (>= 1.0) wikipedia-client (1.0.0) diff --git a/fassets_resources.gemspec b/fassets_resources.gemspec index 5531942..de41ce8 100644 --- a/fassets_resources.gemspec +++ b/fassets_resources.gemspec @@ -17,7 +17,7 @@ Gem::Specification.new do |s| s.test_files = Dir["test/**/*"] s.add_dependency "rails", "~> 3.1.1" - s.add_dependency "fassets_core", "~> 0.3.1" + s.add_dependency "fassets_core", "~> 0.4.0" s.add_dependency "jquery-rails" s.add_dependency "haml" s.add_dependency "sqlite3" From 41c3a2c183670e002da31a754540c44e3bc68054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20B=C3=A4ume?= Date: Mon, 12 Nov 2012 12:45:20 +0100 Subject: [PATCH 09/11] work on (rails-)assets for file_assets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * remove jquery.fileupload stuff, this isn’t needed any longer * add some styling --- app/assets/javascripts/fassets_resources/index.js | 2 -- app/assets/stylesheets/fassets_resources/file_assets.css.scss | 3 +++ app/assets/stylesheets/fassets_resources/index.css | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 app/assets/stylesheets/fassets_resources/file_assets.css.scss diff --git a/app/assets/javascripts/fassets_resources/index.js b/app/assets/javascripts/fassets_resources/index.js index 565cb8a..a4e53fd 100644 --- a/app/assets/javascripts/fassets_resources/index.js +++ b/app/assets/javascripts/fassets_resources/index.js @@ -1,7 +1,5 @@ //= require fassets_core //= require flowplayer -//= require jquery.fileupload -//= require jquery.fileupload-ui //= require_self //= require ./add_asset_box //= require ./wikipedia_search diff --git a/app/assets/stylesheets/fassets_resources/file_assets.css.scss b/app/assets/stylesheets/fassets_resources/file_assets.css.scss new file mode 100644 index 0000000..66cd0ea --- /dev/null +++ b/app/assets/stylesheets/fassets_resources/file_assets.css.scss @@ -0,0 +1,3 @@ +#file_asset_form { + float: none; +} \ No newline at end of file diff --git a/app/assets/stylesheets/fassets_resources/index.css b/app/assets/stylesheets/fassets_resources/index.css index 6ef6089..25cf624 100644 --- a/app/assets/stylesheets/fassets_resources/index.css +++ b/app/assets/stylesheets/fassets_resources/index.css @@ -2,5 +2,6 @@ *= require fancybox *= require_self *= require fassets_core + *= require ./file_assets *= require ./wikipedia */ From 9aac54e902006d62fdf98580dc234f53e143712c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20B=C3=A4ume?= Date: Mon, 12 Nov 2012 12:47:50 +0100 Subject: [PATCH 10/11] remove jquery-fileupload-rail dependency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We should make it work without this, before integrating all this again. I don’t know if it’s worth the effort to keep this dependency. May be, plain file-upload just does the trick for us. --- Gemfile.lock | 4 ---- fassets_resources.gemspec | 1 - 2 files changed, 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 9773e16..fd3a4c1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,7 +6,6 @@ PATH fancybox-rails fassets_core (~> 0.4.0) haml - jquery-fileupload-rails jquery-rails mime-types mini_magick @@ -86,9 +85,6 @@ GEM haml (3.1.7) hike (1.2.1) i18n (0.6.1) - jquery-fileupload-rails (0.3.5) - actionpack (>= 3.1) - railties (>= 3.1) jquery-rails (2.1.3) railties (>= 3.1.0, < 5.0) thor (~> 0.14) diff --git a/fassets_resources.gemspec b/fassets_resources.gemspec index de41ce8..03d65ff 100644 --- a/fassets_resources.gemspec +++ b/fassets_resources.gemspec @@ -27,7 +27,6 @@ Gem::Specification.new do |s| s.add_dependency "streamio-ffmpeg" s.add_dependency "fancybox-rails" s.add_dependency "wikipedia-client" - s.add_dependency "jquery-fileupload-rails" s.add_development_dependency "devise" s.add_development_dependency "guard-rspec" From ffec797539de2607249636690e7ec9218d1e0b92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20B=C3=A4ume?= Date: Mon, 12 Nov 2012 17:08:59 +0100 Subject: [PATCH 11/11] fix usage of rails form_for form builder To allow the form builder code to add the multipart option to the form, the file input field must be created using the original form object. This propagates the form object into the local_file_form partial and makes use of it to create the field. Makes file upload finally work again. --- app/views/fassets_resources/file_assets/_form.html.haml | 2 +- .../fassets_resources/file_assets/_local_file_form.html.haml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/fassets_resources/file_assets/_form.html.haml b/app/views/fassets_resources/file_assets/_form.html.haml index 2cc688b..d7993cb 100644 --- a/app/views/fassets_resources/file_assets/_form.html.haml +++ b/app/views/fassets_resources/file_assets/_form.html.haml @@ -1,6 +1,6 @@ - if controller.action_name == "new" %p#file_asset_form - = render :partial => FassetsResources::FileAssetsHelper::partial_for_type(@selected_type) + = render :partial => FassetsResources::FileAssetsHelper::partial_for_type(@selected_type), :object => form - if controller.action_name == "edit" #edit_asset_content diff --git a/app/views/fassets_resources/file_assets/_local_file_form.html.haml b/app/views/fassets_resources/file_assets/_local_file_form.html.haml index 6321aae..aa24abd 100644 --- a/app/views/fassets_resources/file_assets/_local_file_form.html.haml +++ b/app/views/fassets_resources/file_assets/_local_file_form.html.haml @@ -1,3 +1,5 @@ +-local_file_form.multipart = true # set multipart for the form builder to true to allow file uploads + =fields_for :fassets_resources_file_asset do |f| =f.label :file =f.file_field :file