nali 0.1.7 → 0.1.9
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.
- data/bin/nali +0 -0
- data/lib/assets/javascripts/nali/application.js.coffee +2 -2
- data/lib/assets/javascripts/nali/controller.js.coffee +56 -24
- data/lib/assets/javascripts/nali/nali.js.coffee +4 -4
- data/lib/assets/javascripts/nali/router.js.coffee +1 -1
- data/lib/assets/javascripts/nali/view.js.coffee +8 -3
- data/lib/generator/Gemfile +9 -7
- data/lib/generator/app/assets/javascripts/application.js.coffee +1 -3
- data/lib/generator/config/environments/production.rb +6 -3
- data/lib/nali/application.rb +2 -3
- data/lib/nali/version.rb +1 -1
- metadata +2 -2
data/bin/nali
CHANGED
File without changes
|
@@ -5,36 +5,68 @@ Nali.extend Controller:
|
|
5
5
|
@prepareActions()
|
6
6
|
@modelSysname = @sysname.replace /s$/, ''
|
7
7
|
@
|
8
|
-
|
8
|
+
|
9
|
+
actions: {}
|
10
|
+
|
9
11
|
prepareActions: ->
|
10
|
-
@routedActions
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
@routedActions = {}
|
13
|
+
@preparedActions = {}
|
14
|
+
for name, action of @actions when not ( name in [ 'default', 'before', 'after' ] )
|
15
|
+
[ name, filters... ] = name.split '/'
|
16
|
+
params = []
|
17
|
+
for filter in filters[ 0.. ] when /^:/.test filter
|
18
|
+
filters.splice filters.indexOf( filter ), 1
|
19
|
+
params.push filter[ 1.. ]
|
20
|
+
@routedActions[ name ] = filters: filters, params: params
|
21
|
+
@preparedActions[ name ] = [ action ]
|
22
|
+
@prepareBefores()
|
23
|
+
@prepareAfters()
|
24
|
+
@
|
25
|
+
|
26
|
+
prepareBefores: ->
|
27
|
+
if @actions.before?
|
28
|
+
beforeActions = {}
|
29
|
+
for names, action of @actions.before
|
30
|
+
for name in names.split /\s*,\s*/
|
31
|
+
( beforeActions[ name ] ?= [] ).push action
|
32
|
+
for name, actions of beforeActions
|
33
|
+
@preparedActions[ name ] = actions.concat @preparedActions[ name ]
|
19
34
|
@
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
35
|
+
|
36
|
+
prepareAfters: ->
|
37
|
+
if @actions.after?
|
38
|
+
afterActions = {}
|
39
|
+
for names, action of @actions.after
|
40
|
+
for name in names.split /\s*,\s*/
|
41
|
+
( afterActions[ name ] ?= [] ).push action
|
42
|
+
for name, actions of afterActions
|
43
|
+
@preparedActions[ name ] = @preparedActions[ name ].concat actions
|
44
|
+
@
|
45
|
+
|
46
|
+
run: ( action, filters, params ) ->
|
47
|
+
controller = @clone
|
48
|
+
collection: @Model.extensions[ @modelSysname ].where filters
|
49
|
+
params: params
|
50
|
+
controller.runAction action
|
51
|
+
if controller.defaultPrevented
|
52
|
+
controller.collection.destroy()
|
26
53
|
else
|
27
|
-
collection.show
|
28
|
-
@changeUrl
|
54
|
+
controller.collection.show action
|
55
|
+
@changeUrl action, filters
|
56
|
+
@
|
57
|
+
|
58
|
+
runAction: ( name ) ->
|
59
|
+
action.call @ for action in @preparedActions[ name ] when not @defaultPrevented
|
29
60
|
@
|
61
|
+
|
62
|
+
preventDefault: ->
|
63
|
+
@defaultPrevented = true
|
64
|
+
@
|
30
65
|
|
31
66
|
redirect: ( args... ) ->
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
query: ( args... ) ->
|
36
|
-
@::query args...
|
37
|
-
render: false
|
67
|
+
@Router.go args...
|
68
|
+
@preventDefault()
|
69
|
+
@
|
38
70
|
|
39
71
|
changeUrl: ( action, filters ) ->
|
40
72
|
params = ( value for own key, value of filters )
|
@@ -81,7 +81,7 @@ window.Nali =
|
|
81
81
|
@
|
82
82
|
|
83
83
|
removeObservationItem: ( from, obj, event ) ->
|
84
|
-
for item in @[ from ][
|
84
|
+
for item in @[ from ][..] when item[0] is obj and ( item[1] is event or not event )
|
85
85
|
@[ from ].splice @[ from ].indexOf( item ), 1
|
86
86
|
@
|
87
87
|
|
@@ -115,13 +115,13 @@ window.Nali =
|
|
115
115
|
@
|
116
116
|
|
117
117
|
unsubscribeAll: ( event ) ->
|
118
|
-
@unsubscribe item[0], event for item in @observers[
|
118
|
+
@unsubscribe item[0], event for item in @observers[..]
|
119
119
|
@
|
120
120
|
|
121
121
|
unsubscribeFromAll: ( event ) ->
|
122
|
-
@unsubscribeTo item[0], event for item in @observables[
|
122
|
+
@unsubscribeTo item[0], event for item in @observables[..]
|
123
123
|
@
|
124
124
|
|
125
125
|
trigger: ( event, args... ) ->
|
126
|
-
item[2].call item[0], args... for item in @observers[
|
126
|
+
item[2].call item[0], args... for item in @observers[..] when item[1] is event
|
127
127
|
@
|
@@ -32,7 +32,7 @@ Nali.extend Router:
|
|
32
32
|
if found = @findRoute url
|
33
33
|
{ controller, action, filters, params } = found
|
34
34
|
params[ name ] = value for name, value in options
|
35
|
-
controller.
|
35
|
+
controller.run action, filters, params
|
36
36
|
else if @Application.notFoundUrl
|
37
37
|
@go @Application.notFoundUrl
|
38
38
|
else console.warn "Not exists route to the address %s", url
|
@@ -190,8 +190,8 @@ Nali.extend View:
|
|
190
190
|
for attribute, index in node.attributes
|
191
191
|
if attribute.name is 'bind'
|
192
192
|
@assistantsMap.push nodepath: path, type: 'Form'
|
193
|
-
else if /{\s*.+?\s*}/.test attribute.
|
194
|
-
@assistantsMap.push nodepath: path.concat( 'attributes', index ), type: '
|
193
|
+
else if /{\s*.+?\s*}/.test attribute.value
|
194
|
+
@assistantsMap.push nodepath: path.concat( 'attributes', index ), type: 'Attr'
|
195
195
|
@scanAssistants child, path.concat 'childNodes', index for child, index in node.childNodes
|
196
196
|
@
|
197
197
|
|
@@ -205,6 +205,11 @@ Nali.extend View:
|
|
205
205
|
@assistants.push -> node.textContent = @analize initialValue
|
206
206
|
@
|
207
207
|
|
208
|
+
addAttrAssistant: ( node ) ->
|
209
|
+
initialValue = node.value
|
210
|
+
@assistants.push -> node.value = @analize initialValue
|
211
|
+
@
|
212
|
+
|
208
213
|
addHtmlAssistant: ( node ) ->
|
209
214
|
parent = node.parentNode
|
210
215
|
initialValue = node.innerHTML
|
@@ -254,7 +259,7 @@ Nali.extend View:
|
|
254
259
|
|
255
260
|
source.subscribe @, "update.#{ property }", =>
|
256
261
|
option.selected = true for option in node when source[ property ] + '' is option.value
|
257
|
-
|
262
|
+
@
|
258
263
|
|
259
264
|
|
260
265
|
analize: ( value ) ->
|
data/lib/generator/Gemfile
CHANGED
@@ -2,10 +2,12 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
gem 'nali'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
gem '
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
gem '
|
5
|
+
group :development, :test do
|
6
|
+
gem 'debugger'
|
7
|
+
gem 'sqlite3'
|
8
|
+
end
|
9
|
+
|
10
|
+
group :production do
|
11
|
+
gem 'yui-compressor'
|
12
|
+
gem 'uglifier'
|
13
|
+
end
|
@@ -1,11 +1,14 @@
|
|
1
|
+
require 'uglifier'
|
2
|
+
require 'yui/compressor'
|
3
|
+
|
1
4
|
Nali::Application.configure :production do |config|
|
2
5
|
|
3
|
-
|
6
|
+
ActiveRecord::Base.logger = false
|
4
7
|
|
5
|
-
|
8
|
+
config.assets_digest = true
|
6
9
|
|
7
10
|
config.assets.js_compressor = Uglifier.new( mangle: true )
|
8
|
-
|
11
|
+
|
9
12
|
config.assets.css_compressor = YUI::CssCompressor.new
|
10
13
|
|
11
14
|
end
|
data/lib/nali/application.rb
CHANGED
@@ -63,9 +63,8 @@ module Nali
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def self.initialize!
|
66
|
-
Dir[ File.join( root, 'lib/*/**/*.rb'
|
67
|
-
Dir[ File.join( root, 'app/**/*.rb'
|
68
|
-
#Dir[ File.join( root, 'vendor/*/**/*.rb' ) ].each { |file| require( file ) }
|
66
|
+
Dir[ File.join( root, 'lib/*/**/*.rb' ) ].each { |file| require( file ) }
|
67
|
+
Dir[ File.join( root, 'app/**/*.rb' ) ].each { |file| require( file ) }
|
69
68
|
require File.join( root, 'config/application' )
|
70
69
|
self
|
71
70
|
end
|
data/lib/nali/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nali
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-10-
|
12
|
+
date: 2014-10-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thin
|