ende 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/README.md +29 -0
  5. data/Rakefile +1 -0
  6. data/WTFP-LICENSE +13 -0
  7. data/component.json +31 -0
  8. data/ende.gemspec +23 -0
  9. data/lib/assets/.gitkeep +0 -0
  10. data/lib/assets/javascripts/aura/extensions/devise.js.coffee +110 -0
  11. data/lib/assets/javascripts/aura/extensions/loader.js.coffee +48 -0
  12. data/lib/assets/javascripts/aura/extensions/mediator.js +98 -0
  13. data/lib/assets/javascripts/aura/extensions/models.js.coffee.erb +56 -0
  14. data/lib/assets/javascripts/aura/extensions/rivets.js.coffee +251 -0
  15. data/lib/assets/javascripts/aura/extensions/states.js.coffee +62 -0
  16. data/lib/assets/javascripts/aura/extensions/widget/eventable.js.coffee +66 -0
  17. data/lib/assets/javascripts/aura/extensions/widget/lifecycleable.js.coffee +75 -0
  18. data/lib/assets/javascripts/config/initializers/jquery.js.coffee +6 -0
  19. data/lib/assets/javascripts/config/initializers/load_components.js.coffee +73 -0
  20. data/lib/assets/javascripts/config/initializers/requirejs.js.coffee +3 -0
  21. data/lib/assets/javascripts/ende.js.coffee +1 -0
  22. data/lib/assets/javascripts/widgets/authenticator/main.js.coffee +95 -0
  23. data/lib/assets/javascripts/widgets/authenticator/presenter.js.coffee +35 -0
  24. data/lib/assets/javascripts/widgets/authenticator/states/default.html +7 -0
  25. data/lib/assets/javascripts/widgets/authenticator/states/index.js.coffee +3 -0
  26. data/lib/assets/javascripts/widgets/authenticator/states/passwords.html +6 -0
  27. data/lib/assets/javascripts/widgets/list/main.js.coffee +82 -0
  28. data/lib/assets/javascripts/widgets/list/presenter.js.coffee +34 -0
  29. data/lib/assets/javascripts/widgets/list/states/default.html +4 -0
  30. data/lib/assets/javascripts/widgets/list/states/index.js.coffee +2 -0
  31. data/lib/assets/javascripts/widgets/viewer/main.js.coffee +139 -0
  32. data/lib/assets/javascripts/widgets/viewer/presenter.js.coffee +54 -0
  33. data/lib/assets/javascripts/widgets/viewer/states/default.html +6 -0
  34. data/lib/assets/javascripts/widgets/viewer/states/index.js.coffee +2 -0
  35. data/lib/assets/stylesheets/application/modules/authenticator.css.styl +7 -0
  36. data/lib/assets/stylesheets/application/modules/widgets/structure/list.css.styl +9 -0
  37. data/lib/assets/stylesheets/application/modules/widgets/structure/viewer.css.styl +21 -0
  38. data/lib/assets/stylesheets/application/modules/widgets/structure/widget.css.styl +5 -0
  39. data/lib/assets/stylesheets/filter.styl +10 -0
  40. data/lib/assets/stylesheets/helpers/button.styl +61 -0
  41. data/lib/assets/stylesheets/helpers/general.styl +36 -0
  42. data/lib/assets/stylesheets/helpers/index.styl +4 -0
  43. data/lib/assets/stylesheets/helpers/link.styl +6 -0
  44. data/lib/assets/stylesheets/helpers/url.styl +5 -0
  45. data/lib/assets/stylesheets/modules/button.styl +42 -0
  46. data/lib/assets/stylesheets/sprite.styl +40 -0
  47. data/lib/assets/stylesheets/ssprites.styl +1 -0
  48. data/lib/ende/version.rb +3 -0
  49. data/lib/ende.rb +21 -0
  50. data/lib/tasks/.gitkeep +0 -0
  51. data/lib/tasks/component.thor +63 -0
  52. data/lib/tasks/sprite.thor +62 -0
  53. data/vendor/assets/javascripts/stampit/stampit.js +392 -0
  54. metadata +126 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 95b8f0102eaf6c3d5fdf84a364afa9f01495d633
