remotipart 1.2.1 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +35 -0
- data/Appraisals +25 -0
- data/Gemfile +14 -1
- data/History.rdoc +34 -0
- data/LICENSE +4 -0
- data/README.rdoc +35 -8
- data/Rakefile +5 -7
- data/gemfiles/rails_3.2.gemfile +26 -0
- data/gemfiles/rails_4.2.gemfile +24 -0
- data/gemfiles/rails_5.2.gemfile +24 -0
- data/gemfiles/rails_6.0.gemfile +24 -0
- data/lib/remotipart/middleware.rb +9 -4
- data/lib/remotipart/rails/engine.rb +15 -5
- data/lib/remotipart/rails/railtie.rb +8 -4
- data/lib/remotipart/rails/version.rb +2 -2
- data/lib/remotipart/render_overrides.rb +29 -7
- data/lib/remotipart/request_helper.rb +2 -0
- data/lib/remotipart/view_helper.rb +2 -0
- data/remotipart.gemspec +95 -19
- data/spec/dummy_app/.gitignore +17 -0
- data/spec/dummy_app/Rakefile +7 -0
- data/spec/dummy_app/app/assets/config/manifest.js +4 -0
- data/spec/dummy_app/app/assets/images/rails.png +0 -0
- data/spec/dummy_app/app/assets/javascripts/application.js.erb +8 -0
- data/spec/dummy_app/app/assets/javascripts/comments.js +28 -0
- data/spec/dummy_app/app/assets/stylesheets/application.css +6 -0
- data/spec/dummy_app/app/assets/stylesheets/scaffold.css +65 -0
- data/spec/dummy_app/app/controllers/application_controller.rb +3 -0
- data/spec/dummy_app/app/controllers/comments_controller.rb +72 -0
- data/spec/dummy_app/app/controllers/prepended_controller.rb +9 -0
- data/spec/dummy_app/app/helpers/application_helper.rb +2 -0
- data/spec/dummy_app/app/helpers/comments_helper.rb +2 -0
- data/spec/dummy_app/app/models/comment.rb +7 -0
- data/spec/dummy_app/app/views/comments/_comment.html.erb +9 -0
- data/spec/dummy_app/app/views/comments/_form.html.erb +40 -0
- data/spec/dummy_app/app/views/comments/_new_comment_links.html.erb +5 -0
- data/spec/dummy_app/app/views/comments/create.html.erb +7 -0
- data/spec/dummy_app/app/views/comments/create.js.erb +20 -0
- data/spec/dummy_app/app/views/comments/destroy.js.erb +1 -0
- data/spec/dummy_app/app/views/comments/edit.html.erb +6 -0
- data/spec/dummy_app/app/views/comments/escape_test.html.erb +1 -0
- data/spec/dummy_app/app/views/comments/index.html.erb +19 -0
- data/spec/dummy_app/app/views/comments/new.html.erb +7 -0
- data/spec/dummy_app/app/views/comments/show.html.erb +15 -0
- data/spec/dummy_app/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy_app/app/views/prepended/show.html.erb +1 -0
- data/spec/dummy_app/bin/bundle +3 -0
- data/spec/dummy_app/bin/rails +4 -0
- data/spec/dummy_app/bin/rake +4 -0
- data/spec/dummy_app/bin/setup +34 -0
- data/spec/dummy_app/bin/update +29 -0
- data/spec/dummy_app/config/application.rb +18 -0
- data/spec/dummy_app/config/boot.rb +3 -0
- data/spec/dummy_app/config/database.yml +7 -0
- data/spec/dummy_app/config/environment.rb +5 -0
- data/spec/dummy_app/config/environments/development.rb +54 -0
- data/spec/dummy_app/config/environments/test.rb +53 -0
- data/spec/dummy_app/config/initializers/secret_token.rb +3 -0
- data/spec/dummy_app/config/routes.rb +7 -0
- data/spec/dummy_app/config/secrets.yml +5 -0
- data/spec/dummy_app/config.ru +4 -0
- data/spec/dummy_app/db/migrate/20110209210252_create_comments.rb +14 -0
- data/spec/dummy_app/db/migrate/20110209210315_add_attachment_to_comment.rb +15 -0
- data/spec/dummy_app/db/migrate/20110714205346_add_other_attachment_to_comment.rb +8 -0
- data/spec/dummy_app/db/schema.rb +31 -0
- data/spec/dummy_app/db/seeds.rb +7 -0
- data/spec/features/comments_spec.rb +414 -0
- data/spec/features/prepended_spec.rb +9 -0
- data/spec/fixtures/hi.txt +1 -0
- data/spec/fixtures/qr.jpg +0 -0
- data/spec/spec_helper.rb +40 -0
- data/spec/support/arel_helper.rb +15 -0
- data/spec/support/connection_helper.rb +12 -0
- data/spec/support/integration_helper.rb +28 -0
- data/vendor/assets/javascripts/jquery.iframe-transport.js +41 -27
- data/vendor/assets/javascripts/jquery.remotipart.js +3 -1
- metadata +157 -27
- data/Gemfile.lock +0 -20
data/remotipart.gemspec
CHANGED
@@ -2,30 +2,37 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: remotipart 1.4.4 ruby lib
|
5
6
|
|
6
7
|
Gem::Specification.new do |s|
|
7
|
-
s.name = "remotipart"
|
8
|
-
s.version = "1.
|
8
|
+
s.name = "remotipart".freeze
|
9
|
+
s.version = "1.4.4"
|
9
10
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.
|
12
|
-
s.
|
13
|
-
s.
|
14
|
-
s.
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib".freeze]
|
13
|
+
s.authors = ["Greg Leppert".freeze, "Steve Schwartz".freeze]
|
14
|
+
s.date = "2019-12-29"
|
15
|
+
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
|
16
|
+
s.email = ["greg@formasfunction.com".freeze, "steve@alfajango.com".freeze]
|
15
17
|
s.extra_rdoc_files = [
|
16
18
|
"LICENSE",
|
17
19
|
"README.rdoc"
|
18
20
|
]
|
19
21
|
s.files = [
|
20
22
|
".document",
|
23
|
+
".travis.yml",
|
24
|
+
"Appraisals",
|
21
25
|
"CONTRIBUTING.md",
|
22
26
|
"Gemfile",
|
23
|
-
"Gemfile.lock",
|
24
27
|
"History.rdoc",
|
25
28
|
"LICENSE",
|
26
29
|
"README.rdoc",
|
27
30
|
"Rakefile",
|
28
31
|
"VERSION_COMPATIBILITY.rdoc",
|
32
|
+
"gemfiles/rails_3.2.gemfile",
|
33
|
+
"gemfiles/rails_4.2.gemfile",
|
34
|
+
"gemfiles/rails_5.2.gemfile",
|
35
|
+
"gemfiles/rails_6.0.gemfile",
|
29
36
|
"lib/generators/remotipart/install/install_generator.rb",
|
30
37
|
"lib/remotipart.rb",
|
31
38
|
"lib/remotipart/middleware.rb",
|
@@ -37,27 +44,96 @@ Gem::Specification.new do |s|
|
|
37
44
|
"lib/remotipart/request_helper.rb",
|
38
45
|
"lib/remotipart/view_helper.rb",
|
39
46
|
"remotipart.gemspec",
|
47
|
+
"spec/dummy_app/.gitignore",
|
48
|
+
"spec/dummy_app/Rakefile",
|
49
|
+
"spec/dummy_app/app/assets/config/manifest.js",
|
50
|
+
"spec/dummy_app/app/assets/images/rails.png",
|
51
|
+
"spec/dummy_app/app/assets/javascripts/application.js.erb",
|
52
|
+
"spec/dummy_app/app/assets/javascripts/comments.js",
|
53
|
+
"spec/dummy_app/app/assets/stylesheets/application.css",
|
54
|
+
"spec/dummy_app/app/assets/stylesheets/scaffold.css",
|
55
|
+
"spec/dummy_app/app/controllers/application_controller.rb",
|
56
|
+
"spec/dummy_app/app/controllers/comments_controller.rb",
|
57
|
+
"spec/dummy_app/app/controllers/prepended_controller.rb",
|
58
|
+
"spec/dummy_app/app/helpers/application_helper.rb",
|
59
|
+
"spec/dummy_app/app/helpers/comments_helper.rb",
|
60
|
+
"spec/dummy_app/app/models/comment.rb",
|
61
|
+
"spec/dummy_app/app/views/comments/_comment.html.erb",
|
62
|
+
"spec/dummy_app/app/views/comments/_form.html.erb",
|
63
|
+
"spec/dummy_app/app/views/comments/_new_comment_links.html.erb",
|
64
|
+
"spec/dummy_app/app/views/comments/create.html.erb",
|
65
|
+
"spec/dummy_app/app/views/comments/create.js.erb",
|
66
|
+
"spec/dummy_app/app/views/comments/destroy.js.erb",
|
67
|
+
"spec/dummy_app/app/views/comments/edit.html.erb",
|
68
|
+
"spec/dummy_app/app/views/comments/escape_test.html.erb",
|
69
|
+
"spec/dummy_app/app/views/comments/index.html.erb",
|
70
|
+
"spec/dummy_app/app/views/comments/new.html.erb",
|
71
|
+
"spec/dummy_app/app/views/comments/show.html.erb",
|
72
|
+
"spec/dummy_app/app/views/layouts/application.html.erb",
|
73
|
+
"spec/dummy_app/app/views/prepended/show.html.erb",
|
74
|
+
"spec/dummy_app/bin/bundle",
|
75
|
+
"spec/dummy_app/bin/rails",
|
76
|
+
"spec/dummy_app/bin/rake",
|
77
|
+
"spec/dummy_app/bin/setup",
|
78
|
+
"spec/dummy_app/bin/update",
|
79
|
+
"spec/dummy_app/config.ru",
|
80
|
+
"spec/dummy_app/config/application.rb",
|
81
|
+
"spec/dummy_app/config/boot.rb",
|
82
|
+
"spec/dummy_app/config/database.yml",
|
83
|
+
"spec/dummy_app/config/environment.rb",
|
84
|
+
"spec/dummy_app/config/environments/development.rb",
|
85
|
+
"spec/dummy_app/config/environments/test.rb",
|
86
|
+
"spec/dummy_app/config/initializers/secret_token.rb",
|
87
|
+
"spec/dummy_app/config/routes.rb",
|
88
|
+
"spec/dummy_app/config/secrets.yml",
|
89
|
+
"spec/dummy_app/db/migrate/20110209210252_create_comments.rb",
|
90
|
+
"spec/dummy_app/db/migrate/20110209210315_add_attachment_to_comment.rb",
|
91
|
+
"spec/dummy_app/db/migrate/20110714205346_add_other_attachment_to_comment.rb",
|
92
|
+
"spec/dummy_app/db/schema.rb",
|
93
|
+
"spec/dummy_app/db/seeds.rb",
|
94
|
+
"spec/features/comments_spec.rb",
|
95
|
+
"spec/features/prepended_spec.rb",
|
96
|
+
"spec/fixtures/hi.txt",
|
97
|
+
"spec/fixtures/qr.jpg",
|
98
|
+
"spec/spec_helper.rb",
|
99
|
+
"spec/support/arel_helper.rb",
|
100
|
+
"spec/support/connection_helper.rb",
|
101
|
+
"spec/support/integration_helper.rb",
|
40
102
|
"vendor/assets/javascripts/jquery.iframe-transport.js",
|
41
103
|
"vendor/assets/javascripts/jquery.remotipart.js"
|
42
104
|
]
|
43
|
-
s.homepage = "http://opensource.alfajango.com/remotipart/"
|
44
|
-
s.
|
45
|
-
s.
|
46
|
-
s.summary = "Remotipart is a Ruby on Rails gem enabling remote multipart forms (AJAX style file uploads) with jquery-rails."
|
105
|
+
s.homepage = "http://opensource.alfajango.com/remotipart/".freeze
|
106
|
+
s.rubygems_version = "3.0.3".freeze
|
107
|
+
s.summary = "Remotipart is a Ruby on Rails gem enabling remote multipart forms (AJAX style file uploads) with jquery-rails.".freeze
|
47
108
|
|
48
109
|
if s.respond_to? :specification_version then
|
49
|
-
s.specification_version =
|
110
|
+
s.specification_version = 4
|
50
111
|
|
51
112
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
52
|
-
s.add_development_dependency(%q<rake
|
53
|
-
s.add_development_dependency(%q<jeweler
|
113
|
+
s.add_development_dependency(%q<rake>.freeze, [">= 0"])
|
114
|
+
s.add_development_dependency(%q<jeweler>.freeze, [">= 0"])
|
115
|
+
s.add_development_dependency(%q<appraisal>.freeze, [">= 0"])
|
116
|
+
s.add_development_dependency(%q<jquery-rails>.freeze, [">= 0"])
|
117
|
+
s.add_development_dependency(%q<sqlite3>.freeze, [">= 0"])
|
118
|
+
s.add_development_dependency(%q<paperclip>.freeze, [">= 0"])
|
119
|
+
s.add_development_dependency(%q<remotipart>.freeze, [">= 0"])
|
54
120
|
else
|
55
|
-
s.add_dependency(%q<rake
|
56
|
-
s.add_dependency(%q<jeweler
|
121
|
+
s.add_dependency(%q<rake>.freeze, [">= 0"])
|
122
|
+
s.add_dependency(%q<jeweler>.freeze, [">= 0"])
|
123
|
+
s.add_dependency(%q<appraisal>.freeze, [">= 0"])
|
124
|
+
s.add_dependency(%q<jquery-rails>.freeze, [">= 0"])
|
125
|
+
s.add_dependency(%q<sqlite3>.freeze, [">= 0"])
|
126
|
+
s.add_dependency(%q<paperclip>.freeze, [">= 0"])
|
127
|
+
s.add_dependency(%q<remotipart>.freeze, [">= 0"])
|
57
128
|
end
|
58
129
|
else
|
59
|
-
s.add_dependency(%q<rake
|
60
|
-
s.add_dependency(%q<jeweler
|
130
|
+
s.add_dependency(%q<rake>.freeze, [">= 0"])
|
131
|
+
s.add_dependency(%q<jeweler>.freeze, [">= 0"])
|
132
|
+
s.add_dependency(%q<appraisal>.freeze, [">= 0"])
|
133
|
+
s.add_dependency(%q<jquery-rails>.freeze, [">= 0"])
|
134
|
+
s.add_dependency(%q<sqlite3>.freeze, [">= 0"])
|
135
|
+
s.add_dependency(%q<paperclip>.freeze, [">= 0"])
|
136
|
+
s.add_dependency(%q<remotipart>.freeze, [">= 0"])
|
61
137
|
end
|
62
138
|
end
|
63
139
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile ~/.gitignore_global
|
6
|
+
|
7
|
+
# Ignore bundler config
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore the default SQLite database.
|
11
|
+
/db/*.sqlite3
|
12
|
+
|
13
|
+
# Ignore all logfiles and tempfiles.
|
14
|
+
/log/*.log
|
15
|
+
/tmp
|
16
|
+
|
17
|
+
/public/system
|
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
DummyApp::Application.load_tasks
|
Binary file
|
@@ -0,0 +1,8 @@
|
|
1
|
+
// FIXME: Tell people that this is a manifest file, real code should go into discrete files
|
2
|
+
// FIXME: Tell people how Sprockets and CoffeeScript works
|
3
|
+
//
|
4
|
+
<% require_asset "jquery#{ENV['JQUERY_VERSION']}" %>
|
5
|
+
<% require_asset "jquery_ujs" %>
|
6
|
+
<% require_asset "jquery.remotipart" %>
|
7
|
+
<% require_asset "comments" %>
|
8
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
$(document)
|
2
|
+
.delegate('#new-comment-link, #new-comment-attachment-link', 'ajax:success', function(e, data, status, xhr){
|
3
|
+
var $this = $(this),
|
4
|
+
$container = $('#new-comment-links'),
|
5
|
+
$responseText = $(xhr.responseText),
|
6
|
+
$cancelButton = $responseText.find('#cancel-button');
|
7
|
+
$container.replaceWith($responseText)
|
8
|
+
$cancelButton.click(function(e){
|
9
|
+
$cancelButton.parent().replaceWith($container);
|
10
|
+
e.preventDefault();
|
11
|
+
});
|
12
|
+
})
|
13
|
+
.delegate('form[data-remote]', 'ajax:aborted:required', function(){
|
14
|
+
var $form = $(this),
|
15
|
+
errorDivId = 'ajax-validation-errors',
|
16
|
+
$errorDiv = $form.find('#' + errorDivId);
|
17
|
+
if ( ! $errorDiv.length ) {
|
18
|
+
$errorDiv = $('<div>', { id: errorDivId});
|
19
|
+
$form.prepend($errorDiv)
|
20
|
+
}
|
21
|
+
$errorDiv.html($('<h2>', {
|
22
|
+
text: 'You must fill in all required fields!'
|
23
|
+
}));
|
24
|
+
})
|
25
|
+
.delegate('form[data-remote]', 'ajax:error', function(e, xhr, status, statusText) {
|
26
|
+
$('#comments').after('Error status code: ' + xhr.status + ', Error status message: ' + statusText);
|
27
|
+
});
|
28
|
+
|
@@ -0,0 +1,65 @@
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
2
|
+
|
3
|
+
body, p, ol, ul, td {
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
+
font-size: 13px;
|
6
|
+
line-height: 18px;
|
7
|
+
}
|
8
|
+
|
9
|
+
pre {
|
10
|
+
background-color: #eee;
|
11
|
+
padding: 10px;
|
12
|
+
font-size: 11px;
|
13
|
+
}
|
14
|
+
|
15
|
+
a { color: #000; }
|
16
|
+
a:visited { color: #666; }
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
18
|
+
|
19
|
+
div.field, div.actions {
|
20
|
+
margin-bottom: 10px;
|
21
|
+
}
|
22
|
+
|
23
|
+
#notice {
|
24
|
+
color: green;
|
25
|
+
}
|
26
|
+
|
27
|
+
legend.required:before {
|
28
|
+
content: "*";
|
29
|
+
color: red;
|
30
|
+
}
|
31
|
+
label.required:after {
|
32
|
+
content: "*";
|
33
|
+
color: red;
|
34
|
+
}
|
35
|
+
|
36
|
+
.field_with_errors {
|
37
|
+
padding: 2px;
|
38
|
+
background-color: red;
|
39
|
+
display: table;
|
40
|
+
}
|
41
|
+
|
42
|
+
#error_explanation, #ajax-validation-errors {
|
43
|
+
width: 450px;
|
44
|
+
border: 2px solid red;
|
45
|
+
padding: 7px;
|
46
|
+
padding-bottom: 0;
|
47
|
+
margin-bottom: 20px;
|
48
|
+
background-color: #f0f0f0;
|
49
|
+
}
|
50
|
+
|
51
|
+
#error_explanation h2, #ajax-validation-errors h2{
|
52
|
+
text-align: left;
|
53
|
+
font-weight: bold;
|
54
|
+
padding: 5px 5px 5px 15px;
|
55
|
+
font-size: 12px;
|
56
|
+
margin: -7px;
|
57
|
+
margin-bottom: 0px;
|
58
|
+
background-color: #c00;
|
59
|
+
color: #fff;
|
60
|
+
}
|
61
|
+
|
62
|
+
#error_explanation ul li {
|
63
|
+
font-size: 12px;
|
64
|
+
list-style: square;
|
65
|
+
}
|
@@ -0,0 +1,72 @@
|
|
1
|
+
class CommentsController < ApplicationController
|
2
|
+
def index
|
3
|
+
@comments = Comment.all
|
4
|
+
respond_to do |format|
|
5
|
+
format.html
|
6
|
+
format.json { render json: @comments }
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def show
|
11
|
+
@comment = Comment.find(params[:id])
|
12
|
+
respond_to do |format|
|
13
|
+
format.html
|
14
|
+
format.json { render json: @comment }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def new
|
19
|
+
@comment = Comment.new
|
20
|
+
respond_to do |format|
|
21
|
+
format.html { render :layout => ! request.xhr? }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def edit
|
26
|
+
@comment = Comment.find(params[:id])
|
27
|
+
respond_to do |format|
|
28
|
+
format.html
|
29
|
+
format.json { render json: @comment }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def create
|
34
|
+
@comment = Comment.create(comment_params)
|
35
|
+
if request.xhr? || remotipart_submitted?
|
36
|
+
sleep 1 if params[:pause]
|
37
|
+
respond_to do |format|
|
38
|
+
format.html { render (params[:template] == 'escape' ? 'comments/escape_test' : 'comments/create'), layout: false }
|
39
|
+
format.js { render 'comments/create', layout: false, status:(@comment.errors.any? ? :unprocessable_entity : :ok) }
|
40
|
+
format.json { render json: @comment }
|
41
|
+
end
|
42
|
+
else
|
43
|
+
redirect_to comments_path
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def update
|
48
|
+
@comment = Comment.find(params[:id])
|
49
|
+
respond_to do |format|
|
50
|
+
format.html { redirect_to @comment }
|
51
|
+
format.js { render json: @comment }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def destroy
|
56
|
+
@comment = Comment.destroy(params[:id])
|
57
|
+
end
|
58
|
+
|
59
|
+
def say
|
60
|
+
if Rails.version < '4'
|
61
|
+
render text: params[:message], content_type: 'text/plain'
|
62
|
+
else
|
63
|
+
render plain: params[:message]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def comment_params
|
70
|
+
params.require(:comment).permit(:subject, :body, :attachment, :other_attachment)
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
class Comment < ActiveRecord::Base
|
2
|
+
has_attached_file :attachment
|
3
|
+
has_attached_file :other_attachment
|
4
|
+
validates :subject, :body, :presence => true
|
5
|
+
validates_attachment :attachment, content_type: { content_type: /\Aimage\/.*\Z/ }
|
6
|
+
validates_attachment :other_attachment, content_type: { content_type: 'text/plain' }
|
7
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<tr class='comment' id='comment-<%= comment.id %>'>
|
2
|
+
<td><%= comment.subject %></td>
|
3
|
+
<td><%= comment.body %></td>
|
4
|
+
<td><%= link_to comment.attachment_file_name, comment.attachment.url if comment.attachment? %></td>
|
5
|
+
<td><%= link_to comment.other_attachment_file_name, comment.other_attachment.url if comment.other_attachment? %></td>
|
6
|
+
<td><%= link_to 'Show', comment %></td>
|
7
|
+
<td><%= link_to 'Edit', edit_comment_path(comment) %></td>
|
8
|
+
<td><%= link_to 'Destroy', comment, :data => {:confirm => 'Are you sure?'}, :method => :delete, :remote => true %></td>
|
9
|
+
</tr>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<%= form_for(@comment, :remote => (params[:action] == 'new' ? true : false)) do |f| %>
|
2
|
+
<% if @comment.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(@comment.errors.count, "error") %> prohibited this comment from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @comment.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%= msg %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<fieldset>
|
15
|
+
<legend class='required'>
|
16
|
+
Required fields
|
17
|
+
</legend>
|
18
|
+
<div class="field">
|
19
|
+
<%= f.label :subject, :class => 'required' %><br />
|
20
|
+
<%= f.text_field :subject, :required => true %>
|
21
|
+
</div>
|
22
|
+
<div class="field">
|
23
|
+
<%= f.label :body, :class => 'required' %><br />
|
24
|
+
<%= f.text_area :body, :required => true %>
|
25
|
+
</div>
|
26
|
+
<% if params[:attachment] %>
|
27
|
+
<div class="field">
|
28
|
+
<%= f.label :attachment %><br />
|
29
|
+
<%= f.file_field :attachment %>
|
30
|
+
</div>
|
31
|
+
<div class="field">
|
32
|
+
<%= f.label :other_attachment %><br />
|
33
|
+
<%= f.file_field :other_attachment %>
|
34
|
+
</div>
|
35
|
+
<% end %>
|
36
|
+
</fieldset>
|
37
|
+
<div class="actions">
|
38
|
+
<%= f.submit :data => {disable_with: "Submitting..."} %>
|
39
|
+
</div>
|
40
|
+
<% end %>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<div id='new-comment-links'>
|
2
|
+
<%= link_to 'New Comment', new_comment_path, :remote => true, :'data-type' => 'html', :id => 'new-comment-link' %>
|
3
|
+
<br />
|
4
|
+
<%= link_to 'New Comment with Attachment', new_comment_path(:attachment => true), :remote => true, :'data-type' => 'html', :id => 'new-comment-attachment-link' %>
|
5
|
+
</div>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<%= remotipart_response do %>
|
2
|
+
<% unless @comment.errors.any? %>
|
3
|
+
$('#comments').append( '<%= escape_javascript(
|
4
|
+
render @comment
|
5
|
+
) %>' );
|
6
|
+
$('#new-comment-form-container').find('input:not(:submit),select,textarea').val('');
|
7
|
+
<% if request.put? %>
|
8
|
+
$('#comments').after('PUT request!');
|
9
|
+
<% end %>
|
10
|
+
<% else %>
|
11
|
+
var $form = $('#new_comment'),
|
12
|
+
$errorDiv = $('<div id="error_explanation">'),
|
13
|
+
$errorList = $('<ul>');
|
14
|
+
<% @comment.errors.full_messages.each do |msg| %>
|
15
|
+
$errorList.append('<li><%= escape_javascript msg %></li>');
|
16
|
+
<% end %>
|
17
|
+
$form.find('#error_explanation').remove();
|
18
|
+
$form.prepend($errorDiv.append($errorList));
|
19
|
+
<% end %>
|
20
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
$('#comment-<%= @comment.id %>').remove();
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= text_field_tag :quote, '"' %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<h1>Listing comments</h1>
|
2
|
+
|
3
|
+
<table id='comments'>
|
4
|
+
<tr>
|
5
|
+
<th>Subject</th>
|
6
|
+
<th>Body</th>
|
7
|
+
<th>Attachment</td>
|
8
|
+
<th>Other Attachment</td>
|
9
|
+
<th></th>
|
10
|
+
<th></th>
|
11
|
+
<th></th>
|
12
|
+
</tr>
|
13
|
+
|
14
|
+
<%= render @comments %>
|
15
|
+
</table>
|
16
|
+
|
17
|
+
<br />
|
18
|
+
|
19
|
+
<%= render 'new_comment_links' %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<p>prepended</p>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
require 'fileutils'
|
4
|
+
include FileUtils
|
5
|
+
|
6
|
+
# path to your application root.
|
7
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
8
|
+
|
9
|
+
def system!(*args)
|
10
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
11
|
+
end
|
12
|
+
|
13
|
+
chdir APP_ROOT do
|
14
|
+
# This script is a starting point to setup your application.
|
15
|
+
# Add necessary setup steps to this file.
|
16
|
+
|
17
|
+
puts '== Installing dependencies =='
|
18
|
+
system! 'gem install bundler --conservative'
|
19
|
+
system('bundle check') or system!('bundle install')
|
20
|
+
|
21
|
+
# puts "\n== Copying sample files =="
|
22
|
+
# unless File.exist?('config/database.yml')
|
23
|
+
# cp 'config/database.yml.sample', 'config/database.yml'
|
24
|
+
# end
|
25
|
+
|
26
|
+
puts "\n== Preparing database =="
|
27
|
+
system! 'bin/rails db:setup'
|
28
|
+
|
29
|
+
puts "\n== Removing old logs and tempfiles =="
|
30
|
+
system! 'bin/rails log:clear tmp:clear'
|
31
|
+
|
32
|
+
puts "\n== Restarting application server =="
|
33
|
+
system! 'bin/rails restart'
|
34
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
require 'fileutils'
|
4
|
+
include FileUtils
|
5
|
+
|
6
|
+
# path to your application root.
|
7
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
8
|
+
|
9
|
+
def system!(*args)
|
10
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
11
|
+
end
|
12
|
+
|
13
|
+
chdir APP_ROOT do
|
14
|
+
# This script is a way to update your development environment automatically.
|
15
|
+
# Add necessary update steps to this file.
|
16
|
+
|
17
|
+
puts '== Installing dependencies =='
|
18
|
+
system! 'gem install bundler --conservative'
|
19
|
+
system 'bundle check' or system! 'bundle install'
|
20
|
+
|
21
|
+
puts "\n== Updating database =="
|
22
|
+
system! 'bin/rails db:migrate'
|
23
|
+
|
24
|
+
puts "\n== Removing old logs and tempfiles =="
|
25
|
+
system! 'bin/rails log:clear tmp:clear'
|
26
|
+
|
27
|
+
puts "\n== Restarting application server =="
|
28
|
+
system! 'bin/rails restart'
|
29
|
+
end
|