remotipart-1.2.1/0000755000004100000410000000000012250223214013722 5ustar www-datawww-dataremotipart-1.2.1/Rakefile0000644000004100000410000000351112250223214015367 0ustar www-datawww-datarequire 'rubygems' require 'rake' require File.expand_path('../lib/remotipart/rails/version', __FILE__) begin require 'jeweler' Jeweler::Tasks.new do |gem| gem.name = "remotipart" gem.summary = %Q{Remotipart is a Ruby on Rails gem enabling remote multipart forms (AJAX style file uploads) with jquery-rails.} gem.description = %Q{Remotipart is a Ruby on Rails gem enabling remote multipart forms (AJAX style file uploads) with jquery-rails. This gem augments the native Rails 3 jQuery-UJS remote form function enabling asynchronous file uploads with little to no modification to your application. } gem.email = %w{greg@formasfunction.com steve@alfajango.com} gem.homepage = "http://opensource.alfajango.com/remotipart/" gem.authors = ["Greg Leppert", "Steve Schwartz"] gem.version = Remotipart::Rails::VERSION # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings end Jeweler::RubygemsDotOrgTasks.new rescue LoadError puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler" end require 'rake/testtask' Rake::TestTask.new(:test) do |test| test.libs << 'lib' << 'test' test.pattern = 'test/**/test_*.rb' test.verbose = true end begin require 'rcov/rcovtask' Rcov::RcovTask.new do |test| test.libs << 'test' test.pattern = 'test/**/test_*.rb' test.verbose = true end rescue LoadError task :rcov do abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov" end end require 'rdoc/task' require File.expand_path('../lib/remotipart/rails/version', __FILE__) Rake::RDocTask.new do |rdoc| version = Remotipart::Rails::VERSION rdoc.rdoc_dir = 'rdoc' rdoc.title = "remotipart #{version}" rdoc.rdoc_files.include('README*') rdoc.rdoc_files.include('lib/**/*.rb') end remotipart-1.2.1/Gemfile.lock0000644000004100000410000000041312250223214016142 0ustar www-datawww-dataGEM remote: https://rubygems.org/ specs: git (1.2.5) jeweler (1.8.4) bundler (~> 1.0) git (>= 1.2.5) rake rdoc json (1.7.6) rake (10.0.3) rdoc (3.12) json (~> 1.4) PLATFORMS ruby DEPENDENCIES jeweler rake remotipart-1.2.1/Gemfile0000644000004100000410000000032112250223214015211 0ustar www-datawww-datasource 'https://rubygems.org' group :development do gem 'rake' gem 'jeweler' # This conflicts with jeweler gemspec generation, # causes dependencies to be added to gemspec recursively #gemspec end remotipart-1.2.1/History.rdoc0000644000004100000410000000641412250223214016241 0ustar www-datawww-data= History === 1.2.1 / 2013-07-07 * Added automatic authenticity_token detection and appending to iframe submission. === 1.2.0 / 2013-07-06 * Removed support for older jquery-ujs and jquery < 1.7. * Fixed json (and other type) parsing issues, only html_escape HTML responses. === 1.1.1 / 2013-07-05 * Fixed issue with GET params not being available in middleware. * Fixed issue with clicked submit button not being submitted via remotipart ajax. * Fixed issue with HTML not being escaped correctly. * Fixed issue with iframe-transport on jQuery 1.10.x. * Fixed compatibility issue with Rails 4. === 1.1.0 / 2013-07-04 * Updated to latest iframe-transport. * Added status-text to js response. === 1.0.5 / 2013-02-09 * Fixed gem dependency info. === 1.0.4 / 2013-02-09 * Fixed render override compatibility with other gems that override render (e.g. wicked_pdf) === 1.0.3 / 2013-02-08 * Fixed for jquery-rails v2.2.x (i.e. jQuery v1.9.x) === 1.0.2 / 2012-02-03 * Minor Enhancements * Fixed rendering when JS response contains `textarea` tag === 1.0.1 / 2011-11-27 * Minor Enhancements * Added support for non-post methods from Rails's `_method` hidden input. * Fixed IE form submit-bubbling support for jquery 1.7 === 1.0 / 2011-08-26 * New Features * New dependency on simpler jquery.iframe-transport.js (no more form.js) * New Rack middleware, making `remotipart_response` block obsolete in js.erb responses * Better support for all requested ajax data-types === 0.4.2 / 2011-08-26 * Minor Enhancements * Updated to jquery.form.js v2.84 === 0.4.1 / 2011-07-12 * Minor Enhancements * Updated README and docs === 0.4.0 / 2011-07-12 * New Features * Added `remotipart_submitted?` helper method for controllers and views * Added railtie and engine support to add remotipart and dependencies to Rails 3.0 (in the js :defaults) and 3.1 (in the asset pipeline) apps automatically * Enhancements * Restructured gem to integrate better with Rails apps === 0.3.0 / 2011-02-24 * New Features * Added support for all data-type ajax submissions, not just 'script'. * Made a little more flexible, so that separate js.erb response templates are no longer needed between remotipart (i.e. multipart) ajax form submissions and regular ajax form submissions, so multiple versions of the same form can now submit to the same action. === 0.2.1 / 2011-01-16 * Minor Enhancements * Added support for passing text_area_tag options to remotipart_response. {GitHub Issue #7}[https://github.com/formasfunction/remotipart/issues#issue/7] - patch by {Todd Eichel}[https://github.com/tfe] === 0.2.0 / 2010-12-08 * Bug Fixes * Added support for form action URLs that include GET params. {GitHub Issue #4}[https://github.com/formasfunction/remotipart/issues/closed#issue/4] - initial patch by ramontayag[https://github.com/ramontayag]. * Added proper HTML escaping for the remotipart_response textarea content. {GitHub Issue #5}[https://github.com/formasfunction/remotipart/issues/closed#issue/5] - patch by gucki[https://github.com/gucki]. === 0.1.1 / 2010-08-27 * Bug Fixes * Removed a call to the JS console. {GitHub Issue #1}[https://github.com/formasfunction/remotipart/issues/closed#issue/5] - reported by {Trevor Burnham}[https://github.com/TrevorBurnham]. === 0.1.0 / 2010-04-09 * Initial Release remotipart-1.2.1/vendor/0000755000004100000410000000000012250223214015217 5ustar www-datawww-dataremotipart-1.2.1/vendor/assets/0000755000004100000410000000000012250223214016521 5ustar www-datawww-dataremotipart-1.2.1/vendor/assets/javascripts/0000755000004100000410000000000012250223214021052 5ustar www-datawww-dataremotipart-1.2.1/vendor/assets/javascripts/jquery.iframe-transport.js0000644000004100000410000002345412250223214026233 0ustar www-datawww-data// This [jQuery](http://jquery.com/) plugin implements an `"); // The first load event gets fired after the iframe has been injected // into the DOM, and is used to prepare the actual submission. iframe.bind("load", function() { // The second load event gets fired when the response to the form // submission is received. The implementation detects whether the // actual payload is embedded in a `} response.content_type = Mime::HTML end response_body end end end remotipart-1.2.1/lib/remotipart/middleware.rb0000644000004100000410000000143212250223214021320 0ustar www-datawww-datamodule Remotipart # A middleware to look for our form parameters and # encourage Rails to respond with the requested format class Middleware def initialize app @app = app end def call env # Get request params params = Rack::Request.new(env).params if params # This was using an iframe transport, and is therefore an XHR # This is required if we're going to override the http_accept if params['X-Requested-With'] == 'IFrame' env['HTTP_X_REQUESTED_WITH'] = 'xmlhttprequest' end # Override the accepted format, because it isn't what we really want if params['X-Http-Accept'] env['HTTP_ACCEPT'] = params['X-Http-Accept'] end end @app.call(env) end end end remotipart-1.2.1/lib/remotipart/request_helper.rb0000644000004100000410000000031112250223214022225 0ustar www-datawww-datamodule Remotipart module RequestHelper def remotipart_submitted? params[:remotipart_submitted] ? true : false end alias :remotipart_requested? :remotipart_submitted? end end remotipart-1.2.1/lib/remotipart/rails/0000755000004100000410000000000012250223214017770 5ustar www-datawww-dataremotipart-1.2.1/lib/remotipart/rails/engine.rb0000644000004100000410000000113412250223214021561 0ustar www-datawww-data# Configure Rails 3.1 module Remotipart module Rails class Engine < ::Rails::Engine initializer "remotipart.view_helper" do ActionView::Base.send :include, RequestHelper ActionView::Base.send :include, ViewHelper end initializer "remotipart.controller_helper" do ActionController::Base.send :include, RequestHelper ActionController::Base.send :include, RenderOverrides end initializer "remotipart.include_middelware" do config.app_middleware.insert_after ActionDispatch::ParamsParser, Middleware end end end end remotipart-1.2.1/lib/remotipart/rails/version.rb0000644000004100000410000000015412250223214022002 0ustar www-datawww-datamodule Remotipart module Rails VERSION = "1.2.1" IFRAMETRANSPORT_VERSION = "02.06.2013" end end remotipart-1.2.1/lib/remotipart/rails/railtie.rb0000644000004100000410000000304612250223214021751 0ustar www-datawww-data# Configure Rails 3.0 to use form.js and remotipart module Remotipart module Rails class Railtie < ::Rails::Railtie config.before_configuration do # Files to be added to :defaults FILES = ['jquery.iframe-transport', 'jquery.remotipart'] # Figure out where rails.js (aka jquery_ujs.js if install by jquery-rails gem) is # in the :defaults array position = config.action_view.javascript_expansions[:defaults].index('rails') || config.action_view.javascript_expansions[:defaults].index('jquery_ujs') # Merge form.js and then remotipart into :defaults array right after rails.js if position && position > 0 config.action_view.javascript_expansions[:defaults].insert(position + 1, *FILES) # If rails.js couldn't be found, it may have a custom filename, or not be in the :defaults. # In that case, just try adding to the end of the :defaults array. else config.action_view.javascript_expansions[:defaults].push(*FILES) end end initializer "remotipart.view_helper" do ActionView::Base.send :include, RequestHelper ActionView::Base.send :include, ViewHelper end initializer "remotipart.controller_helper" do ActionController::Base.send :include, RequestHelper ActionController::Base.send :include, RenderOverrides end initializer "remotipart.include_middelware" do config.app_middleware.insert_after ActionDispatch::ParamsParser, Middleware end end end end remotipart-1.2.1/lib/remotipart/rails.rb0000644000004100000410000000033012250223214020311 0ustar www-datawww-datamodule Remotipart module Rails if ::Rails.version.to_s < "3.1" require 'remotipart/rails/railtie' else require 'remotipart/rails/engine' end require 'remotipart/rails/version' end end remotipart-1.2.1/lib/remotipart.rb0000644000004100000410000000027112250223214017203 0ustar www-datawww-datarequire 'remotipart/view_helper' require 'remotipart/request_helper' require 'remotipart/render_overrides' require 'remotipart/middleware' require 'remotipart/rails' if defined?(Rails) remotipart-1.2.1/lib/generators/0000755000004100000410000000000012250223214016641 5ustar www-datawww-dataremotipart-1.2.1/lib/generators/remotipart/0000755000004100000410000000000012250223214021027 5ustar www-datawww-dataremotipart-1.2.1/lib/generators/remotipart/install/0000755000004100000410000000000012250223214022475 5ustar www-datawww-dataremotipart-1.2.1/lib/generators/remotipart/install/install_generator.rb0000644000004100000410000000146412250223214026543 0ustar www-datawww-datarequire 'rails' module Remotipart module Generators class InstallGenerator < ::Rails::Generators::Base desc "This generator installs IframeTransport.js #{Remotipart::Rails::IFRAMETRANSPORT_VERSION} and Remotipart #{Remotipart::Rails::VERSION}" source_root File.expand_path('../../../../../vendor/assets/javascripts', __FILE__) def install_iframe_transport say_status "copying", "IframeTransport.js #{Remotipart::Rails::IFRAMETRANSPORT_VERSION}", :green copy_file "jquery.iframe-transport.js", "public/javascripts/jquery.iframe-transport.js" end def install_remotipart say_status "copying", "Remotipart.js #{Remotipart::Rails::VERSION}", :green copy_file 'jquery.remotipart.js', 'public/javascripts/jquery.remotipart.js' end end end end remotipart-1.2.1/metadata.yml0000644000004100000410000000506012250223214016226 0ustar www-datawww-data--- !ruby/object:Gem::Specification name: remotipart version: !ruby/object:Gem::Version version: 1.2.1 prerelease: platform: ruby authors: - Greg Leppert - Steve Schwartz autorequire: bindir: bin cert_chain: [] date: 2013-07-08 00:00:00.000000000Z dependencies: - !ruby/object:Gem::Dependency name: rake requirement: &70170920954340 !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: *70170920954340 - !ruby/object:Gem::Dependency name: jeweler requirement: &70170920953080 !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: *70170920953080 description: ! "Remotipart is a Ruby on Rails gem enabling remote multipart forms (AJAX style file uploads) with jquery-rails.\n This gem augments the native Rails 3 jQuery-UJS remote form function enabling asynchronous file uploads with little to no modification to your application.\n " email: - greg@formasfunction.com - steve@alfajango.com executables: [] extensions: [] extra_rdoc_files: - LICENSE - README.rdoc files: - .document - CONTRIBUTING.md - Gemfile - Gemfile.lock - History.rdoc - LICENSE - README.rdoc - Rakefile - VERSION_COMPATIBILITY.rdoc - lib/generators/remotipart/install/install_generator.rb - lib/remotipart.rb - lib/remotipart/middleware.rb - lib/remotipart/rails.rb - lib/remotipart/rails/engine.rb - lib/remotipart/rails/railtie.rb - lib/remotipart/rails/version.rb - lib/remotipart/render_overrides.rb - lib/remotipart/request_helper.rb - lib/remotipart/view_helper.rb - remotipart.gemspec - vendor/assets/javascripts/jquery.iframe-transport.js - vendor/assets/javascripts/jquery.remotipart.js homepage: http://opensource.alfajango.com/remotipart/ licenses: [] post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' segments: - 0 hash: -3061483236240277448 required_rubygems_version: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: rubygems_version: 1.8.15 signing_key: specification_version: 3 summary: Remotipart is a Ruby on Rails gem enabling remote multipart forms (AJAX style file uploads) with jquery-rails. test_files: [] remotipart-1.2.1/remotipart.gemspec0000644000004100000410000000434512250223214017463 0ustar www-datawww-data# Generated by jeweler # DO NOT EDIT THIS FILE DIRECTLY # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = "remotipart" s.version = "1.2.1" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Greg Leppert", "Steve Schwartz"] s.date = "2013-07-08" s.description = "Remotipart is a Ruby on Rails gem enabling remote multipart forms (AJAX style file uploads) with jquery-rails.\n This gem augments the native Rails 3 jQuery-UJS remote form function enabling asynchronous file uploads with little to no modification to your application.\n " s.email = ["greg@formasfunction.com", "steve@alfajango.com"] s.extra_rdoc_files = [ "LICENSE", "README.rdoc" ] s.files = [ ".document", "CONTRIBUTING.md", "Gemfile", "Gemfile.lock", "History.rdoc", "LICENSE", "README.rdoc", "Rakefile", "VERSION_COMPATIBILITY.rdoc", "lib/generators/remotipart/install/install_generator.rb", "lib/remotipart.rb", "lib/remotipart/middleware.rb", "lib/remotipart/rails.rb", "lib/remotipart/rails/engine.rb", "lib/remotipart/rails/railtie.rb", "lib/remotipart/rails/version.rb", "lib/remotipart/render_overrides.rb", "lib/remotipart/request_helper.rb", "lib/remotipart/view_helper.rb", "remotipart.gemspec", "vendor/assets/javascripts/jquery.iframe-transport.js", "vendor/assets/javascripts/jquery.remotipart.js" ] s.homepage = "http://opensource.alfajango.com/remotipart/" s.require_paths = ["lib"] s.rubygems_version = "1.8.15" s.summary = "Remotipart is a Ruby on Rails gem enabling remote multipart forms (AJAX style file uploads) with jquery-rails." if s.respond_to? :specification_version then s.specification_version = 3 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then s.add_development_dependency(%q, [">= 0"]) s.add_development_dependency(%q, [">= 0"]) else s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) end else s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) end end remotipart-1.2.1/CONTRIBUTING.md0000644000004100000410000000332512250223214016156 0ustar www-datawww-data## Note on Patches/Pull Requests * Fork the project. * Make your feature addition or bug fix. * Add tests for it. This is important so I don't break it in a future version unintentionally. * Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull) * Send me a pull request. Bonus points for topic branches. ## Tests Because of the nature of AJAX file uploads and certain browser restrictions, we could not simply create unit tests (using qunit or jasmine) to test the file upload functionality of remotipart (since the browsers running those test suites won't allow us to set the target of a file upload input using javascript). So, instead we created a demo Rails app using remotipart with all remotipart functionality tested using RSpec and Capybara. * [Demo Rails App with Tests](https://github.com/JangoSteve/Rails-jQuery-Demo/tree/remotipart) * [Tests](https://github.com/JangoSteve/Rails-jQuery-Demo/blob/remotipart/spec/features/comments_spec.rb) To run tests: Clone the remotipart branch of the demo app ``` git clone -b remotipart git://github.com/JangoSteve/Rails-jQuery-Demo.git ``` Install the dependencies ``` bundle install ``` Run the tests ``` bundle exec rspec spec/ ``` If you need to test your own changes to remotipart, just update the Gemfile with your own fork/branch of remotipart: ``` gem 'remotipart', :git => 'git://github.com/MY_FORK/remotipart.git', :branch => 'MY_BRANCH' ``` To save time, you can also just bundle remotipart from your current local machine / filesystem without having to commit your changes or push them remotely: ``` gem 'remotipart', :path => '../remotipart' ``` remotipart-1.2.1/LICENSE0000644000004100000410000000204012250223214014723 0ustar www-datawww-dataCopyright (c) 2009 Greg Leppert Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. remotipart-1.2.1/.document0000644000004100000410000000007412250223214015542 0ustar www-datawww-dataREADME.rdoc lib/**/*.rb bin/* features/**/*.feature LICENSE