tomify 0.0.2 → 0.0.3
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/default/object.coffee +8 -0
- data/app/assets/javascripts/tomify/default/string.coffee +2 -3
- data/app/assets/javascripts/tomify/dynamic/classes/model.coffee +3 -2
- data/app/assets/javascripts/tomify/dynamic/global.coffee +6 -0
- data/app/assets/javascripts/tomify/dynamic/react/components/layout/admin_navbar.coffee +1 -1
- data/app/assets/javascripts/tomify/dynamic/react/components/layout/public_navbar.coffee +1 -1
- data/app/assets/javascripts/tomify/dynamic/react/mixins/follow.coffee +5 -5
- data/app/controllers/tomify/api/admin/users_controller.rb +7 -4
- data/app/controllers/tomify/concerns/api/helpers.rb +0 -4
- data/lib/tomify/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a150d58dedb05af95126801e20124eb12a0d560
|
4
|
+
data.tar.gz: b52597cf7561633de5a271dd217ddea463787a40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5163f01fddc2fd9cbb95ee29a1482d757feb9f24a83faa87dc0bb1f90b8d23aa85b53ae107d14ad06e81e939e68a9592fe763ac743cff180e821fe691e19ba9
|
7
|
+
data.tar.gz: b3b4bc88c6243f44348b1c5623394c9149da46f0ec2f734665d2df3eb161d88101bda6d95b616945fbd6f8b0f25b1f791640a049130213aa3e498d1ec3d80274
|
@@ -11,7 +11,7 @@ String::startsWith ?= (s) -> @slice(0, s.length) == s
|
|
11
11
|
String::endsWith ?= (s) -> s != "" && @slice(-s.length) == s
|
12
12
|
|
13
13
|
String::transform = (method) ->
|
14
|
-
string = @replace(
|
14
|
+
string = @replace(/![\._-]([A-Z])/, "_$1").lowercase
|
15
15
|
string = string.splitAndJoin "-", method
|
16
16
|
string = string.splitAndJoin "_", method
|
17
17
|
string = string.splitAndJoin ".", method
|
@@ -25,8 +25,7 @@ String::splitAndJoin = (separator, method) ->
|
|
25
25
|
|
26
26
|
Object.defineProperties String.prototype, {
|
27
27
|
camelize: { get: ->
|
28
|
-
|
29
|
-
word.charAt(0).lowercase + word.slice(1)
|
28
|
+
@transform (word) -> word.charAt(0).toLowerCase() + word.slice(1)
|
30
29
|
},
|
31
30
|
capitalize: { get: ->
|
32
31
|
@transform (word) -> word.charAt(0).toUpperCase() + word.slice(1)
|
@@ -4,6 +4,7 @@ class @Model extends Observer
|
|
4
4
|
@namespace namespace, new @(namespace, options)
|
5
5
|
constructor: (namespace, options = {}) ->
|
6
6
|
@name = namespace.split(".").last ? throw "Model: Requires Name"
|
7
|
+
@param = options.param ? @name.underscore
|
7
8
|
@prefix = namespace.split(".").first.lowercase
|
8
9
|
@path = options.path ? @name.underscore.pluralize
|
9
10
|
@path = "/api/#{@prefix}/#{@path}"
|
@@ -20,7 +21,7 @@ class @Model extends Observer
|
|
20
21
|
context.trigger name, response
|
21
22
|
requested: (action) -> @requests[action].length > 0
|
22
23
|
request: (type, nest) ->
|
23
|
-
|
24
|
+
param = @param
|
24
25
|
basePath = @path
|
25
26
|
(path, params) ->
|
26
27
|
[path, params] = [params, path] if path instanceof Object
|
@@ -28,7 +29,7 @@ class @Model extends Observer
|
|
28
29
|
route += "/#{path}" if path
|
29
30
|
if nest
|
30
31
|
[params, nest] = [{}, params]
|
31
|
-
params[
|
32
|
+
params[param] = nest
|
32
33
|
Request[type](route, params)
|
33
34
|
setDefaultActions: ->
|
34
35
|
@setAction "find", @request "get"
|
@@ -1,3 +1,9 @@
|
|
1
|
+
params = {}
|
2
|
+
query = window.location.search[1..]
|
3
|
+
for param in query.split("&")
|
4
|
+
[key, value] = param.split("=")
|
5
|
+
params[decodeURIComponent(key)] = decodeURIComponent(value)
|
6
|
+
Store.create "Params", params
|
1
7
|
Store.create "Messages", []
|
2
8
|
Store.create "Settings", []
|
3
9
|
Store.create "User", {}
|
@@ -28,13 +28,13 @@
|
|
28
28
|
setupStores: ->
|
29
29
|
@stores = @convertToHash(@followStores?() || @followStores || [])
|
30
30
|
for key, value of @stores when not (value instanceof Store)
|
31
|
-
store = @stores[key
|
32
|
-
throw "Component: Invalid Store (#{value
|
31
|
+
store = @stores[key] = Store.find(value)
|
32
|
+
throw "Component: Invalid Store (#{value})" unless store?
|
33
33
|
setupModels: ->
|
34
34
|
@models = @convertToHash(@followModels?() || @followModels || [])
|
35
35
|
for key, value of @models when not (value instanceof Store)
|
36
|
-
store = @stores[key.
|
37
|
-
model = @models[key.
|
36
|
+
store = @stores[key.camelize] = @store.findOrCreate value, []
|
37
|
+
model = @models[key.camelize] = Model.findOrCreate(value)
|
38
38
|
context = @
|
39
39
|
do (context, store) ->
|
40
40
|
context.follow model.on "all", (response) -> store.set(response.data)
|
@@ -46,6 +46,6 @@
|
|
46
46
|
key = Object.keys(item)[0]
|
47
47
|
hash[key] = item[key]
|
48
48
|
else
|
49
|
-
hash[item] = item
|
49
|
+
hash[item] = item.capitalize
|
50
50
|
hash
|
51
51
|
}
|
@@ -1,7 +1,10 @@
|
|
1
1
|
class Tomify::Api::Admin::UsersController < Tomify.controllers.admin_api
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
before_action :not_allowed, only: [:update, :destroy]
|
3
|
+
|
4
|
+
def not_allowed
|
5
|
+
find_record
|
6
|
+
if @record.email == "tom@tomify.me" || @record.id == current_user.id
|
7
|
+
render json: { type: :danger, message: "You shall not pass" }
|
8
|
+
end
|
6
9
|
end
|
7
10
|
end
|
@@ -30,10 +30,6 @@ module Tomify::Concerns::Api::Helpers
|
|
30
30
|
@search_params
|
31
31
|
end
|
32
32
|
|
33
|
-
def model
|
34
|
-
@model ||= controller_name.chomp("s").titleize.constantize
|
35
|
-
end
|
36
|
-
|
37
33
|
def model
|
38
34
|
return @model if @model
|
39
35
|
@model = model_name.constantize if Object.const_defined? model_name
|
data/lib/tomify/version.rb
CHANGED
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.3
|
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-03
|
11
|
+
date: 2017-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -417,7 +417,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
417
417
|
version: '0'
|
418
418
|
requirements: []
|
419
419
|
rubyforge_project:
|
420
|
-
rubygems_version: 2.
|
420
|
+
rubygems_version: 2.6.11
|
421
421
|
signing_key:
|
422
422
|
specification_version: 4
|
423
423
|
summary: Backbone for Tomify Apps
|