remotipart-1.4.4/0000755000004100000410000000000013641335712013743 5ustar www-datawww-dataremotipart-1.4.4/.travis.yml0000644000004100000410000000130213641335712016050 0ustar www-datawww-datalanguage: ruby before_install: # https://github.com/danmayer/coverband/issues/162#issuecomment-452173268 - rm /home/travis/.rvm/gems/*/specifications/bundler-2.*.gemspec || true - gem install bundler -v '<2' bundler_args: --without development --jobs=3 --retry=3 --path=../vendor/bundle cache: bundler env: matrix: - JQUERY_VERSION= rvm: - 2.5.5 gemfile: - gemfiles/rails_3.2.gemfile - gemfiles/rails_4.2.gemfile - gemfiles/rails_5.2.gemfile - gemfiles/rails_6.0.gemfile dist: trusty sudo: false matrix: include: - env: JQUERY_VERSION=2 gemfile: gemfiles/rails_6.0.gemfile - env: JQUERY_VERSION=3 gemfile: gemfiles/rails_6.0.gemfile fast_finish: true remotipart-1.4.4/remotipart.gemspec0000644000004100000410000001377313641335712017511 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 -*- # stub: remotipart 1.4.4 ruby lib Gem::Specification.new do |s| s.name = "remotipart".freeze s.version = "1.4.4" s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= s.require_paths = ["lib".freeze] s.authors = ["Greg Leppert".freeze, "Steve Schwartz".freeze] s.date = "2019-12-29" 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 ".freeze s.email = ["greg@formasfunction.com".freeze, "steve@alfajango.com".freeze] s.extra_rdoc_files = [ "LICENSE", "README.rdoc" ] s.files = [ ".document", ".travis.yml", "Appraisals", "CONTRIBUTING.md", "Gemfile", "History.rdoc", "LICENSE", "README.rdoc", "Rakefile", "VERSION_COMPATIBILITY.rdoc", "gemfiles/rails_3.2.gemfile", "gemfiles/rails_4.2.gemfile", "gemfiles/rails_5.2.gemfile", "gemfiles/rails_6.0.gemfile", "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", "spec/dummy_app/.gitignore", "spec/dummy_app/Rakefile", "spec/dummy_app/app/assets/config/manifest.js", "spec/dummy_app/app/assets/images/rails.png", "spec/dummy_app/app/assets/javascripts/application.js.erb", "spec/dummy_app/app/assets/javascripts/comments.js", "spec/dummy_app/app/assets/stylesheets/application.css", "spec/dummy_app/app/assets/stylesheets/scaffold.css", "spec/dummy_app/app/controllers/application_controller.rb", "spec/dummy_app/app/controllers/comments_controller.rb", "spec/dummy_app/app/controllers/prepended_controller.rb", "spec/dummy_app/app/helpers/application_helper.rb", "spec/dummy_app/app/helpers/comments_helper.rb", "spec/dummy_app/app/models/comment.rb", "spec/dummy_app/app/views/comments/_comment.html.erb", "spec/dummy_app/app/views/comments/_form.html.erb", "spec/dummy_app/app/views/comments/_new_comment_links.html.erb", "spec/dummy_app/app/views/comments/create.html.erb", "spec/dummy_app/app/views/comments/create.js.erb", "spec/dummy_app/app/views/comments/destroy.js.erb", "spec/dummy_app/app/views/comments/edit.html.erb", "spec/dummy_app/app/views/comments/escape_test.html.erb", "spec/dummy_app/app/views/comments/index.html.erb", "spec/dummy_app/app/views/comments/new.html.erb", "spec/dummy_app/app/views/comments/show.html.erb", "spec/dummy_app/app/views/layouts/application.html.erb", "spec/dummy_app/app/views/prepended/show.html.erb", "spec/dummy_app/bin/bundle", "spec/dummy_app/bin/rails", "spec/dummy_app/bin/rake", "spec/dummy_app/bin/setup", "spec/dummy_app/bin/update", "spec/dummy_app/config.ru", "spec/dummy_app/config/application.rb", "spec/dummy_app/config/boot.rb", "spec/dummy_app/config/database.yml", "spec/dummy_app/config/environment.rb", "spec/dummy_app/config/environments/development.rb", "spec/dummy_app/config/environments/test.rb", "spec/dummy_app/config/initializers/secret_token.rb", "spec/dummy_app/config/routes.rb", "spec/dummy_app/config/secrets.yml", "spec/dummy_app/db/migrate/20110209210252_create_comments.rb", "spec/dummy_app/db/migrate/20110209210315_add_attachment_to_comment.rb", "spec/dummy_app/db/migrate/20110714205346_add_other_attachment_to_comment.rb", "spec/dummy_app/db/schema.rb", "spec/dummy_app/db/seeds.rb", "spec/features/comments_spec.rb", "spec/features/prepended_spec.rb", "spec/fixtures/hi.txt", "spec/fixtures/qr.jpg", "spec/spec_helper.rb", "spec/support/arel_helper.rb", "spec/support/connection_helper.rb", "spec/support/integration_helper.rb", "vendor/assets/javascripts/jquery.iframe-transport.js", "vendor/assets/javascripts/jquery.remotipart.js" ] s.homepage = "http://opensource.alfajango.com/remotipart/".freeze s.rubygems_version = "3.0.3".freeze s.summary = "Remotipart is a Ruby on Rails gem enabling remote multipart forms (AJAX style file uploads) with jquery-rails.".freeze if s.respond_to? :specification_version then s.specification_version = 4 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then s.add_development_dependency(%q.freeze, [">= 0"]) s.add_development_dependency(%q.freeze, [">= 0"]) s.add_development_dependency(%q.freeze, [">= 0"]) s.add_development_dependency(%q.freeze, [">= 0"]) s.add_development_dependency(%q.freeze, [">= 0"]) s.add_development_dependency(%q.freeze, [">= 0"]) s.add_development_dependency(%q.freeze, [">= 0"]) else s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) end else s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) s.add_dependency(%q.freeze, [">= 0"]) end end remotipart-1.4.4/gemfiles/0000755000004100000410000000000013641335712015536 5ustar www-datawww-dataremotipart-1.4.4/gemfiles/rails_6.0.gemfile0000644000004100000410000000057313641335712020572 0ustar www-datawww-data# This file was generated by Appraisal source "https://rubygems.org" gem "rails", "~> 6.0.0.rc1" group :development do gem "rake" gem "jeweler" end group :development, :test do gem "appraisal" gem "jquery-rails" gem "sqlite3" gem "paperclip" gem "remotipart", path: "../" end group :test do gem "database_cleaner" gem "poltergeist" gem "rspec-rails" end remotipart-1.4.4/gemfiles/rails_3.2.gemfile0000644000004100000410000000066513641335712020573 0ustar www-datawww-data# This file was generated by Appraisal source "https://rubygems.org" gem "rails", "~> 3.2.0" gem "test-unit", "~> 3.0" gem "strong_parameters" group :development do gem "rake" gem "jeweler" end group :development, :test do gem "appraisal" gem "jquery-rails" gem "sqlite3", "~> 1.3.5" gem "paperclip" gem "remotipart", path: "../" end group :test do gem "database_cleaner" gem "poltergeist" gem "rspec-rails" end remotipart-1.4.4/gemfiles/rails_5.2.gemfile0000644000004100000410000000056713641335712020576 0ustar www-datawww-data# This file was generated by Appraisal source "https://rubygems.org" gem "rails", "~> 5.2.0" group :development do gem "rake" gem "jeweler" end group :development, :test do gem "appraisal" gem "jquery-rails" gem "sqlite3" gem "paperclip" gem "remotipart", path: "../" end group :test do gem "database_cleaner" gem "poltergeist" gem "rspec-rails" end remotipart-1.4.4/gemfiles/rails_4.2.gemfile0000644000004100000410000000060313641335712020564 0ustar www-datawww-data# This file was generated by Appraisal source "https://rubygems.org" gem "rails", "~> 4.2.0" group :development do gem "rake" gem "jeweler" end group :development, :test do gem "appraisal" gem "jquery-rails" gem "sqlite3", "~> 1.3.6" gem "paperclip" gem "remotipart", path: "../" end group :test do gem "database_cleaner" gem "poltergeist" gem "rspec-rails" end remotipart-1.4.4/spec/0000755000004100000410000000000013641335712014675 5ustar www-datawww-dataremotipart-1.4.4/spec/fixtures/0000755000004100000410000000000013641335712016546 5ustar www-datawww-dataremotipart-1.4.4/spec/fixtures/hi.txt0000644000004100000410000000004013641335712017701 0ustar www-datawww-dataSmile, you're on candid camera! remotipart-1.4.4/spec/fixtures/qr.jpg0000644000004100000410000000071613641335712017676 0ustar www-datawww-dataPNG  IHDRtt PPLTEU~IDATxQ EQ %;pmBZQEÁ'(ꗺ\5_hpO׬|x<~DͿ7Я+rjSVi<k˪!^tmOyxǡ\Uu@ֆ/Gޔ:<=.eV>pbSǧWJG >x|NDs\sa{JeƲ餍o~\Tw!㛿5% ZuzW o;Gx+lv:J=7_Ѧj[| je#;_yk˽i2HˤER}W/ TrgIENDB`remotipart-1.4.4/spec/dummy_app/0000755000004100000410000000000013641335712016670 5ustar www-datawww-dataremotipart-1.4.4/spec/dummy_app/config.ru0000644000004100000410000000023513641335712020505 0ustar www-datawww-data# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run DummyApp::Application remotipart-1.4.4/spec/dummy_app/bin/0000755000004100000410000000000013641335712017440 5ustar www-datawww-dataremotipart-1.4.4/spec/dummy_app/bin/bundle0000755000004100000410000000020113641335712020630 0ustar www-datawww-data#!/usr/bin/env ruby ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) load Gem.bin_path('bundler', 'bundle') remotipart-1.4.4/spec/dummy_app/bin/update0000755000004100000410000000141413641335712020650 0ustar www-datawww-data#!/usr/bin/env ruby require 'pathname' require 'fileutils' include FileUtils # path to your application root. APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") end chdir APP_ROOT do # This script is a way to update your development environment automatically. # Add necessary update steps to this file. puts '== Installing dependencies ==' system! 'gem install bundler --conservative' system 'bundle check' or system! 'bundle install' puts "\n== Updating database ==" system! 'bin/rails db:migrate' puts "\n== Removing old logs and tempfiles ==" system! 'bin/rails log:clear tmp:clear' puts "\n== Restarting application server ==" system! 'bin/rails restart' end remotipart-1.4.4/spec/dummy_app/bin/rails0000755000004100000410000000022113641335712020473 0ustar www-datawww-data#!/usr/bin/env ruby APP_PATH = File.expand_path('../../config/application', __FILE__) require_relative '../config/boot' require 'rails/commands' remotipart-1.4.4/spec/dummy_app/bin/setup0000755000004100000410000000163013641335712020526 0ustar www-datawww-data#!/usr/bin/env ruby require 'pathname' require 'fileutils' include FileUtils # path to your application root. APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") end chdir APP_ROOT do # This script is a starting point to setup your application. # Add necessary setup steps to this file. puts '== Installing dependencies ==' system! 'gem install bundler --conservative' system('bundle check') or system!('bundle install') # puts "\n== Copying sample files ==" # unless File.exist?('config/database.yml') # cp 'config/database.yml.sample', 'config/database.yml' # end puts "\n== Preparing database ==" system! 'bin/rails db:setup' puts "\n== Removing old logs and tempfiles ==" system! 'bin/rails log:clear tmp:clear' puts "\n== Restarting application server ==" system! 'bin/rails restart' end remotipart-1.4.4/spec/dummy_app/bin/rake0000755000004100000410000000013213641335712020304 0ustar www-datawww-data#!/usr/bin/env ruby require_relative '../config/boot' require 'rake' Rake.application.run remotipart-1.4.4/spec/dummy_app/.gitignore0000644000004100000410000000067613641335712020671 0ustar www-datawww-data# See http://help.github.com/ignore-files/ for more about ignoring files. # # If you find yourself ignoring temporary files generated by your text editor # or operating system, you probably want to add a global ignore instead: # git config --global core.excludesfile ~/.gitignore_global # Ignore bundler config /.bundle # Ignore the default SQLite database. /db/*.sqlite3 # Ignore all logfiles and tempfiles. /log/*.log /tmp /public/system remotipart-1.4.4/spec/dummy_app/app/0000755000004100000410000000000013641335712017450 5ustar www-datawww-dataremotipart-1.4.4/spec/dummy_app/app/helpers/0000755000004100000410000000000013641335712021112 5ustar www-datawww-dataremotipart-1.4.4/spec/dummy_app/app/helpers/application_helper.rb0000644000004100000410000000003513641335712025277 0ustar www-datawww-datamodule ApplicationHelper end remotipart-1.4.4/spec/dummy_app/app/helpers/comments_helper.rb0000644000004100000410000000003213641335712024616 0ustar www-datawww-datamodule CommentsHelper end remotipart-1.4.4/spec/dummy_app/app/controllers/0000755000004100000410000000000013641335712022016 5ustar www-datawww-dataremotipart-1.4.4/spec/dummy_app/app/controllers/comments_controller.rb0000644000004100000410000000324213641335712026434 0ustar www-datawww-dataclass CommentsController < ApplicationController def index @comments = Comment.all respond_to do |format| format.html format.json { render json: @comments } end end def show @comment = Comment.find(params[:id]) respond_to do |format| format.html format.json { render json: @comment } end end def new @comment = Comment.new respond_to do |format| format.html { render :layout => ! request.xhr? } end end def edit @comment = Comment.find(params[:id]) respond_to do |format| format.html format.json { render json: @comment } end end def create @comment = Comment.create(comment_params) if request.xhr? || remotipart_submitted? sleep 1 if params[:pause] respond_to do |format| format.html { render (params[:template] == 'escape' ? 'comments/escape_test' : 'comments/create'), layout: false } format.js { render 'comments/create', layout: false, status:(@comment.errors.any? ? :unprocessable_entity : :ok) } format.json { render json: @comment } end else redirect_to comments_path end end def update @comment = Comment.find(params[:id]) respond_to do |format| format.html { redirect_to @comment } format.js { render json: @comment } end end def destroy @comment = Comment.destroy(params[:id]) end def say if Rails.version < '4' render text: params[:message], content_type: 'text/plain' else render plain: params[:message] end end private def comment_params params.require(:comment).permit(:subject, :body, :attachment, :other_attachment) end end remotipart-1.4.4/spec/dummy_app/app/controllers/prepended_controller.rb0000644000004100000410000000031313641335712026551 0ustar www-datawww-dataclass PrependedController < ApplicationController # order matters, only prepend then include causes the issue prepend Module.new include Remotipart::RenderOverrides def show render end endremotipart-1.4.4/spec/dummy_app/app/controllers/application_controller.rb0000644000004100000410000000012013641335712027102 0ustar www-datawww-dataclass ApplicationController < ActionController::Base protect_from_forgery end remotipart-1.4.4/spec/dummy_app/app/models/0000755000004100000410000000000013641335712020733 5ustar www-datawww-dataremotipart-1.4.4/spec/dummy_app/app/models/comment.rb0000644000004100000410000000050713641335712022724 0ustar www-datawww-dataclass Comment < ActiveRecord::Base has_attached_file :attachment has_attached_file :other_attachment validates :subject, :body, :presence => true validates_attachment :attachment, content_type: { content_type: /\Aimage\/.*\Z/ } validates_attachment :other_attachment, content_type: { content_type: 'text/plain' } end remotipart-1.4.4/spec/dummy_app/app/assets/0000755000004100000410000000000013641335712020752 5ustar www-datawww-dataremotipart-1.4.4/spec/dummy_app/app/assets/javascripts/0000755000004100000410000000000013641335712023303 5ustar www-datawww-dataremotipart-1.4.4/spec/dummy_app/app/assets/javascripts/application.js.erb0000644000004100000410000000047013641335712026714 0ustar www-datawww-data// FIXME: Tell people that this is a manifest file, real code should go into discrete files // FIXME: Tell people how Sprockets and CoffeeScript works // <% require_asset "jquery#{ENV['JQUERY_VERSION']}" %> <% require_asset "jquery_ujs" %> <% require_asset "jquery.remotipart" %> <% require_asset "comments" %> remotipart-1.4.4/spec/dummy_app/app/assets/javascripts/comments.js0000644000004100000410000000206513641335712025471 0ustar www-datawww-data$(document) .delegate('#new-comment-link, #new-comment-attachment-link', 'ajax:success', function(e, data, status, xhr){ var $this = $(this), $container = $('#new-comment-links'), $responseText = $(xhr.responseText), $cancelButton = $responseText.find('#cancel-button'); $container.replaceWith($responseText) $cancelButton.click(function(e){ $cancelButton.parent().replaceWith($container); e.preventDefault(); }); }) .delegate('form[data-remote]', 'ajax:aborted:required', function(){ var $form = $(this), errorDivId = 'ajax-validation-errors', $errorDiv = $form.find('#' + errorDivId); if ( ! $errorDiv.length ) { $errorDiv = $('
', { id: errorDivId}); $form.prepend($errorDiv) } $errorDiv.html($('

