ende 0.1.7 → 0.1.8

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: 05341be16c6adf9fb604e0fdbb587139d9cd6835
4
- data.tar.gz: 9a6ef4d5d143fa40eceb5325ea9d5fb5e43fd981
3
+ metadata.gz: caaa7f535f49335e7750267ca46931905ff7b23e
4
+ data.tar.gz: 25f153014541704bf57f2ba14164dac5e1f748cf
5
5
  SHA512:
6
- metadata.gz: 3187b8b68a424f0a0bdfe940b7e8e07a622b42430d0163f889865b24c3a025e952f629a0b6a3757813408764147780551ddb3c2f2f3d0f01b3e1b885c02d4b07
7
- data.tar.gz: 2ec1d55d52ae63a412296cedd20e32837bab8a1e862fc2f4162f48c713c771afcfa01ab5e197c0fbea50534058260351bc2e74686aaa147a262d8b4b8e00e44f
6
+ metadata.gz: b6cabe61279b7634405d4f46f6f3b9d60afb2495d150a1dc0647a8bc54f4484c8e304841cb8a054da20534aff1a0f4b8a35ae87a8fc7d51b384d057ebf5439e0
7
+ data.tar.gz: 15724ab7f7bb9a085dda78e3274a7c290752d440727168c2b7b2f985211e04b60567b72d854e12a4e667007f57960707c7b1973ff3e0cc23c93a71f83df8f77e
data/component.json CHANGED
@@ -13,6 +13,7 @@
13
13
  "component/type": "*",
14
14
  "component/bind": "*",
15
15
  "component/jquery": "*",
16
+ "component/querystring": "*",
16
17
  "components/modernizr": "*",
17
18
  "indefinido/indemma": "*",
18
19
  "indefinido/observable": "*",
@@ -112,7 +112,7 @@ define 'aura/extensions/devise', () ->
112
112
 
113
113
  # user_password POST /users/password(.:format) devise/passwords#create
114
114
  # new_user_password GET /users/password/new(.:format) devise/passwords#new
115
- # edit_user_password GET /userss/password/edit(.:format) devise/passwords#edit
115
+ # edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
116
116
  # PATCH /users/password(.:format) devise/passwords#update
117
117
  # PUT /users/password(.:format) devise/passwords#updaet
118
118
  password =
@@ -123,7 +123,7 @@ define 'aura/extensions/devise', () ->
123
123
  password: user.password
124
124
 
125
125
  create: (user) ->
126
-
126
+ event_name = @event
127
127
  user_password = password.build user
128
128
  password.instance = user_password
129
129
 
@@ -131,7 +131,18 @@ define 'aura/extensions/devise', () ->
131
131
 
132
132
  user_password
133
133
  .save ->
134
- mediator.emit 'user.password_recovered', @
134
+ # TODO add models event emission to the models extension
135
+ # TODO detect model event emission need based on
136
+ # subscriptions to resource events
137
+ mediator.emit 'password.created', @
138
+
139
+ switch(event_name)
140
+ when 'user.create_password'
141
+ mediator.emit 'user.password_created' , user
142
+ when 'user.recover_password'
143
+ mediator.emit 'user.password_recovered', user
144
+ else
145
+ console.warn "devise password created: no corresponding confirmation event found for #{event_name}"
135
146
  .fail ->
136
147
  # TODO improve event naming
137
148
  mediator.emit 'user.unauthorized', @
@@ -168,17 +179,6 @@ define 'aura/extensions/devise', () ->
168
179
  core = application.core
169
180
  sandbox = application.sandbox
170
181
  mediator = core.mediator
171
-
172
- # Define callbacks
173
- # TODO get json with features info from devise
174
- # gem and only use apropriated listeners
175
- mediator.on 'user.sign_in' , session.create
176
- mediator.on 'user.sign_out', session.destroy
177
- mediator.on 'user.recover_password', password.create
178
-
179
-
180
- mediator.on 'action.unauthorized', domain.action_unauthorized
181
-
182
182
  # TODO add ajax control into an extension and stop using jquery directly
183
183
  jQuery(document).ajaxError (event, xhr) ->
184
184
  if xhr.status == 401
