Skip to content

Commit

Permalink
Fixes for Meteor v0.6:
Browse files Browse the repository at this point in the history
- removed 'var' on global variables
- changed __meteor_bootstrap__.require() to Npm.require()
- 1 change to CryptoJS (removed first 'or' clause)--(review this one in particular, Tom)
  • Loading branch information
dankirkpatrick committed Apr 10, 2013
1 parent f77bc8e commit 3ca378d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion client/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Template.body.events({
})

Template.header.preserve(['#header', '#controls', '#controls .top']);
var checkBanner = function() {
checkBanner = function() {
// if the banner is no longer visible, we have scrolled enough
var bannerBottom = $('#banner').offset().top + $('#banner').height();
Session.set('scrolledEnough', $(window).scrollTop() > bannerBottom);
Expand Down
16 changes: 8 additions & 8 deletions client/lib/postState.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
// OPEN
var isOpen = function(post) {
isOpen = function(post) {
var opened = Session.equals('post-opened-' + post.slug, true);

return (isSelected(post) || opened) && ! post._isPrev && ! post._isNext;
}

var setOpen = function(post, value) {
setOpen = function(post, value) {
Session.set('post-opened-' + post.slug, value);;
}

// SELECTED
var isSelected = function(post) {
isSelected = function(post) {
return Session.equals('selected-post-slug', post.slug);
}

var anySelected = function() {
anySelected = function() {
return !! Session.get('selected-post-slug') || Session.get('creating-post');
}

var setSelected = function(post) {
setSelected = function(post) {
Session.set('selected-post-slug', post.slug);
}

var getSelected = function(post) {
getSelected = function(post) {
return Posts.findOne({slug: Session.get('selected-post-slug')});
}

// EDITING / NEW
var inEditMode = function() {
inEditMode = function() {
return Session.get('editing-post') || Session.get('creating-post');
}

var isEditing = function(post) {
isEditing = function(post) {
return isSelected(post) && inEditMode();
}
2 changes: 1 addition & 1 deletion client/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Session.set('currentPage', 'loading');
N_VISIBLE_POSTS = 3;

var Router = Backbone.Router.extend({
Router = Backbone.Router.extend({
routes: {
'': 'home',
'users': 'users',
Expand Down
18 changes: 9 additions & 9 deletions lib/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,39 @@ userState = function(user) {
}

// {name: 'blogName', value: 'Meteor Blog'}
var Settings = new Meteor.Collection('settings');
Settings = new Meteor.Collection('settings');

var getSetting = function(name) {
getSetting = function(name) {
var setting = Settings.findOne({name: name});
return setting && setting.value;
}

var updateSetting = function(name, value) {
updateSetting = function(name, value) {
Settings.update({name: name}, {$set: {value: value}});
}

// XXX: fill this out, consolidate author stuff.
// {title: '..', author: 'Tom Coleman', body: markdown, publishedAt: date}
var Posts = new Meteor.Collection('posts');
Posts = new Meteor.Collection('posts');

var titleToSlug = function(title) {
titleToSlug = function(title) {
// XXX: this is a first approximation, needs:
// - deal with non-latin chars
// - check for overlap? (add a -1 or something?)
return title.trim().toLowerCase().replace(/\W+/g, '-');
}

var allPosts = function(finder, options) {
allPosts = function(finder, options) {
return Posts.find(finder || {}, _.extend(options || {}, {sort: {publishedAt: -1}}));
}

var publishedPosts = function(options) {
publishedPosts = function(options) {
return allPosts({published: true});
}

// is this post saveable? returns an errors object,
// which is empty if the post is valid
var validatePost = function(post) {
validatePost = function(post) {
var errors = {}

if (!post.title || post.title === '')
Expand All @@ -69,7 +69,7 @@ var validatePost = function(post) {
}

N_COLORS = 6;
var nextPostColor = function() {
nextPostColor = function() {
var latestPost = Posts.findOne({}, {sort: {publishedAt: -1}});
if (latestPost) {
return (latestPost.color + 1) % N_COLORS;
Expand Down
2 changes: 1 addition & 1 deletion lib/external/md5.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/lib/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Sure, we could make it smarter, but I'm guessing this isn't the way things
// will work long term.
Meteor.serve = function(path, fn) {
var connect = __meteor_bootstrap__.require("connect");
var connect = Npm.require("connect");
__meteor_bootstrap__.app
.use(connect.query()) // <- XXX: we can probably assume accounts did this
.use(function(req, res, next) {
Expand Down

0 comments on commit 3ca378d

Please sign in to comment.