backbone-subroute-rails 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +19 -0
- data/VERSION +1 -0
- data/backbone-subroute-rails.gemspec +15 -0
- data/lib/backbone-subroute-rails.rb +8 -0
- data/vendor/assets/javascripts/backbone.subroute.js +109 -0
- metadata +52 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e339aa5e5c878797891d1efeeb8e0d69ee2ce5e3
|
4
|
+
data.tar.gz: 4ee5280ea80e7bfae00888d4af5f798cd8be95f8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9ca1db87558c44a4fe9d2481faaa115a9f8c16e423510e7ed61a4b08aa1dd9e7677b492e8c436a5ebb91a594ef299ce517d751aafbd9be037c9df2028d7d1868
|
7
|
+
data.tar.gz: 47fe02fe09643978adbe8a7043828cf4aa99bb7544897641468c37ae0a5714bdec15ccaa743478f7b8fc05bacc866dd7ab18eb588607cf386a5ac9b4683bd762
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
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
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.DS_Store
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Alexander Schwartzberg
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
backbone-subroute-rails
|
2
|
+
=======================
|
3
|
+
|
4
|
+
Rails (3.1 and up) asset wrapper for the latest version of [backbone.subroute](https://github.com/ModelN/backbone.subroute) (0.4.5).
|
5
|
+
|
6
|
+
# Installation
|
7
|
+
#### Step 1: Add it to your gemfile:
|
8
|
+
|
9
|
+
gem 'backbone-subroute-rails'
|
10
|
+
|
11
|
+
#### Step 2: Include assets:
|
12
|
+
|
13
|
+
```javascript
|
14
|
+
// In application.js
|
15
|
+
//= require backbone.subroute
|
16
|
+
```
|
17
|
+
|
18
|
+
#####Special thanks to [Model N](https://github.com/ModelN) for their work on [backbone.subroute](https://github.com/ModelN/backbone.subroute).
|
19
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.4.5
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
VERSION = File.read(File.expand_path('../VERSION', __FILE__)).strip
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "backbone-subroute-rails"
|
6
|
+
spec.version = VERSION
|
7
|
+
spec.authors = ["Alexander Schwartzberg"]
|
8
|
+
spec.email = ["aeksco@gmail.com"]
|
9
|
+
spec.summary = "Rails asset wrapper for backbone.subroute"
|
10
|
+
spec.homepage = "https://github.com/aeksco/backbone-subroute-rails"
|
11
|
+
spec.license = "MIT"
|
12
|
+
|
13
|
+
spec.files = `git ls-files`.split("\n")
|
14
|
+
spec.require_paths = ["lib"]
|
15
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
// backbone-subroute 0.4.5
|
2
|
+
//
|
3
|
+
// Copyright (C) 2012 Dave Cadwallader, Model N, Inc.
|
4
|
+
// Distributed under the MIT License
|
5
|
+
//
|
6
|
+
// Documentation and full license available at:
|
7
|
+
// https://github.com/ModelN/backbone.subroute
|
8
|
+
|
9
|
+
(function(factory) {
|
10
|
+
if (typeof define === 'function' && define.amd) {
|
11
|
+
// Register as an AMD module if available...
|
12
|
+
define(['underscore', 'backbone'], factory);
|
13
|
+
} else if (typeof exports === 'object') {
|
14
|
+
// Next for Node.js, CommonJS, browserify...
|
15
|
+
module.exports = factory(require('underscore'), require('backbone'));
|
16
|
+
} else {
|
17
|
+
// Browser globals for the unenlightened...
|
18
|
+
factory(_, Backbone);
|
19
|
+
}
|
20
|
+
}(function(_, Backbone) {
|
21
|
+
|
22
|
+
Backbone.SubRoute = Backbone.Router.extend({
|
23
|
+
constructor: function(prefix, options) {
|
24
|
+
|
25
|
+
// each subroute instance should have its own routes hash
|
26
|
+
this.routes = _.clone(this.routes) || {};
|
27
|
+
|
28
|
+
// Prefix is optional, set to empty string if not passed
|
29
|
+
this.prefix = prefix = prefix || "";
|
30
|
+
|
31
|
+
// SubRoute instances may be instantiated using a prefix with or without a trailing slash.
|
32
|
+
// If the prefix does *not* have a trailing slash, we need to insert a slash as a separator
|
33
|
+
// between the prefix and the sub-route path for each route that we register with Backbone.
|
34
|
+
this.separator = (prefix.slice(-1) === "/") ? "" : "/";
|
35
|
+
|
36
|
+
// if you want to match "books" and "books/" without creating separate routes, set this
|
37
|
+
// option to "true" and the sub-router will automatically create those routes for you.
|
38
|
+
this.createTrailingSlashRoutes = options && options.createTrailingSlashRoutes;
|
39
|
+
|
40
|
+
// Required to have Backbone set up routes
|
41
|
+
Backbone.Router.prototype.constructor.call(this, options);
|
42
|
+
|
43
|
+
// grab the full URL
|
44
|
+
var hash;
|
45
|
+
if (Backbone.history.fragment) {
|
46
|
+
hash = Backbone.history.getFragment();
|
47
|
+
} else {
|
48
|
+
hash = Backbone.history.getHash();
|
49
|
+
}
|
50
|
+
|
51
|
+
// Trigger the subroute immediately. this supports the case where
|
52
|
+
// a user directly navigates to a URL with a subroute on the first page load.
|
53
|
+
// Check every element, if one matches, break. Prevent multiple matches
|
54
|
+
_.every(this.routes, function(key, route) {
|
55
|
+
// Use the Backbone parser to turn route into regex for matching
|
56
|
+
if (hash.match(Backbone.Router.prototype._routeToRegExp(route))) {
|
57
|
+
Backbone.history.loadUrl(hash);
|
58
|
+
return false;
|
59
|
+
}
|
60
|
+
return true;
|
61
|
+
}, this);
|
62
|
+
|
63
|
+
if (this.postInitialize) {
|
64
|
+
this.postInitialize(options);
|
65
|
+
}
|
66
|
+
},
|
67
|
+
navigate: function(route, options) {
|
68
|
+
if (route.substr(0, 1) != '/' &&
|
69
|
+
route.indexOf(this.prefix.substr(0, this.prefix.length - 1)) !== 0) {
|
70
|
+
|
71
|
+
route = this.prefix +
|
72
|
+
(route ? this.separator : "") +
|
73
|
+
route;
|
74
|
+
}
|
75
|
+
Backbone.Router.prototype.navigate.call(this, route, options);
|
76
|
+
},
|
77
|
+
route: function(route, name, callback) {
|
78
|
+
// strip off any leading slashes in the sub-route path,
|
79
|
+
// since we already handle inserting them when needed.
|
80
|
+
if (route.substr(0) === "/") {
|
81
|
+
route = route.substr(1, route.length);
|
82
|
+
}
|
83
|
+
|
84
|
+
var _route = this.prefix;
|
85
|
+
if (route && route.length > 0) {
|
86
|
+
if (this.prefix.length > 0)
|
87
|
+
_route += this.separator;
|
88
|
+
|
89
|
+
_route += route;
|
90
|
+
}
|
91
|
+
|
92
|
+
if (this.createTrailingSlashRoutes) {
|
93
|
+
this.routes[_route + '/'] = name;
|
94
|
+
Backbone.Router.prototype.route.call(this, _route + '/', name, callback);
|
95
|
+
}
|
96
|
+
|
97
|
+
// remove the un-prefixed route from our routes hash
|
98
|
+
delete this.routes[route];
|
99
|
+
|
100
|
+
// add the prefixed-route. note that this routes hash is just provided
|
101
|
+
// for informational and debugging purposes and is not used by the actual routing code.
|
102
|
+
this.routes[_route] = name;
|
103
|
+
|
104
|
+
// delegate the creation of the properly-prefixed route to Backbone
|
105
|
+
return Backbone.Router.prototype.route.call(this, _route, name, callback);
|
106
|
+
}
|
107
|
+
});
|
108
|
+
return Backbone.SubRoute;
|
109
|
+
}));
|
metadata
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: backbone-subroute-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander Schwartzberg
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-21 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
- aeksco@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".gitignore"
|
21
|
+
- Gemfile
|
22
|
+
- LICENSE
|
23
|
+
- README.md
|
24
|
+
- VERSION
|
25
|
+
- backbone-subroute-rails.gemspec
|
26
|
+
- lib/backbone-subroute-rails.rb
|
27
|
+
- vendor/assets/javascripts/backbone.subroute.js
|
28
|
+
homepage: https://github.com/aeksco/backbone-subroute-rails
|
29
|
+
licenses:
|
30
|
+
- MIT
|
31
|
+
metadata: {}
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
requirements: []
|
47
|
+
rubyforge_project:
|
48
|
+
rubygems_version: 2.2.2
|
49
|
+
signing_key:
|
50
|
+
specification_version: 4
|
51
|
+
summary: Rails asset wrapper for backbone.subroute
|
52
|
+
test_files: []
|