@@ -197,7 +197,11 @@ define 'aura/extensions/devise', () ->
197
197
  router.define '/users/sign_out' , 'session.destroy'
198
198
 
199
199
  # TODO get devise configuration for password recovery
200
- router.define '/users/password/new', 'password.new'
200
+ router.define '/users/password/new' , 'password.new'
201
+ router.define '/users/password/edit', 'password.edit'
202
+
203
+ # TODO get devise configuration for user registry
204
+ router.define '/users/new' , 'registration.new'
201
205
 
202
206
  define_resources: (model) ->
203
207
 
@@ -217,15 +221,28 @@ define 'aura/extensions/devise', () ->
217
221
 
218
222
  email: String
219
223
 
224
+ define_handlers: ->
225
+ # TODO get json with features info from devise
226
+ # gem and only use apropriated listeners
227
+ mediator.on 'user.sign_in' , session.create
228
+ mediator.on 'user.sign_out', session.destroy
229
+ mediator.on 'user.create_password' , password.create
230
+ mediator.on 'user.recover_password', password.create
231
+
232
+ mediator.on 'action.unauthorized', domain.action_unauthorized
233
+
234
+
220
235
  afterAppStart: (application) ->
221
236
  {router, models} = application.core
222
237
  @define_resources models
223
238
 
239
+ # We must define handlers only after resources have been
240
+ # acknowledged
241
+ @define_handlers()
242
+
224
243
  # TODO move to an external module
225
244
  @define_routes router if router?
226
245
 
227
- @define_handlers
228
-
229
246
  # Restore session if not already
230
247
  # TODO Restore only when application is ready
231
248
  session.restore()
@@ -6,23 +6,44 @@ define 'aura/extensions/routes', (routes) ->
6
6
  # TODO Remove .call null
7
7
  loader.require.call null, 'modernizr'
8
8
  loader.require.call null, 'ened/vendor/assets/javascripts/lennon/lennon.js'
9
+ query = loader.require.call null, 'querystring'
9
10
  router = null
10
11
 
11
12
  (application) ->
12
13
  core = application.core
13
14
  mediator = core.mediator
14
- _ = core.util._
15
+
16
+ # TODO unify router api
15
17
  router = new Lennon
16
18
  # TODO implement logger api for lennon or change lennon library
17
19
  # logger: application.logger
18
20
  publishEvent: (name, params) ->
19
- # TODO better method parsing
20
- params.method = "get"
21
+ # TODO method parsing (get, delete, put, post)
21
22
  mediator.emit name, params
22
23
 
24
+
25
+ router.location = (href) ->
26
+ if Modernizr.history
27
+ window.history.pushState null, null, href
28
+ else
29
+ # TODO parse href and extract path!
30
+ window.location.hash = href
31
+
32
+ router.process()
33
+
23
34
  application.core.router = router
24
35
 
25
- version: '0.1.0'
36
+ location = Object.create null,
37
+ # TODO cache query parsing
38
+ query:
39
+ get: -> query.parse window.location.search.substring(1)
40
+
41
+ toString: -> window.location
42
+
43
+ version: '0.2.0'
44
+
45
+ initialize: (application) ->
46
+ application.sandbox.location = location
26
47
 
27
48
  afterAppStart: (application) ->
28
49
  router.process()
@@ -3,54 +3,67 @@ define 'aura/extensions/states', ['application/states'], (states) ->
3
3
  'use strict'
4
4
 
5
5
  (application) ->
6
- core = application.core
7
- logger = application.logger
8
- mediator = core.mediator
9
- _ = core.util._
6
+ {core, logger} = application
7
+ {dom, mediator} = core
10
8
 
11
9
  state =
12
10
  current: 'initializing'
13
11
  list: []
14
12
  previous: null
15
13
  change: (transition) ->
16
- if state.current != transition.to
17
- from = core.state
18
- to = if transition.to == 'previous' then state.previous else transition.to
19
- state.previous = state.current
20
- state.current = to
21
- mediator.emit 'state.changed', to: to, from: from
14
+
15
+ unless transition.to == transition.from
16
+ # The application transition consists in simply store the
17
+ # old state and updating the current one
18
+ state.previous = state.current
19
+ state.current = transition.to
20
+
21
+ mediator.emit 'state.changed', transition
22
22
  else
