One way of achieving a 404 page...

This commit is contained in:
Tom Coleman 2012-10-18 10:53:57 +11:00
parent d8fef4581a
commit 8d4682a558
4 changed files with 29 additions and 14 deletions

View file

@ -66,6 +66,7 @@ var postsView={
sessionSetObject('postsView', postsView);
Meteor.autosubscribe(function() {
Session.set('postsReady', false);
var view=sessionGetObject('postsView');
Meteor.subscribe('posts', view, function() {
// collectionArray=Posts.find().fetch();
@ -75,6 +76,7 @@ Meteor.autosubscribe(function() {
// console.log('- '+collectionArray[i].headline);
// }
// console.log('found '+collectionArray.length+' posts');
Session.set('postsReady', true);
});
});

View file

@ -120,7 +120,7 @@ SimpleRouter = FilteredRouter.extend({
top: function(page) {
if(canView(Meteor.user(), 'replace')) {
var pageNumber = (typeof page === 'undefined') ? 1 : page;
var postsPerPage=10;
var postsPerPage=1;
var postsView={
find: {},
sort: {score: -1},
@ -186,11 +186,29 @@ SimpleRouter = FilteredRouter.extend({
admin: function() { this.goto('admin'); },
categories: function() { this.goto('categories'); },
post: function(id, commentId) {
window.template='post_page';
Session.set('selectedPostId', id);
if(typeof commentId !== 'undefined')
Session.set('scrollToCommentId', commentId);
this.goto('post_page');
var postsView={
find: {_id:Session.get('selectedPostId')},
sort: {},
skip:0,
postsPerPage:1,
limit:1
}
sessionSetObject('postsView', postsView);
this.goto(function() {
if (Posts.findOne(id)) {
return 'post_page';
} else if (! Session.get('postsReady')) {
return 'loading';
} else {
return 'not_found';
}
});
// on post page, we show the comment recursion
window.repress_recursion=false;
// reset the new comment time at each new request of the post page

View file

@ -0,0 +1,6 @@
<template name="not_found">
<div class="grid-small grid-block dialog">
<h2>Not Found!</h2>
<p>We're sorry; whatever you were looking for isn't here..</p>
</div>
</template>

View file

@ -1,14 +1,3 @@
Template.post_page.created = function(){
var postsView={
find: {_id:Session.get('selectedPostId')},
sort: {},
skip:0,
postsPerPage:1,
limit:1
}
sessionSetObject('postsView', postsView);
};
Template.post_page.helpers({
post: function(){
var post = Posts.findOne(Session.get('selectedPostId'));