spine-rails 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,184 @@
1
+ (function() {
2
+ var $, escapeRegExp, hashStrip, namedParam, splatParam;
3
+ var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
4
+ for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
5
+ function ctor() { this.constructor = child; }
6
+ ctor.prototype = parent.prototype;
7
+ child.prototype = new ctor;
8
+ child.__super__ = parent.prototype;
9
+ return child;
10
+ }, __slice = Array.prototype.slice;
11
+ if (typeof Spine === "undefined" || Spine === null) {
12
+ Spine = require("spine");
13
+ }
14
+ $ = Spine.$;
15
+ hashStrip = /^#*/;
16
+ namedParam = /:([\w\d]+)/g;
17
+ splatParam = /\*([\w\d]+)/g;
18
+ escapeRegExp = /[-[\]{}()+?.,\\^$|#\s]/g;
19
+ Spine.Route = (function() {
20
+ __extends(Route, Spine.Module);
21
+ Route.extend(Spine.Events);
22
+ Route.historySupport = "history" in window;
23
+ Route.routes = [];
24
+ Route.options = {
25
+ trigger: true,
26
+ history: false,
27
+ shim: false
28
+ };
29
+ Route.add = function(path, callback) {
30
+ var key, value, _results;
31
+ if (typeof path === "object") {
32
+ _results = [];
33
+ for (key in path) {
34
+ value = path[key];
35
+ _results.push(this.add(key, value));
36
+ }
37
+ return _results;
38
+ } else {
39
+ return this.routes.unshift(new this(path, callback));
40
+ }
41
+ };
42
+ Route.setup = function(options) {
43
+ if (options == null) {
44
+ options = {};
45
+ }
46
+ this.options = $.extend({}, this.options, options);
47
+ if (this.options.history) {
48
+ this.history = this.historySupport && this.options.history;
49
+ }
50
+ if (this.options.shim) {
51
+ return;
52
+ }
53
+ if (this.history) {
54
+ $(window).bind("popstate", this.change);
55
+ } else {
56
+ $(window).bind("hashchange", this.change);
57
+ }
58
+ return this.change();
59
+ };
60
+ Route.unbind = function() {
61
+ if (this.history) {
62
+ return $(window).unbind("popstate", this.change);
63
+ } else {
64
+ return $(window).unbind("hashchange", this.change);
65
+ }
66
+ };
67
+ Route.navigate = function() {
68
+ var args, lastArg, options, path;
69
+ args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
70
+ options = {};
71
+ lastArg = args[args.length - 1];
72
+ if (typeof lastArg === "object") {
73
+ options = args.pop();
74
+ } else if (typeof lastArg === "boolean") {
75
+ options.trigger = args.pop();
76
+ }
77
+ options = $.extend({}, this.options, options);
78
+ path = args.join("/");
79
+ if (this.path === path) {
80
+ return;
81
+ }
82
+ this.path = path;
83
+ if (options.trigger) {
84
+ this.matchRoute(this.path, options);
85
+ }
86
+ if (options.shim) {
87
+ return;
88
+ }
89
+ if (this.history) {
90
+ return history.pushState({}, document.title, this.getHost() + this.path);
91
+ } else {
92
+ return window.location.hash = this.path;
93
+ }
94
+ };
95
+ Route.getPath = function() {
96
+ return window.location.pathname;
97
+ };
98
+ Route.getHash = function() {
99
+ return window.location.hash;
100
+ };
101
+ Route.getFragment = function() {
102
+ return this.getHash().replace(hashStrip, "");
103
+ };
104
+ Route.getHost = function() {
105
+ return (document.location + "").replace(this.getPath() + this.getHash(), "");
106
+ };
107
+ Route.change = function() {
108
+ var path;
109
+ path = this.history ? this.getPath() : this.getFragment();
110
+ if (path === this.path) {
111
+ return;
112
+ }
113
+ this.path = path;
114
+ return this.matchRoute(this.path);
115
+ };
116
+ Route.matchRoute = function(path, options) {
117
+ var route, _i, _len, _ref;
118
+ _ref = this.routes;
119
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
120
+ route = _ref[_i];
121
+ if (route.match(path, options)) {
122
+ this.trigger("change", route, path);
123
+ return route;
124
+ }
125
+ }
126
+ };
127
+ function Route(path, callback) {
128
+ var match;
129
+ this.path = path;
130
+ this.callback = callback;
131
+ this.names = [];
132
+ if (typeof path === "string") {
133
+ while ((match = namedParam.exec(path)) !== null) {
134
+ this.names.push(match[1]);
135
+ }
136
+ path = path.replace(escapeRegExp, "\\$&").replace(namedParam, "([^\/]*)").replace(splatParam, "(.*?)");
137
+ this.route = new RegExp('^' + path + '$');
138
+ } else {
139
+ this.route = path;
140
+ }
141
+ }
142
+ Route.prototype.match = function(path, options) {
143
+ var i, match, param, params, _len;
144
+ if (options == null) {
145
+ options = {};
146
+ }
147
+ match = this.route.exec(path);
148
+ if (!match) {
149
+ return false;
150
+ }
151
+ options.match = match;
152
+ params = match.slice(1);
153
+ if (this.names.length) {
154
+ for (i = 0, _len = params.length; i < _len; i++) {
155
+ param = params[i];
156
+ options[this.names[i]] = param;
157
+ }
158
+ }
159
+ return this.callback.call(null, options) !== false;
160
+ };
161
+ return Route;
162
+ })();
163
+ Spine.Route.change = Spine.Route.proxy(Spine.Route.change);
164
+ Spine.Controller.include({
165
+ route: function(path, callback) {
166
+ return Spine.Route.add(path, this.proxy(callback));
167
+ },
168
+ routes: function(routes) {
169
+ var key, value, _results;
170
+ _results = [];
171
+ for (key in routes) {
172
+ value = routes[key];
173
+ _results.push(this.route(key, value));
174
+ }
175
+ return _results;
176
+ },
177
+ navigate: function() {
178
+ return Spine.Route.navigate.apply(Spine.Route, arguments);
179
+ }
180
+ });
181
+ if (typeof module !== "undefined" && module !== null) {
182
+ module.exports = Spine.Route;
183
+ }
184
+ }).call(this);
@@ -0,0 +1,58 @@
1
+ (function() {
2
+ var $;
3
+ var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
4
+ for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
5
+ function ctor() { this.constructor = child; }
6
+ ctor.prototype = parent.prototype;
7
+ child.prototype = new ctor;
8
+ child.__super__ = parent.prototype;
9
+ return child;
10
+ };
11
+ if (typeof Spine === "undefined" || Spine === null) {
12
+ Spine = require("spine");
13
+ }
14
+ $ = Spine.$;
15
+ Spine.Tabs = (function() {
16
+ __extends(Tabs, Spine.Controller);
17
+ Tabs.prototype.events = {
18
+ "click [data-name]": "click"
19
+ };
20
+ function Tabs() {
21
+ this.change = __bind(this.change, this); Tabs.__super__.constructor.apply(this, arguments);
22
+ this.bind("change", this.change);
23
+ }
24
+ Tabs.prototype.change = function(name) {
25
+ if (!name) {
26
+ return;
27
+ }
28
+ this.current = name;
29
+ this.children().removeClass("active");
30
+ return this.children("[data-name='" + this.current + "']").addClass("active");
31
+ };
32
+ Tabs.prototype.render = function() {
33
+ this.change(this.current);
34
+ if (!(this.children(".active").length || this.current)) {
35
+ return this.children(":first").click();
36
+ }
37
+ };
38
+ Tabs.prototype.children = function(sel) {
39
+ return this.el.children(sel);
40
+ };
41
+ Tabs.prototype.click = function(e) {
42
+ var name;
43
+ name = $(e.target).attr("data-name");
44
+ return this.trigger("change", name);
45
+ };
46
+ Tabs.prototype.connect = function(tabName, controller) {
47
+ return this.bind("change", function(name) {
48
+ if (name === tabName) {
49
+ return controller.active();
50
+ }
51
+ });
52
+ };
53
+ return Tabs;
54
+ })();
55
+ if (typeof module !== "undefined" && module !== null) {
56
+ module.exports = Spine.Tabs;
57
+ }
58
+ }).call(this);
@@ -0,0 +1,17 @@
1
+ (function() {
2
+ var $;
3
+ $ = typeof jQuery !== "undefined" && jQuery !== null ? jQuery : require("jqueryify");
4
+ $.fn.item = function() {
5
+ var item;
6
+ item = $(this);
7
+ item = item.data("item") || (typeof item.tmplItem === "function" ? item.tmplItem().data : void 0);
8
+ return item != null ? typeof item.reload === "function" ? item.reload() : void 0 : void 0;
9
+ };
10
+ $.fn.forItem = function(item) {
11
+ return this.filter(function() {
12
+ var compare;
13
+ compare = $(this).item();
14
+ return (typeof item.eql === "function" ? item.eql(compare) : void 0) || item === compare;
15
+ });
16
+ };
17
+ }).call(this);
@@ -0,0 +1,18 @@
1
+ require 'rails'
2
+
3
+ module Spine
4
+ module Generators
5
+ class InstallGenerator < ::Rails::Generators::Base
6
+
7
+ desc "This generator installs Spine #{Spine::Rails::SPINE_VERSION}"
8
+
9
+ source_root File.expand_path('../../../../../app/assets/javascripts', __FILE__)
10
+
11
+ def copy_spine
12
+ say_status("copying", "Spine (#{Spine::Rails::SPINE_VERSION})", :green)
13
+ copy_file "spine.js", "public/javascripts/spine.js"
14
+ copy_file "spine.min.js", "public/javascripts/spine.min.js"
15
+ end
16
+ end
17
+ end
18
+ end if ::Rails.version < "3.1"
data/lib/spine-rails.rb CHANGED
@@ -1,12 +1 @@
1
- require 'rails/generators/base'
2
-
3
- #$: << File.expand_path(File.dirname(__FILE__))
4
-
5
- module Spinejs
6
- module Rails #Generators
7
- # Your code goes here...
8
- if ::Rails.version < "3.1"
9
- require 'spine-rails/railtie'
10
- end
11
- end
12
- end
1
+ require 'spine/rails'
@@ -0,0 +1,6 @@
1
+ module Spine
2
+ module Rails
3
+ require 'spine/rails/engine'
4
+ require 'spine/rails/version'
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Spine
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Spine
2
+ module Rails
3
+ VERSION = "0.0.2"
4
+ SPINE_VERSION = "0.0.9"
5
+ end
6
+ end
data/spine-rails.gemspec CHANGED
@@ -1,27 +1,24 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "spine-rails/version"
2
+ require File.expand_path('../lib/spine/rails/version', __FILE__)
4
3
 