23
23
  mediator.emit 'state.errored', to: transition.to, message: 'Application already in this state!'
24
+
24
25
  changed: (transition) ->
25
- core.dom.find('html').addClass(transition.to).removeClass(transition.from)
26
+ dom.find('html').addClass(transition.to).removeClass(transition.from)
26
27
 
27
28
  # Set default intial state
28
- core.dom.find('html').addClass state.current
29
+ dom.find('html').addClass state.current
29
30
 
30
31
  # Application flow control
31
32
  flow =
32
33
 
33
34
  changed: (transition) ->
34
- widget_configurations = states[transition.to]
35
- if widget_configurations
35
+ unormalized_widget_options = states[transition.to]
36
+
37
+ # TODO cache rendered widgets!
38
+
39
+ if unormalized_widget_options
36
40
  widgets = []
37
41
 
38
- for name, options of widget_configurations
42
+ for name, options of unormalized_widget_options
43
+ widget_name = options.name || name
44
+
45
+ # To allow user controlling the application change the
46
+ # widget configuration at runtime, we check the transition
47
+ # for widget options
39
48
  widgets.push
40
- name: options.name || name
41
- options: options
49
+ name: widget_name
50
+ options: core.util.extend transition[widget_name], options
42
51
 
52
+ # TODO document why we delete this?
43
53
  delete options.name
44
54
 
45
55
  # TODO update aura and use native start method
46
56
  core.inject(widgets).fail flow.failed
47
57
 
58
+ # To prevent reinstation upon changing to this state for the
59
+ # second time, delete stored configuration for this state
48
60
  delete states[transition.to]
61
+
49
62
  failed: (exception) ->
50
- logger.error "states.flow.failed: Failed autostarting widget #{@} \n Message: #{exception.message}", exception
63
+ logger.error "states.flow.failed: Failed autostarting widget! \n Message: #{exception.message}", exception
51
64
 
52
65
 
53
- version: '0.2.0'
66
+ version: '0.2.1'
54
67
 
55
68
  initialize: (application) ->
56
69
  mediator.on 'state.change' , state.change
@@ -65,13 +78,33 @@ define 'aura/extensions/states', ['application/states'], (states) ->
65
78
  Object.defineProperty core, 'state',
66
79
  set: (to) ->
67
80
  console.warn 'Changing state through the core object is no longer supported. Use application.state = \"other_state\" instead.'
68
- state.change to: to
81
+ application.state = to
69
82
  get: ->
70
83
  console.warn 'Getting state through the core object is no longer supported. Use application.state instead.'
71
- state.current
84
+ application.state
72
85
 
73
86
  Object.defineProperty application, 'state',
74
- set: (to) -> state.change to: to
87
+ set: (to) ->
88
+ # To use a unified internal api, transform the setter call
89
+ # into the transition api
90
+
91
+ # app.state = name: 'new_state', ...
92
+ unless $.type(to) == 'string'
93
+ transition = to: to.name
94
+ delete to.name
95
+
96
+ # app.state = 'new_state'
97
+ else
98
+ transition = to: to
99
+
100
+ # app.state = 'previous'
101
+ transition.to = if transition.to == 'previous' then state.previous else transition.to
102
+
103
+ # To change the application state, must invoke the change
104
+ # function with the apropriated transition object
105
+ transition.from = state.current
106
+ state.change transition
107
+
75
108
  get: -> state.current
76
109
 
77
110
  afterAppStart: (application) -> application.state = "default"
@@ -12,22 +12,25 @@ define 'aura/extensions/widget/lifecycleable', ->
12
12
 
13
13
  # TODO check for existing widgets before convert options, and
14
14
  # not only if type is object
15
- for subwidget_name, suboptions of options
16
- # TODO if isWidget subwidget_name
17
- if $.type(suboptions) == 'object' and not suboptions instanceof jQuery
15
+ unless options.nested
16
+ for subwidget_name, suboptions of options
17
+ # TODO if isWidget subwidget_name
18
+ if $.type(suboptions) == 'object' and not (suboptions instanceof jQuery)
18
19
 
19
- for name, suboption of suboptions
20
+ for name, suboption of suboptions
20
21
 
