Fixing style issues.

Also, switching Router.routes[].path to Router.path
This commit is contained in:
Anthony Mayer 2015-01-19 00:48:17 -08:00
parent f197b930e6
commit 2bafca52e3
9 changed files with 43 additions and 39 deletions

View file

@ -6,9 +6,9 @@ Template[getTemplate('userMenu')].helpers({
return getDisplayName(Meteor.user());
},
profileUrl: function () {
return Router.routes['user_profile'].path({_idOrSlug: Meteor.user().slug});
return Router.path('user_profile', {_idOrSlug: Meteor.user().slug});
},
userEditUrl: function () {
return Router.routes['user_edit'].path(Meteor.user());
return Router.path('user_edit', {slug: Meteor.user().slug});
}
});

View file

@ -1,6 +1,7 @@
Template[getTemplate('postRank')].helpers({
oneBasedRank: function(){
if(typeof this.rank !== 'undefined')
if (typeof this.rank !== 'undefined') {
return this.rank + 1;
}
}
});

View file

@ -48,7 +48,8 @@ goTo = function(url){
// and shouldn't care about the siteUrl.
getRouteUrl = function (routeName, params, options) {
options = options || {};
var route = Router.routes[routeName].url(
var route = Router.url(
routeName,
params || {},
options
);

View file

@ -61,7 +61,7 @@ PostsListController = RouteController.extend({
var count = parseInt(Session.get('postsLimit')) + parseInt(getSetting('postsPerPage', 10));
var categorySegment = Session.get('categorySlug') ? Session.get('categorySlug') + '/' : '';
// TODO: use Router.routes[].path here?
// TODO: use Router.path here?
Router.go('/' + Session.get('view') + '/' + categorySegment + count);
}
};

View file

@ -33,7 +33,7 @@ servePostRSS = function(view, url) {
};
serveCommentRSS = function() {
var feed = new RSS(getMeta(Router.routes['rss_comments'].path()));
var feed = new RSS(getMeta(Router.path('rss_comments')));
Comments.find({isDeleted: {$ne: true}}, {sort: {postedAt: -1}, limit: 20}).forEach(function(comment) {
post = Posts.findOne(comment.postId);

View file

@ -21,7 +21,7 @@ Template[getTemplate('singleDay')].created = function () {
view: 'digest',
after: moment(currentDate).startOf('day').toDate(),
before: moment(currentDate).endOf('day').toDate()
}
};
};
// 2. Autorun
@ -70,9 +70,9 @@ Template[getTemplate('singleDay')].created = function () {
var termsLoaded = _.extend(instance.getTerms(), {limit: instance.postsLoaded.get()});
var parameters = getPostsParameters(termsLoaded);
return Posts.find(parameters.find, parameters.options);
}
};
}
};
Template[getTemplate('singleDay')].helpers({
showDateNav: function () {
@ -114,7 +114,7 @@ Template[getTemplate('singleDay')].helpers({
// the current instance
controllerInstance: instance
}
};
return context;
}

View file

@ -21,10 +21,12 @@ Template[getTemplate('singleDayNav')].helpers({
var currentDate = moment(Session.get('currentDate'));
var today = moment(new Date());
var diff = today.diff(currentDate, 'days');
if(diff === 0)
if (diff === 0) {
return i18n.t("today");
if(diff === 1)
}
if (diff === 1) {
return i18n.t("yesterday");
}
return currentDate.format("dddd, MMMM Do YYYY");
},
previousDateURL: function(){
@ -44,6 +46,6 @@ Template[getTemplate('singleDayNav')].helpers({
showNextDate: function(){
var currentDate = moment(Session.get('currentDate')).startOf('day');
var today = moment(new Date()).startOf('day');
return isAdmin(Meteor.user()) || (today.diff(currentDate, 'days') > 0)
return isAdmin(Meteor.user()) || (today.diff(currentDate, 'days') > 0);
}
})

View file

@ -16,10 +16,10 @@ viewParameters.digest = function (terms) {
sort: {sticky: -1, score: -1}
}
};
}
};
getDateURL = function(moment){
return Router.routes['postsSingleDay'].path({
return Router.path('postsSingleDay', {
year: moment.year(),
month: moment.month() + 1,
day: moment.date()

View file

@ -19,16 +19,16 @@ describe('test clicking vote buttons', function () {
var shouldRedirectIfLoggedOut = function (selector) {
render();
var userSpy = spyOn(Meteor, 'user').and.returnValue(false);
spyOn(Meteor, 'user').and.returnValue(false);
var routerSpy = spyOn(Router, 'go');
var flashMessageSpy = spyOn(window, 'flashMessage');
var meteorCallSpy = spyOn(Meteor, 'call')
var meteorCallSpy = spyOn(Meteor, 'call');
$div.find(selector).click();
expect(routerSpy.calls.count()).toEqual(1);
expect(routerSpy).toHaveBeenCalledWith('atSignIn');
expect(flashMessage.calls.count()).toEqual(1);
expect(flashMessageSpy.calls.count()).toEqual(1);
expect(meteorCallSpy.calls.count()).toEqual(0);
};
@ -59,7 +59,7 @@ describe('test clicking vote buttons', function () {
render(data);
var userSpy = spyOn(Meteor, 'user').and.returnValue(true);
spyOn(Meteor, 'user').and.returnValue(true);
var routerSpy = spyOn(Router, 'go');
var flashMessageSpy = spyOn(window, 'flashMessage');
var trackEventSpy = spyOn(window, 'trackEvent').and.stub();
@ -70,7 +70,7 @@ describe('test clicking vote buttons', function () {
$div.find(selector).click();
expect(routerSpy.calls.count()).toEqual(0);
expect(flashMessage.calls.count()).toEqual(0);
expect(flashMessageSpy.calls.count()).toEqual(0);
expect(meteorCallSpy.calls.count()).toEqual(1);
expect(meteorCallSpy.calls.first().args[0]).toEqual(meteorMethodName);
expect(trackEventSpy.calls.count()).toEqual(1);