{"id":13427879,"url":"https://github.com/JangoSteve/remotipart","last_synced_at":"2025-03-16T00:32:24.315Z","repository":{"id":56891744,"uuid":"1322564","full_name":"JangoSteve/remotipart","owner":"JangoSteve","description":"Rails jQuery file uploads via standard Rails \"remote: true\" forms.","archived":false,"fork":true,"pushed_at":"2021-03-23T13:16:38.000Z","size":220,"stargazers_count":1007,"open_issues_count":42,"forks_count":215,"subscribers_count":29,"default_branch":"master","last_synced_at":"2024-04-14T13:19:27.593Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://os.alfajango.com/remotipart","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"leppert/remotipart","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JangoSteve.png","metadata":{"files":{"readme":"README.rdoc","changelog":"History.rdoc","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-02-03T00:41:46.000Z","updated_at":"2024-04-12T14:21:33.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/JangoSteve/remotipart","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JangoSteve%2Fremotipart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JangoSteve%2Fremotipart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JangoSteve%2Fremotipart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JangoSteve%2Fremotipart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JangoSteve","download_url":"https://codeload.github.com/JangoSteve/remotipart/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243809865,"owners_count":20351403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T01:00:41.849Z","updated_at":"2025-03-16T00:32:23.999Z","avatar_url":"https://github.com/JangoSteve.png","language":"Ruby","funding_links":[],"categories":["File Uploading","Ruby","文件上传"],"sub_categories":["Omniauth"],"readme":"= Remotipart: Rails jQuery File Uploads\n\n{\u003cimg src=\"https://badge.fury.io/rb/remotipart.svg\" alt=\"Gem Version\" /\u003e}[https://badge.fury.io/rb/remotipart]\n{\u003cimg src=\"https://travis-ci.com/JangoSteve/remotipart.svg?branch=master\" alt=\"Build Status\" /\u003e}[https://travis-ci.com/JangoSteve/remotipart]\n{\u003cimg src=\"https://codeclimate.com/github/JangoSteve/remotipart/badges/gpa.svg\" /\u003e}[https://codeclimate.com/github/JangoSteve/remotipart]\n\nRemotipart is a Ruby on Rails gem enabling AJAX file uploads with jQuery in Rails 3 and Rails 4 remote forms.\nThis gem augments the native Rails jQuery remote form functionality enabling asynchronous file uploads with little to no modification to your application.\n\n* {Homepage and Demos}[http://www.alfajango.com/blog/remotipart-rails-gem/]\n* {How AJAX File Uploads Work}[http://www.alfajango.com/blog/ajax-file-uploads-with-the-iframe-method/]\n\n== Dependencies\n\n* {Rails 3 or Rails 4}[http://github.com/rails/rails]\n* {The jquery-rails gem}[http://rubygems.org/gems/jquery-rails]\n\n\u003cem\u003eThe 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]\u003c/em\u003e\n\n== Installation\n\n\u003cb\u003eYour app should be using jquery-rails gem v2.3.0 or above.\u003c/b\u003e\n\nIf you're using an old version of the jquery-rails gem,\nmake 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].\n\n[1.]\n  Install the Remotipart gem\n\n  * Add this line to your GEMFILE (use the appropriate version from the compatibilty chart if needed)\n\n   gem 'remotipart', '~\u003e 1.2'\n\n  * And run\n\n   bundle install\n\n=== Rails 3.1 and Rails 4\n\n[2.]\n  The necessary js files will automatically be added to the asset pipeline, so add the following to app/assets/javascripts/application.js (right after \u003ctt\u003e//= require jquery_ujs\u003c/tt\u003e):\n\n   //= require jquery.remotipart\n\n=== Rails 3.0\n\n[2.]\n  Run the Remotipart install generator to add jquery.iframe-transport.js and jquery.remotipart.js to public/javascripts/\n\n   rails g remotipart:install\n\n[3.]\n  The necessary js files will be added to your app's javascript \u003ctt\u003e:defaults\u003c/tt\u003e, so make sure the following is in your application layout:\n\n   \u003c%= javascript_include_tag :defaults %\u003e\n\n== Usage\n\n* For multipart / forms with file inputs, set your form_for to remote as you would for a normal ajax form:\n   :remote =\u003e true\n* When Javascript is enabled in the user's browser, the form, including the file, will be submitted asynchronously to your controller with:\n   :format =\u003e 'js'\n* If you need to determine if a particular request was made via a remotipart-enabled form...\n  * from your Rails controller or view:\n\n      if remotipart_submitted?\n  * from your javascript:\n\n      $(form).bind(\"ajax:success\", function(){\n        if ( $(this).data('remotipartSubmitted') )\n      });\n* If you want to be notified when the upload is complete (which can be either success or error)\n  * from your javascript:\n\n      $(form).on(\"ajax:remotipartComplete\", function(e, data){\n        console.log(e, data)\n      });\n      \n=== Example\n\n\u003ctt\u003esample_layout.html.erb\u003c/tt\u003e\n  \u003c%= form_for @sample, :html =\u003e { :multipart =\u003e true }, :remote =\u003e true do |f| %\u003e\n    \u003cdiv class=\"field\"\u003e\n      \u003c%= f.label :file %\u003e\n      \u003c%= f.file_field :file %\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"actions\"\u003e\n      \u003c%= f.submit %\u003e\n    \u003c/div\u003e\n  \u003c% end %\u003e\n\n\u003ctt\u003esample_controller.rb\u003c/tt\u003e\n  def create\n    respond_to do |format|\n      if @sample.save\n        format.js\n      end\n    end\n  end\n\n\u003ctt\u003ecreate.js.erb\u003c/tt\u003e\n  // Display a Javascript alert\n  alert('success!');\n  \u003c% if remotipart_submitted? %\u003e\n    alert('submitted via remotipart')\n  \u003c% else %\u003e\n    alert('submitted via native jquery-ujs')\n  \u003c% end %\u003e\n\nThe content type requested from the application can be overridden via the \u003ctt\u003edata-type\u003c/tt\u003e HTML5 attribute:\n\n\u003ctt\u003esample_layout2.html.erb\u003c/tt\u003e\n  \u003c%= form_for @sample, :html =\u003e { :multipart =\u003e true }, :remote =\u003e true, :data =\u003e { :type =\u003e :html } do |f| %\u003e\n    \u003cdiv class=\"field\"\u003e\n      \u003c%= f.label :file %\u003e\n      \u003c%= f.file_field :file %\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"actions\"\u003e\n      \u003c%= f.submit %\u003e\n    \u003c/div\u003e\n  \u003c% end %\u003e\n\nIn this case, the application should serve HTML using a \u003ctt\u003ecreate.html.erb\u003c/tt\u003e template instead of JavaScript.\n\n== Note on Patches/Pull Requests\n\n\u003cb\u003eIf you have a general improvement, optimization, or refactoring, please {read this first}[https://github.com/formasfunction/remotipart/wiki/Refactoring-and-Improving-Remotipart].\u003c/b\u003e\n\n* Fork the project.\n* Make your feature addition or bug fix.\n* Add tests for it. This is important so I don't break it in a\n  future version unintentionally.\n* Commit, do not mess with rakefile, version, or history.\n  (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)\n* Send me a pull request. Bonus points for topic branches.\n\n== Tests\n\nBecause of the nature of AJAX file uploads and certain browser restrictions, we could not simply create unit tests (using qunit or jasmine)\nto 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\nupload input using javascript). So, instead we created a demo Rails app using remotipart with all remotipart functionality tested using RSpec and Capybara.\n\n* {Demo Rails App with Tests}[https://github.com/JangoSteve/Rails-jQuery-Demo/tree/remotipart]\n  * {Tests}[https://github.com/JangoSteve/Rails-jQuery-Demo/blob/master/spec/features/comments_spec.rb]\n\nTo run tests:\n\nClone the remotipart branch of the demo app\n  git clone -b remotipart git://github.com/JangoSteve/Rails-jQuery-Demo.git\n\nInstall the dependencies\n  bundle install\n\nRun the tests\n  bundle exec rspec spec/\n\nIf you need to test your own changes to remotipart, just update the Gemfile with your own fork/branch of remotipart:\n\n  gem 'remotipart', :git =\u003e 'git://github.com/MY_FORK/remotipart.git', :branch =\u003e 'MY_BRANCH'\n\n== Special Thanks\n\nThank you to Greg Leppert for writing the original version of this gem and providing inspiration for the gem in its current incarnation.\n\nThank 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.\n\n== Copyright\n\nCopyright (c) 2013 {Steve Schwartz}[https://github.com/JangoSteve], {Greg Leppert}[https://github.com/leppert]. See LICENSE for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJangoSteve%2Fremotipart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJangoSteve%2Fremotipart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJangoSteve%2Fremotipart/lists"}