21
- if $.type(suboption) == 'object' and not suboption instanceof jQuery
22
+ if $.type(suboption) == 'object' and not (suboption instanceof jQuery)
22
23
 
23
- for subname, subsuboption of suboption
24
- options["#{subwidget_name}#{@capitalize name}#{@capitalize subname}"] = subsuboption
24
+ for subname, subsuboption of suboption
25
+ options["#{subwidget_name}#{@capitalize name}#{@capitalize subname}"] = subsuboption
25
26
 
26
- else
27
+ else
27
28
 
28
- options["#{subwidget_name}#{@capitalize name}"] = suboption
29
+ options["#{subwidget_name}#{@capitalize name}"] = suboption
29
30
 
30
- # TODO delete options[subwidget_name]
31
+ # TODO delete options[subwidget_name]
32
+
33
+ delete options.nested
31
34
 
32
35
  ref = definition.name.split "@"
33
36
  widgetName = @decamelize ref[0]
@@ -68,14 +71,15 @@ define 'aura/extensions/widget/lifecycleable', ->
68
71
 
69
72
  (application) ->
70
73
 
74
+ version: '0.1.0'
75
+
71
76
  initialize: (application) ->
72
- core = application.core
77
+ {core} = application
73
78
 
74
79
  # TODO use indemma inflections module instead
75
80
  core.util.capitalize = (string) ->
76
81
  string.charAt(0).toUpperCase() + string.slice(1);
77
82
 
78
-
79
83
  # Cache usefull methods
80
84
  lifecycleable.sources = application.config.widgets.sources
81
85
  lifecycleable.find = core.dom.find
@@ -0,0 +1,3 @@
1
+ <h1 data-html="form.title"> </h1>
2
+ <p data-html="form.description"> </p>
3
+
@@ -0,0 +1,23 @@
1
+ define ['./presenter', 'text!./template'], (presenter, template) ->
2
+
3
+ type: 'Base'
4
+
5
+ initialize: (options) ->
6
+ sandbox = @sandbox
7
+ sandbox.logger.log "initialized!"
8
+
9
+ model = sandbox.model options.resource
10
+ record = model options.record
11
+
12
+ # Create defaults
13
+ # TODO extract and vaidate options
14
+ form = sandbox.util.extend options,
15
+ title: options.resource
16
+
17
+ # Will also initialize sandbox!
18
+ @html template
19
+
20
+ # Bind presenter to template
21
+ presentation = presenter form, record
22
+ @$el.addClass 'form widget'
23
+ @bind presentation
@@ -0,0 +1,18 @@
1
+ 'use strict'
2
+ observable = require('observable').mixin
3
+
4
+ define ->
5
+
6
+ (form, record) ->
7
+
8
+
9
+ # TODO create view_model
10
+ form: observable Object.create null,
11
+ title:
12
+ set: (title) -> record.title = title
13
+ get: -> record.title
14
+ configurable: true
15
+ body:
16
+ set: (body) -> record.body = body
17
+ get: -> record.body
18
+ configurable: true
@@ -0,0 +1,2 @@
1
+ <h1 data-html="form.title"> </h1>
2
+ <p data-html="form.body" > </p>
@@ -10,17 +10,17 @@ define ['./states/index', './presenter'], (templates, presenter) ->
10
10
  sandbox:
11
11
  search:
12
12
  index: lunr
13
- initialize: (models) ->
14
- throw 'no models provided' unless models?
13
+ initialize: (records) ->
14
+ throw 'no records provided' unless records?
15
15
 
16
- @sample = models[0]
16
+ @sample = records[0]
17
17
  @index = @sandbox.search.index(@indexate)
18
18
 
19
- for model in models
20
- @index.add model
21
- @store.set model._id, model
19
+ for record in records
20
+ @index.add record
21
+ @store.set record._id, record
22
22
 
23
- @store.all = models
23
+ @store.all = records
24
24
 
25
25
  # TODO put bold face on matched texts
26
26
  search: (params...) ->
@@ -41,27 +41,16 @@ define ['./states/index', './presenter'], (templates, presenter) ->
41
41
  true
42
42
 
43
43
 
