rails-backbone 0.5.2 → 0.5.3
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/lib/generators/backbone/install/install_generator.rb +6 -11
- data/lib/generators/backbone/install/templates/app.coffee +1 -1
- data/lib/generators/backbone/resource_helpers.rb +16 -4
- data/lib/generators/backbone/router/router_generator.rb +0 -3
- data/vendor/assets/javascripts/backbone.js +8 -5
- metadata +4 -4
@@ -1,6 +1,10 @@
|
|
1
|
+
require 'generators/backbone/resource_helpers'
|
2
|
+
|
1
3
|
module Backbone
|
2
4
|
module Generators
|
3
5
|
class InstallGenerator < Rails::Generators::Base
|
6
|
+
include Backbone::Generators::ResourceHelpers
|
7
|
+
|
4
8
|
source_root File.expand_path("../templates", __FILE__)
|
5
9
|
|
6
10
|
desc "This generator installs backbone.js with a default folder layout in app/assets/javascripts/backbone"
|
@@ -10,7 +14,7 @@ module Backbone
|
|
10
14
|
|
11
15
|
def inject_backbone
|
12
16
|
inject_into_file "app/assets/javascripts/application.js", :before => "//= require_tree" do
|
13
|
-
"//= require underscore\n//= require backbone\n//= require backbone_rails_sync\n//= require backbone_datalink\n//= require backbone/#{application_name}\n"
|
17
|
+
"//= require underscore\n//= require backbone\n//= require backbone_rails_sync\n//= require backbone_datalink\n//= require backbone/#{application_name.underscore}\n"
|
14
18
|
end
|
15
19
|
end
|
16
20
|
|
@@ -22,17 +26,8 @@ module Backbone
|
|
22
26
|
end
|
23
27
|
|
24
28
|
def create_app_file
|
25
|
-
template "app.coffee", "app/assets/javascripts/backbone/#{application_name}.js.coffee"
|
29
|
+
template "app.coffee", "app/assets/javascripts/backbone/#{application_name.underscore}.js.coffee"
|
26
30
|
end
|
27
|
-
|
28
|
-
protected
|
29
|
-
def application_name
|
30
|
-
if defined?(Rails) && Rails.application
|
31
|
-
Rails.application.class.name.split('::').first
|
32
|
-
else
|
33
|
-
"application"
|
34
|
-
end
|
35
|
-
end
|
36
31
|
|
37
32
|
end
|
38
33
|
end
|
@@ -7,7 +7,7 @@ module Backbone
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def model_namespace
|
10
|
-
[
|
10
|
+
[js_app_name, "Models", class_name].join(".")
|
11
11
|
end
|
12
12
|
|
13
13
|
def singular_model_name
|
@@ -19,21 +19,33 @@ module Backbone
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def collection_namespace
|
22
|
-
[
|
22
|
+
[js_app_name, "Collections", plural_name.camelize].join(".")
|
23
23
|
end
|
24
24
|
|
25
25
|
def view_namespace
|
26
|
-
[
|
26
|
+
[js_app_name, "Views", plural_name.camelize].join(".")
|
27
27
|
end
|
28
28
|
|
29
29
|
def router_namespace
|
30
|
-
[
|
30
|
+
[js_app_name, "Routers", plural_name.camelize].join(".")
|
31
31
|
end
|
32
32
|
|
33
33
|
def jst(action)
|
34
34
|
"backbone/templates/#{plural_name}/#{action}"
|
35
35
|
end
|
36
36
|
|
37
|
+
def js_app_name
|
38
|
+
application_name.camelize
|
39
|
+
end
|
40
|
+
|
41
|
+
def application_name
|
42
|
+
if defined?(Rails) && Rails.application
|
43
|
+
Rails.application.class.name.split('::').first
|
44
|
+
else
|
45
|
+
"application"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
37
49
|
def uncapitalize(str)
|
38
50
|
str[0, 1].downcase + str[1..-1]
|
39
51
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
// Backbone.js 0.5.
|
1
|
+
// Backbone.js 0.5.3
|
2
2
|
// (c) 2010 Jeremy Ashkenas, DocumentCloud Inc.
|
3
3
|
// Backbone may be freely distributed under the MIT license.
|
4
4
|
// For all details and documentation:
|
@@ -25,7 +25,7 @@
|
|
25
25
|
}
|
26
26
|
|
27
27
|
// Current version of the library. Keep in sync with `package.json`.
|
28
|
-
Backbone.VERSION = '0.5.
|
28
|
+
Backbone.VERSION = '0.5.3';
|
29
29
|
|
30
30
|
// Require Underscore, if we're on the server, and it's not already present.
|
31
31
|
var _ = root._;
|
@@ -766,7 +766,7 @@
|
|
766
766
|
fragment = window.location.hash;
|
767
767
|
}
|
768
768
|
}
|
769
|
-
return fragment.replace(hashStrip, '');
|
769
|
+
return decodeURIComponent(fragment.replace(hashStrip, ''));
|
770
770
|
},
|
771
771
|
|
772
772
|
// Start the hash change handling, returning `true` if the current URL matches
|
@@ -812,7 +812,10 @@
|
|
812
812
|
this.fragment = loc.hash.replace(hashStrip, '');
|
813
813
|
window.history.replaceState({}, document.title, loc.protocol + '//' + loc.host + this.options.root + this.fragment);
|
814
814
|
}
|
815
|
-
|
815
|
+
|
816
|
+
if (!this.options.silent) {
|
817
|
+
return this.loadUrl();
|
818
|
+
}
|
816
819
|
},
|
817
820
|
|
818
821
|
// Add a route to be tested when the fragment changes. Routes added later may
|
@@ -1071,7 +1074,7 @@
|
|
1071
1074
|
}
|
1072
1075
|
|
1073
1076
|
// Don't process data on a non-GET request.
|
1074
|
-
if (params.type !== 'GET' && !
|
1077
|
+
if (params.type !== 'GET' && !Backbone.emulateJSON) {
|
1075
1078
|
params.processData = false;
|
1076
1079
|
}
|
1077
1080
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rails-backbone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ryan Fitzgerald
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-08-
|
14
|
+
date: 2011-08-13 00:00:00 -04:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -103,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
103
|
requirements:
|
104
104
|
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
|
-
hash:
|
106
|
+
hash: 2831200879708897934
|
107
107
|
segments:
|
108
108
|
- 0
|
109
109
|
version: "0"
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
requirements:
|
113
113
|
- - ">="
|
114
114
|
- !ruby/object:Gem::Version
|
115
|
-
hash:
|
115
|
+
hash: 2831200879708897934
|
116
116
|
segments:
|
117
117
|
- 0
|
118
118
|
version: "0"
|