5
4
  Gem::Specification.new do |s|
6
5
  s.name = "spine-rails"
7
- s.version = Spinejs::Rails::VERSION
6
+ s.version = Spine::Rails::VERSION
8
7
  s.platform = Gem::Platform::RUBY
9
- s.authors = ["Andrew Gertig"]
10
- s.email = ["andrew.gertig@gmail.com"]
11
- s.homepage = ""
12
- s.summary = %q{Add Spine.js, json2.js, and icanhaz.js to your Rails app.}
13
- s.description = %q{A gem of convenience.}
8
+ s.authors = ["Alex MacCaw"]
9
+ s.email = ["info@eribium.org"]
10
+ s.homepage = "http://rubygems.org/gems/spine-rails"
11
+ s.summary = "Use Spine with Rails 3"
12
+ s.description = "This gem provides Spine for your Rails 3 application."
14
13
 
15
- s.rubyforge_project = "spine-rails"
16
-
17
- s.add_dependency "railties", "~> 3.0"
18
- s.add_dependency "thor", "~> 0.14"
19
- s.add_dependency "curb", "~> 0.7.15"
14
+ s.required_rubygems_version = ">= 1.3.6"
15
+ s.rubyforge_project = "spine-rails"
16
+
17
+ s.add_dependency "actionpack", "~> 3.1.0"
20
18
  s.add_development_dependency "bundler", "~> 1.0.0"