4
+ data.tar.gz: 44a73feca7b3353f4a51831292dc96b8f83d51dc
5
+ SHA512:
6
+ metadata.gz: 98cda4fb64e3911896acb8fdb3029c5a734a6f2ea7d99f174c439a292858596097b3d61fde980dfd93d89a799dc8f103392aa0f40063d9353d8829342b3b4dec
7
+ data.tar.gz: 08ac320f4d91562324f8a70261859e749b212fa7f0a1be9d42a13e52dfbf9cc5a780349ad9a276722045abbc9c822212144a4dde6ed90a20f0473cc55aed889b
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ende.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Ende
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ende'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ende
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/WTFP-LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2
+ Version 2, December 2004
3
+
4
+ Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
5
+
6
+ Everyone is permitted to copy and distribute verbatim or modified
7
+ copies of this license document, and changing it is allowed as long
8
+ as the name is changed.
9
+
10
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
+
13
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
data/component.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "ened",
3
+ "repo": "indefinido/ened",
4
+ "description": "Core web application functionality",
5
+ "version": "0.0.1",
6
+ "keywords": [],
7
+ "dependencies": {
8
+ "mikeric/rivets": "*",
9
+ "bestiejs/lodash": "*",
10
+ "KapIT/observe-utils": "*",
11
+ "segmentio/extend": "*",
12
+ "pluma/assimilate": "*",
13
+ "paulmillr/es6-shim": "*",
14
+ "component/type": "*",
15
+ "component/bind": "*",
16
+ "component/jquery": "*",
17
+ "indefinido/indemma": "*",
18
+ "indefinido/observable": "*",
19
+ "indefinido/advisable": "*"
20
+ },
21
+ "scripts": [
22
+ "vendor/assets/javascripts/stampit/stampit.js"
23
+ ],
24
+ "development": {},
25
+ "paths": [
26
+ "lib/components",
27
+ "vendor/components",
28
+ "vendor/assets/javascripts"
29
+ ],
30
+ "license": "MIT"
31
+ }
data/ende.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # cofding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ende/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ende"
8
+ spec.version = Ende::VERSION
9
+ spec.authors = ["Heitor Salazar"]
10
+ spec.email = ["heitorsalazar@gmail.com"]
11
+ spec.description = %q{A modular web application engine for rails. Using aurajs and indemma by default. the goal is to provideseamlessly integrstion with rails and popular rails engines, such as devise.}
12
+ spec.summary = %q{Endë (core, middle) a web application engine for rails with aurajs.}
13
+ spec.homepage = ""
14
+ spec.license = "WTFPL"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
File without changes
@@ -0,0 +1,110 @@
1
+ root = exports ? this
2
+
3
+ define 'aura/extensions/devise', () ->
4
+
5
+ 'use strict'
6
+
7
+ sandbox = null
8
+ mediator = null
9
+ core = null
10
+
11
+ # TODO create an indemma model
12
+ session =
13
+ build: (user = {}) ->
14
+
15
+ core.models.record.call
16
+ resource: 'user'
17
+ route : '/users/sessions'
18
+ email : user.email
19
+ password: user.password
20
+
21
+ # TODO better and more formal way to restore
22
+ restore: ->
23
+ # We make a dummy request to the new session path and if user is
24
+ # logged in, devise redirects us to the users/show.json path for
25
+ # the current loged in user
26
+
27
+
28
+ session.restoring = true
29
+
30
+ # Also find a better way to publish events after all widgets are
31
+ # loaded
32
+ setTimeout (( ) -> session.create()), 3000
33
+ # session.create()
34
+
35
+ create: (user) ->
36
+
37
+ user_session = session.build user
38
+ session.instance = user_session
39
+
40
+ user_session.dirty = true
41
+
42
+ user_session
43
+ .save ->
44
+ sandbox.current_user = @
45
+ sandbox.signed_in = true
46
+ mediator.emit 'user.signed_in', @
47
+
48
+ .fail ->
49
+ sandbox.current_user = null
50
+ mediator.emit 'user.unauthorized', @ unless session.restoring
51
+ sandbox.signed_in ||= false
52
+ .always ->
53
+ mediator.emit 'session.restore.tried', @ if session.restoring
54
+ session.restoring = false
55
+
56
+ # user_password POST /users/password(.:format) devise/passwords#create
57
+ # new_user_password GET /users/password/new(.:format) devise/passwords#new
58
+ # edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
59
+ # PATCH /users/password(.:format) devise/passwords#update
60
+ # PUT /users/password(.:format) devise/passwords#updaet
61
+ password =
62
+ build: (user = {}) ->
63
+ core.models.record.call
64
+ resource: 'user'
65
+ route : '/users/password'
66
+ email : user.email
67
+ password: user.password
68
+
69
+ create: (user) ->
70
+
71
+ user_password = password.build user
72
+ password.instance = user_password
73
+
74
+ user_password.dirty = true
75
+
76
+ user_password
77
+ .save ->
78
+ mediator.emit 'user.password_recovered', @
79
+ .fail ->
80
+ mediator.emit 'user.unauthorized', @
81
+
82
+
83
+
84
+ # Extension definition
85
+ name: 'devise'
86
+ initialize: (application) ->
87
+
88
+ core = application.core
89
+ sandbox = application.sandbox
90
+ mediator = core.mediator
91
+
92
+ # Define callbacks
93
+ # TODO get json with features info from devise
94
+ # gem and only use apropriated listeners
95
+ mediator.on 'user.sign_in', session.create
96
+ mediator.on 'user.recover_password', password.create
97
+
98
+ # Define api
99
+ Object.defineProperty sandbox, 'current_user',
100
+ set: (user) -> session.current_user = user
101
+ get: -> session.current_user
102
+
103
+ sandbox.session = session
104
+
105
+
106
+
107
+ afterAppStart: () ->
108
+ # Restore session if not already
109
+ # TODO Restore only when application is ready
110
+ session.restore()
@@ -0,0 +1,48 @@
1
+ define 'aura/extensions/loader', ->
2
+
3
+ 'use strict';
4
+
5
+ try
6
+ Spinner = require 'seminovos/vendor/assets/javascripts/spin/spin'
7
+ catch e
8
+ Spinner = require 'modacad/vendor/assets/javascripts/spin/spin'
9
+
10
+
11
+ (application) ->
12
+ core = application.core
13
+ mediator = core.mediator
14
+
15
+ loader =
16
+
17
+ options:
18
+ lines: 5 # The number of lines to draw
19
+ length: 0 # The length of each line
20
+ width: 12 # The line thickness
21
+ radius: 0 # The radius of the inner circle
22
+ corners: 0 # Corner roundness (0..1)
23
+ rotate: 90 # The rotation offset
24
+ direction: 1 # 1: clockwise -1: counterclockwise
25
+ color: '#FFF' # #rgb or #rrggbb
26
+ speed: 1.6 # Rounds per second
27
+ trail: 75 # Afterglow percentage
28
+ shadow: false # Whether to render a shadow
29
+ hwaccel: false # Whether to use hardware acceleration
30
+ className: 'loader' # The CSS class to assign to the spinner
31
+ zIndex: 2e9 # The z-index (defaults to 2000000000)
32
+ top: 'auto' # Top position relative to parent in px
33
+ left: 'auto' # Left position relative to parent in px
34
+
35
+ # Returns a new spinner (http://fgnass.github.io/spin.js)
36
+ # Hiding the spinner
37
+ # To hide the spinner, invoke the stop() method, which removes the UI elements from the DOM
38
+ # and stops the animation. Stopped spinners may be reused by calling spin() again.
39
+ create: (selector, options) ->
40
+ target = core.dom.find selector
41
+ new Spinner(core.util.extend {}, @options, options).spin target[0]
42
+
43
+ name: 'loader'
44
+ initialize: (application) ->
45
+ core.ui ||= {}
46
+ application.sandbox.ui = core.ui
47
+ core.ui.loader = ->
48
+ loader.create arguments...
@@ -0,0 +1,98 @@
1
+ define('aura/extensions/mediator', function () {
2
+ 'use strict';
3
+
4
+ return {
5
+ name: 'mediator',
6
+
7
+ require: {
8
+ paths: {
9
+ eventemitter: 'components/eventemitter2/lib/eventemitter2',
10
+ underscore: 'components/underscore/underscore'
11
+ },
12
+ shim: {
13
+ underscore: {
14
+ exports: '_'
15
+ }
16
+ }
17
+ },
18
+
19
+ initialize: function (app) {
20
+ var EventEmitter = require('eventemitter');
21
+ var _ = require('underscore');
22
+
23
+ app.config.mediator = _.defaults(app.config.mediator || {}, {
24
+ wildcard: true,
25
+ delimiter: '.',
26
+ newListener: true,
27
+ maxListeners: 20
28
+ });
29
+
30
+ var mediator = new EventEmitter(app.config.mediator);
31
+
32
+ app.core.mediator = mediator;
33
+
34
+ var attachListener = function(listenerType) {
35
+ return function (name, listener, context) {
36
+ if (!_.isFunction(listener) || !_.isString(name)) {
37
+ throw new Error('Invalid arguments passed to sandbox.' + listenerType);
38
+ }
39
+ context = context || this;
40
+ var callback = function() {
41
+ var args = Array.prototype.slice.call(arguments);
42
+ try {
43
+ listener.apply(context, args);
44
+ } catch(e) {
45
+ var message = "Event emission error on context: " + (context._ref || context) + "\n";
46
+ message += "With message " + (e.message || e) + "\n";
47
+ message += "Trying to emit event " + name + "\n";
48
+ message += "Failed on listener: \n " + (listener.name || listener) + "\n";
49
+ e.stack && (message += e.stack);
50
+
51
+ mediator.emit("emission.error", context);
52
+ app.logger.error("emission.error", message, 'Context:', context, 'Exception:', e);
53
+ }
54
+ };
55
+
56
+ this._events = this._events || [];
57
+ this._events.push({ name: name, listener: listener, callback: callback });
58
+
59
+ mediator[listenerType](name, callback);
60
+ };
61
+ };
62
+
63
+ app.sandbox.on = attachListener('on');
64
+ app.sandbox.once = attachListener('once');
65
+
66
+ app.sandbox.off = function (name, listener) {
67
+ if(!this._events) { return; }
68
+ this._events = _.reject(this._events, function (evt) {
69
+ var ret = (evt.name === name && evt.listener === listener);
70
+ if (ret) { mediator.off(name, evt.callback); }
71
+ return ret;
72
+ });
73
+ };
74
+
75
+ app.sandbox.emit = function () {
76
+ var debug = app.config.debug;
77
+ if(debug.enable && (debug.components.length === 0 || debug.components.indexOf("aura:mediator") !== -1)){
78
+ var eventData = Array.prototype.slice.call(arguments);
79
+ eventData.unshift('Event emitted');
80
+ app.logger.log.apply(app.logger, eventData);
81
+ }
82
+ mediator.emit.apply(mediator, arguments);
83
+ };
84
+
85
+ app.sandbox.stopListening = function () {
86
+ if (!this._events) { return; }
87
+ _.each(this._events, function (evt) {
88
+ mediator.off(evt.name, evt.callback);
89
+ });
90
+ };
91
+
92
+ var eventName = ['aura', 'sandbox', 'stop'].join(app.config.mediator.delimiter);
93
+ app.core.mediator.on(eventName, function (sandbox) {
94
+ sandbox.stopListening();
95
+ });
96
+ }
97
+ };
98
+ });
@@ -0,0 +1,56 @@
1
+ <% # TODO mover para helper %>
2
+ <% base_path = Rails.root.join('app', 'assets', 'javascripts', 'models') %>
3
+ <% models_list = Dir.glob(Rails.root.join(base_path, '**', '*.js*')) %>
4
+ <% models_list.map! do |file|
5
+ file.sub! base_path.to_s + '/', ''
6
+
7
+ # Ignore Emacs temporary files
8
+ next nil if file =~ /~/
9
+
10
+ entries = file.split /\// || []
11
+ entries.unshift 'models'
12
+ entries.push File.basename entries.pop, '.js.coffee'
13
+ File.join *entries
14
+
15
+ end.compact!
16
+ %>
17
+
18
+ root = exports ? this
19
+
20
+ define 'aura/extensions/models', <%= models_list.to_json %>, (models...) ->
21
+
22
+ 'use strict'
23
+
24
+ # TODO better require api for indemma
25
+ indemma = require 'indemma'
26
+ require 'indefinido-indemma/lib/extensions/rivets'
27
+ require 'indefinido-indemma/lib/record/rest'
28
+ require 'indefinido-indemma/lib/record/associable'
29
+ require 'indefinido-indemma/lib/record/scopable'
30
+ require 'indefinido-indemma/lib/record/restfulable'
31
+ require 'indefinido-indemma/lib/record/resource'
32
+ require 'indefinido-indemma/lib/record/maid'
33
+ require 'indefinido-indemma/lib/record/validatable'
34
+
35
+
36
+ # Extension definition
37
+ initialize: (application) ->
38
+ core = application.core
39
+ sandbox = application.sandbox
40
+ core.util.inflector =
41
+ cssify: (sentence) -> sentence.replace /\//, '-'
42
+
43
+ # TODO rename core.models to core.domain, completely
44
+ core.domain = core.models = sandbox.models = indemma.model
45
+
46
+ core.model = sandbox.model = (name) ->
47
+ # TODO use a Map internally in indemma
48
+ model = indemma.model[name]
49
+ throw new Error "Model '#{name}' not found!" unless model?
50
+ model
51
+
52
+ # TODO rename core.models to core.domain, completely
53
+ core.domain.record = core.models.record = sandbox.models.record = indemma.record
54
+
55
+ # build all model definitions
56
+ core.util._.map models, (model) -> indemma.model.call model