backbonify 0.1.0

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.
Files changed (43) hide show
  1. data/LICENSE +22 -0
  2. data/README.md +52 -0
  3. data/Rakefile +2 -0
  4. data/lib/assets/javascripts/backbone.filter.js +66 -0
  5. data/lib/assets/javascripts/backbone.grid.js +295 -0
  6. data/lib/assets/javascripts/backbone.js +1290 -0
  7. data/lib/assets/javascripts/backbone_datalink.js +21 -0
  8. data/lib/assets/javascripts/backbone_rails_sync.js +68 -0
  9. data/lib/assets/javascripts/jquery-ui.js +783 -0
  10. data/lib/assets/javascripts/jquery.js +9266 -0
  11. data/lib/assets/javascripts/jquery.notice.js +79 -0
  12. data/lib/assets/javascripts/json2.js +480 -0
  13. data/lib/assets/javascripts/underscore.js +999 -0
  14. data/lib/backbonify.rb +4 -0
  15. data/lib/backbonify/engine.rb +5 -0
  16. data/lib/backbonify/version.rb +3 -0
  17. data/lib/generators/backbonify/USAGE +8 -0
  18. data/lib/generators/backbonify/hbs/hbs_generator.rb +29 -0
  19. data/lib/generators/backbonify/hbs/templates/_form.haml +6 -0
  20. data/lib/generators/backbonify/hbs/templates/_row.haml +4 -0
  21. data/lib/generators/backbonify/hbs/templates/edit.haml +1 -0
  22. data/lib/generators/backbonify/hbs/templates/index.haml +13 -0
  23. data/lib/generators/backbonify/hbs/templates/new.haml +1 -0
  24. data/lib/generators/backbonify/hbs/templates/page.haml +6 -0
  25. data/lib/generators/backbonify/hbs/templates/show.haml +1 -0
  26. data/lib/generators/backbonify/install/install_generator.rb +57 -0
  27. data/lib/generators/backbonify/install/templates/app.js +47 -0
  28. data/lib/generators/backbonify/model/model_generator.rb +20 -0
  29. data/lib/generators/backbonify/model/templates/model.js +35 -0
  30. data/lib/generators/backbonify/resource_helpers.rb +63 -0
  31. data/lib/generators/backbonify/router/router_generator.rb +44 -0
  32. data/lib/generators/backbonify/router/templates/router.js +24 -0
  33. data/lib/generators/backbonify/router/templates/template.jst +2 -0
  34. data/lib/generators/backbonify/router/templates/view.coffee +8 -0
  35. data/lib/generators/backbonify/scaffold/scaffold_generator.rb +26 -0
  36. data/lib/generators/backbonify/views/templates/edit_view.js +34 -0
  37. data/lib/generators/backbonify/views/templates/filter_view.js +36 -0
  38. data/lib/generators/backbonify/views/templates/index_view.js +15 -0
  39. data/lib/generators/backbonify/views/templates/new_view.js +22 -0
  40. data/lib/generators/backbonify/views/templates/page_view.js +30 -0
  41. data/lib/generators/backbonify/views/templates/show_view.js +18 -0
  42. data/lib/generators/backbonify/views/views_generator.rb +21 -0
  43. metadata +122 -0