', { text: 'You must fill in all required fields!' })); }) .delegate('form[data-remote]', 'ajax:error', function(e, xhr, status, statusText) { $('#comments').after('Error status code: ' + xhr.status + ', Error status message: ' + statusText); }); remotipart-1.4.4/spec/dummy_app/app/assets/images/0000755000004100000410000000000013641335712022217 5ustar www-datawww-dataremotipart-1.4.4/spec/dummy_app/app/assets/images/rails.png0000644000004100000410000001476613641335712024055 0ustar www-datawww-dataPNG  IHDR2@X${tEXtSoftwareAdobe ImageReadyqe<IDATxڬ[ \eR֮^;Iwga@`gGgDgtqDFqFDqF@NRU]˫|_-Qy^Ǹ.݋0W_6kbf̻ܸ6<4 w5~*r?9m&"M7@vm' {_S)Vi\WG?իjMd@ lDLX鸺W-TU+@EPo\&*Rnn, fDWrX|3M=\EJB[d6A'=tx^$a86̈{, ϱPepN*_W_3o;ޥ(0E:i6eXnhGf"L|S+(+.gФg=Ych=m#V_#}Ǫ|tR D8VՄM~xg!ni%Dy( B,{(Np$3iر$h.@e[a'eJԂyϠ4>H*MHQ(Jgt-֢QI ^d„@s-'- 51{'0 |n4ۉh{V@ܩw"BT =rzqPpBHȃ?ň ]-qpgsPiSӪg`jn)m 御B2L.x!jJP! K/\ ʮRB[09Trӈu. uH$ DDQ+:ݘٻ 3/nލ%Sjm2!&D/[EHwW A-RR!PeuHim"t6lFgЫ-O.1?ƞksX~VtmZJR11Nu&<⽩,Tb,`w WPx-G5 `մ/5pbAtIVJ_]0/DiH=ô#*77-3 VuQ0.pݔ%yw hљW0),2$b6&I/@bj$I(fx' JnO"`<-/LѮ%^ȫͶn2wҗ2}}XսL'Q-,m/ꤋ4#0Q&00NKrsA,Aײ)aIEC(ERK{8Ȭ[y?iI5$%f{}u F 1~;v1l'@F 'IF'm!K7"&]w 15#4Vižn[v 8Ě)>C=LBo~/3% wF4֓ʿ8>bWX@bb@IzP9IvFfQL!2cEP(se4~5RhAŽ90_? cMEteVOaOr B]pȱؓ"Eyx: NJ)bl׋hYuTdԫw=آMgwVPOFΒ25-TD[Z2>]V,xӛIOƅ)Jͺ[)?cn28p#(mk+./phʮQ6?w7HIoSj)1<#-N9O1ͰސkIKr:(ŗ;rR&<93v@w(w:~:TFSޒ" ՊTdT9PIb3JzTQׄBP23ƵW*|@^)Qw?Iq =,<@ B8);50H-=T SA@@f5r[T%#c|Z&w(B)tDQ%vyC(,Ɵ|ʰi&<#u:3EHkzд)ndF>1V2kFGYL KMQlR&TB,igv8]C8Sf#ą4Q'?,= aV9WEXYrr*!cƯ~),=yџ]jlGeE̺5r_2Ԏ}d"a]0M9PZG17nE"Rr\YQ)!|5U(d=^ŗo8+2NU6jB[B5V.]ŲW/^䩬 ;Y"Vi$2ٲ_c(F^Egq{CP/ #K8Y+Q M1>ܞAߏ,gytޕn,zE$V.v.PyLapG9Tn:uiRZ! zI0?Џ1u#$6ɱGMhFdtd|~d\O9Ij**zD؍b)PBҽh-q ql%/{Gz*d7=QS]:RQbUMPᒯ$% du] XefQz$('ИZH#ARXDB ~`0.F|XXK)wFolzyhߚKz>.&n EjU,2' &iw[d[ V)*Qavl QDit[VIQhR@$)y~m|>?cJ+VH'6? 7 i.XH8Fި)dAYUBjE".4w-?l2Y.RjWD@Bج.߆s[H-gASF3Fj]آBP떬_>M%bt ?_rլ -h]r_ž[nȶQ+Gԭ_\Ê Z٦fet(|U('.g VFEN9}Ll4T&nto¨Ӓ X F "_fYzF~y& Gu]$O[v#].@$VA`ⱧTѰZ[2u+/mUC_ TnyѠ |l\ M"G[R$d|:ěFIire"ٵt,+ی1Z11udt*K2 sd; [)xW.z2jTh#DV\NO &e_vU2B^%0FH(/ԘI2>=L]dv UUpk"ijB$,O-0y<}~*T5LErE4B߳XXN:<9>Ed -V*uBLsN**JxRU辖,T( Gu @ůY{u|CJF(OLbnմiKhpFtx8#9FsFڋDTAn1veF^M ^kf.ĆݠVʓǰ3JaY@n&jLl:McӚ…vu?9w!/~#hM ڛ ̴nMA}m W,)(î.N y%$*={P9c DzH>Blu޾K78x->V,'JU \L]l>W*r-hXf~oI Z3f玱>vN3 uZTgg}Վ363:.g /-H+"PKۉSZ4Z_GlXMc7";ҿ (5fMUCOF6 CNft>$S1VaR&4) ٗay]%W A*|gX{Qc>iTX1F M`|![$P4ʊ$#,dɌ(?KTJR۸S%C7jHb浃j+N$,[.@˹_ ?.3ĵH"U$Z^ X02!Kc 8q.NMI6N&3n8exoWfPIJB<pREAdo$*m)e9D 5X[T$LΠ:]C$n#mC[P~Yt*d?\q^WXs!E-2#_mw8;2!vw:DUn$)GiGn3_o EZE3k-EHv.OûzE>"֛}l\/-nرQHԽab*#K׋eIƳd#G et\ ,:MێÜIC}m ٽO?eb%ːٰStB|Aznaz*FlQ/K uu*1wDvE֯SJTK;(4kƣ;v2P9`k{?~_[hʢ^9фǡ;m|]o9<#jz\wD,8V]]%K9er懇0n^FcI>`Ub+kօO1|NO]t+,Ȑl_ˮ6 ĒDbrz^pe7^[aþo確jN+xsNC߅wμ7|za2, omrbZ~,pN>;?Y,z[u◿jq 4aqڶNu6Zid@h!!F9#,#UrOa0=Då ,,,bE#ȮX3ªޏ=a< =&_~ ٵѽacj񫒆LsXuXB (wzEk_QIف*4'ѣSl{.,p۵2`jp^؇nZXPź^]wމ]aQ-oI5O3a] _wb ŭL]$"|sԩȬ= VсLIUbYY搮͢I$tf$2|r;~'GSXkᇦԭF4b4 xo[,04F~<}ۭR%myb׾\mlO.4}tE\7}M)tՉ13xF [-26t䢄&E"9;ٜrq e)K!:bwY }g;Jר)5D$!Kɤ9߫-K$$ hlDUFF J{s2R6rC&&0;@>]/Z3E,k;( 2^09 <%= comment.subject %> <%= comment.body %> <%= link_to comment.attachment_file_name, comment.attachment.url if comment.attachment? %> <%= link_to comment.other_attachment_file_name, comment.other_attachment.url if comment.other_attachment? %> <%= link_to 'Show', comment %> <%= link_to 'Edit', edit_comment_path(comment) %> <%= link_to 'Destroy', comment, :data => {:confirm => 'Are you sure?'}, :method => :delete, :remote => true %> remotipart-1.4.4/spec/dummy_app/app/views/comments/_new_comment_links.html.erb0000644000004100000410000000050713641335712027743 0ustar www-datawww-data remotipart-1.4.4/spec/dummy_app/app/views/comments/new.html.erb0000644000004100000410000000024213641335712024656 0ustar www-datawww-data

