tomify 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/tomify/dynamic/classes/field.coffee +7 -1
- data/app/assets/javascripts/tomify/dynamic/classes/form.coffee +2 -2
- data/app/assets/javascripts/tomify/dynamic/classes/request.coffee +1 -1
- data/app/assets/javascripts/tomify/dynamic/classes/store.coffee +5 -4
- data/app/assets/javascripts/tomify/dynamic/react/components/admin/pages.coffee.erb +1 -1
- data/app/assets/javascripts/tomify/dynamic/react/components/admin/settings.coffee +10 -5
- data/app/assets/javascripts/tomify/dynamic/react/components/admin/{sidebars.coffee → sidebars.coffee.erb} +2 -1
- data/app/assets/javascripts/tomify/dynamic/react/components/admin/uploads.coffee +1 -1
- data/app/assets/javascripts/tomify/dynamic/react/components/admin/users.coffee +1 -1
- data/app/assets/javascripts/tomify/dynamic/react/components/fields/json.coffee +30 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/layout/analytics.coffee +1 -2
- data/app/assets/stylesheets/tomify/_page.scss +5 -1
- data/app/controllers/tomify/concerns/default/env_helper.rb +2 -0
- data/app/controllers/tomify/public/pages_controller.rb +1 -1
- data/app/helpers/tomify/carrierwave_helper.rb +16 -10
- data/app/models/tomify/concerns/sidebar.rb +3 -2
- data/app/models/tomify/concerns/upload.rb +1 -1
- data/app/models/tomify/setting.rb +1 -1
- data/app/views/templates/contact.haml +1 -1
- data/app/views/templates/default.haml +1 -1
- data/app/views/templates/sidebar.haml +4 -0
- data/app/views/tomify/defaults/_container.haml +6 -1
- data/db/migrate/19900000000010_add_template_to_sidebars.rb +5 -0
- data/lib/tomify/version.rb +1 -1
- data/lib/tomify.rb +5 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af725db32ac310b47ea7eefedfaf879b7b927040
|
4
|
+
data.tar.gz: 80da5c622cdb34254d793df17e2919afcef6c98a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34a9285af9d4e3f98bc13e7173c7c0bf34ef3e932c0321bfa8bf651ad74dd06610ae64c8329675a8b0e72ff08a5cb4b6e2d6ac163f5fdb2e636b4bccd6dc37b4
|
7
|
+
data.tar.gz: edd76bd3edf8f8545c2895a1066187822f42e302a58176cf4374b6e88857d36a6e1e5d4f1ff87147a68802d7243d587767196f955eb21f8ac15bd725555d3771
|
@@ -16,10 +16,16 @@ class @Field
|
|
16
16
|
field.setForm(options.form)
|
17
17
|
field
|
18
18
|
copy: (form) ->
|
19
|
-
Field.build
|
19
|
+
Field.build Object.assign({}, @options, { form: form })
|
20
20
|
constructor: (options) ->
|
21
21
|
@options = options
|
22
22
|
setForm: (form) ->
|
23
23
|
@props.value = form.value.bind(form)
|
24
24
|
@props.onChange = form.onChange.bind(form)
|
25
25
|
@props.options = form.options.bind(form, @props) if @props.model
|
26
|
+
show: ->
|
27
|
+
record = @options.form.record.get()
|
28
|
+
changes = @options.form.changes.get()
|
29
|
+
return @options.if(record, changes) if @options.if
|
30
|
+
return !@options.unless(record, changes) if @options.unless
|
31
|
+
true
|
@@ -25,7 +25,7 @@ class @Form
|
|
25
25
|
options.push { value: record.id, name: record.name }
|
26
26
|
options
|
27
27
|
add: (name, type, options = {}) ->
|
28
|
-
options =
|
28
|
+
options = Object.assign { type: type, name: name, form: @ }, options
|
29
29
|
@fields.push Field.build(options)
|
30
30
|
@models.push options.model if options.model
|
31
31
|
setComponent: (component, store) ->
|
@@ -70,4 +70,4 @@ class @Form
|
|
70
70
|
<FieldComponent {...field.props} />
|
71
71
|
</div>
|
72
72
|
render: ->
|
73
|
-
@renderField(field) for field in @fields
|
73
|
+
@renderField(field) for field in @fields when field.show()
|
@@ -9,7 +9,7 @@ class @Request
|
|
9
9
|
@ajax: (options) ->
|
10
10
|
options.url = options.url.assign(options.data)
|
11
11
|
if options.type in ["POST", "PUT"]
|
12
|
-
|
12
|
+
Object.assign options, {
|
13
13
|
data: @formData(new FormData(), options.data),
|
14
14
|
cache: false,
|
15
15
|
processData: false,
|
@@ -11,21 +11,22 @@ class @Store extends Observer
|
|
11
11
|
merge: (data) ->
|
12
12
|
throw "Store: Invalid Data Type" unless @isObject()
|
13
13
|
@trigger "merge", data
|
14
|
-
@set(
|
14
|
+
@set Object.assign({}, @get(), data)
|
15
15
|
push: (data) ->
|
16
16
|
throw "Store: Invalid Data Type" unless @isArray()
|
17
17
|
@trigger "push", data
|
18
|
-
@set
|
18
|
+
@set @get().concat([data])
|
19
19
|
remove: (field) ->
|
20
20
|
throw "Store: Invalid Data Type" unless @isObject()
|
21
21
|
@trigger "remove", data
|
22
22
|
data = @get()
|
23
23
|
delete data[field]
|
24
|
-
|
24
|
+
data = (item for item in data when item?) if @isArray()
|
25
|
+
@set data
|
25
26
|
get: (field) ->
|
26
27
|
throw "Store: Invalid Data Type" unless @isDefined()
|
27
28
|
return @data if @isBoolean() || @isString()
|
28
|
-
data =
|
29
|
+
data = Object.assign @data.constructor(), @data
|
29
30
|
if field then data[field] else data
|
30
31
|
empty: ->
|
31
32
|
return @data.length == 0 if @isArray()
|
@@ -12,7 +12,7 @@ model.columns = [
|
|
12
12
|
}
|
13
13
|
]
|
14
14
|
|
15
|
-
form = new Form
|
15
|
+
form = new Form "horizontal"
|
16
16
|
form.add "parent_id", "select", model: "Admin.Page", allowBlank: true
|
17
17
|
form.add "sidebar_id", "select", model: "Admin.Sidebar", allowBlank: true
|
18
18
|
form.add "active", "checkbox"
|
@@ -6,7 +6,7 @@ model.columns = [
|
|
6
6
|
{ name: "value", value: (r) ->
|
7
7
|
type = r.type.split("::").last
|
8
8
|
return "#{r.value}" if type == "Boolean"
|
9
|
-
return "JSON
|
9
|
+
return "JSON" if type == "Json"
|
10
10
|
r.value
|
11
11
|
},
|
12
12
|
{ name: "updated_at", value: (r) -> r.updated_at.date() },
|
@@ -16,15 +16,20 @@ model.columns = [
|
|
16
16
|
options = ["Boolean", "Json", "Text", "Uploader"]
|
17
17
|
options = ({ name: option, value: "Tomify::Setting::#{option}" } for option in options)
|
18
18
|
|
19
|
-
newForm = new Form
|
19
|
+
newForm = new Form "horizontal"
|
20
20
|
newForm.add "type", "select", options: options
|
21
21
|
newForm.add "public", "checkbox"
|
22
22
|
newForm.add "name", "text"
|
23
|
-
newForm.add "value", "
|
23
|
+
newForm.add "value", "checkbox", if: (record, changes) -> changes.type.split("::").last == "Boolean"
|
24
|
+
newForm.add "value", "text", if: (record, changes) -> changes.type.split("::").last == "Text"
|
25
|
+
newForm.add "json", "json", if: (record, changes) -> changes.type.split("::").last == "Json"
|
24
26
|
|
25
|
-
editForm = new Form
|
27
|
+
editForm = new Form "horizontal"
|
26
28
|
editForm.add "public", "checkbox"
|
27
29
|
editForm.add "name", "text"
|
28
|
-
editForm.add "value", "
|
30
|
+
editForm.add "value", "checkbox", if: (record) -> record.type.split("::").last == "Boolean"
|
31
|
+
editForm.add "value", "text", if: (record) -> record.type.split("::").last == "Text"
|
32
|
+
editForm.add "json", "json", if: (record) -> record.type.split("::").last == "Json"
|
33
|
+
# editForm.add "value", "json", if: (record) -> record.type.split("::").last == "Uploader"
|
29
34
|
|
30
35
|
Component.create "Admin.Settings.Index.Container", render: -> <Index.Container name="Admin.Setting" newForm={newForm} editForm={editForm} />
|
@@ -7,9 +7,10 @@ model.columns = [
|
|
7
7
|
{ name: "actions", edit: true, destroy: true }
|
8
8
|
]
|
9
9
|
|
10
|
-
form = new Form
|
10
|
+
form = new Form "horizontal"
|
11
11
|
form.add "active", "checkbox"
|
12
12
|
form.add "name", "text"
|
13
|
+
form.add "template", "select", options: <%= Tomify::Page.templates %>
|
13
14
|
form.add "heading", "text"
|
14
15
|
form.add "text", "markdown"
|
15
16
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Component.create "Form.Field.Json",
|
2
|
+
onKeyChange: (key, e) ->
|
3
|
+
changes = Object.assign {}, @props.value(@props.name)
|
4
|
+
value = changes[key]
|
5
|
+
delete changes[key]
|
6
|
+
key = e.target.value
|
7
|
+
changes[key] = value if key
|
8
|
+
@props.onChange(@props.name, target: { value: changes })
|
9
|
+
onValueChange: (key, e) ->
|
10
|
+
changes = Object.assign {}, @props.value(@props.name)
|
11
|
+
changes[key] = e.target.value
|
12
|
+
@props.onChange(@props.name, target: { value: changes })
|
13
|
+
render: ->
|
14
|
+
changes = Object.assign {}, @props.value(@props.name)
|
15
|
+
changes[""] ?= ""
|
16
|
+
index = 0
|
17
|
+
<div>
|
18
|
+
{for key, value of changes
|
19
|
+
<div key={index++} className="form-group">
|
20
|
+
<div className="col-xs-6">
|
21
|
+
<input placeholder="Key" className="form-control" type="text" value={key} onChange={@onKeyChange.bind(null, key)} />
|
22
|
+
</div>
|
23
|
+
{if key
|
24
|
+
<div className="col-xs-6">
|
25
|
+
<input placeholder="Value" className="form-control" type="text" value={value} onChange={@onValueChange.bind(null, key)} />
|
26
|
+
</div>
|
27
|
+
}
|
28
|
+
</div>
|
29
|
+
}
|
30
|
+
</div>
|
@@ -6,8 +6,7 @@ Component.create "Layout.Analytics",
|
|
6
6
|
return unless code = setting "google_analytics_code"
|
7
7
|
|
8
8
|
window.GoogleAnalyticsObject = "ga"
|
9
|
-
window.
|
10
|
-
window?[window.GoogleAnalyticsObject] ?= (args...) ->
|
9
|
+
window[window.GoogleAnalyticsObject] ?= (args...) ->
|
11
10
|
api = window[window.GoogleAnalyticsObject]
|
12
11
|
(api.q or= []).push args
|
13
12
|
return
|
@@ -16,6 +16,8 @@ module Tomify::Concerns::Default::EnvHelper
|
|
16
16
|
[
|
17
17
|
{ name: "App", path: "admin/settings" },
|
18
18
|
{ name: "Pages", path: "admin/pages" },
|
19
|
+
{ name: "Sidebars", path: "admin/sidebars" },
|
20
|
+
{ name: "Uploads", path: "admin/uploads" },
|
19
21
|
{ name: "Users", path: "admin/users" }
|
20
22
|
]
|
21
23
|
end
|
@@ -1,17 +1,23 @@
|
|
1
1
|
module Tomify::CarrierwaveHelper
|
2
2
|
def self.load_config
|
3
|
-
return unless defined?
|
3
|
+
return unless defined? CarrierWave
|
4
4
|
return unless settings = Tomify.setting(:aws)
|
5
5
|
|
6
|
-
CarrierWave.
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
descendants = CarrierWave::Uploader::Base.descendants
|
7
|
+
descendants.push CarrierWave::Uploader::Base
|
8
|
+
descendants.push CarrierWave
|
9
|
+
descendants.each do |klass|
|
10
|
+
klass.configure do |config|
|
11
|
+
config.fog_provider = "fog/aws"
|
12
|
+
config.fog_credentials = {
|
13
|
+
provider: "AWS",
|
14
|
+
aws_access_key_id: settings["access_key"],
|
15
|
+
aws_secret_access_key: settings["secret_key"]
|
16
|
+
}
|
17
|
+
config.fog_directory = settings["bucket"]
|
18
|
+
config.fog_public = true
|
19
|
+
config.storage = :fog
|
20
|
+
end
|
15
21
|
end
|
16
22
|
end
|
17
23
|
end
|
@@ -3,7 +3,8 @@ module Tomify::Concerns::Sidebar
|
|
3
3
|
|
4
4
|
included do
|
5
5
|
has_many :pages, class_name: Tomify.models.page.to_s
|
6
|
-
|
6
|
+
|
7
|
+
validates_presence_of :name, :template
|
7
8
|
|
8
9
|
scope :active, -> { where(active: true) }
|
9
10
|
|
@@ -12,7 +13,7 @@ module Tomify::Concerns::Sidebar
|
|
12
13
|
|
13
14
|
class_methods do
|
14
15
|
def admin_params
|
15
|
-
[:active, :name, :heading, :text]
|
16
|
+
[:active, :name, :heading, :template, :text]
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
@@ -2,7 +2,7 @@ module Tomify::Concerns::Upload
|
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
4
|
included do
|
5
|
-
mount_uploader :file, Tomify
|
5
|
+
mount_uploader :file, Tomify.uploaders.file
|
6
6
|
|
7
7
|
before_validation :set_model
|
8
8
|
before_validation :validate_content_type, on: :update, if: :content_type_changed?
|
data/lib/tomify/version.rb
CHANGED
data/lib/tomify.rb
CHANGED
@@ -36,7 +36,11 @@ module Tomify
|
|
36
36
|
)
|
37
37
|
|
38
38
|
mattr_accessor :uploaders
|
39
|
-
self.uploaders = Constantly.new(
|
39
|
+
self.uploaders = Constantly.new(
|
40
|
+
base: "TomifyUploader",
|
41
|
+
file: "Tomify::FileUploader",
|
42
|
+
setting: "Tomify::SettingUploader"
|
43
|
+
)
|
40
44
|
|
41
45
|
def self.root
|
42
46
|
Pathname.new Gem::Specification.find_by_name("tomify").gem_dir
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tomify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Prats
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -267,13 +267,14 @@ files:
|
|
267
267
|
- app/assets/javascripts/tomify/dynamic/global.coffee
|
268
268
|
- app/assets/javascripts/tomify/dynamic/react/components/admin/pages.coffee.erb
|
269
269
|
- app/assets/javascripts/tomify/dynamic/react/components/admin/settings.coffee
|
270
|
-
- app/assets/javascripts/tomify/dynamic/react/components/admin/sidebars.coffee
|
270
|
+
- app/assets/javascripts/tomify/dynamic/react/components/admin/sidebars.coffee.erb
|
271
271
|
- app/assets/javascripts/tomify/dynamic/react/components/admin/uploads.coffee
|
272
272
|
- app/assets/javascripts/tomify/dynamic/react/components/admin/users.coffee
|
273
273
|
- app/assets/javascripts/tomify/dynamic/react/components/edit.coffee
|
274
274
|
- app/assets/javascripts/tomify/dynamic/react/components/fields/checkbox.coffee
|
275
275
|
- app/assets/javascripts/tomify/dynamic/react/components/fields/default.coffee
|
276
276
|
- app/assets/javascripts/tomify/dynamic/react/components/fields/file.coffee
|
277
|
+
- app/assets/javascripts/tomify/dynamic/react/components/fields/json.coffee
|
277
278
|
- app/assets/javascripts/tomify/dynamic/react/components/fields/markdown.coffee
|
278
279
|
- app/assets/javascripts/tomify/dynamic/react/components/fields/select.coffee
|
279
280
|
- app/assets/javascripts/tomify/dynamic/react/components/fields/textarea.coffee
|
@@ -368,6 +369,7 @@ files:
|
|
368
369
|
- app/uploaders/tomify_uploader.rb
|
369
370
|
- app/views/templates/contact.haml
|
370
371
|
- app/views/templates/default.haml
|
372
|
+
- app/views/templates/sidebar.haml
|
371
373
|
- app/views/tomify/defaults/_body.haml
|
372
374
|
- app/views/tomify/defaults/_container.haml
|
373
375
|
- app/views/tomify/defaults/_env.haml
|
@@ -398,6 +400,7 @@ files:
|
|
398
400
|
- db/migrate/19900000000007_add_verified_to_users.rb
|
399
401
|
- db/migrate/19900000000008_add_name_to_tokens.rb
|
400
402
|
- db/migrate/19900000000009_add_invited_to_users.rb
|
403
|
+
- db/migrate/19900000000010_add_template_to_sidebars.rb
|
401
404
|
- db/seeds.rb
|
402
405
|
- lib/generators/tomify/bundle/bundle_generator.rb
|
403
406
|
- lib/generators/tomify/bundle/templates/default.js
|