21
19
  s.add_development_dependency "rails", "~> 3.0"
22
20
 
23
- s.files = `git ls-files`.split("\n")
24
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
25
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
26
- s.require_paths = ["lib"]
27
- end
21
+ s.files = `git ls-files`.split("\n")
22
+ s.executables = `git ls-files`.split("\n").select{|f| f =~ /^bin/}
23
+ s.require_path = 'lib'
24
+ end
metadata CHANGED
@@ -1,125 +1,98 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: spine-rails
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
4
5
  prerelease:
5
- version: 0.0.1
6
6
  platform: ruby
7
- authors:
8
- - Andrew Gertig
7
+ authors:
8
+ - Alex MacCaw
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-05-20 00:00:00 -04:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: railties
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
20
- none: false
21
- requirements:
22
- - - ~>
23
- - !ruby/object:Gem::Version
24
- version: "3.0"
25
- type: :runtime
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: thor
29
- prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
12
+ date: 2011-09-27 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: actionpack
16
+ requirement: &70181005400000 !ruby/object:Gem::Requirement
31
17
  none: false
32
- requirements:
18
+ requirements:
33
19
  - - ~>
34
- - !ruby/object:Gem::Version
35
- version: "0.14"
20
+ - !ruby/object:Gem::Version
21
+ version: 3.1.0
36
22
  type: :runtime
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: curb
40
23
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
44
- - - ~>
45
- - !ruby/object:Gem::Version
46
- version: 0.7.15
47
- type: :runtime
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
24
+ version_requirements: *70181005400000
25
+ - !ruby/object:Gem::Dependency
50
26
  name: bundler