44
- # If some extension provides you can use the type defineda in there
45
- # to extend your widget. Defaults to Base constructor.
46
- #
47
- # type: 'Base'
44
+ # Widget Prototype
48
45
 
49
- # Default values for the options passed to this widget
50
- #
51
- # Note: the options are passed thorught the html element data
52
- # attributes for this widget: <div data-aura-amount="3"></div>
53
- #
54
- # options: {}
46
+ type: 'Base'
55
47
 
56
-
57
- # Widget initialization method, will be called upon loading, options
58
- # are already filled with defaults
59
48
  initialize: (options) ->
60
49
  widget = @
61
50
  sandbox = @sandbox
62
51
  sandbox.logger.log "initialized!"
63
52
 
64
- model = sandbox.models[options.model]
53
+ record = sandbox.models[options.model]
65
54
 
66
55
  # Will also initialize sandbox!
67
56
  @html templates.default
@@ -86,19 +86,12 @@ define ['./states/index', './presenters/default', '/assets/jquery/inview.js'], (
86
86
 
87
87
  populate: (handlers) ->
88
88
  # Initialize dependencies
89
- list = ''
90
- if @options.listModel
91
- list = "<div data-aura-widget=\"list\" data-model=\"#{@options.listModel}\"></div>"
92
- @sandbox.on 'list.stabilized' , handlers.list.stabilized
93
- @sandbox.on 'list.selection.incremented' , handlers.list.changed
94
- @sandbox.on 'list.selection.decremented' , handlers.list.changed
95
-
96
89
  @scope.all (records) =>
97
90
  @load.stop()
98
91
 
99
92
  @presentation = @presenter records
100
93
 
101
- @html list + templates[@options.resource]
94
+ @html templates[@options.resource]
102
95
  boo.initialize @$el.find '.results .items'
103
96
 
104
97
  sandbox = @sandbox
@@ -107,7 +100,7 @@ define ['./states/index', './presenters/default', '/assets/jquery/inview.js'], (
107
100
  @bind @presentation,
108
101
  binders:
109
102
  unfolding: (element) ->
110
- drawing = sandbox.modacad.drawing $(element), @model[@keypath]
103
+ drawing = sandbox.modacad.drawing $(element), @model.model
111
104
  setTimeout ->
112
105
  drawing.redisplay
113
106
  doll:
@@ -128,10 +121,9 @@ define ['./states/index', './presenters/default', '/assets/jquery/inview.js'], (
128
121
  initialize: (options) ->
129
122
  # TODO rename all options model to options.resource
130
123
  options.model ||= options.resource
131
- options.listModel ||= options.listResource
132
124
 
133
125
  # TODO import core extensions in another place
134
- @scope = model = @sandbox.models[options.model]
126
+ @scope = model = @sandbox.models[options.resource]
135
127
  cssify = @sandbox.util.inflector.cssify
136
128
  loader = @sandbox.ui.loader
137
129
  @sandbox.on "viewer.#{@identifier}.scope", @scope_to, @
@@ -46,7 +46,6 @@ define () ->
46
46
  for item in items
47
47
  unless item.normalized
48
48
  index = @items.indexOf item
49
- console.debug item, item.code, item.name, index
50
49
  @observed.items[index] = normalizer.normalize item
51
50
 
52
51
  normalizer.drawings()
data/lib/ende/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ende
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ende
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Heitor Salazar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-23 00:00:00.000000000 Z
11
+ date: 2013-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -89,6 +89,10 @@ files:
89
89
  - lib/assets/javascripts/widgets/authenticator/states/default.html
90
90
  - lib/assets/javascripts/widgets/authenticator/states/index.js.coffee
91
91
  - lib/assets/javascripts/widgets/authenticator/states/passwords.html
92
+ - lib/assets/javascripts/widgets/form/default.html
93
+ - lib/assets/javascripts/widgets/form/main.js.coffee
94
+ - lib/assets/javascripts/widgets/form/presenter.js.coffee
95
+ - lib/assets/javascripts/widgets/form/templates/password.html
92
96
  - lib/assets/javascripts/widgets/list/main.js.coffee
93
97
  - lib/assets/javascripts/widgets/list/presenter.js.coffee
94
98
  - lib/assets/javascripts/widgets/list/states/default.html