pretty_file_input 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d9d858237efdd985c2cd1783d782c5316279ddf0
4
- data.tar.gz: b5c7be942739395b281ada54c05e164efcb2bad7
3
+ metadata.gz: 68b54fdac68bd00ae0371edd16a8eea1e4430115
4
+ data.tar.gz: ce5eb69566b3f2ff100973d57171bae85ff2f560
5
5
  SHA512:
6
- metadata.gz: 19808dec620c250d33bef54a691e473a1f1e27d8ec83e5b84ec16a3036ea3a5a243f7777c1438fff9c241f8ab720861e7117aff53d0cefd8a62037e2d6ab794c
7
- data.tar.gz: f6d3e7a4d34c544403c25d4bfcbe309ced7f12d57bf9411534eff8c276750d49849cb310dc2e6e476ce27e00b39914b661c76193e816aee7c1c56ba9215fae90
6
+ metadata.gz: 14e98da6f206086cd9f60359d9a93647b48aff45e45e7b0a741491407f6071f6bcbf0a8f4c0c7abf650f01d8f9af7878236c6beab355806acd296484c176d8f8
7
+ data.tar.gz: 24f7d7d052888e177d91098f8b50b50ffd7075819cf01bae9d4be4a6120b6553ab1758bb817fa88fad7a9f34d89352bd414202fdcdb5b28b9a1bf3ea840002d3
data/README.md CHANGED
@@ -52,7 +52,7 @@ The resulting behavior will depend on whether or not the parent object is alread
52
52
 
53
53
  ### Manual
54
54
 
55
- If your use case doesn't fit the patterns above, you can use the "Manual" integration with pretty_file_input. `PrettyFileInput::Component` is an Erector widget that can be customized with the following options:
55
+ If your use case doesn't fit the patterns above, you can use the "Manual" integration with pretty_file_input. `PrettyFileInput::Views::Component` is a Fortitude widget that can be customized with the following options:
56
56
 
