uploadbox 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +42 -0
- data/Rakefile +6 -12
- data/app/controllers/uploadbox/images_controller.rb +2 -0
- data/app/models/image.rb +3 -0
- data/app/views/uploadbox/images/_uploader.html.slim +16 -9
- data/lib/generators/uploadbox/image/image_generator.rb +2 -0
- data/lib/uploadbox/engine.rb +20 -2
- data/lib/uploadbox/image_uploader.rb +27 -8
- data/lib/uploadbox/version.rb +1 -1
- metadata +52 -107
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/Rakefile +0 -6
- data/test/dummy/app/assets/javascripts/application.coffee +0 -3
- data/test/dummy/app/assets/stylesheets/application.sass +0 -2
- data/test/dummy/app/assets/stylesheets/scaffold.css +0 -56
- data/test/dummy/app/controllers/application_controller.rb +0 -5
- data/test/dummy/app/controllers/posts_controller.rb +0 -61
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/helpers/home_helper.rb +0 -2
- data/test/dummy/app/helpers/posts_helper.rb +0 -2
- data/test/dummy/app/models/post.rb +0 -3
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/app/views/posts/_form.slim +0 -26
- data/test/dummy/app/views/posts/edit.html.erb +0 -6
- data/test/dummy/app/views/posts/index.html.erb +0 -32
- data/test/dummy/app/views/posts/new.html.erb +0 -5
- data/test/dummy/app/views/posts/show.html.erb +0 -21
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/bin/rails +0 -4
- data/test/dummy/bin/rake +0 -4
- data/test/dummy/config/application.rb +0 -23
- data/test/dummy/config/boot.rb +0 -5
- data/test/dummy/config/database.yml +0 -25
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -11
- data/test/dummy/config/environments/production.rb +0 -80
- data/test/dummy/config/environments/test.rb +0 -36
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/secret_token.rb +0 -12
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -23
- data/test/dummy/config/routes.rb +0 -6
- data/test/dummy/config.ru +0 -4
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20130624130249_create_posts.rb +0 -10
- data/test/dummy/db/schema.rb +0 -33
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +0 -20837
- data/test/dummy/public/404.html +0 -58
- data/test/dummy/public/422.html +0 -58
- data/test/dummy/public/500.html +0 -57
- data/test/dummy/public/favicon.ico +0 -0
- data/test/integration/navigation_test.rb +0 -10
- data/test/test_helper.rb +0 -15
- data/test/uploadbox_test.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bde58e89daaa9aaa9c7dd01ef81d9b07281b1adb
|
4
|
+
data.tar.gz: da4528b93e337d1d0af19ab7efc1af1113aa2aed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d14891638c745bcdc4ef404b79527ed542426e17b47379a6b3aa541c46deec78572ef3c0f4d43df6f72b11cb8cb733e0d3e5fa67d65c52d7f320d02663e5075
|
7
|
+
data.tar.gz: 32515e040f6aa705d146bac3242c651b62326e8358c733389e2df2a9e80712ef73b864e4b7d9bd929462875a5c4ff5a760d3f2ab3eaeb014220f9f91cc097755
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# Do not use (not yet released)
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add to Gemfile
|
6
|
+
`gem 'uploadbox'`
|
7
|
+
|
8
|
+
Run generators
|
9
|
+
`rails g uploadbox:image`
|
10
|
+
|
11
|
+
Add jquery and uploadbox to `application.js`
|
12
|
+
```
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require uploadbox
|
16
|
+
```
|
17
|
+
|
18
|
+
Add uploadbox to `application.css`
|
19
|
+
```
|
20
|
+
/*
|
21
|
+
*= require uploadbox
|
22
|
+
*/
|
23
|
+
```
|
24
|
+
|
25
|
+
Migrate database
|
26
|
+
`rake db:migrate`
|
27
|
+
|
28
|
+
Update `routes.rb`
|
29
|
+
`mount Uploadbox::Engine => '/uploadbox', as: :uploadbox`
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
Add `uploads_one` to your model
|
33
|
+
`uploads_one :picture, thumb: [100, 100], regular: [300, 200]`
|
34
|
+
|
35
|
+
Add field to form
|
36
|
+
`<%= f.uploader :picture %>`
|
37
|
+
|
38
|
+
Attach upload on controller
|
39
|
+
`@post.attach_picture(params[:picture_id])`
|
40
|
+
|
41
|
+
Show image
|
42
|
+
`<%= img @post.picture.regular if @post.picture? %>`
|
data/Rakefile
CHANGED
@@ -14,21 +14,15 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
14
14
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
15
|
end
|
16
16
|
|
17
|
-
APP_RAKEFILE = File.expand_path("../
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
18
|
load 'rails/tasks/engine.rake'
|
19
19
|
|
20
20
|
|
21
21
|
|
22
22
|
Bundler::GemHelper.install_tasks
|
23
23
|
|
24
|
-
require '
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
t.pattern = 'test/**/*_test.rb'
|
30
|
-
t.verbose = false
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
task default: :test
|
24
|
+
require 'rspec/core'
|
25
|
+
require 'rspec/core/rake_task'
|
26
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
27
|
+
RSpec::Core::RakeTask.new(spec: 'app:db:test:prepare')
|
28
|
+
task default: :spec
|
data/app/models/image.rb
CHANGED
@@ -2,7 +2,10 @@ class Image < ActiveRecord::Base
|
|
2
2
|
belongs_to :imageable, polymorphic: true
|
3
3
|
|
4
4
|
def self.create_upload(attributes)
|
5
|
+
attributes[:imageable_type].constantize # load class
|
6
|
+
|
5
7
|
upload_class_name = attributes[:imageable_type] + attributes[:upload_name].camelize
|
8
|
+
attributes.delete(:upload_name)
|
6
9
|
Uploadbox.const_get(upload_class_name).create!(attributes)
|
7
10
|
end
|
8
11
|
end
|
@@ -1,18 +1,25 @@
|
|
1
1
|
= form.fields_for :image do
|
2
2
|
div data-component="ImageUploader"
|
3
|
-
|
4
|
-
|
3
|
+
- if namespace
|
4
|
+
input name="[#{namespace}]#{upload_name}_id" data-item="id" type="hidden"
|
5
|
+
- else
|
6
|
+
input name="#{upload_name}_id" data-item="id" type="hidden"
|
7
|
+
.fileupload data-provides="fileupload" class="fileupload-#{(resource.send(upload_name).present? or default) ? 'exists' : 'new'}"
|
5
8
|
.fileupload-preview.thumbnail data-version="#{version}" data-width="#{width}" data-height="#{height}" style="width: #{width}px; height: #{height}px;"
|
6
|
-
|
9
|
+
- if resource.send(upload_name).present?
|
10
|
+
= img resource.send(upload_name).send(version)
|
11
|
+
- elsif default
|
12
|
+
= image_tag default, width: width, height: height
|
7
13
|
div
|
8
14
|
span.btn.btn-file
|
9
|
-
span.fileupload-new
|
10
|
-
span.fileupload-exists
|
15
|
+
span.fileupload-new = choose_label
|
16
|
+
span.fileupload-exists = update_label
|
11
17
|
input type="file" data-url="#{uploadbox.images_path}" name="image[file]"
|
12
18
|
input type="hidden" name="image[imageable_type]" value="#{resource.class}"
|
13
19
|
input type="hidden" name="image[upload_name]" value="#{upload_name}"
|
14
|
-
- if
|
15
|
-
|
16
|
-
|
17
|
-
|
20
|
+
- if removable
|
21
|
+
- if resource.send(upload_name).present?
|
22
|
+
= link_to destroy_label, uploadbox.image_path(resource.send(upload_name)), class: 'btn fileupload-exists', remote: true, method: :delete
|
23
|
+
- else
|
24
|
+
= link_to destroy_label, '#', class: 'btn fileupload-exists', remote: true, method: :delete
|
18
25
|
|
data/lib/uploadbox/engine.rb
CHANGED
@@ -9,6 +9,13 @@ require 'jbuilder'
|
|
9
9
|
|
10
10
|
module Uploadbox
|
11
11
|
class Engine < ::Rails::Engine
|
12
|
+
config.generators do |g|
|
13
|
+
g.test_framework :rspec, fixture: false, view_specs: false
|
14
|
+
g.fixture_replacement :factory_girl, dir: 'spec/factories'
|
15
|
+
g.assets false
|
16
|
+
g.helper false
|
17
|
+
end
|
18
|
+
|
12
19
|
initializer 'uploadbox.action_controller' do |app|
|
13
20
|
ActiveSupport.on_load :action_controller do
|
14
21
|
helper Uploadbox::ImgHelper
|
@@ -21,7 +28,12 @@ end
|
|
21
28
|
class ActionView::Helpers::FormBuilder
|
22
29
|
def uploader(upload_name, options={})
|
23
30
|
upload_model_class = "Uploadbox::#{@object.class.to_s + upload_name.to_s.camelize}".constantize
|
24
|
-
options.reverse_merge!(preview: upload_model_class.versions.keys.first
|
31
|
+
options.reverse_merge!(preview: upload_model_class.versions.keys.first,
|
32
|
+
namespace: false,
|
33
|
+
default: false,
|
34
|
+
update_label: 'Alterar',
|
35
|
+
choose_label: 'Escolher',
|
36
|
+
destroy_label: 'Excluir')
|
25
37
|
dimensions = upload_model_class.versions[options[:preview]]
|
26
38
|
@template.render partial: 'uploadbox/images/uploader', locals: {
|
27
39
|
upload_name: upload_name,
|
@@ -29,7 +41,13 @@ class ActionView::Helpers::FormBuilder
|
|
29
41
|
form: self,
|
30
42
|
version: options[:preview],
|
31
43
|
width: dimensions[0],
|
32
|
-
height: dimensions[1]
|
44
|
+
height: dimensions[1],
|
45
|
+
namespace: options[:namespace],
|
46
|
+
default: options[:default],
|
47
|
+
removable: upload_model_class.removable?,
|
48
|
+
update_label: options[:update_label],
|
49
|
+
choose_label: options[:choose_label],
|
50
|
+
destroy_label: options[:destroy_label]
|
33
51
|
}
|
34
52
|
end
|
35
53
|
end
|
@@ -3,6 +3,7 @@ module Uploadbox
|
|
3
3
|
def uploads_one(upload_name, options={})
|
4
4
|
default_options = {
|
5
5
|
default: false,
|
6
|
+
removable: true,
|
6
7
|
retina: Uploadbox.retina,
|
7
8
|
quality: Uploadbox.retina ? (Uploadbox.retina_quality || 40) : (Uploadbox.image_quality || 80)
|
8
9
|
}
|
@@ -15,27 +16,45 @@ module Uploadbox
|
|
15
16
|
upload_class = Class.new(Image)
|
16
17
|
Uploadbox.const_set(upload_class_name, upload_class)
|
17
18
|
|
18
|
-
# picture?
|
19
|
+
# @post.picture?
|
19
20
|
define_method("#{upload_name}?") { send(upload_name) and send(upload_name).file? }
|
20
21
|
|
21
|
-
# attach_picture
|
22
|
+
# @post.attach_picture
|
22
23
|
define_method("attach_#{upload_name}") do |upload_id|
|
23
24
|
if upload_id.present?
|
24
25
|
self.send("attach_#{upload_name}!", upload_id)
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
|
-
# attach_picture!
|
29
|
+
# @post.attach_picture!
|
29
30
|
define_method("attach_#{upload_name}!") do |upload_id|
|
30
31
|
self.send("#{upload_name}=", upload_class.find(upload_id))
|
31
32
|
end
|
32
33
|
|
34
|
+
# Post.update_picture_versions!
|
35
|
+
self.define_singleton_method "update_#{upload_name}_versions!" do
|
36
|
+
Uploadbox.const_get(upload_class_name).find_each{|upload| upload.file.recreate_versions!}
|
37
|
+
end
|
38
|
+
|
33
39
|
# Uploadbox::PostPicture < Image
|
34
|
-
upload_class.
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
40
|
+
upload_class.define_singleton_method :versions do
|
41
|
+
upload_versions
|
42
|
+
end
|
43
|
+
|
44
|
+
upload_class.define_singleton_method :removable? do
|
45
|
+
options[:removable]
|
46
|
+
end
|
47
|
+
|
48
|
+
# Uploadbox::PostPicture < Image
|
49
|
+
# upload_class.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
50
|
+
# def self.versions
|
51
|
+
# #{upload_versions}
|
52
|
+
# end
|
53
|
+
|
54
|
+
# def self.removable?
|
55
|
+
# #{options[:removable]}
|
56
|
+
# end
|
57
|
+
# RUBY
|
39
58
|
|
40
59
|
upload_class.instance_eval do
|
41
60
|
delegate *upload_versions.keys, to: :file
|
data/lib/uploadbox/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uploadbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julio Protzek
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: 2.0.0
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - ~>
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: 2.0.0
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: sass-rails
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -183,16 +183,58 @@ dependencies:
|
|
183
183
|
name: sqlite3
|
184
184
|
requirement: !ruby/object:Gem::Requirement
|
185
185
|
requirements:
|
186
|
-
- -
|
186
|
+
- - ~>
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: 1.3.7
|
189
|
+
type: :development
|
190
|
+
prerelease: false
|
191
|
+
version_requirements: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - ~>
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: 1.3.7
|
196
|
+
- !ruby/object:Gem::Dependency
|
197
|
+
name: rspec-rails
|
198
|
+
requirement: !ruby/object:Gem::Requirement
|
199
|
+
requirements:
|
200
|
+
- - ~>
|
187
201
|
- !ruby/object:Gem::Version
|
188
|
-
version:
|
202
|
+
version: 2.14.0
|
189
203
|
type: :development
|
190
204
|
prerelease: false
|
191
205
|
version_requirements: !ruby/object:Gem::Requirement
|
192
206
|
requirements:
|
193
|
-
- -
|
207
|
+
- - ~>
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: 2.14.0
|
210
|
+
- !ruby/object:Gem::Dependency
|
211
|
+
name: capybara
|
212
|
+
requirement: !ruby/object:Gem::Requirement
|
213
|
+
requirements:
|
214
|
+
- - ~>
|
215
|
+
- !ruby/object:Gem::Version
|
216
|
+
version: 2.1.0
|
217
|
+
type: :development
|
218
|
+
prerelease: false
|
219
|
+
version_requirements: !ruby/object:Gem::Requirement
|
220
|
+
requirements:
|
221
|
+
- - ~>
|
222
|
+
- !ruby/object:Gem::Version
|
223
|
+
version: 2.1.0
|
224
|
+
- !ruby/object:Gem::Dependency
|
225
|
+
name: factory_girl_rails
|
226
|
+
requirement: !ruby/object:Gem::Requirement
|
227
|
+
requirements:
|
228
|
+
- - ~>
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: 4.2.1
|
231
|
+
type: :development
|
232
|
+
prerelease: false
|
233
|
+
version_requirements: !ruby/object:Gem::Requirement
|
234
|
+
requirements:
|
235
|
+
- - ~>
|
194
236
|
- !ruby/object:Gem::Version
|
195
|
-
version:
|
237
|
+
version: 4.2.1
|
196
238
|
description: Uploadbox makes easy to manage files in your Rails application.
|
197
239
|
email:
|
198
240
|
- julio@startae.com.br
|
@@ -232,55 +274,7 @@ files:
|
|
232
274
|
- lib/uploadbox.rb
|
233
275
|
- MIT-LICENSE
|
234
276
|
- Rakefile
|
235
|
-
-
|
236
|
-
- test/dummy/app/assets/stylesheets/application.sass
|
237
|
-
- test/dummy/app/assets/stylesheets/scaffold.css
|
238
|
-
- test/dummy/app/controllers/application_controller.rb
|
239
|
-
- test/dummy/app/controllers/posts_controller.rb
|
240
|
-
- test/dummy/app/helpers/application_helper.rb
|
241
|
-
- test/dummy/app/helpers/home_helper.rb
|
242
|
-
- test/dummy/app/helpers/posts_helper.rb
|
243
|
-
- test/dummy/app/models/post.rb
|
244
|
-
- test/dummy/app/views/layouts/application.html.erb
|
245
|
-
- test/dummy/app/views/posts/_form.slim
|
246
|
-
- test/dummy/app/views/posts/edit.html.erb
|
247
|
-
- test/dummy/app/views/posts/index.html.erb
|
248
|
-
- test/dummy/app/views/posts/new.html.erb
|
249
|
-
- test/dummy/app/views/posts/show.html.erb
|
250
|
-
- test/dummy/bin/bundle
|
251
|
-
- test/dummy/bin/rails
|
252
|
-
- test/dummy/bin/rake
|
253
|
-
- test/dummy/config/application.rb
|
254
|
-
- test/dummy/config/boot.rb
|
255
|
-
- test/dummy/config/database.yml
|
256
|
-
- test/dummy/config/environment.rb
|
257
|
-
- test/dummy/config/environments/development.rb
|
258
|
-
- test/dummy/config/environments/production.rb
|
259
|
-
- test/dummy/config/environments/test.rb
|
260
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
261
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
262
|
-
- test/dummy/config/initializers/inflections.rb
|
263
|
-
- test/dummy/config/initializers/mime_types.rb
|
264
|
-
- test/dummy/config/initializers/secret_token.rb
|
265
|
-
- test/dummy/config/initializers/session_store.rb
|
266
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
267
|
-
- test/dummy/config/locales/en.yml
|
268
|
-
- test/dummy/config/routes.rb
|
269
|
-
- test/dummy/config.ru
|
270
|
-
- test/dummy/db/development.sqlite3
|
271
|
-
- test/dummy/db/migrate/20130624130249_create_posts.rb
|
272
|
-
- test/dummy/db/schema.rb
|
273
|
-
- test/dummy/db/test.sqlite3
|
274
|
-
- test/dummy/log/development.log
|
275
|
-
- test/dummy/public/404.html
|
276
|
-
- test/dummy/public/422.html
|
277
|
-
- test/dummy/public/500.html
|
278
|
-
- test/dummy/public/favicon.ico
|
279
|
-
- test/dummy/Rakefile
|
280
|
-
- test/dummy/README.rdoc
|
281
|
-
- test/integration/navigation_test.rb
|
282
|
-
- test/test_helper.rb
|
283
|
-
- test/uploadbox_test.rb
|
277
|
+
- README.md
|
284
278
|
homepage: https://github.com/startae/uploadbox
|
285
279
|
licenses:
|
286
280
|
- MIT
|
@@ -305,53 +299,4 @@ rubygems_version: 2.0.4
|
|
305
299
|
signing_key:
|
306
300
|
specification_version: 4
|
307
301
|
summary: Ajax file uploader for Rails applications.
|
308
|
-
test_files:
|
309
|
-
- test/dummy/app/assets/javascripts/application.coffee
|
310
|
-
- test/dummy/app/assets/stylesheets/application.sass
|
311
|
-
- test/dummy/app/assets/stylesheets/scaffold.css
|
312
|
-
- test/dummy/app/controllers/application_controller.rb
|
313
|
-
- test/dummy/app/controllers/posts_controller.rb
|
314
|
-
- test/dummy/app/helpers/application_helper.rb
|
315
|
-
- test/dummy/app/helpers/home_helper.rb
|
316
|
-
- test/dummy/app/helpers/posts_helper.rb
|
317
|
-
- test/dummy/app/models/post.rb
|
318
|
-
- test/dummy/app/views/layouts/application.html.erb
|
319
|
-
- test/dummy/app/views/posts/_form.slim
|
320
|
-
- test/dummy/app/views/posts/edit.html.erb
|
321
|
-
- test/dummy/app/views/posts/index.html.erb
|
322
|
-
- test/dummy/app/views/posts/new.html.erb
|
323
|
-
- test/dummy/app/views/posts/show.html.erb
|
324
|
-
- test/dummy/bin/bundle
|
325
|
-
- test/dummy/bin/rails
|
326
|
-
- test/dummy/bin/rake
|
327
|
-
- test/dummy/config/application.rb
|
328
|
-
- test/dummy/config/boot.rb
|
329
|
-
- test/dummy/config/database.yml
|
330
|
-
- test/dummy/config/environment.rb
|
331
|
-
- test/dummy/config/environments/development.rb
|
332
|
-
- test/dummy/config/environments/production.rb
|
333
|
-
- test/dummy/config/environments/test.rb
|
334
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
335
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
336
|
-
- test/dummy/config/initializers/inflections.rb
|
337
|
-
- test/dummy/config/initializers/mime_types.rb
|
338
|
-
- test/dummy/config/initializers/secret_token.rb
|
339
|
-
- test/dummy/config/initializers/session_store.rb
|
340
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
341
|
-
- test/dummy/config/locales/en.yml
|
342
|
-
- test/dummy/config/routes.rb
|
343
|
-
- test/dummy/config.ru
|
344
|
-
- test/dummy/db/development.sqlite3
|
345
|
-
- test/dummy/db/migrate/20130624130249_create_posts.rb
|
346
|
-
- test/dummy/db/schema.rb
|
347
|
-
- test/dummy/db/test.sqlite3
|
348
|
-
- test/dummy/log/development.log
|
349
|
-
- test/dummy/public/404.html
|
350
|
-
- test/dummy/public/422.html
|
351
|
-
- test/dummy/public/500.html
|
352
|
-
- test/dummy/public/favicon.ico
|
353
|
-
- test/dummy/Rakefile
|
354
|
-
- test/dummy/README.rdoc
|
355
|
-
- test/integration/navigation_test.rb
|
356
|
-
- test/test_helper.rb
|
357
|
-
- test/uploadbox_test.rb
|
302
|
+
test_files: []
|
data/test/dummy/README.rdoc
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
== README
|
2
|
-
|
3
|
-
This README would normally document whatever steps are necessary to get the
|
4
|
-
application up and running.
|
5
|
-
|
6
|
-
Things you may want to cover:
|
7
|
-
|
8
|
-
* Ruby version
|
9
|
-
|
10
|
-
* System dependencies
|
11
|
-
|
12
|
-
* Configuration
|
13
|
-
|
14
|
-
* Database creation
|
15
|
-
|
16
|
-
* Database initialization
|
17
|
-
|
18
|
-
* How to run the test suite
|
19
|
-
|
20
|
-
* Services (job queues, cache servers, search engines, etc.)
|
21
|
-
|
22
|
-
* Deployment instructions
|
23
|
-
|
24
|
-
* ...
|
25
|
-
|
26
|
-
|
27
|
-
Please feel free to use a different markup language if you do not plan to run
|
28
|
-
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
DELETED
@@ -1,56 +0,0 @@
|
|
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
|
-
.field_with_errors {
|
28
|
-
padding: 2px;
|
29
|
-
background-color: red;
|
30
|
-
display: table;
|
31
|
-
}
|
32
|
-
|
33
|
-
#error_explanation {
|
34
|
-
width: 450px;
|
35
|
-
border: 2px solid red;
|
36
|
-
padding: 7px;
|
37
|
-
padding-bottom: 0;
|
38
|
-
margin-bottom: 20px;
|
39
|
-
background-color: #f0f0f0;
|
40
|
-
}
|
41
|
-
|
42
|
-
#error_explanation h2 {
|
43
|
-
text-align: left;
|
44
|
-
font-weight: bold;
|
45
|
-
padding: 5px 5px 5px 15px;
|
46
|
-
font-size: 12px;
|
47
|
-
margin: -7px;
|
48
|
-
margin-bottom: 0px;
|
49
|
-
background-color: #c00;
|
50
|
-
color: #fff;
|
51
|
-
}
|
52
|
-
|
53
|
-
#error_explanation ul li {
|
54
|
-
font-size: 12px;
|
55
|
-
list-style: square;
|
56
|
-
}
|
@@ -1,61 +0,0 @@
|
|
1
|
-
class PostsController < ApplicationController
|
2
|
-
before_action :set_post, only: [:show, :edit, :update, :destroy]
|
3
|
-
|
4
|
-
# GET /posts
|
5
|
-
def index
|
6
|
-
@posts = Post.all
|
7
|
-
end
|
8
|
-
|
9
|
-
# GET /posts/1
|
10
|
-
def show
|
11
|
-
end
|
12
|
-
|
13
|
-
# GET /posts/new
|
14
|
-
def new
|
15
|
-
@post = Post.new
|
16
|
-
end
|
17
|
-
|
18
|
-
# GET /posts/1/edit
|
19
|
-
def edit
|
20
|
-
end
|
21
|
-
|
22
|
-
# POST /posts
|
23
|
-
def create
|
24
|
-
@post = Post.new(post_params)
|
25
|
-
@post.image = Image.find_by(id: params[:image_id])
|
26
|
-
|
27
|
-
if @post.save
|
28
|
-
redirect_to @post, notice: 'Post was successfully created.'
|
29
|
-
else
|
30
|
-
render action: 'new'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# PATCH/PUT /posts/1
|
35
|
-
def update
|
36
|
-
@post.image = Image.find_by(id: params[:image_id])
|
37
|
-
|
38
|
-
if @post.update(post_params)
|
39
|
-
redirect_to @post, notice: 'Post was successfully updated.'
|
40
|
-
else
|
41
|
-
render action: 'edit'
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
# DELETE /posts/1
|
46
|
-
def destroy
|
47
|
-
@post.destroy
|
48
|
-
redirect_to posts_url, notice: 'Post was successfully destroyed.'
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
# Use callbacks to share common setup or constraints between actions.
|
53
|
-
def set_post
|
54
|
-
@post = Post.find(params[:id])
|
55
|
-
end
|
56
|
-
|
57
|
-
# Only allow a trusted parameter "white list" through.
|
58
|
-
def post_params
|
59
|
-
params.require(:post).permit(:title, :body)
|
60
|
-
end
|
61
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>Dummy</title>
|
5
|
-
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
|
6
|
-
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<%= yield %>
|
12
|
-
|
13
|
-
</body>
|
14
|
-
</html>
|