carload 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/app/assets/javascripts/carload/dashboard.js +1 -0
- data/app/assets/stylesheets/carload/dashboard.scss +3 -0
- data/app/controllers/carload/dashboard_controller.rb +1 -0
- data/app/helpers/carload/application_helper.rb +11 -0
- data/app/helpers/carload/dashboard_helper.rb +2 -0
- data/lib/carload/version.rb +1 -1
- data/lib/carload.rb +3 -0
- data/lib/generators/carload/USAGE +6 -2
- data/lib/generators/carload/templates/carload.rb +3 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6050c145967b23fa0d4d7f7a2d889cdf182a818e
|
4
|
+
data.tar.gz: 204ebca653c8f0268157b62bde3d11722a13e0fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20ebcfbd2520b19b94b0936174e039962475fb991b45a14738d96c1945f2756ed283a390e6407cfeb0f09ec916ef82bf0679c0bf13d82ce54fa2e80f65887d0a
|
7
|
+
data.tar.gz: 0bd18274a4164a9a3741387fbda4f0daf9ee181064ed0fcebbada84c8090827b8be12d6f1894943e71f6a730019451fc1f1623ced440ba00616056526cc3aa5e
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ DEMO: [https://carload-demo.herokuapp.com/carload/dashboard/](https://carload-de
|
|
10
10
|

|
11
11
|
|
12
12
|
## Usage
|
13
|
-
- Run `rails g carload:install` to mount engine routes, add require statement and
|
13
|
+
- Run `rails g carload:install` to mount engine routes, add require statement, initializer, and `Dashboard` class file.
|
14
14
|
|
15
15
|
You can edit the initializer `config/initializers/carload.rb` for example:
|
16
16
|
|
@@ -35,7 +35,7 @@ Carload.setup do |config|
|
|
35
35
|
end
|
36
36
|
```
|
37
37
|
|
38
|
-
|
38
|
+
Edit `app/carload/dashboard.rb` to adapt for your needs, for example:
|
39
39
|
|
40
40
|
```ruby
|
41
41
|
# Dashboard class is used to tell Carload what models are needed to administrated,
|
@@ -118,8 +118,8 @@ Or install it yourself as:
|
|
118
118
|
$ gem install carload
|
119
119
|
```
|
120
120
|
|
121
|
-
##
|
122
|
-
|
121
|
+
## TODO List
|
122
|
+
- Support upload file (using `carrierwave`)
|
123
123
|
|
124
124
|
## License
|
125
125
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
@@ -1,6 +1,7 @@
|
|
1
1
|
//= require font-awesome
|
2
2
|
//= require select2
|
3
3
|
//= require select2-bootstrap
|
4
|
+
//= require upload-image
|
4
5
|
|
5
6
|
$spacing: 16px;
|
6
7
|
|
@@ -41,6 +42,8 @@ $spacing: 16px;
|
|
41
42
|
|
42
43
|
#main-container {
|
43
44
|
width: 100%;
|
45
|
+
padding-left: $spacing;
|
46
|
+
padding-right: $spacing;
|
44
47
|
#main-content {
|
45
48
|
margin-top: 50px;
|
46
49
|
}
|
@@ -1,4 +1,15 @@
|
|
1
1
|
module Carload
|
2
2
|
module ApplicationHelper
|
3
|
+
def needs_upload? model_name, attribute_name
|
4
|
+
case Carload.upload_solution
|
5
|
+
when :carrierwave
|
6
|
+
model_class = model_name.to_s.classify.constantize
|
7
|
+
not model_class.instance_methods.map(&:to_s).select { |x| x =~ /#{attribute_name}_url/ }.empty?
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def image? attribute_name
|
12
|
+
attribute_name.to_s =~ /image|logo|img/
|
13
|
+
end
|
3
14
|
end
|
4
15
|
end
|
@@ -13,6 +13,8 @@ module Carload
|
|
13
13
|
placeholder: t('carload.placeholder.select', thing: t("activerecord.attributes.#{associated_model}.#{label_attribute}"))
|
14
14
|
}
|
15
15
|
}
|
16
|
+
elsif needs_upload?(model_name, attribute_name) and image?(attribute_name)
|
17
|
+
upload_image form: form, image_name: attribute_name, width: 150, height: 150
|
16
18
|
else
|
17
19
|
form.input attribute_name
|
18
20
|
end
|
data/lib/carload/version.rb
CHANGED
data/lib/carload.rb
CHANGED
@@ -17,6 +17,9 @@ module Carload
|
|
17
17
|
if not [:devise, :none].include? @@config[:auth_solution]
|
18
18
|
raise UnsupportedError.new("authentication solution #{@@config[:auth_solution]}")
|
19
19
|
end
|
20
|
+
if not [:carrierwave].include? @@config[:upload_solution]
|
21
|
+
raise UnsupportedError.new("upload solution #{@@config[:upload_solution]}")
|
22
|
+
end
|
20
23
|
|
21
24
|
@@config.each do |key, value|
|
22
25
|
define_singleton_method key do
|
@@ -1,7 +1,11 @@
|
|
1
1
|
Description:
|
2
|
-
|
2
|
+
This generator does the following jobs:
|
3
3
|
|
4
|
-
|
4
|
+
- Mount Carload routes.
|
5
|
+
|
6
|
+
- Add require statement.
|
7
|
+
|
8
|
+
- Copy initializer and dashboard template files.
|
5
9
|
|
6
10
|
Example:
|
7
11
|
rails generate carload:install
|
@@ -2,6 +2,9 @@ Carload.setup do |config|
|
|
2
2
|
# Specify which authentication solution is used. Currently, we only support Devise.
|
3
3
|
config.auth_solution = :devise
|
4
4
|
|
5
|
+
# Specify which file upload solution is used. Currently, we only support Carrierwave.
|
6
|
+
config.upload_solution = :carrierwave
|
7
|
+
|
5
8
|
# Set the actions used to discern user's permission to access dashboard.
|
6
9
|
#
|
7
10
|
# config.dashboard.permits_user.<method> = '...'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Li Dong
|
@@ -184,6 +184,20 @@ dependencies:
|
|
184
184
|
- - "~>"
|
185
185
|
- !ruby/object:Gem::Version
|
186
186
|
version: '4.0'
|
187
|
+
- !ruby/object:Gem::Dependency
|
188
|
+
name: upload-image
|
189
|
+
requirement: !ruby/object:Gem::Requirement
|
190
|
+
requirements:
|
191
|
+
- - "~>"
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: '0.1'
|
194
|
+
type: :runtime
|
195
|
+
prerelease: false
|
196
|
+
version_requirements: !ruby/object:Gem::Requirement
|
197
|
+
requirements:
|
198
|
+
- - "~>"
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '0.1'
|
187
201
|
description: Carload is built with taste, and tries to be just right!
|
188
202
|
email:
|
189
203
|
- dongli.init@gmail.com
|