51
- prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
27
+ requirement: &70181005399540 !ruby/object:Gem::Requirement
53
28
  none: false
54
- requirements:
29
+ requirements:
55
30
  - - ~>
56
- - !ruby/object:Gem::Version
31
+ - !ruby/object:Gem::Version
57
32
  version: 1.0.0
58
33
  type: :development
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
61
- name: rails
62
34
  prerelease: false
63
- requirement: &id005 !ruby/object:Gem::Requirement
35
+ version_requirements: *70181005399540
36
+ - !ruby/object:Gem::Dependency
37
+ name: rails
38
+ requirement: &70181005399080 !ruby/object:Gem::Requirement
64
39
  none: false
65
- requirements:
40
+ requirements:
66
41
  - - ~>
67
- - !ruby/object:Gem::Version
68
- version: "3.0"
42
+ - !ruby/object:Gem::Version
43
+ version: '3.0'
69
44
  type: :development
70
- version_requirements: *id005
71
- description: A gem of convenience.
72
- email:
73
- - andrew.gertig@gmail.com
45
+ prerelease: false
46
+ version_requirements: *70181005399080
47
+ description: This gem provides Spine for your Rails 3 application.
48
+ email:
49
+ - info@eribium.org
74
50
  executables: []
75
-
76
51
  extensions: []
77
-
78
52
  extra_rdoc_files: []
79
-
80
- files:
53
+ files:
81
54
  - .gitignore
82
55
  - Gemfile
56
+ - Gemfile.lock
83
57
  - Rakefile
84
- - lib/generators/spinejs/install/install_generator.rb
58
+ - app/assets/javascripts/json2.js
59
+ - app/assets/javascripts/spine.js
60
+ - app/assets/javascripts/spine/ajax.js
61
+ - app/assets/javascripts/spine/list.js
62
+ - app/assets/javascripts/spine/local.js
63
+ - app/assets/javascripts/spine/manager.js
64
+ - app/assets/javascripts/spine/relation.js
65
+ - app/assets/javascripts/spine/route.js
66
+ - app/assets/javascripts/spine/tabs.js
67
+ - app/assets/javascripts/spine/tmpl.js
68
+ - lib/generators/spine/install/install_generator.rb
85
69
  - lib/spine-rails.rb
86
- - lib/spine-rails/railtie.rb
87
- - lib/spine-rails/version.rb
88
- - lib/tasks/get_js.rake
70
+ - lib/spine/rails.rb
71
+ - lib/spine/rails/engine.rb
72
+ - lib/spine/rails/version.rb
89
73
  - spine-rails.gemspec
90
- - tasks/get_js.rake
91
- - vendor/assets/javascripts/icanhaz.js
92
- - vendor/assets/javascripts/icanhaz.min.js
93
- - vendor/assets/javascripts/json2.js
94
- - vendor/assets/javascripts/spine.js
95
- - vendor/assets/javascripts/spine.min.js
96
- has_rdoc: true
97
- homepage: ""
74
+ homepage: http://rubygems.org/gems/spine-rails
98
75
  licenses: []
99
-
100
76
  post_install_message:
101
77
  rdoc_options: []
102
-
103
- require_paths:
78
+ require_paths:
104
79
  - lib
105
- required_ruby_version: !ruby/object:Gem::Requirement
80
+ required_ruby_version: !ruby/object:Gem::Requirement
106
81
  none: false
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: "0"
111
- required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
87
  none: false
113
- requirements:
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- version: "0"
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: 1.3.6
117
92
  requirements: []
118
-
119
93
  rubyforge_project: spine-rails
120
- rubygems_version: 1.6.2
94
+ rubygems_version: 1.8.6
121
95
  signing_key:
122
96
  specification_version: 3
123
- summary: Add Spine.js, json2.js, and icanhaz.js to your Rails app.
97
+ summary: Use Spine with Rails 3
124
98
  test_files: []
125
-