iron-meteor / iron-router

A client and server side router designed specifically for Meteor.
MIT License
1.98k stars 412 forks source link

Appcache support for ironrouter #1331

Open Buom01 opened 9 years ago

Buom01 commented 9 years ago

I doesn't know if I must ask it here or on appcache's github.

I want to use appcache, but it convert url to hashes;

In this way, iron-router thing that the page is the home page http://localhost:3000/#![...] So, my probleme can be show with;

Router.onBeforeAction(function() {
  if (!Meteor.userId()) {
    this.render('connexion');
  } else {
    this.next();
  }
}, {
  except: ['home', 'connexion']
});

This code is useless because with a "#" we are considered on the home page and the requested page is trying to be loaded


How to say to iron-router the true url with onBeforeAction hook, or solve this probleme? I think that the actual only and easiest way is fork it to reconvert internally the showed url to the original url (exemple: url = window.location.replace("!#",""); ).

An dreamly (not working and not real) solution;

Router.onBeforeAction(function(url) {
  this.next(url.replace("#!",""));
});

A trashy (real and working) solution;

Router.onAfterAction(function() {
  if (!(window.location.hash == "" || window.location.hash == "#" || window.location.hash == "#!" || window.location.hash == "#!connexion")
   && !Meteor.userId()) {
    Router.go('/connexion');
  }
});
isAlmogK commented 9 years ago

Why can't you have hashtag in your URL? I'm using AppCache and Iron Router with no issues

Anonyfox commented 9 years ago

[Log] Error: Syntax error, unrecognized expression: #!records/Dk6TDAgbqbNfxwt5W/edit/2

Iron router + appcache errors with this one. Everything is fine without appcache, though.

EDIT: resolved for me, the issue was iron-router-scroll package, not iron router itself. False alert

vladholubiev commented 9 years ago

@Anonyfox Thanks!

EDIT: resolved for me, the issue was iron-router-autoscroll package, not iron router itself

Anyone who came here, just run meteor remove okgrow:iron-router-autoscroll

@Buom01 can close the issue