57
57
  ```rb
58
58
  :name, # input name that will be sent to the server
@@ -1,7 +1,7 @@
1
1
  class PrettyFileInputInput < SimpleForm::Inputs::Base
2
2
  def input(wrapper_options)
3
3
  @builder.multipart = true
4
- PrettyFileInput::Component.new(
4
+ PrettyFileInput::Views::Component.new(
5
5
  name: tag_name,
6
6
  persisted: object.try(:persisted?),
7
7
  filename: object.try(:send, attribute_name).try(:file).try(:filename)
@@ -1,8 +1,15 @@
1
1
  require 'pretty_file_input/version'
2
- require 'pretty_file_input/component'
2
+ require 'fortitude'
3
3
 
4
4
  module PrettyFileInput
5
5
  class Engine < ::Rails::Engine
6
+ initializer 'pretty_file_input.load_views' do |app|
7
+ require 'pretty_file_input/views/component'
8
+ end
9
+ end
6
10
 
11
+ module Views
12
+ mattr_accessor :base_view_class
13
+ self.base_view_class = 'Views::Base'
7
14
  end
8
15
  end
@@ -1,3 +1,3 @@
1
1
  module PrettyFileInput
2
- VERSION = '0.0.5'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -0,0 +1,31 @@
1
+ class PrettyFileInput::Views::Component < PrettyFileInput::Views.base_view_class.constantize
2
+ needs :name,
3
+ persisted: false,
4
+ filename: nil,
5
+ method: nil,
6
+ action: nil,
7
+ additional_params: {}
8
+
9
+ def content
10
+ div(
11
+ class: "pfi cf #{filename ? 'is_uploaded' : ''}",
12
+ 'data-pfi' => {
13
+ name: name,
14
+ persisted: persisted,
15
+ action: action,
16
+ method: method,
17
+ additionalParams: additional_params
18
+ }.to_json
19
+ ) {
20
+ div(class: 'pfi_uploaded') {
21
+ span filename, class: 'pfi_existing_filename'
22
+ text ' '
23
+ a 'Remove', 'data-pfi-remove' => true, class: 'button mini info'
24
+ }
25
+ div(class: 'pfi_not_uploaded') {
26
+ input type: 'file'
27
+ span class: 'pfi_status'
28
+ }
29
+ }
30
+ end
31
+ end
@@ -17,12 +17,12 @@ Gem::Specification.new do |s|
17
17
  s.homepage = 'http://github.com/dobtco/pretty_file_input'
18
18
 
19
19
  s.add_dependency 'coffee-script'
20
- s.add_dependency 'erector-rails4'
20
+ s.add_dependency 'fortitude'
21
21
  s.add_dependency 'sass'
22
22
 
23
23
  s.add_development_dependency 'capybara', '2.4.4'
24
24
  s.add_development_dependency 'carrierwave'
25
- s.add_development_dependency 'rails', '4.1.9'
25
+ s.add_development_dependency 'rails', '4.2.5'
26
26
  s.add_development_dependency 'rspec-rails', '3.1.0'
27
27
  s.add_development_dependency 'selenium-webdriver', '2.45.0'
28
28
  s.add_development_dependency 'simple_form', '3.1.0'
@@ -0,0 +1,7 @@
1
+ class Views::Base < Fortitude::Widget
2
+ doctype :html5
3
+ use_instance_variables_for_assigns true
4
+ format_output false
5
+ start_and_end_comments false
6
+ extra_assigns :use
7
+ end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -13,8 +13,8 @@
13
13
 
14
14
  ActiveRecord::Schema.define(version: 20141123205413) do
15
15
 
16
- create_table "users", force: true do |t|
17
- t.string "avatar"
16
+ create_table "users", force: :cascade do |t|
17
+ t.string "avatar", limit: 255
18
18
  end
19
19
 
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pretty_file_input
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Becker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-30 00:00:00.000000000 Z
11
+ date: 2015-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coffee-script
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: erector-rails4
28
+ name: fortitude
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - '='
88
88
  - !ruby/object:Gem::Version
89
- version: 4.1.9
89
+ version: 4.2.5
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
- version: 4.1.9
96
+ version: 4.2.5
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec-rails
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -165,8 +165,8 @@ files:
165
165
  - app/assets/stylesheets/pretty_file_input.scss
166
166
  - app/inputs/pretty_file_input_input.rb
167
167
  - lib/pretty_file_input.rb
168
- - lib/pretty_file_input/component.rb
169
168
  - lib/pretty_file_input/version.rb
169
+ - lib/pretty_file_input/views/component.rb
170
170
  - pretty_file_input.gemspec
171
171
  - script/cibuild
172
172
  - script/release
@@ -176,10 +176,12 @@ files:
176
176
  - spec/dummy/app/assets/stylesheets/application.css
177
177
  - spec/dummy/app/controllers/users_controller.rb
178
178
  - spec/dummy/app/models/user.rb
179
+ - spec/dummy/app/views/base.rb
179
180
  - spec/dummy/app/views/layouts/application.html.erb
180
181
  - spec/dummy/app/views/users/_form.html.erb
181
182
  - spec/dummy/app/views/users/edit.html.erb
182
183
  - spec/dummy/app/views/users/new.html.erb
184
+ - spec/dummy/bin/rails
183
185
  - spec/dummy/config.ru
184
186
  - spec/dummy/config/application.rb
185
187
  - spec/dummy/config/boot.rb
@@ -225,10 +227,12 @@ test_files:
225
227
  - spec/dummy/app/assets/stylesheets/application.css
226
228
  - spec/dummy/app/controllers/users_controller.rb
227
229
  - spec/dummy/app/models/user.rb
230
+ - spec/dummy/app/views/base.rb
228
231
  - spec/dummy/app/views/layouts/application.html.erb
229
232
  - spec/dummy/app/views/users/_form.html.erb
230
233
  - spec/dummy/app/views/users/edit.html.erb
231
234
  - spec/dummy/app/views/users/new.html.erb
235
+ - spec/dummy/bin/rails
232
236
  - spec/dummy/config.ru
233
237
  - spec/dummy/config/application.rb
234
238
  - spec/dummy/config/boot.rb
@@ -1,33 +0,0 @@
1
- require 'erector'
2
-
3
- class PrettyFileInput::Component < Erector::Widget
4
- needs :name,
5
- persisted: false,
6
- filename: nil,
7
- method: nil,
8
- action: nil,
9
- additional_params: {}
10
-
11
- def content
12
- div(
13
- class: "pfi cf #{@filename ? 'is_uploaded' : ''}",
14
- 'data-pfi' => {
15
- name: @name,
16
- persisted: @persisted,
17
- action: @action,
18
- method: @method,
19
- additionalParams: @additional_params
20
- }.to_json
21
- ) {
22
- div.pfi_uploaded {
23
- span.pfi_existing_filename @filename
24
- text ' '
25
- a.button.mini.info 'Remove', 'data-pfi-remove' => true
26
- }
27
- div.pfi_not_uploaded {
28
- input type: 'file'
29
- span.pfi_status
30
- }
31
- }
32
- end
33
- end