mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
perl -pi -e 's/Sky/Meteor/g' **/*
This commit is contained in:
@@ -74,7 +74,7 @@ var run = function (bundle_dir) {
|
||||
// start up app
|
||||
__meteor_bootstrap__ = {require: require, startup_hooks: [], app: app};
|
||||
Fiber(function () {
|
||||
// (put in a fiber to let Sky.db operations happen during loading)
|
||||
// (put in a fiber to let Meteor.db operations happen during loading)
|
||||
|
||||
// pass in database info
|
||||
__meteor_bootstrap__.mongo_url = mongo_url;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Sky.subscribe('clicks');
|
||||
Meteor.subscribe('clicks');
|
||||
|
||||
Template.button_demo.events = {
|
||||
'click input': function () {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Clicks = Sky.Collection('clicks');
|
||||
Clicks = Meteor.Collection('clicks');
|
||||
|
||||
if (Sky.is_server) {
|
||||
Sky.publish('clicks', {});
|
||||
if (Meteor.is_server) {
|
||||
Meteor.publish('clicks', {});
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Set up a collection to contain player information. On the server,
|
||||
// it is backed by a MongoDB collection named "players."
|
||||
Players = Sky.Collection("players");
|
||||
Players = Meteor.Collection("players");
|
||||
|
||||
/*** Client ***/
|
||||
|
||||
if (Sky.is_client) {
|
||||
if (Meteor.is_client) {
|
||||
// Get the top 10 players from the server, updated continuously.
|
||||
Sky.subscribe("top10");
|
||||
Meteor.subscribe("top10");
|
||||
|
||||
// Start with no player selected.
|
||||
Session.set("selected_player", null);
|
||||
@@ -14,7 +14,7 @@ if (Sky.is_client) {
|
||||
$(document).ready(function () {
|
||||
// List the players by score. You can click to select a player.
|
||||
var leaderboard_elt = $('<div class="leaderboard"></div>')[0];
|
||||
Sky.ui.renderList(Players, leaderboard_elt, {
|
||||
Meteor.ui.renderList(Players, leaderboard_elt, {
|
||||
sort: {score: -1}, // sort from high to low score
|
||||
render: function (player) {
|
||||
if (Session.equals("selected_player", player._id))
|
||||
@@ -35,7 +35,7 @@ if (Sky.is_client) {
|
||||
$('body').append(leaderboard_elt);
|
||||
|
||||
// Details area, showing the currently selected player.
|
||||
var details_elt = Sky.ui.render(function () {
|
||||
var details_elt = Meteor.ui.render(function () {
|
||||
var selected_player = Session.get("selected_player");
|
||||
if (!selected_player)
|
||||
return $('<div class="none">Click a player to select</div>')[0];
|
||||
@@ -54,13 +54,13 @@ if (Sky.is_client) {
|
||||
|
||||
/*** Server ***/
|
||||
|
||||
if (Sky.is_server) {
|
||||
if (Meteor.is_server) {
|
||||
// Publish the top 10 players, live, to any client that wants them.
|
||||
Sky.publish("top10", {collection: Players, sort: {score: -1},
|
||||
Meteor.publish("top10", {collection: Players, sort: {score: -1},
|
||||
limit: 10});
|
||||
|
||||
// On server startup, create some players if the database is empty.
|
||||
Sky.startup(function () {
|
||||
Meteor.startup(function () {
|
||||
if (Players.find().length === 0) {
|
||||
var names = ["Glinnes Hulden", "Shira Hulden", "Denzel Warhound",
|
||||
"Lute Casagave", "Akadie", "Thammas, Lord Gensifer",
|
||||
|
||||
@@ -4,7 +4,7 @@ Session.set('editing_addtag', null);
|
||||
Session.set('editing_listname', null);
|
||||
Session.set('editing_itemname', null);
|
||||
|
||||
Sky.subscribe('lists', {}, function () {
|
||||
Meteor.subscribe('lists', {}, function () {
|
||||
// Once the lists have loaded, select the first one.
|
||||
if (!Session.get('list_id')) {
|
||||
var lists = Lists.find({}, {sort: {name: 1}, limit: 1});
|
||||
@@ -13,10 +13,10 @@ Sky.subscribe('lists', {}, function () {
|
||||
}
|
||||
});
|
||||
|
||||
Sky.autosubscribe(function () {
|
||||
Meteor.autosubscribe(function () {
|
||||
var list_id = Session.get('list_id');
|
||||
if (list_id)
|
||||
Sky.subscribe('todos', {list: list_id});
|
||||
Meteor.subscribe('todos', {list: list_id});
|
||||
});
|
||||
|
||||
////////// Tag Filter //////////
|
||||
@@ -77,7 +77,7 @@ Template.list_item.events = {
|
||||
'dblclick': function (evt) { // start editing list name
|
||||
var top = $(evt.target).parents('.list');
|
||||
Session.set('editing_listname', this._id);
|
||||
Sky.flush();
|
||||
Meteor.flush();
|
||||
top.find('.edit input').val(this.name).focus().select();
|
||||
},
|
||||
'blur .edit input, keypress .edit input': function (evt) {
|
||||
@@ -184,14 +184,14 @@ Template.todo_item.events = {
|
||||
'click .addtag': function (evt) {
|
||||
var top = $(evt.target).closest('li.todo');
|
||||
Session.set('editing_addtag', this._id);
|
||||
Sky.flush();
|
||||
Meteor.flush();
|
||||
top.find('.edittag input').focus();
|
||||
},
|
||||
|
||||
'dblclick': function (evt) {
|
||||
var top = $(evt.target).closest('li.todo');
|
||||
Session.set('editing_itemname', this._id);
|
||||
Sky.flush();
|
||||
Meteor.flush();
|
||||
top.find('.edit input').val(this.text).focus().select();
|
||||
},
|
||||
|
||||
@@ -243,7 +243,7 @@ Router = new TodosRouter;
|
||||
|
||||
////////// Startup //////////
|
||||
|
||||
Sky.startup(function () {
|
||||
Meteor.startup(function () {
|
||||
$('body').layout({north__minSize: 50,
|
||||
spacing_open: 10,
|
||||
north__fxSettings: { direction: "vertical" }});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Lists = Sky.Collection("lists");
|
||||
Lists = Meteor.Collection("lists");
|
||||
|
||||
Todos = Sky.Collection("todos");
|
||||
Todos = Meteor.Collection("todos");
|
||||
|
||||
/* Schema support coming soon!
|
||||
|
||||
@@ -11,8 +11,8 @@ Todos.schema({text: String,
|
||||
tags: [String]});
|
||||
*/
|
||||
|
||||
Sky.publish('lists');
|
||||
Sky.publish('todos', {
|
||||
Meteor.publish('lists');
|
||||
Meteor.publish('todos', {
|
||||
selector: function (params) {
|
||||
return {list_id: params.list};
|
||||
}
|
||||
|
||||
2
examples/todos/server/bootstrap.js
vendored
2
examples/todos/server/bootstrap.js
vendored
@@ -1,5 +1,5 @@
|
||||
// if the database is empty on server start, create some sample data.
|
||||
Sky.startup(function () {
|
||||
Meteor.startup(function () {
|
||||
if (Lists.find().length === 0) {
|
||||
var data = [
|
||||
{name: "* Seven Principles *",
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
Sky.subscribe('rooms');
|
||||
Meteor.subscribe('rooms');
|
||||
|
||||
Session.set('current_room', null);
|
||||
Session.set('editing_room_name', false);
|
||||
|
||||
Sky.autosubscribe(function () {
|
||||
Meteor.autosubscribe(function () {
|
||||
var room_id = Session.get('current_room');
|
||||
if (room_id) Sky.subscribe('room-detail', {room: room_id});
|
||||
if (room_id) Meteor.subscribe('room-detail', {room: room_id});
|
||||
});
|
||||
|
||||
// XXX would be nice to eliminate this function and have people just
|
||||
@@ -49,7 +49,7 @@ Template.add_room.events = {
|
||||
// principled way to do this is to narrow the scope of the
|
||||
// rerender to not include the <input>.
|
||||
Session.set('editing_room_name', true);
|
||||
Sky.ui.focus('#room_name_input');
|
||||
Meteor.ui.focus('#room_name_input');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -61,7 +61,7 @@ Template.room.events = {
|
||||
Session.set('editing_room_name', true);
|
||||
// XXX XXX doesn't generalize.. the element might very reasonably
|
||||
// not have a unique id. may need a different strategy..
|
||||
Sky.ui.focus('#room_name_input');
|
||||
Meteor.ui.focus('#room_name_input');
|
||||
},
|
||||
'blur input': function (evt) {
|
||||
Session.set('editing_room_name', false);
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
// XXX it is actually very dangerous to store times as Number. use
|
||||
// Date type once it's implemented in minimongo
|
||||
Rooms = Sky.Collection("rooms");
|
||||
Rooms = Meteor.Collection("rooms");
|
||||
Rooms.schema({name: String, created: Number});
|
||||
|
||||
Chat = Sky.Collection("chat");
|
||||
Chat = Meteor.Collection("chat");
|
||||
Chat.schema({room: String, message: String,
|
||||
username: String, created: Number});
|
||||
|
||||
Sky.publish('rooms');
|
||||
Meteor.publish('rooms');
|
||||
|
||||
// XXX should limit to just a certain amount of recent chat ..
|
||||
Sky.publish('room-detail', {
|
||||
Meteor.publish('room-detail', {
|
||||
collection: Chat,
|
||||
selector: function (params) {
|
||||
return {room: params.room};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Sky.subscribe 'presses'
|
||||
Meteor.subscribe 'presses'
|
||||
|
||||
Template.button_demo.events =
|
||||
'click input': ->
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
root = exports ? this # export Presses globally.
|
||||
root.Presses = Sky.Collection 'presses'
|
||||
root.Presses = Meteor.Collection 'presses'
|
||||
|
||||
Sky.publish 'presses'
|
||||
Meteor.publish 'presses'
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Load the application once the DOM is ready, using `jQuery.ready`:
|
||||
$(function(){
|
||||
// ask for all the todos in my cache
|
||||
Sky.subscribe('todos');
|
||||
Meteor.subscribe('todos');
|
||||
|
||||
// helper functions
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Todos = Sky.Collection("todos");
|
||||
Todos = Meteor.Collection("todos");
|
||||
Todos.schema({text: String, done: Boolean, order: Number});
|
||||
|
||||
Sky.publish('todos');
|
||||
Meteor.publish('todos');
|
||||
|
||||
@@ -116,7 +116,7 @@ $(function () {
|
||||
|
||||
// render individual todo list, stash kill function
|
||||
current_list_stop =
|
||||
Sky.ui.renderList(Todos, $('#item-list'), {
|
||||
Meteor.ui.renderList(Todos, $('#item-list'), {
|
||||
selector: query,
|
||||
sort: {timestamp: 1},
|
||||
render: renderItem,
|
||||
@@ -125,7 +125,7 @@ $(function () {
|
||||
};
|
||||
|
||||
// render list of lists in the left sidebar.
|
||||
Sky.ui.renderList(Lists, $('#lists'), {
|
||||
Meteor.ui.renderList(Lists, $('#lists'), {
|
||||
sort: {name: 1},
|
||||
template: $('#list-template'),
|
||||
events: {
|
||||
@@ -174,7 +174,7 @@ $(function () {
|
||||
// support aggregate queries, construct a local collection to serve
|
||||
// the same purpose, and drive the renderList() off of it.
|
||||
|
||||
var LocalTags = Sky.Collection();
|
||||
var LocalTags = Meteor.Collection();
|
||||
(function () {
|
||||
function updateLocalTags() {
|
||||
var real = _(Todos.find()).chain().pluck('tags').compact().flatten().uniq().value();
|
||||
@@ -205,7 +205,7 @@ $(function () {
|
||||
|
||||
Session.set('tag_filter', null);
|
||||
|
||||
Sky.ui.renderList(LocalTags, $('#tag-filter'), {
|
||||
Meteor.ui.renderList(LocalTags, $('#tag-filter'), {
|
||||
sort: {tag: 1},
|
||||
template: $('#tag-filter-template'),
|
||||
events: {
|
||||
@@ -229,7 +229,7 @@ $(function () {
|
||||
|
||||
// subscribe to all available todo lists. once the inital load
|
||||
// completes, navigate to the list specified by URL, if any.
|
||||
Sky.subscribe('lists', {}, function () {
|
||||
Meteor.subscribe('lists', {}, function () {
|
||||
var initial_list_id = window.location.pathname.split('/')[1];
|
||||
var list;
|
||||
|
||||
@@ -254,5 +254,5 @@ $(function () {
|
||||
|
||||
// subscribe to all the items in each list. no need for a callback
|
||||
// here: todo items are never queried using collection.find().
|
||||
Sky.subscribe('todos');
|
||||
Meteor.subscribe('todos');
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Lists = Sky.Collection("lists");
|
||||
Lists = Meteor.Collection("lists");
|
||||
|
||||
Todos = Sky.Collection("todos");
|
||||
Todos = Meteor.Collection("todos");
|
||||
|
||||
/* Schema support coming soon!
|
||||
|
||||
@@ -11,5 +11,5 @@ Todos.schema({text: String,
|
||||
tags: [String]});
|
||||
*/
|
||||
|
||||
Sky.publish('lists');
|
||||
Sky.publish('todos');
|
||||
Meteor.publish('lists');
|
||||
Meteor.publish('todos');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// if the database is empty on server start, create some sample data.
|
||||
Sky.startup(function () {
|
||||
Meteor.startup(function () {
|
||||
if (Lists.find().length === 0) {
|
||||
var list1 = Lists.insert({name: 'Things to do'});
|
||||
Todos.insert({list_id: list1._id,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if (typeof Sky === "undefined") Sky = {};
|
||||
if (typeof Meteor === "undefined") Meteor = {};
|
||||
|
||||
(function () {
|
||||
var pending_invalidate = [];
|
||||
@@ -30,7 +30,7 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
if (!this._invalidated) {
|
||||
this._invalidated = true;
|
||||
if (!pending_invalidate.length)
|
||||
setTimeout(Sky.flush, 0);
|
||||
setTimeout(Meteor.flush, 0);
|
||||
pending_invalidate.push(this);
|
||||
}
|
||||
},
|
||||
@@ -44,7 +44,7 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
}
|
||||
});
|
||||
|
||||
_.extend(Sky, {
|
||||
_.extend(Meteor, {
|
||||
// XXX specify what happens when flush calls flush. eg, flushing
|
||||
// causes a dom update, which causes onblur, which invokes an
|
||||
// event handler that calls flush. it's probably an exception --
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if (typeof Sky === "undefined") Sky = {};
|
||||
if (typeof Meteor === "undefined") Meteor = {};
|
||||
|
||||
(function () {
|
||||
var collections = {}; // name -> Collection-type object
|
||||
@@ -10,10 +10,10 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
// list of subscription tokens outstanding during a
|
||||
// captureDependencies run. only set when we're doing a run. The fact
|
||||
// that this is a singleton means we can't do recursive
|
||||
// Sky.subscriptions(). But who wants that? What does that even mean?
|
||||
// Meteor.subscriptions(). But who wants that? What does that even mean?
|
||||
var capture_subs;
|
||||
|
||||
Sky._stream.on('published', function (data) {
|
||||
Meteor._stream.on('published', function (data) {
|
||||
_.each(data, function (changes, collection_name) {
|
||||
var coll = collections[collection_name];
|
||||
if (!coll) {
|
||||
@@ -42,14 +42,14 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
});
|
||||
});
|
||||
|
||||
Sky._stream.on('subscription_ready', function (id) {
|
||||
Meteor._stream.on('subscription_ready', function (id) {
|
||||
var arr = sub_ready_callbacks[id];
|
||||
if (arr) _.each(arr, function (c) { c(); });
|
||||
delete sub_ready_callbacks[id];
|
||||
});
|
||||
|
||||
|
||||
Sky._stream.reset(function (msg_list) {
|
||||
Meteor._stream.reset(function (msg_list) {
|
||||
// remove existing subscribe and unsubscribe
|
||||
msg_list = _.reject(msg_list, function (elem) {
|
||||
return (!elem || elem[0] === "subscribe" || elem[0] === "unsubscribe");
|
||||
@@ -74,7 +74,7 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
|
||||
var subsToken = subs.findLive({}, {
|
||||
added: function (sub) {
|
||||
Sky._stream.emit('subscribe', {
|
||||
Meteor._stream.emit('subscribe', {
|
||||
_id: sub._id, name: sub.name, args: sub.args});
|
||||
},
|
||||
changed: function (sub) {
|
||||
@@ -84,13 +84,13 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
}
|
||||
},
|
||||
removed: function (id) {
|
||||
Sky._stream.emit('unsubscribe', {_id: id});
|
||||
Meteor._stream.emit('unsubscribe', {_id: id});
|
||||
}
|
||||
});
|
||||
|
||||
// XXX let it take a second argument, the URL of the domain that
|
||||
// hosts the collection :)
|
||||
Sky.Collection = function (name) {
|
||||
Meteor.Collection = function (name) {
|
||||
if (name && (name in collections))
|
||||
// maybe should just return collections[name]?
|
||||
throw new Error("There is already a remote collection '" + name + "'");
|
||||
@@ -108,7 +108,7 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
obj._id = _id;
|
||||
|
||||
if (this._name)
|
||||
Sky._stream.emit('handle', {
|
||||
Meteor._stream.emit('handle', {
|
||||
collection: this._name, type: 'insert', args: obj});
|
||||
this._collection.insert(obj);
|
||||
|
||||
@@ -128,7 +128,7 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
selector = {_id: selector};
|
||||
|
||||
if (this._name)
|
||||
Sky._stream.emit('handle', {
|
||||
Meteor._stream.emit('handle', {
|
||||
collection: this._name, type: 'update',
|
||||
selector: selector, mutator: mutator, options: options});
|
||||
this._collection.update(selector, mutator, options);
|
||||
@@ -139,7 +139,7 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
selector = {_id: selector};
|
||||
|
||||
if (this._name)
|
||||
Sky._stream.emit('handle', {
|
||||
Meteor._stream.emit('handle', {
|
||||
collection: this._name, type: 'remove', selector: selector});
|
||||
this._collection.remove(selector);
|
||||
},
|
||||
@@ -160,7 +160,7 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
|
||||
// tell the server to run the handler
|
||||
if (this._name)
|
||||
Sky._stream.emit('handle', {
|
||||
Meteor._stream.emit('handle', {
|
||||
collection: this._name, type: 'method',
|
||||
method: method, args: args});
|
||||
};
|
||||
@@ -174,7 +174,7 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
return ret;
|
||||
};
|
||||
|
||||
_.extend(Sky, {
|
||||
_.extend(Meteor, {
|
||||
is_server: false,
|
||||
is_client: true,
|
||||
|
||||
@@ -223,18 +223,18 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
|
||||
autosubscribe: function (sub_func) {
|
||||
var local_subs = [];
|
||||
var context = new Sky.deps.Context();
|
||||
var context = new Meteor.deps.Context();
|
||||
|
||||
context.on_invalidate(function () {
|
||||
// recurse.
|
||||
Sky.autosubscribe(sub_func);
|
||||
Meteor.autosubscribe(sub_func);
|
||||
// unsub after re-subbing, to avoid bouncing.
|
||||
_.each(local_subs, function (x) { x.stop() });
|
||||
});
|
||||
|
||||
context.run(function () {
|
||||
if (capture_subs)
|
||||
throw new Error("Sky.autosubscribe may not be called recursively");
|
||||
throw new Error("Meteor.autosubscribe may not be called recursively");
|
||||
|
||||
capture_subs = [];
|
||||
try {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if (typeof Sky === "undefined") Sky = {};
|
||||
if (typeof Meteor === "undefined") Meteor = {};
|
||||
|
||||
(function () {
|
||||
|
||||
@@ -119,7 +119,7 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
// XXX note that running this in a fiber means that two serial
|
||||
// requests from the client can try to execute in parallel.. we're
|
||||
// going to have to think that through at some point. also, consider
|
||||
// races against Sky.Collection(), though this shouldn't happen in
|
||||
// races against Meteor.Collection(), though this shouldn't happen in
|
||||
// most normal use cases
|
||||
Fiber(function () {
|
||||
if (!('collection' in data) || !(data.collection in collections))
|
||||
@@ -159,7 +159,7 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
}).run();
|
||||
};
|
||||
|
||||
Sky._stream.register(function (socket) {
|
||||
Meteor._stream.register(function (socket) {
|
||||
socket.sky = {};
|
||||
socket.sky.subs = [];
|
||||
socket.sky.cache = {};
|
||||
@@ -174,7 +174,7 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
});
|
||||
|
||||
socket.on('handle', function (data) {
|
||||
run_handler(socket, data, Sky._stream.all_sockets());
|
||||
run_handler(socket, data, Meteor._stream.all_sockets());
|
||||
});
|
||||
|
||||
// 5/sec updates tops, once every 10sec min.
|
||||
@@ -187,7 +187,7 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
|
||||
////////// User visible API //////////
|
||||
|
||||
_.extend(Sky, {
|
||||
_.extend(Meteor, {
|
||||
is_server: true,
|
||||
is_client: false,
|
||||
|
||||
@@ -202,7 +202,7 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
* named 'name' on disk in mongodb
|
||||
* - selector {Function<args> OR Object} either a mongodb selector,
|
||||
* or a function that takes the argument object passed to
|
||||
* Sky.subscribe and returns a mongodb selector. default {}
|
||||
* Meteor.subscribe and returns a mongodb selector. default {}
|
||||
*/
|
||||
publish: function (name, options) {
|
||||
if (name in publishes) {
|
||||
@@ -242,7 +242,7 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
}
|
||||
});
|
||||
|
||||
Sky.Collection = function (name) {
|
||||
Meteor.Collection = function (name) {
|
||||
if (!name)
|
||||
// XXX maybe support this using minimongo?
|
||||
throw new Error("Anonymous collections aren't allowed on the server");
|
||||
@@ -265,17 +265,17 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
new_doc = {};
|
||||
_.extend(new_doc, doc);
|
||||
doc = new_doc;
|
||||
doc._id = Sky.uuid();
|
||||
doc._id = Meteor.uuid();
|
||||
}
|
||||
|
||||
Sky._mongo_driver.insert(this._name, doc);
|
||||
Meteor._mongo_driver.insert(this._name, doc);
|
||||
|
||||
// return the doc w/ _id, so we can use it.
|
||||
return doc;
|
||||
},
|
||||
|
||||
find: function (selector, options) {
|
||||
return Sky._mongo_driver.find(this._name, selector, options);
|
||||
return Meteor._mongo_driver.find(this._name, selector, options);
|
||||
},
|
||||
|
||||
findLive: function () {
|
||||
@@ -283,11 +283,11 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
},
|
||||
|
||||
update: function (selector, mod, options) {
|
||||
return Sky._mongo_driver.update(this._name, selector, mod, options);
|
||||
return Meteor._mongo_driver.update(this._name, selector, mod, options);
|
||||
},
|
||||
|
||||
remove: function (selector) {
|
||||
return Sky._mongo_driver.remove(this._name, selector);
|
||||
return Meteor._mongo_driver.remove(this._name, selector);
|
||||
},
|
||||
|
||||
schema: function () {
|
||||
|
||||
@@ -20,7 +20,7 @@ var client;
|
||||
var with_collection_queue;
|
||||
|
||||
/**
|
||||
* Initialize the Sky library
|
||||
* Initialize the Meteor library
|
||||
*
|
||||
* @param url {String} mongo DB URL (eg mongodb://localhost:27017/meteor)
|
||||
*/
|
||||
@@ -158,7 +158,7 @@ function update (collection_name, selector, mod, options) {
|
||||
return future.wait();
|
||||
};
|
||||
|
||||
Sky._mongo_driver = {
|
||||
Meteor._mongo_driver = {
|
||||
find: find,
|
||||
insert: insert,
|
||||
remove: remove,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// XXX dups packages/minimongo/uuid.js
|
||||
|
||||
// Sky.random() -- known good PRNG, replaces Math.random()
|
||||
// Sky.uuid() -- returns RFC 4122 v4 UUID.
|
||||
// Meteor.random() -- known good PRNG, replaces Math.random()
|
||||
// Meteor.uuid() -- returns RFC 4122 v4 UUID.
|
||||
|
||||
// see http://baagoe.org/en/wiki/Better_random_numbers_for_javascript
|
||||
// for a full discussion and Alea implementation.
|
||||
@@ -28,9 +28,9 @@
|
||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
if (typeof Sky === "undefined") Sky = {};
|
||||
if (typeof Meteor === "undefined") Meteor = {};
|
||||
|
||||
Sky._Alea = function () {
|
||||
Meteor._Alea = function () {
|
||||
function Mash() {
|
||||
var n = 0xefc8249d;
|
||||
|
||||
@@ -104,14 +104,14 @@ Sky._Alea = function () {
|
||||
}
|
||||
|
||||
// instantiate RNG. use the default seed, which is current time.
|
||||
Sky.random = new Sky._Alea();
|
||||
Meteor.random = new Meteor._Alea();
|
||||
|
||||
// RFC 4122 v4 UUID.
|
||||
Sky.uuid = function () {
|
||||
Meteor.uuid = function () {
|
||||
var s = [];
|
||||
var hexDigits = "0123456789abcdef";
|
||||
for (var i = 0; i < 36; i++) {
|
||||
s[i] = hexDigits.substr(Math.floor(Sky.random() * 0x10), 1);
|
||||
s[i] = hexDigits.substr(Math.floor(Meteor.random() * 0x10), 1);
|
||||
}
|
||||
s[14] = "4";
|
||||
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
Sky.ui = Sky.ui || {};
|
||||
Meteor.ui = Meteor.ui || {};
|
||||
|
||||
// update in place by hollowing out old element(s), and copying
|
||||
// over all of the children and attributes. unfortunately there
|
||||
// is no way to change the tag name. leave the events in place.
|
||||
Sky.ui._patch = function (old_elt_in, new_elt_in) {
|
||||
Meteor.ui._patch = function (old_elt_in, new_elt_in) {
|
||||
// Don't let more than one instance of patch run simultaneously.
|
||||
// http://code.google.com/p/chromium/issues/detail?id=104397
|
||||
//
|
||||
@@ -12,15 +12,15 @@ Sky.ui._patch = function (old_elt_in, new_elt_in) {
|
||||
// the DOM immediately.. except if, somewhere above them on
|
||||
// the stack, is a onblur handler triggered by patch, in which
|
||||
// case updates are queued up?? That makes no kind of sense.
|
||||
var already_in_patch = !!Sky.ui._patch_queue;
|
||||
var already_in_patch = !!Meteor.ui._patch_queue;
|
||||
if (!already_in_patch)
|
||||
Sky.ui._patch_queue = [];
|
||||
Sky.ui._patch_queue.push([old_elt_in, new_elt_in])
|
||||
Meteor.ui._patch_queue = [];
|
||||
Meteor.ui._patch_queue.push([old_elt_in, new_elt_in])
|
||||
if (already_in_patch)
|
||||
return;
|
||||
|
||||
while (Sky.ui._patch_queue.length) {
|
||||
var x = Sky.ui._patch_queue.splice(0, 10)[0];
|
||||
while (Meteor.ui._patch_queue.length) {
|
||||
var x = Meteor.ui._patch_queue.splice(0, 10)[0];
|
||||
var old_elt = x[0];
|
||||
var new_elt = x[1];
|
||||
|
||||
@@ -47,7 +47,7 @@ Sky.ui._patch = function (old_elt_in, new_elt_in) {
|
||||
new_elt.attributes[i].value);
|
||||
};
|
||||
|
||||
delete Sky.ui._patch_queue;
|
||||
delete Meteor.ui._patch_queue;
|
||||
};
|
||||
|
||||
|
||||
@@ -75,20 +75,20 @@ Sky.ui._patch = function (old_elt_in, new_elt_in) {
|
||||
///
|
||||
/// XXX refactor renderList to make it use this?
|
||||
/// XXX need to provide a way to stop the updating and let GC happen!!!
|
||||
Sky.ui.render = function (render_func, events, event_data) {
|
||||
Meteor.ui.render = function (render_func, events, event_data) {
|
||||
var result = null;
|
||||
var update = function () {
|
||||
var context = new Sky.deps.Context();
|
||||
var context = new Meteor.deps.Context();
|
||||
context.on_invalidate(update);
|
||||
var new_result = context.run(render_func);
|
||||
if (result === null) {
|
||||
result = new_result;
|
||||
if (result instanceof Array)
|
||||
_.each(result, function (elt) {
|
||||
Sky.ui._setupEvents(elt, events || {}, event_data);
|
||||
Meteor.ui._setupEvents(elt, events || {}, event_data);
|
||||
});
|
||||
else
|
||||
Sky.ui._setupEvents(result, events || {}, event_data);
|
||||
Meteor.ui._setupEvents(result, events || {}, event_data);
|
||||
} else {
|
||||
if ((new_result instanceof Array) !==
|
||||
(result instanceof Array))
|
||||
@@ -100,9 +100,9 @@ Sky.ui.render = function (render_func, events, event_data) {
|
||||
"elements it returns (from " + result.length +
|
||||
" to " + new_result.length + ")");
|
||||
for (var i = 0; i < result.length; i++)
|
||||
Sky.ui._patch(result[i], new_result[i]);
|
||||
Meteor.ui._patch(result[i], new_result[i]);
|
||||
} else
|
||||
Sky.ui._patch(result, new_result);
|
||||
Meteor.ui._patch(result, new_result);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -126,7 +126,7 @@ Sky.ui.render = function (render_func, events, event_data) {
|
||||
///
|
||||
/// returns an object with:
|
||||
/// stop(): stop updating, tear everything down and let it get GC'd
|
||||
Sky.ui.renderList = function (collection, element, options) {
|
||||
Meteor.ui.renderList = function (collection, element, options) {
|
||||
if ((typeof $ !== "undefined") && (element instanceof $))
|
||||
// allow element to be a jQuery result set
|
||||
element = element[0];
|
||||
@@ -141,7 +141,7 @@ Sky.ui.renderList = function (collection, element, options) {
|
||||
};
|
||||
|
||||
var render = function (obj) {
|
||||
var context = new Sky.deps.Context();
|
||||
var context = new Meteor.deps.Context();
|
||||
|
||||
context.on_invalidate(function () {
|
||||
var idx = query.indexOf(obj._id);
|
||||
@@ -157,7 +157,7 @@ Sky.ui.renderList = function (collection, element, options) {
|
||||
return options.render(obj);
|
||||
});
|
||||
|
||||
Sky.ui._setupEvents(elt, options.events || {}, obj);
|
||||
Meteor.ui._setupEvents(elt, options.events || {}, obj);
|
||||
return elt;
|
||||
};
|
||||
|
||||
@@ -213,7 +213,7 @@ Sky.ui.renderList = function (collection, element, options) {
|
||||
|
||||
// XXX jQuery dependency
|
||||
// 'event_data' will be an additional argument to event callback
|
||||
Sky.ui._setupEvents = function (elt, events, event_data) {
|
||||
Meteor.ui._setupEvents = function (elt, events, event_data) {
|
||||
events = events || {};
|
||||
function create_callback (callback) {
|
||||
// return a function that will be used as the jquery event
|
||||
|
||||
@@ -40,7 +40,7 @@ Collection.prototype.insert = function (doc) {
|
||||
// (in the first form you're beholden to key enumeration order in
|
||||
// your javascript VM)
|
||||
//
|
||||
// reactive: if given, and false, don't register with Sky.deps (default
|
||||
// reactive: if given, and false, don't register with Meteor.deps (default
|
||||
// is true)
|
||||
//
|
||||
// XXX possibly should support retrieving a subset of fields? and
|
||||
@@ -78,10 +78,10 @@ Collection.prototype.find = function (selector, options) {
|
||||
|
||||
}
|
||||
|
||||
// support Sky.deps if present
|
||||
// support Meteor.deps if present
|
||||
var reactive = (options.reactive === undefined) ? true : options.reactive;
|
||||
var context = reactive && typeof Sky === "object" && Sky.deps &&
|
||||
Sky.deps.Context.current;
|
||||
var context = reactive && typeof Meteor === "object" && Meteor.deps &&
|
||||
Meteor.deps.Context.current;
|
||||
if (context) {
|
||||
var invalidate = _.bind(context.invalidate, context);
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ Session = _.extend({}, {
|
||||
|
||||
get: function (key) {
|
||||
var self = this;
|
||||
var context = Sky.deps.Context.current;
|
||||
var context = Meteor.deps.Context.current;
|
||||
self._ensureKey(key);
|
||||
|
||||
if (context && !(context.id in self.key_deps[key])) {
|
||||
@@ -64,7 +64,7 @@ Session = _.extend({}, {
|
||||
|
||||
equals: function (key, value) {
|
||||
var self = this;
|
||||
var context = Sky.deps.Context.current;
|
||||
var context = Meteor.deps.Context.current;
|
||||
|
||||
if (typeof(value) !== 'string' &&
|
||||
typeof(value) !== 'number' &&
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Package.describe({
|
||||
summary: "Provides Sky.startup",
|
||||
summary: "Provides Meteor.startup",
|
||||
internal: true
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if (typeof Sky === "undefined") Sky = {};
|
||||
if (typeof Meteor === "undefined") Meteor = {};
|
||||
|
||||
(function() {
|
||||
var queue = [];
|
||||
@@ -22,7 +22,7 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
window.attachEvent('load', ready);
|
||||
}
|
||||
|
||||
Sky.startup = function (cb) {
|
||||
Meteor.startup = function (cb) {
|
||||
var doScroll = !document.addEventListener &&
|
||||
document.documentElement.doScroll;
|
||||
|
||||
@@ -34,7 +34,7 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
} else {
|
||||
try { doScroll('left'); }
|
||||
catch (e) {
|
||||
setTimeout(function() { Sky.startup(cb); }, 50);
|
||||
setTimeout(function() { Meteor.startup(cb); }, 50);
|
||||
return;
|
||||
};
|
||||
cb();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
if (typeof Sky === "undefined") Sky = {};
|
||||
if (typeof Meteor === "undefined") Meteor = {};
|
||||
|
||||
Sky.startup = function (callback) {
|
||||
Meteor.startup = function (callback) {
|
||||
__meteor_bootstrap__.startup_hooks.push(callback);
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if (typeof Sky === "undefined") Sky = {};
|
||||
if (typeof Meteor === "undefined") Meteor = {};
|
||||
|
||||
// socket.io reconnect is broken and doesn't tell us when it gives up:
|
||||
// https://github.com/LearnBoost/socket.io/issues/652
|
||||
@@ -172,8 +172,8 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
|
||||
////////// User facing API //////////
|
||||
|
||||
Sky.status = function () {
|
||||
var context = Sky.deps.Context.current;
|
||||
Meteor.status = function () {
|
||||
var context = Meteor.deps.Context.current;
|
||||
if (context && !(context.id in status_listeners)) {
|
||||
status_listeners[context.id] = context;
|
||||
context.on_invalidate(function () {
|
||||
@@ -183,7 +183,7 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
return status;
|
||||
};
|
||||
|
||||
Sky.reconnect = function () {
|
||||
Meteor.reconnect = function () {
|
||||
if (status.connected) return; // already connected. noop.
|
||||
|
||||
// if we're mid-connection, stop it.
|
||||
@@ -200,7 +200,7 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
|
||||
////////// API for other packages //////////
|
||||
|
||||
Sky._stream = {
|
||||
Meteor._stream = {
|
||||
on: function (name, callback) {
|
||||
if (!event_callbacks[name]) event_callbacks[name] = []
|
||||
event_callbacks[name].push(callback);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if (typeof Sky === "undefined") Sky = {};
|
||||
if (typeof Meteor === "undefined") Meteor = {};
|
||||
|
||||
(function () {
|
||||
|
||||
@@ -38,7 +38,7 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
|
||||
////////// API for other packages //////////
|
||||
|
||||
Sky._stream = {
|
||||
Meteor._stream = {
|
||||
// call my callback when a new socket connects.
|
||||
// also call it for all current connections.
|
||||
register: function (callback) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
if (typeof Sky === "undefined") Sky = {};
|
||||
if (typeof Meteor === "undefined") Meteor = {};
|
||||
|
||||
// XXX ugly hack. provides Sky._def_template, which is used to load in
|
||||
// XXX ugly hack. provides Meteor._def_template, which is used to load in
|
||||
// compiled templates.
|
||||
|
||||
// XXX disgusting hack. we want to allow Template.foo to be used as a
|
||||
@@ -14,8 +14,8 @@ if (typeof Sky === "undefined") Sky = {};
|
||||
// attributes, or a text string to be included inside an attribute..)
|
||||
|
||||
// XXX it'd be nice to do a better job of hiding these symbols
|
||||
Sky._pending_partials = null; // id -> element
|
||||
Sky._pending_partials_idx_nonce = 0;
|
||||
Meteor._pending_partials = null; // id -> element
|
||||
Meteor._pending_partials_idx_nonce = 0;
|
||||
|
||||
// XXX another disgusting hack -- we reach into handlebars and
|
||||
// extend #each to know how to cooperate with pending_partials and
|
||||
@@ -25,8 +25,8 @@ Sky._pending_partials_idx_nonce = 0;
|
||||
// don't even pretend to call stop on the findlive, so every time
|
||||
// we're rerendered, we kick off another findlive that runs
|
||||
// .. forever!
|
||||
Sky._hook_handlebars_each = function () {
|
||||
Sky._hook_handlebars_each = function(){}; // install the hook only once
|
||||
Meteor._hook_handlebars_each = function () {
|
||||
Meteor._hook_handlebars_each = function(){}; // install the hook only once
|
||||
|
||||
var orig = Handlebars._default_helpers.each;
|
||||
Handlebars._default_helpers.each = function (context, options) {
|
||||
@@ -54,11 +54,11 @@ Sky._hook_handlebars_each = function () {
|
||||
return markup;
|
||||
}
|
||||
|
||||
var render = Sky._def_template(null, function (obj) {
|
||||
var render = Meteor._def_template(null, function (obj) {
|
||||
return trim(options.fn(obj));
|
||||
});
|
||||
|
||||
var renderElse = Sky._def_template(null, function () {
|
||||
var renderElse = Meteor._def_template(null, function () {
|
||||
return trim(options.inverse({}));
|
||||
});
|
||||
|
||||
@@ -67,7 +67,7 @@ Sky._hook_handlebars_each = function () {
|
||||
var is_empty = true;
|
||||
element.appendChild(renderElse());
|
||||
|
||||
// XXX copied code from Sky.ui.renderList.. bleh
|
||||
// XXX copied code from Meteor.ui.renderList.. bleh
|
||||
// (with addition of is_empty / renderElse)
|
||||
context.reconnect({
|
||||
added: function (obj, before_idx) {
|
||||
@@ -79,7 +79,7 @@ Sky._hook_handlebars_each = function () {
|
||||
element.appendChild(render(obj));
|
||||
else
|
||||
element.insertBefore(render(obj), element.childNodes[before_idx]);
|
||||
Sky.ui._tryFocus();
|
||||
Meteor.ui._tryFocus();
|
||||
},
|
||||
removed: function (id, at_idx) {
|
||||
element.removeChild(element.childNodes[at_idx]);
|
||||
@@ -91,7 +91,7 @@ Sky._hook_handlebars_each = function () {
|
||||
changed: function (obj, at_idx) {
|
||||
element.insertBefore(render(obj), element.childNodes[at_idx]);
|
||||
element.removeChild(element.childNodes[at_idx + 1]);
|
||||
Sky.ui._tryFocus();
|
||||
Meteor.ui._tryFocus();
|
||||
},
|
||||
moved: function (obj, old_idx, new_idx) {
|
||||
var elt = element.removeChild(element.childNodes[old_idx]);
|
||||
@@ -102,15 +102,15 @@ Sky._hook_handlebars_each = function () {
|
||||
}
|
||||
});
|
||||
|
||||
var id = Sky._pending_partials_idx_nonce++;
|
||||
Sky._pending_partials[id] = element;
|
||||
var id = Meteor._pending_partials_idx_nonce++;
|
||||
Meteor._pending_partials[id] = element;
|
||||
return "<div id='" + id +
|
||||
"'><!-- for replacement with findlive each --></div>";
|
||||
}
|
||||
};
|
||||
|
||||
// XXX namespacing
|
||||
Sky._partials = {};
|
||||
Meteor._partials = {};
|
||||
|
||||
// XXX hack: name may be null, in which case nothing is put in
|
||||
// Template, there is no way to define events/data functions, and
|
||||
@@ -121,18 +121,18 @@ Sky._partials = {};
|
||||
// XXX hack: if multi is true, the template is allowed to return
|
||||
// multiple elements at toplevel, and the return value of the created
|
||||
// template function is a list. this is used for <body>.
|
||||
Sky._def_template = function (name, raw_func, multi) {
|
||||
Sky._hook_handlebars_each();
|
||||
Meteor._def_template = function (name, raw_func, multi) {
|
||||
Meteor._hook_handlebars_each();
|
||||
window.Template = window.Template || {};
|
||||
var cooked_func = function (data) {
|
||||
var in_partial = !!Sky._pending_partials;
|
||||
var in_partial = !!Meteor._pending_partials;
|
||||
if (!in_partial)
|
||||
Sky._pending_partials = {};
|
||||
Meteor._pending_partials = {};
|
||||
// XXX should catch exceptions and clean up pending_partials if
|
||||
// stack is unwound
|
||||
var html = raw_func(data, {
|
||||
helpers: name ? Template[name] : {},
|
||||
partials: Sky._partials
|
||||
partials: Meteor._partials
|
||||
});
|
||||
|
||||
if (html === '')
|
||||
@@ -156,10 +156,10 @@ Sky._def_template = function (name, raw_func, multi) {
|
||||
var traverse = function (elt) {
|
||||
for (var i = 0; i < elt.childNodes.length; i++) {
|
||||
var child = elt.childNodes[i];
|
||||
var replacement = child.id && Sky._pending_partials[child.id];
|
||||
var replacement = child.id && Meteor._pending_partials[child.id];
|
||||
if (replacement) {
|
||||
elt.replaceChild(replacement, child);
|
||||
delete Sky._pending_partials[child.id];
|
||||
delete Meteor._pending_partials[child.id];
|
||||
child = replacement;
|
||||
}
|
||||
traverse(child);
|
||||
@@ -168,9 +168,9 @@ Sky._def_template = function (name, raw_func, multi) {
|
||||
|
||||
traverse(div);
|
||||
|
||||
for (var id in Sky._pending_partials)
|
||||
for (var id in Meteor._pending_partials)
|
||||
throw new Error("internal error -- not all pending partials patched");
|
||||
Sky._pending_partials = null;
|
||||
Meteor._pending_partials = null;
|
||||
}
|
||||
|
||||
if (!multi)
|
||||
@@ -185,7 +185,7 @@ Sky._def_template = function (name, raw_func, multi) {
|
||||
};
|
||||
|
||||
var func = function (data) {
|
||||
return Sky.ui.render(_.bind(cooked_func, null, data),
|
||||
return Meteor.ui.render(_.bind(cooked_func, null, data),
|
||||
name && Template[name].events || {}, data);
|
||||
};
|
||||
|
||||
@@ -205,13 +205,13 @@ Sky._def_template = function (name, raw_func, multi) {
|
||||
|
||||
// XXX hacky. sucks that we have to depend on handlebars here.
|
||||
if (name) {
|
||||
Sky._partials[name] = function (data) {
|
||||
if (!Sky._pending_partials)
|
||||
Meteor._partials[name] = function (data) {
|
||||
if (!Meteor._pending_partials)
|
||||
// XXX lame error
|
||||
throw new Error("this partial may only be invoked from inside a Template.foo-style template");
|
||||
var elt = func(data);
|
||||
var id = Sky._pending_partials_idx_nonce++;
|
||||
Sky._pending_partials[id] = elt;
|
||||
var id = Meteor._pending_partials_idx_nonce++;
|
||||
Meteor._pending_partials[id] = elt;
|
||||
return "<div id='" + id + "'><!-- for replacement with partial --></div>";
|
||||
};
|
||||
}
|
||||
|
||||
@@ -66,12 +66,12 @@ var html_scanner = module.exports = {
|
||||
throw new Error("Template missing id attribute, um, somewhere ...");
|
||||
var id = match[1];
|
||||
|
||||
results.js += "Sky._def_template(" + JSON.stringify(id) + "," + code +
|
||||
results.js += "Meteor._def_template(" + JSON.stringify(id) + "," + code +
|
||||
");\n";
|
||||
} else { // tag === "body"
|
||||
// as a special case, and to stop users from stabbing us, body
|
||||
// is allowed to have multiple elements at toplevel
|
||||
results.js += "Sky.startup(function(){var elts = Sky._def_template(null," + code + ",true)();for(var i=0;i<elts.length;i++) {$('body').append(elts[i]);}});";
|
||||
results.js += "Meteor.startup(function(){var elts = Meteor._def_template(null," + code + ",true)();for(var i=0;i<elts.length;i++) {$('body').append(elts[i]);}});";
|
||||
}
|
||||
});
|
||||
if (!found) {
|
||||
|
||||
@@ -46,7 +46,7 @@ Package.register_extension(
|
||||
// provides the runtime logic to instantiate our templates
|
||||
Package.client_file('deftemplate.js');
|
||||
|
||||
// html_scanner.js emits client code that calls Sky.startup
|
||||
// html_scanner.js emits client code that calls Meteor.startup
|
||||
// XXX the correct thing would be to require this only on the client
|
||||
Package.require('startup');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user