New comment

<%= render 'form' %> <%= link_to 'Cancel', comments_path, :id => 'cancel-button' %>
remotipart-1.4.4/spec/dummy_app/app/views/comments/create.html.erb0000644000004100000410000000010713641335712025330 0ustar www-datawww-data HTML response: <%= render @comment %>
remotipart-1.4.4/spec/dummy_app/app/views/comments/escape_test.html.erb0000644000004100000410000000004213641335712026362 0ustar www-datawww-data<%= text_field_tag :quote, '"' %> remotipart-1.4.4/spec/dummy_app/app/views/comments/index.html.erb0000644000004100000410000000042613641335712025200 0ustar www-datawww-data

Listing comments

<%= render @comments %>
Subject Body Attachment Other Attachment

<%= render 'new_comment_links' %> remotipart-1.4.4/spec/dummy_app/app/views/comments/show.html.erb0000644000004100000410000000032013641335712025042 0ustar www-datawww-data <%= render @comment %>
Subject Body Attachment

<%= link_to 'Back', comments_path %> remotipart-1.4.4/spec/dummy_app/app/views/comments/destroy.js.erb0000644000004100000410000000005313641335712025226 0ustar www-datawww-data$('#comment-<%= @comment.id %>').remove(); remotipart-1.4.4/spec/dummy_app/app/views/comments/create.js.erb0000644000004100000410000000131213641335712024777 0ustar www-datawww-data<%= remotipart_response do %> <% unless @comment.errors.any? %> $('#comments').append( '<%= escape_javascript( render @comment ) %>' ); $('#new-comment-form-container').find('input:not(:submit),select,textarea').val(''); <% if request.put? %> $('#comments').after('PUT request!'); <% end %> <% else %> var $form = $('#new_comment'), $errorDiv = $('
'), $errorList = $('
    '); <% @comment.errors.full_messages.each do |msg| %> $errorList.append('
  • <%= escape_javascript msg %>
  • '); <% end %> $form.find('#error_explanation').remove(); $form.prepend($errorDiv.append($errorList)); <% end %> <% end %> remotipart-1.4.4/spec/dummy_app/app/views/comments/edit.html.erb0000644000004100000410000000016713641335712025020 0ustar www-datawww-data

    Editing comment

    <%= render 'form' %> <%= link_to 'Show', @comment %> | <%= link_to 'Back', comments_path %> remotipart-1.4.4/spec/dummy_app/app/views/comments/_form.html.erb0000644000004100000410000000224713641335712025176 0ustar www-datawww-data<%= form_for(@comment, :remote => (params[:action] == 'new' ? true : false)) do |f| %> <% if @comment.errors.any? %>

    <%= pluralize(@comment.errors.count, "error") %> prohibited this comment from being saved:

      <% @comment.errors.full_messages.each do |msg| %>
    • <%= msg %>
    • <% end %>
    <% end %>
    Required fields
    <%= f.label :subject, :class => 'required' %>
    <%= f.text_field :subject, :required => true %>
    <%= f.label :body, :class => 'required' %>
    <%= f.text_area :body, :required => true %>
    <% if params[:attachment] %>
    <%= f.label :attachment %>
    <%= f.file_field :attachment %>
    <%= f.label :other_attachment %>
    <%= f.file_field :other_attachment %>
    <% end %>
    <%= f.submit :data => {disable_with: "Submitting..."} %>
    <% end %> remotipart-1.4.4/spec/dummy_app/app/views/layouts/0000755000004100000410000000000013641335712022305 5ustar www-datawww-dataremotipart-1.4.4/spec/dummy_app/app/views/layouts/application.html.erb0000644000004100000410000000033113641335712026242 0ustar www-datawww-data JqueryRails <%= stylesheet_link_tag "application" %> <%= javascript_include_tag "application" %> <%= csrf_meta_tag %> <%= yield %> remotipart-1.4.4/spec/dummy_app/app/views/prepended/0000755000004100000410000000000013641335712022553 5ustar www-datawww-dataremotipart-1.4.4/spec/dummy_app/app/views/prepended/show.html.erb0000644000004100000410000000002013641335712025160 0ustar www-datawww-data

    prepended

    remotipart-1.4.4/spec/dummy_app/db/0000755000004100000410000000000013641335712017255 5ustar www-datawww-dataremotipart-1.4.4/spec/dummy_app/db/schema.rb0000644000004100000410000000241613641335712021045 0ustar www-datawww-data# encoding: UTF-8 # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # Note that this schema.rb definition is the authoritative source for your # database schema. If you need to create the application database on another # system, you should be using db:schema:load, not running all the migrations # from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # # It's strongly recommended to check this file into your version control system. ActiveRecord::Schema.define(:version => 20110714205346) do create_table "comments", :force => true do |t| t.string "subject" t.text "body" t.datetime "created_at" t.datetime "updated_at" t.string "attachment_file_name" t.string "attachment_content_type" t.integer "attachment_file_size" t.datetime "attachment_updated_at" t.string "other_attachment_file_name" t.string "other_attachment_content_type" t.integer "other_attachment_file_size" t.datetime "other_attachment_updated_at" end end remotipart-1.4.4/spec/dummy_app/db/migrate/0000755000004100000410000000000013641335712020705 5ustar www-datawww-dataremotipart-1.4.4/spec/dummy_app/db/migrate/20110209210315_add_attachment_to_comment.rb0000644000004100000410000000105113641335712030045 0ustar www-datawww-dataclass AddAttachmentToComment < ActiveRecord::Migration def self.up add_column :comments, :attachment_file_name, :string add_column :comments, :attachment_content_type, :string add_column :comments, :attachment_file_size, :integer add_column :comments, :attachment_updated_at, :datetime end def self.down remove_column :comments, :attachment_file_name remove_column :comments, :attachment_content_type remove_column :comments, :attachment_file_size remove_column :comments, :attachment_updated_at end end remotipart-1.4.4/spec/dummy_app/db/migrate/20110714205346_add_other_attachment_to_comment.rb0000644000004100000410000000053613641335712031266 0ustar www-datawww-dataclass AddOtherAttachmentToComment < ActiveRecord::Migration def change add_column :comments, :other_attachment_file_name, :string add_column :comments, :other_attachment_content_type, :string add_column :comments, :other_attachment_file_size, :integer add_column :comments, :other_attachment_updated_at, :datetime end end remotipart-1.4.4/spec/dummy_app/db/migrate/20110209210252_create_comments.rb0000644000004100000410000000034013641335712026031 0ustar www-datawww-dataclass CreateComments < ActiveRecord::Migration def self.up create_table :comments do |t| t.string :subject t.text :body t.timestamps end end def self.down drop_table :comments end end remotipart-1.4.4/spec/dummy_app/db/seeds.rb0000644000004100000410000000054113641335712020705 0ustar www-datawww-data# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) # Mayor.create(:name => 'Daley', :city => cities.first) remotipart-1.4.4/spec/dummy_app/Rakefile0000644000004100000410000000042113641335712020332 0ustar www-datawww-data#!/usr/bin/env rake # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path('../config/application', __FILE__) DummyApp::Application.load_tasks remotipart-1.4.4/spec/dummy_app/config/0000755000004100000410000000000013641335712020135 5ustar www-datawww-dataremotipart-1.4.4/spec/dummy_app/config/boot.rb0000644000004100000410000000023513641335712021425 0ustar www-datawww-dataENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../gemfiles/rails_5.2.gemfile', __FILE__) require 'bundler/setup' # Set up gems listed in the Gemfile. remotipart-1.4.4/spec/dummy_app/config/routes.rb0000644000004100000410000000037613641335712022011 0ustar www-datawww-dataDummyApp::Application.routes.draw do match 'comments' => 'comments#create', :via => [:put] match 'say' => 'comments#say', :via => [:get] resources :comments match 'prepended' => 'prepended#show', :via => [:get] root :to => "comments#index" end remotipart-1.4.4/spec/dummy_app/config/secrets.yml0000644000004100000410000000047413641335712022335 0ustar www-datawww-datadevelopment: secret_key_base: d059ae03480564f4e9dcb7c96b901e5803037b0e09fd53e96343dff0d18dc54390a2f07b99c231eacb1d0cc6b74b90676fec4786afaf0f2e7f69b971ab2f9600 test: secret_key_base: e5e0e4811c8cfc047799cf3e82d1626adbf02fa7a3530b4bdd39cc17e1098d328f4da6ada090ec01449b5c92662bcec92cfb13b4c3c4c4bb3fac5a303e91c356 remotipart-1.4.4/spec/dummy_app/config/initializers/0000755000004100000410000000000013641335712022643 5ustar www-datawww-dataremotipart-1.4.4/spec/dummy_app/config/initializers/secret_token.rb0000644000004100000410000000032213641335712025652 0ustar www-datawww-dataif Rails::VERSION::MAJOR < 4 DummyApp::Application.config.secret_token = 'f2338e8b8018053b0b322cd6469d8c0ed06ab0aaf43dd30a1c33a4c55d9c0d6a1c1ad4140049019f85388db3ce1ddbeff597cf07c49c5b22242cecd146f2bd66' end remotipart-1.4.4/spec/dummy_app/config/application.rb0000644000004100000410000000167613641335712022777 0ustar www-datawww-datarequire File.expand_path('../boot', __FILE__) require 'rails/all' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module DummyApp class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers config.assets.paths << Rails.root.join("..", "..", "vendor", "assets", "javascripts") config.active_record.raise_in_transactional_callbacks = true if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR == 2 config.active_record.time_zone_aware_types = [:datetime, :time] if Rails::VERSION::MAJOR >= 5 config.active_record.sqlite3.represent_boolean_as_integer = true if config.active_record.sqlite3.respond_to?(:represent_boolean_as_integer=) && Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR == 2 end end remotipart-1.4.4/spec/dummy_app/config/environment.rb0000644000004100000410000000023213641335712023023 0ustar www-datawww-data# Load the Rails application. require File.expand_path('../application', __FILE__) # Initialize the Rails application. DummyApp::Application.initialize! remotipart-1.4.4/spec/dummy_app/config/environments/0000755000004100000410000000000013641335712022664 5ustar www-datawww-dataremotipart-1.4.4/spec/dummy_app/config/environments/test.rb0000644000004100000410000000407613641335712024177 0ustar www-datawww-dataDummyApp::Application.configure do # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between test runs. Don't rely on the data there! config.cache_classes = true # Do not eager load code on boot. This avoids loading your whole application # just for the purpose of running a single test. If you are using a tool that # preloads Rails for running tests, you may have to set it to true. config.eager_load = false # Configure public file server for tests with Cache-Control for performance. if config.respond_to?(:public_file_server) config.public_file_server.enabled = true config.public_file_server.headers = {'Cache-Control' => 'public, max-age=3600'} else if Rails::VERSION::MAJOR < 4 config.assets.enabled = true config.assets.debug = true config.serve_static_assets = true else config.serve_static_files = true end config.static_cache_control = 'public, max-age=3600' end # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test # Randomize the order test cases are executed. config.active_support.test_order = :random # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr # Raises error for missing translations # config.action_view.raise_on_missing_translations = true end remotipart-1.4.4/spec/dummy_app/config/environments/development.rb0000644000004100000410000000412513641335712025535 0ustar www-datawww-dataDummyApp::Application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Do not eager load code on boot. config.eager_load = false # Show full error reports. config.consider_all_requests_local = true # Enable/disable caching. By default caching is disabled. if Rails.root.join('tmp/caching-dev.txt').exist? config.action_controller.perform_caching = true config.cache_store = :memory_store config.public_file_server.headers = {'Cache-Control' => 'public, max-age=172800'} else config.action_controller.perform_caching = false config.cache_store = :null_store end # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true # Asset digests allow you to set far-future HTTP expiration dates on all assets, # yet still be able to expire them through the digest params. config.assets.digest = true # Adds additional error checking when serving assets at runtime. # Checks for improperly declared sprockets dependencies. # Raises helpful error messages. config.assets.raise_runtime_errors = true # Raises error for missing translations # config.action_view.raise_on_missing_translations = true # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. # config.file_watcher = ActiveSupport::EventedFileUpdateChecker end remotipart-1.4.4/spec/dummy_app/config/database.yml0000644000004100000410000000016413641335712022425 0ustar www-datawww-datadevelopment: adapter: sqlite3 database: db/development.sqlite3 test: adapter: sqlite3 database: ":memory:" remotipart-1.4.4/spec/features/0000755000004100000410000000000013641335712016513 5ustar www-datawww-dataremotipart-1.4.4/spec/features/prepended_spec.rb0000644000004100000410000000035013641335712022016 0ustar www-datawww-datarequire 'spec_helper' describe 'prepended', type: :feature do context "when another library overrides #render using prepend" do it "does not break" do expect { visit prepended_path }.not_to raise_error end end endremotipart-1.4.4/spec/features/comments_spec.rb0000644000004100000410000003565013641335712021710 0ustar www-datawww-datarequire 'spec_helper' describe 'comments', type: :feature do it 'creates a new comment', js: true do visit root_path click_link 'New Comment' # New Comment link should disappear expect(page).to have_no_link('New Comment') # Comment form should appear expect(page).to have_field('comment_subject') expect(page).to have_field('comment_body') expect(page).to have_no_field('comment_file') # Filling in form and submitting comment_subject = 'A new comment!' comment_body = 'Woo, this is my comment, dude.' fill_in 'comment_subject', with: comment_subject fill_in 'comment_body', with: comment_body click_button 'Create Comment' # Comment should appear in the comments table within '#comments' do expect(page).to have_content(comment_subject) expect(page).to have_content(comment_body) end # Form should clear expect(page).to have_field('comment_subject', with: '') expect(page).to have_field('comment_body', with: '') # ...and be replaced by link again expect(page).to have_link('Cancel') end it "cancels creating a comment", js: true do visit root_path click_link 'New Comment' expect(page).to have_field('comment_subject') expect(page).to have_link('Cancel') click_link 'Cancel' # Form should disappear expect(page).to have_no_field('comment_subject') expect(page).to have_link('New Comment') end it "deletes a comment", js: true do Comment.create(subject: 'The Great Yogurt', body: 'The Schwarz is strong with this one.') visit root_path within '#comments' do expect(page).to have_content('The Great Yogurt') accept_js_confirm do click_link 'Destroy' end expect(page).to have_no_content('The Great Yogurt') end end it "uploads a file", js: true do visit root_path click_link 'New Comment with Attachment' expect(page).to have_field('comment_subject') expect(page).to have_field('comment_body') expect(page).to have_field('comment_attachment') expect(page).to have_field('comment_other_attachment') comment_subject = 'Newby' comment_body = 'Woot, a file!' fill_in 'comment_subject', with: comment_subject fill_in 'comment_body', with: comment_body # Attach file file_path = File.join(fixture_path, 'qr.jpg') other_file_path = File.join(fixture_path, 'hi.txt') attach_file 'comment_attachment', file_path attach_file 'comment_other_attachment', other_file_path page_should_not_redirect do click_button 'Create Comment' end within '#comments' do expect(page).to have_selector("td", text: comment_subject) expect(page).to have_selector("td", text: comment_body) expect(page).to have_selector("a", text: File.basename(file_path)) expect(page).to have_selector("a", text: File.basename(other_file_path)) end end it "Disables submit button while submitting", js: true do visit root_path click_link 'New Comment' # Needed to make test wait for above to finish form = find('form') button = find_button('Create Comment') page.execute_script(%q{$('form').append('');}) fill_in 'comment_subject', with: 'Hi' fill_in 'comment_body', with: 'there' click_button 'Create Comment' expect(button[:disabled]).to be true expect(button.value).to eq "Submitting..." sleep 1.5 expect(button[:disabled]).to be false expect(button.value).to eq "Create Comment" end it "triggers ajax:remotipartSubmit event hook", js: true do visit root_path page.execute_script("$(document).delegate('form', 'ajax:remotipartSubmit', function() { $('#comments').after('remotipart!'); });") click_link 'New Comment with Attachment' fill_in 'comment_subject', with: 'Hi' fill_in 'comment_body', with: 'there' attach_file 'comment_attachment', File.join(fixture_path, 'qr.jpg') click_button 'Create Comment' expect(page).to have_content('remotipart!') end it "allows remotipart submission to be cancelable via event hook", js: true do visit root_path page.execute_script("$(document).delegate('form', 'ajax:remotipartSubmit', function() { $('#comments').after('remotipart!'); return false; });") click_link 'New Comment with Attachment' file_path = File.join(fixture_path, 'qr.jpg') fill_in 'comment_subject', with: 'Hi' fill_in 'comment_body', with: 'there' attach_file 'comment_attachment', file_path click_button 'Create Comment' expect(page).to have_content('remotipart!') within '#comments' do expect(page).to have_no_content('Hi') expect(page).to have_no_content('there') expect(page).to have_no_content(File.basename(file_path)) end end it "allows custom data-type on form", js: true do visit root_path page.execute_script("$(document).delegate('form', 'ajax:success', function(evt, data, status, xhr) { $('#comments').after(xhr.responseText); });") click_link 'New Comment with Attachment' # Needed to make test wait for above to finish form = find('form') page.execute_script("$('form').attr('data-type', 'html');") file_path = File.join(fixture_path, 'qr.jpg') fill_in 'comment_subject', with: 'Hi' fill_in 'comment_body', with: 'there' attach_file 'comment_attachment', file_path click_button 'Create Comment' expect(page).to have_content('HTML response') end it "allows users to use ajax response data safely", js: true do visit root_path page.execute_script("$(document).delegate('form', 'ajax:success', function(evt, data, status, xhr) { $('#comments').after(data); });") click_link 'New Comment with Attachment' # Needed to make test wait for above to finish form = find('form') page.execute_script("$('form').attr('data-type', 'html');") file_path = File.join(fixture_path, 'qr.jpg') fill_in 'comment_subject', with: 'Hi' fill_in 'comment_body', with: 'there' attach_file 'comment_attachment', file_path click_button 'Create Comment' expect(page).to have_content('HTML response') end it "escapes html response content properly", js: true do visit root_path page.execute_script("$(document).delegate('form', 'ajax:success', function(evt, data, status, xhr) { $('#comments').after(xhr.responseText); });") click_link 'New Comment with Attachment' # Needed to make test wait for above to finish form = find('form') page.execute_script("$('form').attr('data-type', 'html');") page.execute_script("$('form').append('');") file_path = File.join(fixture_path, 'qr.jpg') fill_in 'comment_subject', with: 'Hi' fill_in 'comment_body', with: 'there' attach_file 'comment_attachment', file_path click_button 'Create Comment' expect(find('input[name="quote"]').value).to eq '"' end it "returns the correct response status", js: true do visit root_path click_link 'New Comment with Attachment' # Needed to make test wait for above to finish input = find('#comment_subject') page.execute_script("$('#comment_subject').removeAttr('required');") file_path = File.join(fixture_path, 'qr.jpg') fill_in 'comment_body', with: 'there' attach_file 'comment_attachment', file_path click_button 'Create Comment' #within '#error_explanation' do # expect(page).to have_content "Subject can't be blank" #end expect(page).to have_content "Error status code: 422" expect(page).to have_content "Error status message: Unprocessable Entity" end it "passes the method as _method parameter (rails convention)", js: true do visit root_path click_link 'New Comment with Attachment' sleep 0.5 page.execute_script(%q{$('form').append('');}) file_path = File.join(fixture_path, 'qr.jpg') fill_in 'comment_subject', with: 'Hi' fill_in 'comment_body', with: 'there' attach_file 'comment_attachment', file_path click_button 'Create Comment' expect(page).to have_content 'PUT request!' end it "does not submit via remotipart unless file is present", js: true do visit root_path page.execute_script("$(document).delegate('form', 'ajax:remotipartSubmit', function() { $('#comments').after('remotipart!'); });") click_link 'New Comment with Attachment' fill_in 'comment_subject', with: 'Hi' fill_in 'comment_body', with: 'there' click_button 'Create Comment' expect(page).to have_no_content('remotipart!') end it "fires all the ajax callbacks on the form", js: true do visit root_path click_link 'New Comment with Attachment' # Needed to make test wait for above to finish form = find('form') page.execute_script("$('form').bind('ajax:beforeSend', function() { $('#comments').after('thebefore'); });") page.execute_script("$(document).delegate('form', 'ajax:success', function() { $('#comments').after('success'); });") page.execute_script("$(document).delegate('form', 'ajax:complete', function() { $('#comments').after('complete'); });") file_path = File.join(fixture_path, 'qr.jpg') fill_in 'comment_subject', with: 'Hi' fill_in 'comment_body', with: 'there' attach_file 'comment_attachment', file_path click_button 'Create Comment' expect(page).to have_content('before') expect(page).to have_content('success') expect(page).to have_content('complete') end it "fires the ajax callbacks for json data-type with remotipart", js: true do visit root_path click_link 'New Comment with Attachment' # Needed to make test wait for above to finish form = find('form') page.execute_script("$('form').data('type', 'json');") page.execute_script("$('form').bind('ajax:beforeSend', function() { $('#comments').after('thebefore'); });") page.execute_script("$(document).delegate('form', 'ajax:success', function() { $('#comments').after('success'); });") page.execute_script("$(document).delegate('form', 'ajax:complete', function() { $('#comments').after('complete'); });") file_path = File.join(fixture_path, 'qr.jpg') fill_in 'comment_subject', with: 'Hi' fill_in 'comment_body', with: 'there' attach_file 'comment_attachment', file_path click_button 'Create Comment' expect(page).to have_content('before') expect(page).to have_content('success') expect(page).to have_content('complete') end it "only fires the beforeSend hook once", js: true do visit root_path click_link 'New Comment with Attachment' # Needed to make test wait for above to finish form = find('form') page.execute_script("$('form').bind('ajax:beforeSend', function() { $('#comments').after('
    ajax!
    '); });") file_path = File.join(fixture_path, 'qr.jpg') fill_in 'comment_subject', with: 'Hi' fill_in 'comment_body', with: 'there' attach_file 'comment_attachment', file_path click_button 'Create Comment' expect(page).to have_css("div.ajax", :count => 1) end it "cleans up after itself when uploading files", js: true do visit root_path page.execute_script("$(document).delegate('form', 'ajax:remotipartSubmit', function(evt, xhr, data) { if ($(this).data('remotipartSubmitted')) { $('#comments').after('remotipart before!'); } });") click_link 'New Comment with Attachment' page.execute_script("$('form').attr('data-type', 'html');") file_path = File.join(fixture_path, 'qr.jpg') fill_in 'comment_subject', with: 'Hi' fill_in 'comment_body', with: 'there' attach_file 'comment_attachment', file_path click_button 'Create Comment' expect(page).to have_content('remotipart before!') page.execute_script("if (!$('form').data('remotipartSubmitted')) { $('#comments').after('no remotipart after!'); } ") expect(page).to have_content('no remotipart after!') end it "submits via remotipart when a file upload is present", js: true do visit root_path page.execute_script("$(document).delegate('form', 'ajax:remotipartSubmit', function(evt, xhr, data) { $('#comments').after('
    remotipart!
    '); });") click_link 'New Comment with Attachment' page.execute_script("$('form').attr('data-type', 'html');") file_path = File.join(fixture_path, 'qr.jpg') fill_in 'comment_subject', with: 'Hi' fill_in 'comment_body', with: 'there' attach_file 'comment_attachment', file_path click_button 'Create Comment' expect(page).to have_css("div.remotipart") end it "does not submit via remotipart when a file upload is not present", js: true do visit root_path page.execute_script("$(document).delegate('form', 'ajax:remotipartSubmit', function(evt, xhr, data) { $('#comments').after('
    remotipart!
    '); });") click_link 'New Comment with Attachment' page.execute_script("$('form').attr('data-type', 'html');") fill_in 'comment_subject', with: 'Hi' fill_in 'comment_body', with: 'there' click_button 'Create Comment' expect(page).not_to have_css("div.remotipart") end it "Disables submit button while submitting with remotipart", js: true do visit root_path click_link 'New Comment with Attachment' button = find_button('Create Comment') # clicking 'Create Comment' button causes capybara evaluation freeze until request ends, so perform check by JavaScript page.execute_script("$('form').bind('ajax:remotipartComplete', function(data) { window.commitButtonDisabled = $('input[name=\"commit\"]').is(':disabled'); window.commitButtonValue = $('input[name=\"commit\"]').val(); });") file_path = File.join(fixture_path, 'qr.jpg') fill_in 'comment_subject', with: 'Hi' fill_in 'comment_body', with: 'there' attach_file 'comment_attachment', file_path click_button 'Create Comment' expect(page.evaluate_script("window.commitButtonDisabled")).to be true expect(page.evaluate_script("window.commitButtonValue")).to eq "Submitting..." expect(button[:disabled]).to be false expect(button.value).to eq "Create Comment" end it "submits the clicked button with the form like non-file remote form", js: true do visit root_path click_link 'New Comment with Attachment' form = find('form') page.execute_script("$('form').bind('ajax:remotipartSubmit', function(e, xhr, settings) { $('#comments').after('
    ' + $.param(settings.data) + '
    '); });") file_path = File.join(fixture_path, 'qr.jpg') fill_in 'comment_subject', with: 'Hi' fill_in 'comment_body', with: 'there' attach_file 'comment_attachment', file_path click_button 'Create Comment' expect(page).to have_content('commit=') end it "doesn't allow XSS via script injection for text responses", js: true do visit "/say?message=%3C/textarea%3E%3Csvg/onload=alert(domain)%3E&remotipart_submitted=x" expect(page).to have_selector("textarea") expect(find("textarea").value).to eq('') end end ����������������������������������������������������������������������������������������remotipart-1.4.4/spec/spec_helper.rb����������������������������������������������������������������0000644�0000041�0000041�00000002171�13641335712�017514� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������# Configure Rails Envinronment ENV['RAILS_ENV'] = 'test' require File.expand_path('../dummy_app/config/environment', __FILE__) require 'rspec/rails' require 'capybara/rspec' require 'capybara/poltergeist' require 'database_cleaner' Capybara.javascript_driver = :poltergeist Capybara.server = :webrick Capybara.default_max_wait_time = 5 # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. Dir[File.expand_path('../support/**/*.rb', __FILE__)].each {|f| require f } RSpec.configure do |config| load "#{Rails.root.to_s}/db/schema.rb" # use db agnostic schema by default config.mock_with :rspec config.expect_with :rspec do |c| c.syntax = :expect end config.fixture_path = File.expand_path('../fixtures', __FILE__) config.include Rails.application.routes.url_helpers config.include RSpec::Matchers config.include Capybara::DSL, type: :feature config.include IntegrationHelper, type: :feature config.before do |example| DatabaseCleaner.strategy = :truncation DatabaseCleaner.start end config.after(:each) do DatabaseCleaner.clean end end �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������remotipart-1.4.4/spec/support/����������������������������������������������������������������������0000755�0000041�0000041�00000000000�13641335712�016411� 5����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������remotipart-1.4.4/spec/support/arel_helper.rb��������������������������������������������������������0000644�0000041�0000041�00000000523�13641335712�021220� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������module Arel module Visitors class DepthFirst < Arel::Visitors::Visitor alias :visit_Integer :terminal end class Dot < Arel::Visitors::Visitor alias :visit_Integer :visit_String end class ToSql < Arel::Visitors::Visitor alias :visit_Integer :literal end end end if Rails::VERSION::MAJOR == 3 �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������remotipart-1.4.4/spec/support/integration_helper.rb�������������������������������������������������0000644�0000041�0000041�00000002247�13641335712�022625� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������module IntegrationHelper # If you do something that triggers a confirm, do it inside an accept_js_confirm or reject_js_confirm block def accept_js_confirm page.evaluate_script 'window.original_confirm_function = window.confirm;' page.evaluate_script 'window.confirm = function(msg) { return true; }' yield page.evaluate_script 'window.confirm = window.original_confirm_function;' end # If you do something that triggers a confirm, do it inside an accept_js_confirm or reject_js_confirm block def reject_js_confirm page.evaluate_script 'window.original_confirm_function = window.confirm;' page.evaluate_script 'window.confirm = function(msg) { return false; }' yield page.evaluate_script 'window.confirm = window.original_confirm_function;' end # Test that page doesn't redirect (there is probably a much better, built-in way to # test this, I just don't know it. def page_should_not_redirect path = current_path text = "bleep bloop" page.execute_script "var txt = document.createTextNode('#{text}');document.body.appendChild(txt);" yield expect(current_path).to eq path expect(page).to have_content(text) end end ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������remotipart-1.4.4/spec/support/connection_helper.rb��������������������������������������������������0000644�0000041�0000041�00000000551�13641335712�022435� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������class ActiveRecord::Base mattr_accessor :shared_connection @@shared_connection = nil def self.connection @@shared_connection || retrieve_connection end end # Forces all threads to share the same connection. This works on # Capybara because it starts the web server in a thread. ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection �������������������������������������������������������������������������������������������������������������������������������������������������������remotipart-1.4.4/History.rdoc�����������������������������������������������������������������������0000644�0000041�0000041�00000010477�13641335712�016266� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������= History === 1.4.4 / 2019-12-29 * Fixed Rails 6 autoloading deprecation. * Fixed ActiveScaffold incompatibility. === 1.4.3 / 2019-05-23 * Fixed xhr.responseText not being populated. * Security: fixed cross-site scripting vulnerability when server renders user input. === 1.4.2 / 2018-04-25 * Fixed ActionView::Template::Error in web-console. === 1.4.0 / 2018-04-09 * Added jQuery 3 compatibility. * Changed to use ActiveSupport lazy load hooks on initialization. * Changed jQuery iframe-transport to v1.0.1. * Fixed to preserve original return value of render call for non-remotipart requests. * Fixed remote javascript with " not being executed. * Fixed method signature of render_with_remotipart, making RJS templates not usable. === 1.3.1 / 2016-10-06 * Fixed remote form submit not working with Firefox 49. === 1.3.0 / 2016-09-14 * Added Rails 5 support. * Added an event `ajax:remotipartComplete`, which will be fired when the ajax upload completes. * Changed to preserve original input files upon submit. * Fixed TypeError when POST body is empty with Rails 3. === 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.4.4/Appraisals�������������������������������������������������������������������������0000644�0000041�0000041�00000000635�13641335712�015771� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������appraise "rails-3.2" do gem 'rails', '~> 3.2.0' gem 'test-unit', '~> 3.0' gem "strong_parameters" group :development, :test do gem 'sqlite3', '~> 1.3.5' end end appraise "rails-4.2" do gem 'rails', '~> 4.2.0' group :development, :test do gem 'sqlite3', '~> 1.3.6' end end appraise "rails-5.2" do gem 'rails', '~> 5.2.0' end appraise "rails-6.0" do gem 'rails', '~> 6.0.0.rc1' end ���������������������������������������������������������������������������������������������������remotipart-1.4.4/LICENSE����������������������������������������������������������������������������0000644�0000041�0000041�00000002250�13641335712�014747� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������============================================ Remotipart is licensed under the MIT License ============================================ Copyright (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.4.4/.document��������������������������������������������������������������������������0000644�0000041�0000041�00000000074�13641335712�015563� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������README.rdoc lib/**/*.rb bin/* features/**/*.feature LICENSE ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������remotipart-1.4.4/Rakefile���������������������������������������������������������������������������0000644�0000041�0000041�00000003404�13641335712�015411� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������require '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 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 require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) task default: :spec ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������remotipart-1.4.4/lib/�������������������������������������������������������������������������������0000755�0000041�0000041�00000000000�13641335712�014511� 5����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������remotipart-1.4.4/lib/remotipart.rb������������������������������������������������������������������0000644�0000041�0000041�00000000271�13641335712�017224� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������require 'remotipart/view_helper' require 'remotipart/request_helper' require 'remotipart/render_overrides' require 'remotipart/middleware' require 'remotipart/rails' if defined?(Rails) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������remotipart-1.4.4/lib/generators/��������������������������������������������������������������������0000755�0000041�0000041�00000000000�13641335712�016662� 5����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������remotipart-1.4.4/lib/generators/remotipart/���������������������������������������������������������0000755�0000041�0000041�00000000000�13641335712�021050� 5����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������remotipart-1.4.4/lib/generators/remotipart/install/�������������������������������������������������0000755�0000041�0000041�00000000000�13641335712�022516� 5����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������remotipart-1.4.4/lib/generators/remotipart/install/install_generator.rb�����������������������������0000644�0000041�0000041�00000001464�13641335712�026564� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������require '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.4.4/lib/remotipart/��������������������������������������������������������������������0000755�0000041�0000041�00000000000�13641335712�016677� 5����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������remotipart-1.4.4/lib/remotipart/request_helper.rb���������������������������������������������������0000644�0000041�0000041�00000000340�13641335712�022250� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������module Remotipart module RequestHelper def remotipart_submitted? params[:remotipart_submitted] ? true : false rescue false end alias :remotipart_requested? :remotipart_submitted? end end ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������remotipart-1.4.4/lib/remotipart/render_overrides.rb�������������������������������������������������0000644�0000041�0000041�00000003012�13641335712�022561� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������module Remotipart # Responder used to automagically wrap any non-xml replies in a text-area # as expected by iframe-transport. module RenderOverrides include ERB::Util include ActionView::Helpers::JavaScriptHelper def self.included(base) base.class_eval do if respond_to? :prepend base.prepend Prependable else base.include Includable # Do not use alias_method_chain for compatibility alias render_without_remotipart render alias render render_with_remotipart end end end module Prependable def render(*args, &block) treat_render_for_remotipart super(*args, &block) end end module Includable def render_with_remotipart(*args, &block) treat_render_for_remotipart render_without_remotipart(*args, &block) end end private def treat_render_for_remotipart(render_return_value) if remotipart_submitted? response.body = %{} response.content_type = ::Rails.version >= '5' ? Mime[:html] : Mime::HTML response_body else render_return_value end end end end ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������remotipart-1.4.4/lib/remotipart/rails/��������������������������������������������������������������0000755�0000041�0000041�00000000000�13641335712�020011� 5����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������remotipart-1.4.4/lib/remotipart/rails/version.rb����������������������������������������������������0000644�0000041�0000041�00000000162�13641335712�022022� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������module Remotipart module Rails VERSION = "1.4.4" IFRAMETRANSPORT_VERSION = "1.0.1.remotipart" end end ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������remotipart-1.4.4/lib/remotipart/rails/railtie.rb����������������������������������������������������0000644�0000041�0000041�00000003076�13641335712�021775� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-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 ActiveSupport.on_load(:action_view) do include RequestHelper include ViewHelper end end initializer "remotipart.controller_helper" do ActiveSupport.on_load(:action_controller) do include RequestHelper include RenderOverrides end end initializer "remotipart.include_middelware" do config.app_middleware.insert_after ActionDispatch::ParamsParser, Middleware end end end end ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������remotipart-1.4.4/lib/remotipart/rails/engine.rb�����������������������������������������������������0000644�0000041�0000041�00000001601�13641335712�021601� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������# Configure Rails 3.1 module Remotipart module Rails class Engine < ::Rails::Engine initializer "remotipart.view_helper" do ActiveSupport.on_load :action_view do include RequestHelper include ViewHelper end end initializer "remotipart.controller_helper" do ActiveSupport.on_load :action_controller do include RequestHelper include RenderOverrides end end initializer "remotipart.include_middelware" do if ::Rails.version >= '5' # Rails 5 no longer instantiates ActionDispatch::ParamsParser # https://github.com/rails/rails/commit/a1ced8b52ce60d0634e65aa36cb89f015f9f543d config.app_middleware.use Middleware else config.app_middleware.insert_after ActionDispatch::ParamsParser, Middleware end end end end end �������������������������������������������������������������������������������������������������������������������������������remotipart-1.4.4/lib/remotipart/rails.rb������������������������������������������������������������0000644�0000041�0000041�00000000330�13641335712�020332� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������module 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.4.4/lib/remotipart/view_helper.rb������������������������������������������������������0000644�0000041�0000041�00000000321�13641335712�021531� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������module Remotipart module ViewHelper #No longer used #Retrained to prevent issues while updating def remotipart_response(options = {}, &block) with_output_buffer(&block) end end end ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������remotipart-1.4.4/lib/remotipart/middleware.rb�������������������������������������������������������0000644�0000041�0000041�00000001646�13641335712�021350� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������module 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 begin params = Rack::Request.new(env).params rescue TypeError => e ::Rails.logger.warn e.message ::Rails.logger.warn e.backtrace.join("\n") end 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.4.4/CONTRIBUTING.md��������������������������������������������������������������������0000644�0000041�0000041�00000003325�13641335712�016177� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-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.4.4/README.rdoc������������������������������������������������������������������������0000644�0000041�0000041�00000014715�13641335712�015561� 0����������������������������������������������������������������������������������������������������ustar �www-data������������������������www-data���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������= Remotipart: Rails jQuery File Uploads {Gem Version}[https://badge.fury.io/rb/remotipart] {Build Status}[https://travis-ci.com/JangoSteve/remotipart] {}[https://codeclimate.com/github/JangoSteve/remotipart] Remotipart is a Ruby on Rails gem enabling AJAX file uploads with jQuery in Rails 3 and Rails 4 remote forms. This gem augments the native Rails jQuery remote form functionality enabling asynchronous file uploads with little to no modification to your application. * {Homepage and Demos}[http://www.alfajango.com/blog/remotipart-rails-gem/] * {How AJAX File Uploads Work}[http://www.alfajango.com/blog/ajax-file-uploads-with-the-iframe-method/] == Dependencies * {Rails 3 or Rails 4}[http://github.com/rails/rails] * {The jquery-rails gem}[http://rubygems.org/gems/jquery-rails] The jquery-rails gem is included in Rails 3 and Rails 4 by default, and installs {jQuery}[http://jquery.com] and the {Rails jQuery UJS driver (jquery-ujs)}[https://github.com/rails/jquery-ujs] == Installation Your app should be using jquery-rails gem v2.3.0 or above. If you're using an old version of the jquery-rails gem, make sure you have a supported jquery-ujs (rails.js or jquery_ujs.js) version from {VERSION_COMPATIBILITY}[https://github.com/JangoSteve/remotipart/blob/master/VERSION_COMPATIBILITY.rdoc]. [1.] Install the Remotipart gem * Add this line to your GEMFILE (use the appropriate version from the compatibilty chart if needed) gem 'remotipart', '~> 1.2' * And run bundle install === Rails 3.1 and Rails 4 [2.] The necessary js files will automatically be added to the asset pipeline, so add the following to app/assets/javascripts/application.js (right after //= require jquery_ujs): //= require jquery.remotipart === Rails 3.0 [2.] Run the Remotipart install generator to add jquery.iframe-transport.js and jquery.remotipart.js to public/javascripts/ rails g remotipart:install [3.] The necessary js files will be added to your app's javascript :defaults, so make sure the following is in your application layout: <%= javascript_include_tag :defaults %> == Usage * For multipart / forms with file inputs, set your form_for to remote as you would for a normal ajax form: :remote => true * When Javascript is enabled in the user's browser, the form, including the file, will be submitted asynchronously to your controller with: :format => 'js' * If you need to determine if a particular request was made via a remotipart-enabled form... * from your Rails controller or view: if remotipart_submitted? * from your javascript: $(form).bind("ajax:success", function(){ if ( $(this).data('remotipartSubmitted') ) }); * If you want to be notified when the upload is complete (which can be either success or error) * from your javascript: $(form).on("ajax:remotipartComplete", function(e, data){ console.log(e, data) }); === Example sample_layout.html.erb <%= form_for @sample, :html => { :multipart => true }, :remote => true do |f| %>
    <%= f.label :file %> <%= f.file_field :file %>
    <%= f.submit %>
    <% end %> sample_controller.rb def create respond_to do |format| if @sample.save format.js end end end create.js.erb // Display a Javascript alert alert('success!'); <% if remotipart_submitted? %> alert('submitted via remotipart') <% else %> alert('submitted via native jquery-ujs') <% end %> The content type requested from the application can be overridden via the data-type HTML5 attribute: sample_layout2.html.erb <%= form_for @sample, :html => { :multipart => true }, :remote => true, :data => { :type => :html } do |f| %>
    <%= f.label :file %> <%= f.file_field :file %>
    <%= f.submit %>
    <% end %> In this case, the application should serve HTML using a create.html.erb template instead of JavaScript. == Note on Patches/Pull Requests If you have a general improvement, optimization, or refactoring, please {read this first}[https://github.com/formasfunction/remotipart/wiki/Refactoring-and-Improving-Remotipart]. * 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/master/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' == Special Thanks Thank you to Greg Leppert for writing the original version of this gem and providing inspiration for the gem in its current incarnation. Thank you to {Adam Kerr}[https://github.com/ajrkerr] for helping move over to the simpler jQuery 1.6-compatible iframe-transport.js and for helping write the rack middleware, making remotipart even easier to use in Rails. == Copyright Copyright (c) 2013 {Steve Schwartz}[https://github.com/JangoSteve], {Greg Leppert}[https://github.com/leppert]. See LICENSE for details. remotipart-1.4.4/vendor/0000755000004100000410000000000013641335712015240 5ustar www-datawww-dataremotipart-1.4.4/vendor/assets/0000755000004100000410000000000013641335712016542 5ustar www-datawww-dataremotipart-1.4.4/vendor/assets/javascripts/0000755000004100000410000000000013641335712021073 5ustar www-datawww-dataremotipart-1.4.4/vendor/assets/javascripts/jquery.remotipart.js0000644000004100000410000000667113641335712025147 0ustar www-datawww-data//= require jquery.iframe-transport.js //= require_self (function($) { var remotipart; $.remotipart = remotipart = { setup: function(form) { // Preserve form.data('ujs:submit-button') before it gets nulled by $.ajax.handleRemote var button = form.data('ujs:submit-button'), csrfParam = $('meta[name="csrf-param"]').attr('content'), csrfToken = $('meta[name="csrf-token"]').attr('content'), csrfInput = form.find('input[name="' + csrfParam + '"]').length; form // Allow setup part of $.rails.handleRemote to setup remote settings before canceling default remote handler // This is required in order to change the remote settings using the form details .one('ajax:beforeSend.remotipart', function(e, xhr, settings){ // Delete the beforeSend bindings, since we're about to re-submit via ajaxSubmit with the beforeSubmit // hook that was just setup and triggered via the default `$.rails.handleRemote` // delete settings.beforeSend; delete settings.beforeSend; settings.iframe = true; settings.files = $($.rails.fileInputSelector, form); settings.data = form.serializeArray(); // Insert the name/value of the clicked submit button, if any if (button) settings.data.push(button); // jQuery 1.9 serializeArray() contains input:file entries // so exclude them from settings.data, otherwise files will not be sent settings.files.each(function(i, file){ for (var j = settings.data.length - 1; j >= 0; j--) if (settings.data[j].name == file.name) settings.data.splice(j, 1); }) settings.processData = false; // Modify some settings to integrate JS request with rails helpers and middleware if (settings.dataType === undefined) { settings.dataType = 'script *'; } settings.data.push({name: 'remotipart_submitted', value: true}); if (csrfToken && csrfParam && !csrfInput) { settings.data.push({name: csrfParam, value: csrfToken}); } // Allow remotipartSubmit to be cancelled if needed if ($.rails.fire(form, 'ajax:remotipartSubmit', [xhr, settings])) { // Second verse, same as the first $.rails.ajax(settings).always(function(data){ $.rails.fire(form, 'ajax:remotipartComplete', [data]); }); setTimeout(function(){ $.rails.disableFormElements(form); }, 20); } //Run cleanup remotipart.teardown(form); // Cancel the jQuery UJS request return false; }) // Keep track that we just set this particular form with Remotipart bindings // Note: The `true` value will get over-written with the `settings.dataType` from the `ajax:beforeSend` handler .data('remotipartSubmitted', true); }, teardown: function(form) { form .unbind('ajax:beforeSend.remotipart') .removeData('remotipartSubmitted') } }; $(document).on('ajax:aborted:file', 'form', function(){ var form = $(this); remotipart.setup(form); // Manually call jquery-ujs remote call so that it can setup form and settings as usual, // and trigger the `ajax:beforeSend` callback to which remotipart binds functionality. $.rails.handleRemote(form); return false; }); })(jQuery); remotipart-1.4.4/vendor/assets/javascripts/jquery.iframe-transport.js0000644000004100000410000002442613641335712026254 0ustar www-datawww-data// This [jQuery](https://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.one("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 `