boardintel_frenzy_bunnies 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/Guardfile +19 -0
- data/LICENSE +22 -0
- data/README.md +165 -0
- data/Rakefile +2 -0
- data/bin/frenzy_bunnies +6 -0
- data/examples/feed.rb +20 -0
- data/examples/feed_worker.rb +33 -0
- data/examples/feed_workers_bin.rb +21 -0
- data/fb-cap.png +0 -0
- data/frenzy_bunnies.gemspec +27 -0
- data/lib/frenzy_bunnies/cli.rb +29 -0
- data/lib/frenzy_bunnies/context.rb +40 -0
- data/lib/frenzy_bunnies/handlers/maxretry.rb +199 -0
- data/lib/frenzy_bunnies/handlers/oneshot.rb +31 -0
- data/lib/frenzy_bunnies/health/collector.rb +21 -0
- data/lib/frenzy_bunnies/health/providers/jvm.rb +43 -0
- data/lib/frenzy_bunnies/health.rb +10 -0
- data/lib/frenzy_bunnies/queue_factory.rb +23 -0
- data/lib/frenzy_bunnies/version.rb +3 -0
- data/lib/frenzy_bunnies/web/public/css/bootstrap.min.css +9 -0
- data/lib/frenzy_bunnies/web/public/img/bunny16.png +0 -0
- data/lib/frenzy_bunnies/web/public/img/bunny32.png +0 -0
- data/lib/frenzy_bunnies/web/public/index.html +225 -0
- data/lib/frenzy_bunnies/web/public/js/app.coffee +90 -0
- data/lib/frenzy_bunnies/web/public/js/app.js +202 -0
- data/lib/frenzy_bunnies/web/public/js/backbone-min.js +40 -0
- data/lib/frenzy_bunnies/web/public/js/bootstrap.js +2027 -0
- data/lib/frenzy_bunnies/web/public/js/bootstrap.min.js +6 -0
- data/lib/frenzy_bunnies/web/public/js/jquery-1.8.0.min.js +2 -0
- data/lib/frenzy_bunnies/web/public/js/jquery.filesize.js +52 -0
- data/lib/frenzy_bunnies/web/public/js/jquery.timeago.js +152 -0
- data/lib/frenzy_bunnies/web/public/js/underscore-min.js +32 -0
- data/lib/frenzy_bunnies/web.rb +51 -0
- data/lib/frenzy_bunnies/worker.rb +102 -0
- data/lib/frenzy_bunnies.rb +15 -0
- data/spec/frenzy_bunnies/worker_spec.rb +117 -0
- data/spec/spec_helper.rb +35 -0
- metadata +197 -0
@@ -0,0 +1,202 @@
|
|
1
|
+
(function() {
|
2
|
+
var Health, HealthView, Job, JobItemView, Jobs, JobsCollection, JobsView, health, health_view, jobs_view, refresh_data,
|
3
|
+
__hasProp = {}.hasOwnProperty,
|
4
|
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
5
|
+
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
6
|
+
|
7
|
+
Job = (function(_super) {
|
8
|
+
|
9
|
+
__extends(Job, _super);
|
10
|
+
|
11
|
+
function Job() {
|
12
|
+
return Job.__super__.constructor.apply(this, arguments);
|
13
|
+
}
|
14
|
+
|
15
|
+
return Job;
|
16
|
+
|
17
|
+
})(Backbone.Model);
|
18
|
+
|
19
|
+
JobsCollection = (function(_super) {
|
20
|
+
|
21
|
+
__extends(JobsCollection, _super);
|
22
|
+
|
23
|
+
function JobsCollection() {
|
24
|
+
return JobsCollection.__super__.constructor.apply(this, arguments);
|
25
|
+
}
|
26
|
+
|
27
|
+
JobsCollection.prototype.model = Job;
|
28
|
+
|
29
|
+
JobsCollection.prototype.url = '/stats';
|
30
|
+
|
31
|
+
return JobsCollection;
|
32
|
+
|
33
|
+
})(Backbone.Collection);
|
34
|
+
|
35
|
+
Jobs = new JobsCollection;
|
36
|
+
|
37
|
+
Jobs.comparator = function(p) {
|
38
|
+
return p.get('name');
|
39
|
+
};
|
40
|
+
|
41
|
+
Health = (function(_super) {
|
42
|
+
|
43
|
+
__extends(Health, _super);
|
44
|
+
|
45
|
+
function Health() {
|
46
|
+
return Health.__super__.constructor.apply(this, arguments);
|
47
|
+
}
|
48
|
+
|
49
|
+
Health.prototype.url = '/health';
|
50
|
+
|
51
|
+
return Health;
|
52
|
+
|
53
|
+
})(Backbone.Model);
|
54
|
+
|
55
|
+
JobItemView = (function(_super) {
|
56
|
+
|
57
|
+
__extends(JobItemView, _super);
|
58
|
+
|
59
|
+
function JobItemView() {
|
60
|
+
this.render = __bind(this.render, this);
|
61
|
+
return JobItemView.__super__.constructor.apply(this, arguments);
|
62
|
+
}
|
63
|
+
|
64
|
+
JobItemView.prototype.tagName = 'article';
|
65
|
+
|
66
|
+
JobItemView.prototype.className = 'job';
|
67
|
+
|
68
|
+
JobItemView.prototype.template = _.template($('#tmpl-job').html());
|
69
|
+
|
70
|
+
JobItemView.prototype.render = function() {
|
71
|
+
this.$el.html(this.template(this.model.toJSON()));
|
72
|
+
return this.el;
|
73
|
+
};
|
74
|
+
|
75
|
+
return JobItemView;
|
76
|
+
|
77
|
+
})(Backbone.View);
|
78
|
+
|
79
|
+
JobsView = (function(_super) {
|
80
|
+
|
81
|
+
__extends(JobsView, _super);
|
82
|
+
|
83
|
+
function JobsView() {
|
84
|
+
this.render = __bind(this.render, this);
|
85
|
+
return JobsView.__super__.constructor.apply(this, arguments);
|
86
|
+
}
|
87
|
+
|
88
|
+
JobsView.prototype.tagName = 'div';
|
89
|
+
|
90
|
+
JobsView.prototype.id = 'jobs';
|
91
|
+
|
92
|
+
JobsView.prototype.render = function() {
|
93
|
+
var _this = this;
|
94
|
+
this.$el.empty();
|
95
|
+
this.model.forEach(function(p) {
|
96
|
+
var v;
|
97
|
+
v = new JobItemView({
|
98
|
+
model: p
|
99
|
+
});
|
100
|
+
v.render();
|
101
|
+
return _this.$el.append(v.el);
|
102
|
+
});
|
103
|
+
return this.el;
|
104
|
+
};
|
105
|
+
|
106
|
+
return JobsView;
|
107
|
+
|
108
|
+
})(Backbone.View);
|
109
|
+
|
110
|
+
HealthView = (function(_super) {
|
111
|
+
|
112
|
+
__extends(HealthView, _super);
|
113
|
+
|
114
|
+
function HealthView() {
|
115
|
+
this.render = __bind(this.render, this);
|
116
|
+
return HealthView.__super__.constructor.apply(this, arguments);
|
117
|
+
}
|
118
|
+
|
119
|
+
HealthView.prototype.tagName = 'div';
|
120
|
+
|
121
|
+
HealthView.prototype.id = 'health';
|
122
|
+
|
123
|
+
HealthView.prototype.template = _.template($('#tmpl-health').html());
|
124
|
+
|
125
|
+
HealthView.prototype.render = function() {
|
126
|
+
this.$el.html(this.template(this.model.toJSON()));
|
127
|
+
$("#heap-usage .prop-value").filesize();
|
128
|
+
return this.el;
|
129
|
+
};
|
130
|
+
|
131
|
+
return HealthView;
|
132
|
+
|
133
|
+
})(Backbone.View);
|
134
|
+
|
135
|
+
health = new Health;
|
136
|
+
|
137
|
+
jobs_view = new JobsView({
|
138
|
+
model: Jobs,
|
139
|
+
el: $('#job-list')
|
140
|
+
});
|
141
|
+
|
142
|
+
health_view = new HealthView({
|
143
|
+
model: health,
|
144
|
+
el: $('#health')
|
145
|
+
});
|
146
|
+
|
147
|
+
refresh_data = function() {
|
148
|
+
console.debug("refreshing data");
|
149
|
+
return Jobs.fetch({
|
150
|
+
success: function() {
|
151
|
+
jobs_view.render();
|
152
|
+
return health.fetch({
|
153
|
+
success: function() {
|
154
|
+
var $spy;
|
155
|
+
health_view.render();
|
156
|
+
return $spy = $('[data-spy="scroll"]').each(function() {
|
157
|
+
return $(this).scrollspy('refresh');
|
158
|
+
});
|
159
|
+
}
|
160
|
+
});
|
161
|
+
}
|
162
|
+
});
|
163
|
+
};
|
164
|
+
|
165
|
+
$(function() {
|
166
|
+
return refresh_data();
|
167
|
+
});
|
168
|
+
|
169
|
+
setInterval(refresh_data, 60 * 1000);
|
170
|
+
|
171
|
+
this.ellipsis = function(str, max) {
|
172
|
+
var delta, fifth, len;
|
173
|
+
len = str.length;
|
174
|
+
if (len < max) {
|
175
|
+
return str;
|
176
|
+
}
|
177
|
+
fifth = Math.round(max / 5);
|
178
|
+
console.log(fifth);
|
179
|
+
delta = len - max;
|
180
|
+
str = str.slice(0, fifth + 1 || 9e9) + "..." + str.slice(fifth + delta, len + 1 || 9e9);
|
181
|
+
return str;
|
182
|
+
};
|
183
|
+
|
184
|
+
jQuery.timeago.settings.strings = {
|
185
|
+
prefixAgo: null,
|
186
|
+
prefixFromNow: null,
|
187
|
+
suffixAgo: null,
|
188
|
+
suffixFromNow: null,
|
189
|
+
seconds: "sec",
|
190
|
+
minute: "1 min",
|
191
|
+
minutes: "%d mins",
|
192
|
+
hour: "1 hr",
|
193
|
+
hours: "%d hrs",
|
194
|
+
day: "1 day",
|
195
|
+
days: "%d days",
|
196
|
+
month: "1 mo",
|
197
|
+
months: "%d mo",
|
198
|
+
year: "1 year",
|
199
|
+
years: "%d yrs"
|
200
|
+
};
|
201
|
+
|
202
|
+
}).call(this);
|
@@ -0,0 +1,40 @@
|
|
1
|
+
// Backbone.js 0.9.2
|
2
|
+
|
3
|
+
// (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc.
|
4
|
+
// Backbone may be freely distributed under the MIT license.
|
5
|
+
// For all details and documentation:
|
6
|
+
// http://backbonejs.org
|
7
|
+
(function(){var k=this,y=k.Backbone,z=Array.prototype.splice,g;g="undefined"!==typeof exports?exports:k.Backbone={};g.VERSION="0.9.2";var f=k._;!f&&"undefined"!==typeof require&&(f=require("underscore"));g.$=k.jQuery||k.Zepto||k.ender;g.noConflict=function(){k.Backbone=y;return this};g.emulateHTTP=!1;g.emulateJSON=!1;var p=/\s+/,h=g.Events={on:function(a,b,c){var d,e;if(!b)return this;a=a.split(p);for(d=this._callbacks||(this._callbacks={});e=a.shift();)e=d[e]||(d[e]=[]),e.push(b,c);return this},
|
8
|
+
off:function(a,b,c){var d,e,m;if(!(e=this._callbacks))return this;if(!a&&!b&&!c)return delete this._callbacks,this;for(a=a?a.split(p):f.keys(e);d=a.shift();)if(!(m=e[d])||!b&&!c)delete e[d];else for(d=m.length-2;0<=d;d-=2)b&&m[d]!==b||c&&m[d+1]!==c||m.splice(d,2);return this},trigger:function(a){var b,c,d,e,f,g,j;if(!(c=this._callbacks))return this;j=[];a=a.split(p);e=1;for(f=arguments.length;e<f;e++)j[e-1]=arguments[e];for(;b=a.shift();){if(g=c.all)g=g.slice();if(d=c[b])d=d.slice();if(d){e=0;for(f=
|
9
|
+
d.length;e<f;e+=2)d[e].apply(d[e+1]||this,j)}if(g){b=[b].concat(j);e=0;for(f=g.length;e<f;e+=2)g[e].apply(g[e+1]||this,b)}}return this}};h.bind=h.on;h.unbind=h.off;var o=g.Model=function(a,b){var c;a||(a={});b&&b.collection&&(this.collection=b.collection);b&&b.parse&&(a=this.parse(a));if(c=l(this,"defaults"))a=f.extend({},c,a);this.attributes={};this._escapedAttributes={};this.cid=f.uniqueId("c");this.changed={};this._silent={};this._pending={};this.set(a,{silent:!0});this.changed={};this._silent=
|
10
|
+
{};this._pending={};this._previousAttributes=f.clone(this.attributes);this.initialize.apply(this,arguments)};f.extend(o.prototype,h,{changed:null,_silent:null,_pending:null,idAttribute:"id",initialize:function(){},toJSON:function(){return f.clone(this.attributes)},sync:function(){return g.sync.apply(this,arguments)},get:function(a){return this.attributes[a]},escape:function(a){var b;if(b=this._escapedAttributes[a])return b;b=this.get(a);return this._escapedAttributes[a]=f.escape(null==b?"":""+b)},
|
11
|
+
has:function(a){return null!=this.get(a)},set:function(a,b,c){var d,e;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b);c||(c={});if(!d)return this;d instanceof o&&(d=d.attributes);if(c.unset)for(e in d)d[e]=void 0;if(!this._validate(d,c))return!1;this.idAttribute in d&&(this.id=d[this.idAttribute]);var b=c.changes={},g=this.attributes,i=this._escapedAttributes,j=this._previousAttributes||{};for(e in d){a=d[e];if(!f.isEqual(g[e],a)||c.unset&&f.has(g,e))delete i[e],(c.silent?this._silent:b)[e]=!0;c.unset?
|
12
|
+
delete g[e]:g[e]=a;!f.isEqual(j[e],a)||f.has(g,e)!==f.has(j,e)?(this.changed[e]=a,c.silent||(this._pending[e]=!0)):(delete this.changed[e],delete this._pending[e])}c.silent||this.change(c);return this},unset:function(a,b){b=f.extend({},b,{unset:!0});return this.set(a,null,b)},clear:function(a){a=f.extend({},a,{unset:!0});return this.set(f.clone(this.attributes),a)},fetch:function(a){var a=a?f.clone(a):{},b=this,c=a.success;a.success=function(d,e,f){if(!b.set(b.parse(d,f),a))return!1;c&&c(b,d,a);b.trigger("sync",
|
13
|
+
b,d,a)};a.error=g.wrapError(a.error,b,a);return this.sync("read",this,a)},save:function(a,b,c){var d,e,m;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b);c=c?f.clone(c):{};if(c.wait){if(!this._validate(d,c))return!1;e=f.clone(this.attributes)}a=f.extend({},c,{silent:!0});if(d&&!this.set(d,c.wait?a:c)||!d&&!this.isValid())return!1;var i=this,j=c.success;c.success=function(a,b,e){m=true;b=i.parse(a,e);c.wait&&(b=f.extend(d||{},b));if(!i.set(b,c))return false;j&&j(i,a,c);i.trigger("sync",i,a,c)};c.error=
|
14
|
+
g.wrapError(c.error,i,c);b=this.sync(this.isNew()?"create":"update",this,c);!m&&c.wait&&(this.clear(a),this.set(e,a));return b},destroy:function(a){var a=a?f.clone(a):{},b=this,c=a.success,d=function(){b.trigger("destroy",b,b.collection,a)};a.success=function(e){(a.wait||b.isNew())&&d();c&&c(b,e,a);b.isNew()||b.trigger("sync",b,e,a)};if(this.isNew())return a.success(),!1;a.error=g.wrapError(a.error,b,a);var e=this.sync("delete",this,a);a.wait||d();return e},url:function(){var a=l(this,"urlRoot")||
|
15
|
+
l(this.collection,"url")||s();return this.isNew()?a:a+("/"===a.charAt(a.length-1)?"":"/")+encodeURIComponent(this.id)},parse:function(a){return a},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return null==this.id},change:function(a){a||(a={});var b=this._changing;this._changing=!0;for(var c in this._silent)this._pending[c]=!0;var d=f.extend({},a.changes,this._silent);this._silent={};for(c in d)this.trigger("change:"+c,this,this.get(c),a);if(b)return this;for(;!f.isEmpty(this._pending);){this._pending=
|
16
|
+
{};this.trigger("change",this,a);for(c in this.changed)!this._pending[c]&&!this._silent[c]&&delete this.changed[c];this._previousAttributes=f.clone(this.attributes)}this._changing=!1;return this},hasChanged:function(a){return null==a?!f.isEmpty(this.changed):f.has(this.changed,a)},changedAttributes:function(a){if(!a)return this.hasChanged()?f.clone(this.changed):!1;var b,c=!1,d=this._previousAttributes,e;for(e in a)if(!f.isEqual(d[e],b=a[e]))(c||(c={}))[e]=b;return c},previous:function(a){return null==
|
17
|
+
a||!this._previousAttributes?null:this._previousAttributes[a]},previousAttributes:function(){return f.clone(this._previousAttributes)},isValid:function(){return!this.validate||!this.validate(this.attributes)},_validate:function(a,b){if(b.silent||!this.validate)return!0;var a=f.extend({},this.attributes,a),c=this.validate(a,b);if(!c)return!0;b&&b.error?b.error(this,c,b):this.trigger("error",this,c,b);return!1}});var q=g.Collection=function(a,b){b||(b={});b.model&&(this.model=b.model);void 0!==b.comparator&&
|
18
|
+
(this.comparator=b.comparator);this._reset();this.initialize.apply(this,arguments);a&&(b.parse&&(a=this.parse(a)),this.reset(a,{silent:!0,parse:b.parse}))};f.extend(q.prototype,h,{model:o,initialize:function(){},toJSON:function(a){return this.map(function(b){return b.toJSON(a)})},sync:function(){return g.sync.apply(this,arguments)},add:function(a,b){var c,d,e,g,i,j={},k={},h=[];b||(b={});a=f.isArray(a)?a.slice():[a];c=0;for(d=a.length;c<d;c++){if(!(e=a[c]=this._prepareModel(a[c],b)))throw Error("Can't add an invalid model to a collection");
|
19
|
+
g=e.cid;i=e.id;j[g]||this._byCid[g]||null!=i&&(k[i]||this._byId[i])?h.push(c):j[g]=k[i]=e}for(c=h.length;c--;)h[c]=a.splice(h[c],1)[0];c=0;for(d=a.length;c<d;c++)(e=a[c]).on("all",this._onModelEvent,this),this._byCid[e.cid]=e,null!=e.id&&(this._byId[e.id]=e);this.length+=d;z.apply(this.models,[null!=b.at?b.at:this.models.length,0].concat(a));if(b.merge){c=0;for(d=h.length;c<d;c++)(e=this._byId[h[c].id])&&e.set(h[c],b)}this.comparator&&null==b.at&&this.sort({silent:!0});if(b.silent)return this;c=0;
|
20
|
+
for(d=this.models.length;c<d;c++)if(j[(e=this.models[c]).cid])b.index=c,e.trigger("add",e,this,b);return this},remove:function(a,b){var c,d,e,g;b||(b={});a=f.isArray(a)?a.slice():[a];c=0;for(d=a.length;c<d;c++)if(g=this.getByCid(a[c])||this.get(a[c]))delete this._byId[g.id],delete this._byCid[g.cid],e=this.indexOf(g),this.models.splice(e,1),this.length--,b.silent||(b.index=e,g.trigger("remove",g,this,b)),this._removeReference(g);return this},push:function(a,b){a=this._prepareModel(a,b);this.add(a,
|
21
|
+
b);return a},pop:function(a){var b=this.at(this.length-1);this.remove(b,a);return b},unshift:function(a,b){a=this._prepareModel(a,b);this.add(a,f.extend({at:0},b));return a},shift:function(a){var b=this.at(0);this.remove(b,a);return b},slice:function(a,b){return this.models.slice(a,b)},get:function(a){return null==a?void 0:this._byId[null!=a.id?a.id:a]},getByCid:function(a){return a&&this._byCid[a.cid||a]},at:function(a){return this.models[a]},where:function(a){return f.isEmpty(a)?[]:this.filter(function(b){for(var c in a)if(a[c]!==
|
22
|
+
b.get(c))return!1;return!0})},sort:function(a){a||(a={});if(!this.comparator)throw Error("Cannot sort a set without a comparator");var b=f.bind(this.comparator,this);1===this.comparator.length?this.models=this.sortBy(b):this.models.sort(b);a.silent||this.trigger("reset",this,a);return this},pluck:function(a){return f.map(this.models,function(b){return b.get(a)})},reset:function(a,b){a||(a=[]);b||(b={});for(var c=0,d=this.models.length;c<d;c++)this._removeReference(this.models[c]);this._reset();this.add(a,
|
23
|
+
f.extend({silent:!0},b));b.silent||this.trigger("reset",this,b);return this},fetch:function(a){a=a?f.clone(a):{};void 0===a.parse&&(a.parse=!0);var b=this,c=a.success;a.success=function(d,e,f){b[a.add?"add":"reset"](b.parse(d,f),a);c&&c(b,d,a);b.trigger("sync",b,d,a)};a.error=g.wrapError(a.error,b,a);return this.sync("read",this,a)},create:function(a,b){var c=this,b=b?f.clone(b):{},a=this._prepareModel(a,b);if(!a)return!1;b.wait||c.add(a,b);var d=b.success;b.success=function(a,b,f){f.wait&&c.add(a,
|
24
|
+
f);d&&d(a,b,f)};a.save(null,b);return a},parse:function(a){return a},clone:function(){return new this.constructor(this.models)},chain:function(){return f(this.models).chain()},_reset:function(){this.length=0;this.models=[];this._byId={};this._byCid={}},_prepareModel:function(a,b){if(a instanceof o)return a.collection||(a.collection=this),a;b||(b={});b.collection=this;var c=new this.model(a,b);return!c._validate(c.attributes,b)?!1:c},_removeReference:function(a){this===a.collection&&delete a.collection;
|
25
|
+
a.off("all",this._onModelEvent,this)},_onModelEvent:function(a,b,c,d){("add"===a||"remove"===a)&&c!==this||("destroy"===a&&this.remove(b,d),b&&a==="change:"+b.idAttribute&&(delete this._byId[b.previous(b.idAttribute)],null!=b.id&&(this._byId[b.id]=b)),this.trigger.apply(this,arguments))}});f.each("forEach each map reduce reduceRight find detect filter select reject every all some any include contains invoke max min sortBy sortedIndex toArray size first initial rest last without indexOf shuffle lastIndexOf isEmpty groupBy".split(" "),
|
26
|
+
function(a){q.prototype[a]=function(){return f[a].apply(f,[this.models].concat(f.toArray(arguments)))}});var t=g.Router=function(a){a||(a={});a.routes&&(this.routes=a.routes);this._bindRoutes();this.initialize.apply(this,arguments)},A=/:\w+/g,B=/\*\w+/g,C=/[-[\]{}()+?.,\\^$|#\s]/g;f.extend(t.prototype,h,{initialize:function(){},route:function(a,b,c){g.history||(g.history=new n);f.isRegExp(a)||(a=this._routeToRegExp(a));c||(c=this[b]);g.history.route(a,f.bind(function(d){d=this._extractParameters(a,
|
27
|
+
d);c&&c.apply(this,d);this.trigger.apply(this,["route:"+b].concat(d));g.history.trigger("route",this,b,d)},this));return this},navigate:function(a,b){g.history.navigate(a,b)},_bindRoutes:function(){if(this.routes){var a=[],b;for(b in this.routes)a.unshift([b,this.routes[b]]);b=0;for(var c=a.length;b<c;b++)this.route(a[b][0],a[b][1],this[a[b][1]])}},_routeToRegExp:function(a){a=a.replace(C,"\\$&").replace(A,"([^/]+)").replace(B,"(.*?)");return RegExp("^"+a+"$")},_extractParameters:function(a,b){return a.exec(b).slice(1)}});
|
28
|
+
var n=g.History=function(a){this.handlers=[];f.bindAll(this,"checkUrl");this.location=a&&a.location||k.location;this.history=a&&a.history||k.history},r=/^[#\/]/,D=/msie [\w.]+/,u=/\/$/;n.started=!1;f.extend(n.prototype,h,{interval:50,getHash:function(a){return(a=(a||this).location.href.match(/#(.*)$/))?a[1]:""},getFragment:function(a,b){if(null==a)if(this._hasPushState||!this._wantsHashChange||b){var a=this.location.pathname,c=this.options.root.replace(u,"");a.indexOf(c)||(a=a.substr(c.length))}else a=
|
29
|
+
this.getHash();return decodeURIComponent(a.replace(r,""))},start:function(a){if(n.started)throw Error("Backbone.history has already been started");n.started=!0;this.options=f.extend({},{root:"/"},this.options,a);this._wantsHashChange=!1!==this.options.hashChange;this._wantsPushState=!!this.options.pushState;this._hasPushState=!(!this.options.pushState||!this.history||!this.history.pushState);var a=this.getFragment(),b=document.documentMode,b=D.exec(navigator.userAgent.toLowerCase())&&(!b||7>=b);u.test(this.options.root)||
|
30
|
+
(this.options.root+="/");b&&this._wantsHashChange&&(this.iframe=g.$('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow,this.navigate(a));this._hasPushState?g.$(window).bind("popstate",this.checkUrl):this._wantsHashChange&&"onhashchange"in window&&!b?g.$(window).bind("hashchange",this.checkUrl):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval));this.fragment=a;a=this.location;b=a.pathname.replace(/[^/]$/,"$&/")===this.options.root&&
|
31
|
+
!a.search;if(this._wantsHashChange&&this._wantsPushState&&!this._hasPushState&&!b)return this.fragment=this.getFragment(null,!0),this.location.replace(this.options.root+this.location.search+"#"+this.fragment),!0;this._wantsPushState&&(this._hasPushState&&b&&a.hash)&&(this.fragment=this.getHash().replace(r,""),this.history.replaceState({},document.title,a.protocol+"//"+a.host+this.options.root+this.fragment));if(!this.options.silent)return this.loadUrl()},stop:function(){g.$(window).unbind("popstate",
|
32
|
+
this.checkUrl).unbind("hashchange",this.checkUrl);clearInterval(this._checkUrlInterval);n.started=!1},route:function(a,b){this.handlers.unshift({route:a,callback:b})},checkUrl:function(){var a=this.getFragment();a===this.fragment&&this.iframe&&(a=this.getFragment(this.getHash(this.iframe)));if(a===this.fragment)return!1;this.iframe&&this.navigate(a);this.loadUrl()||this.loadUrl(this.getHash())},loadUrl:function(a){var b=this.fragment=this.getFragment(a);return f.any(this.handlers,function(a){if(a.route.test(b))return a.callback(b),
|
33
|
+
!0})},navigate:function(a,b){if(!n.started)return!1;if(!b||!0===b)b={trigger:b};var c=(a||"").replace(r,"");if(this.fragment!==c){this.fragment=c;var d=(0!==c.indexOf(this.options.root)?this.options.root:"")+c;if(this._hasPushState)this.history[b.replace?"replaceState":"pushState"]({},document.title,d);else if(this._wantsHashChange)this._updateHash(this.location,c,b.replace),this.iframe&&c!==this.getFragment(this.getHash(this.iframe))&&(b.replace||this.iframe.document.open().close(),this._updateHash(this.iframe.location,
|
34
|
+
c,b.replace));else return this.location.assign(d);b.trigger&&this.loadUrl(a)}},_updateHash:function(a,b,c){c?a.replace(a.href.replace(/(javascript:|#).*$/,"")+"#"+b):a.hash=b}});var v=g.View=function(a){this.cid=f.uniqueId("view");this._configure(a||{});this._ensureElement();this.initialize.apply(this,arguments);this.delegateEvents()},E=/^(\S+)\s*(.*)$/,w="model collection el id attributes className tagName".split(" ");f.extend(v.prototype,h,{tagName:"div",$:function(a){return this.$el.find(a)},initialize:function(){},
|
35
|
+
render:function(){return this},dispose:function(){this.undelegateEvents();this.model&&this.model.off(null,null,this);this.collection&&this.collection.off(null,null,this);return this},remove:function(){this.dispose();this.$el.remove();return this},make:function(a,b,c){a=document.createElement(a);b&&g.$(a).attr(b);null!=c&&g.$(a).html(c);return a},setElement:function(a,b){this.$el&&this.undelegateEvents();this.$el=a instanceof g.$?a:g.$(a);this.el=this.$el[0];!1!==b&&this.delegateEvents();return this},
|
36
|
+
delegateEvents:function(a){if(a||(a=l(this,"events"))){this.undelegateEvents();for(var b in a){var c=a[b];f.isFunction(c)||(c=this[a[b]]);if(!c)throw Error('Method "'+a[b]+'" does not exist');var d=b.match(E),e=d[1],d=d[2],c=f.bind(c,this),e=e+(".delegateEvents"+this.cid);""===d?this.$el.bind(e,c):this.$el.delegate(d,e,c)}}},undelegateEvents:function(){this.$el.unbind(".delegateEvents"+this.cid)},_configure:function(a){this.options&&(a=f.extend({},this.options,a));for(var b=0,c=w.length;b<c;b++){var d=
|
37
|
+
w[b];a[d]&&(this[d]=a[d])}this.options=a},_ensureElement:function(){if(this.el)this.setElement(this.el,!1);else{var a=f.extend({},l(this,"attributes"));this.id&&(a.id=l(this,"id"));this.className&&(a["class"]=l(this,"className"));this.setElement(this.make(l(this,"tagName"),a),!1)}}});o.extend=q.extend=t.extend=v.extend=function(a,b){var c=this,d;d=a&&a.hasOwnProperty("constructor")?a.constructor:function(){c.apply(this,arguments)};f.extend(d,c);x.prototype=c.prototype;d.prototype=new x;a&&f.extend(d.prototype,
|
38
|
+
a);b&&f.extend(d,b);d.prototype.constructor=d;d.__super__=c.prototype;return d};var F={create:"POST",update:"PUT","delete":"DELETE",read:"GET"};g.sync=function(a,b,c){var d=F[a];c||(c={});var e={type:d,dataType:"json"};c.url||(e.url=l(b,"url")||s());if(!c.data&&b&&("create"===a||"update"===a))e.contentType="application/json",e.data=JSON.stringify(b);g.emulateJSON&&(e.contentType="application/x-www-form-urlencoded",e.data=e.data?{model:e.data}:{});if(g.emulateHTTP&&("PUT"===d||"DELETE"===d))g.emulateJSON&&
|
39
|
+
(e.data._method=d),e.type="POST",e.beforeSend=function(a){a.setRequestHeader("X-HTTP-Method-Override",d)};"GET"!==e.type&&!g.emulateJSON&&(e.processData=!1);return g.ajax(f.extend(e,c))};g.ajax=function(){return g.$.ajax.apply(g.$,arguments)};g.wrapError=function(a,b,c){return function(d,e){e=d===b?e:d;a?a(b,e,c):b.trigger("error",b,e,c)}};var x=function(){},l=function(a,b){return!a||!a[b]?null:f.isFunction(a[b])?a[b]():a[b]},s=function(){throw Error('A "url" property or function must be specified');
|
40
|
+
}}).call(this);
|