@@ -0,0 +1,36 @@
1
+ //
2
+ // FILTER : <%= singular_name.capitalize %>
3
+ //
4
+ <%= view_namespace %> = <%= view_namespace %> || {};
5
+
6
+ <%= view_namespace %>.FilterView = Backbone.View.extend({
7
+ events : {
8
+ "keypress input": "filter"
9
+ },
10
+
11
+ initialize: function() {
12
+ this.collection.bind("reset", this.showLength, this);
13
+ this.collection.bind("filter", this.showLength, this);
14
+ },
15
+
16
+ filter: function(event) {
17
+ if (event.which == 13) {
18
+ event.preventDefault();
19
+ var a = this.getAttrValue(event)
20
+ this.collection.filterAttr(a[0], a[1])
21
+ }
22
+ },
23
+
24
+ showLength:function() {
25
+ this.$(".collectionLength").text(this.collection.length)
26
+ },
27
+
28
+ // helper to get the attr 'film' out of name='performance[film]'
29
+ getAttrValue: function(event) {
30
+ var $target = $(event.currentTarget),
31
+ query = $target.val(),
32
+ attr = $target.prop("name").replace(/[a-z_].*\[([a-z].*)\]/, "$1")
33
+ return [attr, query]
34
+ }
35
+
36
+ });
@@ -0,0 +1,15 @@
1
+ //
2
+ // INDEX : <%= singular_name.capitalize %>
3
+ //
4
+ <%= view_namespace %> = <%= view_namespace %> || {};
5
+
6
+ <%= view_namespace %>.IndexView = Grid.IndexView.extend({
7
+ id: "<%= plural_name %>",
8
+ template : JST["templates/<%= plural_name %>/index"],
9
+
10
+ initialize: function(){
11
+ this.editView = <%= view_namespace %>.EditView;
12
+ },
13
+
14
+ noop: null
15
+ });
@@ -0,0 +1,22 @@
1
+ //
2
+ // NEW : <%= singular_name.capitalize %>
3
+ //
4
+ <%= view_namespace %> = <%= view_namespace %> || {};
5
+
6
+ <%= view_namespace %>.NewView = Grid.NewView.extend({
7
+ id: "new_<%= singular_name %>",
8
+ className: "new_view",
9
+ template : JST["templates/<%= plural_name %>/new"],
10
+
11
+ initialize: function() {
12
+ //if(this.collection) this.collection.bind("created", this.onCreate, this)
13
+ },
14
+
15
+ onCreate: function() {
16
+ //console.log("onCreate called... index re-rendered ?")
17
+ }
18
+
19
+
20
+ });
21
+
22
+ //_.extend(<%= view_namespace %>.EditView.prototype, <%= js_app_name %>.FormHelpers);
@@ -0,0 +1,30 @@
1
+ //
2
+ // PAGE : <%= singular_name.capitalize %>
3
+ //
4
+ <%= view_namespace %> = <%= view_namespace %> || {};
5
+
6
+ <%= view_namespace %>.PageView = Grid.PageView.extend({
7
+ id: "<%= singular_name %>Page",
8
+ template: JST["templates/<%= plural_name %>/page"],
9
+ data: {},
10
+ events : {
11
+ "click .submenu a.reload" : "reloadIndex",
12
+ "click .submenu a.<%= singular_name %>" : "displayNew"
13
+ },
14
+
15
+ initialize: function() {
16
+ this.collection = <%= js_app_name %>.<%= plural_name %>; // or new <%= collection_namespace %>;
17
+ this.collection.fetch({data: this.data});
18
+ this.indexView = new <%= view_namespace %>.IndexView({collection: this.collection});
19
+ this.newView = new <%= view_namespace %>.NewView({collection: this.collection});
20
+ },
21
+
22
+ addToPage: function() {
23
+ this.filterView = new <%= view_namespace %>.FilterView({
24
+ collection: this.collection,
25
+ el: this.$(".filters")
26
+ })
27
+ },
28
+
29
+ noop : null
30
+ });
@@ -0,0 +1,18 @@
1
+ //
2
+ // SHOW : <%= singular_name.capitalize %>
3
+ //
4
+ <%= view_namespace %> = <%= view_namespace %> || {};
5
+
6
+ <%= view_namespace %>.ShowView = Grid.EditView.extend({
7
+ tagName : "tr",
8
+ className : "new_<%= singular_name %>",
9
+ template : JST["templates/<%= plural_name %>/show"],
10
+ cell : null,
11
+ attribute : null,
12
+ inputTag : null,
13
+
14
+
15
+ noop:null
16
+ });
17
+
18
+ //_.extend(<%= view_namespace %>.EditView.prototype, <%= js_app_name %>.FormHelpers);
@@ -0,0 +1,21 @@
1
+ require 'generators/backbonify/resource_helpers'
2
+
3
+ module Backbonify
4
+ module Generators
5
+ class ViewsGenerator < Rails::Generators::NamedBase
6
+ include Backbonify::Generators::ResourceHelpers
7
+
8
+ source_root File.expand_path("../templates", __FILE__)
9
+ desc "This generator creates a set of REST views for a model"
10
+
11
+
12
+ def create_views
13
+ %w(page filter index show new edit).each do |view|
14
+ template "#{view}_view.js", File.join(backbone_path, "views", plural_name, "#{view}_view.js")
15
+ end
16
+ end
17
+
18
+
19
+ end
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: backbonify
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Charles Sistovaris
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-03-16 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rails
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 5
29
+ segments:
30
+ - 3
31
+ - 1
32
+ version: "3.1"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description: A generator for Backbone in Rails >= 3.1. The Language is javascript (no coffee) and the template engine is (only) handlebars wrapped in haml! However this generator takes advantage of hooks (brought by yehuda in rails 3) so it is easy to add other template engines and so on....
36
+ email:
37
+ - charlysisto@gmail.com
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files: []
43
+
44
+ files:
45
+ - lib/assets/javascripts/backbone.filter.js
46
+ - lib/assets/javascripts/backbone.grid.js
47
+ - lib/assets/javascripts/backbone.js
48
+ - lib/assets/javascripts/backbone_datalink.js
49
+ - lib/assets/javascripts/backbone_rails_sync.js
50
+ - lib/assets/javascripts/jquery-ui.js
51
+ - lib/assets/javascripts/jquery.js
52
+ - lib/assets/javascripts/jquery.notice.js
53
+ - lib/assets/javascripts/json2.js
54
+ - lib/assets/javascripts/underscore.js
55
+ - lib/backbonify/engine.rb
56
+ - lib/backbonify/version.rb
57
+ - lib/backbonify.rb
58
+ - lib/generators/backbonify/hbs/hbs_generator.rb
59
+ - lib/generators/backbonify/hbs/templates/_form.haml
60
+ - lib/generators/backbonify/hbs/templates/_row.haml
61
+ - lib/generators/backbonify/hbs/templates/edit.haml
62
+ - lib/generators/backbonify/hbs/templates/index.haml
63
+ - lib/generators/backbonify/hbs/templates/new.haml
64
+ - lib/generators/backbonify/hbs/templates/page.haml
65
+ - lib/generators/backbonify/hbs/templates/show.haml
66
+ - lib/generators/backbonify/install/install_generator.rb
67
+ - lib/generators/backbonify/install/templates/app.js
68
+ - lib/generators/backbonify/model/model_generator.rb
69
+ - lib/generators/backbonify/model/templates/model.js
70
+ - lib/generators/backbonify/resource_helpers.rb
71
+ - lib/generators/backbonify/router/router_generator.rb
72
+ - lib/generators/backbonify/router/templates/router.js
73
+ - lib/generators/backbonify/router/templates/template.jst
74
+ - lib/generators/backbonify/router/templates/view.coffee
75
+ - lib/generators/backbonify/scaffold/scaffold_generator.rb
76
+ - lib/generators/backbonify/USAGE
77
+ - lib/generators/backbonify/views/templates/edit_view.js
78
+ - lib/generators/backbonify/views/templates/filter_view.js
79
+ - lib/generators/backbonify/views/templates/index_view.js
80
+ - lib/generators/backbonify/views/templates/new_view.js
81
+ - lib/generators/backbonify/views/templates/page_view.js
82
+ - lib/generators/backbonify/views/templates/show_view.js
83
+ - lib/generators/backbonify/views/views_generator.rb
84
+ - LICENSE
85
+ - Rakefile
86
+ - README.md
87
+ homepage: https://github.com/charly/backbonify
88
+ licenses: []
89
+
90
+ post_install_message:
91
+ rdoc_options: []
92
+
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ hash: 3
101
+ segments:
102
+ - 0
103
+ version: "0"
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ hash: 3
110
+ segments:
111
+ - 0
112
+ version: "0"
113
+ requirements: []
114
+
115
+ rubyforge_project:
116
+ rubygems_version: 1.8.17
117
+ signing_key:
118
+ specification_version: 3
119
+ summary: Backbone Generator for Rails >= 3.1
120
+ test_files: []
121
+
122
+ has_rdoc: