Flow-Router not working for root url - meteor

I'm having a strange problem where Flow-Router isn't triggering the action for the root url
FlowRouter.route '/',
name: 'home'
action: ->
BlazeLayout.render 'appLayout', header: 'header', main: 'home'
This delivers a blank page, but when I change the route to something else, like '/dog' and go to that URL, the action triggers and the page is rendered
I'm using Flow-Router 2.10.1

Related

Symfony 1.4 - Changing Code With FTP

I am currently editing the code of my Symfony 1.4 Website using Sublime Text and pushing it to the web server with an FTP client.
However I have added a new module called 'about' and added the template and actions folders with the relevant files but when i try to go to mysite /about it just redirects me to another page.
I have the Routing.YML setup as follows
homepage:
url: /
param: { module: home, action: index }
about:
url: /about
param: { module: home, action: about }
stats:
url: /footballfans/stats
param: { module: footballfans, action: stats }
dailytips:
url: /dailytips/index
param: { module: dailytips, action: index }
footballnews:
url: /footballfeed.:sf_format
param: { module: footballfans, action: atom, sf_format: atom }
requirements:
sf_format: (?:atom)
default_index:
url: /:module
param: { action: index }
default:
url: /:module/:action/*
Is there any reason why these changes aren't being pushed to the site? Or do I have to edit a different file as well?
When I edit the template files these changes are being shown in the live site...
When I edit the VIEW.YML file to change the website SEO settings these also aren't being updated...

Using Meteor, useraccounts-core ensureSignedIn plugin won't except '/' route

I am trying to use the ensureSignedIn plugin on all routes except for a front 'home' page that has buttons to login to separate parts of the site.
Here's my route for 'home':
Router.route('/', function () {
this.render('home');
});
Here's the line for the plugin and exceptions:
Router.plugin('ensureSignedIn', {
except: ['home', 'atSignIn', 'atSignUp', 'atForgotPassword']
});
Both snippets are from my lib/routes.js file, if that makes a difference.
I've tried adding different route names in the except: portion, and they get correctly excepted, but I can't for the life of me get the 'home' route to not show "Must be logged in".
I've googled and read through gitHub issues and haven't seen anyone else with this problem, so it's probably something I'm doing wrong and not a bug with useraccounts or iron-router.
Set the name of the / route to root, then add that route name to the ensureSignedIn settings:
Router.route('/', {
name: 'root',
template: 'home',
action: function() {
this.render();
}
});
Router.plugin('ensureSignedIn', {
except: ['root', 'atSignIn', 'atSignUp', 'atForgotPassword', 'atResetPwd']
});

How to go to a route without it being logged in browser history

I never want my logout route to show up the browser history. How can I configure the logout route to never log to the history. I know I can call activate(silent: true) but this doesn't solve my issue.
This is how I am setting up my routes:
activate: function () {
app.init('shopper');
router
.makeRelative({ moduleId: "viewmodels", route: app.routes.routeBase })
.map([
{ route: "logout", title: 'Log Out', moduleId: "logout/index", nav: true, hidden: app.auth.isGuest }
])
.buildNavigationModel()
.mapUnknownRoutes("errors/404")
.activate({ pushState: true });
}
Is there something I can pass in here that will cause the logout route to never be logged in the browser history? If not, what other options do I have to accomplish never logging the logout route in the browser history. Thanks.
There is no water proof way to avoid a page to appear in the history. But what you can do, is add a simple Javascript to throw you back (forward), once you hit that page.
All you do is add this little script on the page that you shouldn't be able to navigate back to:
<script language="JavaScript"><!--
javascript:window.history.forward(1);
//--></script>

How to return 404 using Iron Router

When I hit a route that doesn't exist on my Meteor app that uses IR, I get a 200 response with an HTML that (when rendered on a browser) displays a js error on console saying that No route found for path: "/aRoute".
How can a make it return 404?
There don't seem to be a correct (or even working?) way of handling real 404's right now. See this issue for example: https://github.com/EventedMind/iron-router/issues/1055
Even when you try ways which should work, you'll still end up with a 200 status code. Like this code below which should work:
this.route( 'pageNotFound', {
path: '/(.*)',
where: 'server',
action: function() {
this.response.writeHead(404);
this.response.end( html );
}
});
I find this much easier way to show page not found. In router.js
Router.configure({
layoutTemplate: "layout",
loadingTemplate: "loading",
notFoundTemplate: "notFound"
})
Here "notFound" could be any template where you want to show 404 error
this.route('template404', {
path: '/*'
}
Use it at the end of your Router.map, cause this catches every value - if you use at the begining every path will be caught to this
Of course you can make it more complex, for example:
this.route('template404', {
path: '/posts/*'
}

Iron-router & PathFor

When I am using route without params, I've got normal pathFor in my template. But when I am adding some "slug", like this:
#route "pagesSlug",
path: "/page/:_slug"
name: "page"
And got error in console:
You called Router.path for a route named page but that route doesn't seem to exist. Are you sure you created it?
No change when I add/remove name.
I've got empty {{pathFor ... in my template, and urlFor too empty.
In this case:
#route "articlesList",
path: "/articles"
waitOn: ()->
Meteor.subscribe 'articles'
I've got href="/articles" - no problem.
Update: Meteor 0.9.4, and 0.9.4 of Iron-Router.
The first parameter of the route function is the name of the route. Your route name is pagesSlug
To get the path by the pathFor helper, you need to also pass the parameter _slug
{{pathFor "pagesSlug" _slug="xxxx"}}

Resources