mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
Fixing style issues.
Also, switching Router.routes[].path to Router.path
This commit is contained in:
parent
f197b930e6
commit
2bafca52e3
9 changed files with 43 additions and 39 deletions
|
@ -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});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
Template[getTemplate('postRank')].helpers({
|
||||
oneBasedRank: function(){
|
||||
if(typeof this.rank !== 'undefined')
|
||||
if (typeof this.rank !== 'undefined') {
|
||||
return this.rank + 1;
|
||||
}
|
||||
}
|
||||
});
|
|
@ -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
|
||||
);
|
||||
|
|
|
@ -57,11 +57,11 @@ PostsListController = RouteController.extend({
|
|||
postsReady: this.postsListSub.ready(),
|
||||
hasMorePosts: this._terms.limit == postsCount,
|
||||
loadMoreHandler: function () {
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// see https://www.discovermeteor.com/blog/template-level-subscriptions/
|
||||
|
||||
// this template acts as the controller that sets and
|
||||
// this template acts as the controller that sets and
|
||||
// manages the reactive context for the embedded postsList template
|
||||
|
||||
Template[getTemplate('singleDay')].created = function () {
|
||||
|
@ -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
|
||||
|
@ -56,10 +56,10 @@ Template[getTemplate('singleDay')].created = function () {
|
|||
instance.postsReady.set(true);
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
instance.postsReady.set(false);
|
||||
// console.log("> Subscription is not ready yet. \n\n");
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@ Template[getTemplate('singleDayNav')].created = function(){
|
|||
|
||||
$(document).unbind('keyup'); //remove any potential existing bindings to avoid duplicates
|
||||
|
||||
var currentDate=moment(Session.get('currentDate')).startOf('day');
|
||||
var today=moment(new Date()).startOf('day');
|
||||
var currentDate = moment(Session.get('currentDate')).startOf('day');
|
||||
var today = moment(new Date()).startOf('day');
|
||||
|
||||
$(document).bind('keyup', 'left', function(){
|
||||
Router.go($('.prev-link').attr('href'));
|
||||
|
@ -11,25 +11,27 @@ Template[getTemplate('singleDayNav')].created = function(){
|
|||
|
||||
$(document).bind('keyup', 'right', function(){
|
||||
if(isAdmin(Meteor.user()) || today.diff(currentDate, 'days') > 0)
|
||||
Router.go($('.next-link').attr('href'));
|
||||
});
|
||||
Router.go($('.next-link').attr('href'));
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
Template[getTemplate('singleDayNav')].helpers({
|
||||
currentDate: function(){
|
||||
var currentDate=moment(Session.get('currentDate'));
|
||||
var today=moment(new Date());
|
||||
var diff=today.diff(currentDate, 'days');
|
||||
if(diff === 0)
|
||||
var currentDate = moment(Session.get('currentDate'));
|
||||
var today = moment(new Date());
|
||||
var diff = today.diff(currentDate, 'days');
|
||||
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(){
|
||||
var currentDate=moment(Session.get('currentDate'));
|
||||
var newDate=currentDate.subtract(1, 'days');
|
||||
var currentDate = moment(Session.get('currentDate'));
|
||||
var newDate = currentDate.subtract(1, 'days');
|
||||
return getDateURL(newDate);
|
||||
},
|
||||
showPreviousDate: function(){
|
||||
|
@ -37,13 +39,13 @@ Template[getTemplate('singleDayNav')].helpers({
|
|||
return true;
|
||||
},
|
||||
nextDateURL: function(){
|
||||
var currentDate=moment(Session.get('currentDate'));
|
||||
var newDate=currentDate.add(1, 'days');
|
||||
var currentDate = moment(Session.get('currentDate'));
|
||||
var newDate = currentDate.add(1, 'days');
|
||||
return getDateURL(newDate);
|
||||
},
|
||||
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)
|
||||
var currentDate = moment(Session.get('currentDate')).startOf('day');
|
||||
var today = moment(new Date()).startOf('day');
|
||||
return isAdmin(Meteor.user()) || (today.diff(currentDate, 'days') > 0);
|
||||
}
|
||||
})
|
|
@ -8,7 +8,7 @@ viewParameters.digest = function (terms) {
|
|||
return {
|
||||
find: {
|
||||
postedAt: {
|
||||
$gte: terms.after,
|
||||
$gte: terms.after,
|
||||
$lt: terms.before
|
||||
}
|
||||
},
|
||||
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue