GithubHelp home page GithubHelp logo

iron-meteor / iron-router Goto Github PK

View Code? Open in Web Editor NEW
2.0K 82.0 414.0 1.38 MB

A client and server side router designed specifically for Meteor.

License: MIT License

HTML 2.34% JavaScript 97.66%

iron-router's Introduction

Iron.Router

Join the chat at https://gitter.im/iron-meteor/iron-router

A router that works on the server and the browser, designed specifically for Meteor

The Iron.Router Guide

Detailed explanations of router features can be found in the Guide.

Installation

meteor add iron:router

Examples

There are several examples in the examples folder.

Quick Start

Create some routes in a client/server JavaScript file:

Router.route('/', function () {
  this.render('MyTemplate');
});

Router.route('/items', function () {
  this.render('Items');
});

Router.route('/items/:_id', function () {
  var item = Items.findOne({_id: this.params._id});
  this.render('ShowItem', {data: item});
});

Router.route('/files/:filename', function () {
  this.response.end('hi from the server\n');
}, {where: 'server'});

Router.route('/restful', {where: 'server'})
  .get(function () {
    this.response.end('get request\n');
  })
  .post(function () {
    this.response.end('post request\n');
  });

Migrating from 0.9.4

Iron Router should be reasonably backwards compatible, but there are a few required changes that you need to know about:

Hooks

onRun and onBeforeAction hooks now require you to call this.next(), and no longer take a pause() argument. So the default behaviour is reversed. For example, if you had:

Router.onBeforeAction(function(pause) {
  if (! Meteor.userId()) {
    this.render('login');
    pause();
  }
});

You'll need to update it to

Router.onBeforeAction(function() {
  if (! Meteor.userId()) {
    this.render('login');
  } else {
    this.next();
  }
});

This is to fit better with existing route middleware (e.g. connect) APIs.

Controller Methods

controller.setLayout() is now controller.layout(). Usually called as this.layout("fooTemplate") inside a route action.

Query Parameters

Query parameters now get their own object on this.params. To access the query object you can use this.params.query.

Loading Hook

The loading hook now runs automatically on the client side if your route has a waitOn. As previously, you can set a global or per-route loadingTemplate.

If you want to setup subscriptions but not have an automatic loading hook, you can use the new subscriptions option, which still affects .ready()-ness, but doesn't force the loading hook.

Hook and option inheritance

All hooks and options are now fully inherited from parent controllers and the router itself as you might expect. The order of precendence is now route; controller; parent controller; router.

Route names

A route's name is now accessible at route.getName() (previously it was route.name). In particular, you'll need to write Router.current().route.getName().

Routes on client and server

It's not strictly required, but moving forward, Iron Router expects all routes to be declared on both client and server. This means that the client can route to the server and visa-versa.

Catchall routes

Iron Router now uses path-to-regexp, which means the syntax for catchall routes has changed a little -- it's now '/(.*)'.

Template Lookup

If you don't explicitly set a template option on your route, and you don't explicity render a template name, the router will try to automatically render a template based on the name of the route. By default the router will look for the class case name of the template.

For example, if you have a route defined like this:

Router.route('/items/:_id', {name: 'items.show'});

The router will by default look for a template named ItemsShow with capital letters for each word and punctuation removed. If you would like to customize this behavior you can set your own converter function. For example, let's say you don't want any conversion. You can set the converter function like this:

Router.setTemplateNameConverter(function (str) { return str; });

Contributing

Contributors are very welcome. There are many things you can help with, including finding and fixing bugs, creating examples for the examples folder, contributing to improved design or adding features. Some guidelines below:

  • Questions: Please post to Stack Overflow and tag with iron-router : http://stackoverflow.com/questions/tagged/iron-router.

  • New Features: If you'd like to work on a feature, start by creating a 'Feature Design: Title' issue. This will let people bat it around a bit before you send a full blown pull request. Also, you can create an issue to discuss a design even if you won't be working on it.

  • Bugs: If you think you found a bug, please create a "reproduction." This is a small project that demonstrates the problem as concisely as possible. The project should be cloneable from Github. Any bug reports without a reproduction that don't have an obvious solution will be marked as "awaiting-reproduction" and closed after one week. Want more information on creating reproductions? Watch this video: https://www.eventedmind.com/feed/github-issues-and-reproductions.

Working Locally

This is useful if you're contributing code to iron-router.

  1. Set up a local packages folder
  2. Add the PACKAGE_DIRS environment variable to your .bashrc file - Example: export PACKAGE_DIRS="/Users/cmather/code/packages" - Screencast: https://www.eventedmind.com/posts/meteor-versioning-and-packages
  3. Clone the repository into your local packages directory
  4. Add iron-router just like any other meteor core package like this: meteor add iron:router
> git clone https://github.com/EventedMind/iron-router.git /Users/cmather/code/packages/iron:router
> cd my-project
> meteor add iron:router

License

MIT

iron-router's People

Contributors

alanning avatar apendua avatar aramk avatar ariemer avatar arunoda avatar avital avatar benmgreene avatar chrisbutler avatar cmather avatar dakmor avatar dandv avatar danieljonce avatar dburles avatar doctorpangloss avatar hiraash avatar johnallen avatar lukejagodzinski avatar mitar avatar mizzao avatar panphora avatar robertlowe avatar ryw avatar sachag avatar sylvaingi avatar techplexengineer avatar thebrettd avatar tmeasday avatar waitingkuo avatar xc8tlik avatar zimme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iron-router's Issues

Need help getting started

Hey there,

I really do need help to get started with this project. Currently I'm unable to get the router running. A simple but working example of this router and the controllers would be very helpful.

I've red through a files in the dev branch but it's not making perfect sense to me.

Thanks in advance.

How to have Subscription with arguments

Hi, i really enjoy the iron-router so far!
What i am not sure about is, how i would waitOn subscriptions that need arguments.

An example:

Router-Route:
@route 'profile', {
path: '/profiles/:profileSlug'
}

I have a controller with several subscriptions, depending on the params.profileSlug

waitOn: [
SubscriptionHandler.profile,
SubscriptionHandler.followers
...
]

The waitOn wants a subscription handle already so my SubscriptionHandler methods would look like this:

@SubscriptionHandler =
profile: () ->
return Meteor.subscribe('profile', Session.get('subscriptionOptions'))
followers: () ->
return Meteor.subscribe('followers', Session.get('subscriptionOptions'))

On the run method i would then:
Session.set('subscriptionOptions', {object: 'user', profileSlug: @params.profileSlug})

This seems to work, but every subscription is called right on the start even if the user is on another page, that does not need the 'profile' or 'followers' subscription. Also the subscription is not stopped if i route on another page, that does not need the subscriptions.

Before the iron-router i passed in an array functions that created the subscription handles. Before the routing i would then call all functions to create the subscriptions. I would also check the current subscriptions and unsubscribe all that are not in the given array.

So my question would be:
How do i manage subscriptions with parameters? How do i manage to NOT subscribe to every subscription that exists in my application? And how do i unsubscribe those i don't need?

I hope i am not asking to much ;-)

Manuel (@DerMambo)

Support IE<10

This includes support for browsers that don't support pushState (i.e. IE<10).

It includes researching whether we should roll our own solution or use a library like history.js. The integration point would be with our Location class location in lib/client/location.js

Ideally, the user shouldn't need to think about this at all, other than possibly providing configuration options to the router. Asking the user to include additional packages to make this work shouldn't be required in my opinion. However, if/when Meteor implements conditional file loading for packages (e.g. based on user-agent) we could dynamically send down the right javascript.

Issue with notFoundTemplate

Is there a bug with the notFoundTemplate option? In the basic example, navigating to a non-existent page does not render the notFound template that's been defined as the option in the router configuration. I do see an error being thrown to the console but it isn't handled or passed onto the template like I'd expect.

Enhancement: Layout data

It would be useful to be able to specify data object for layout as well as for template.

Example use case: I've got a dashboard layout with several tabs listed. I'd like to specify which tab should be highlighted for each route.

Inheritance is dependent on load order

Currently, a child cannot inherit from a parent if the child is loaded before the parent.

Not sure yet on the right solution. But I need to be able to inherit from a RouteController that hasn't necessarily been loaded yet, possibly by delaying inheritance until all initial symbols have loaded, prototypes defined, and class methods defined.

Couple of constraints:

  • The prototype of the super must be defined as that's what we'll point to in the inheritance chain.
  • The class methods must be defined because we simply copy them to the child

cc @tmeasday
cc @mizzao (thought you might have some ideas here)

Enhancement request - WaitOn Reactive objects

This isn't an issue but just a request to possibly extend the 'waitOn' feature to not only wait for subscriptions but to other reactive objects such as the 'Session' object. Alot of times, i have 'Session' objects that get set after the page renders and my user's will have missed important information. Currently, i highlight those changes but its becoming cumbersome and for some users with low connection, they don't see anything and assume the app is broken.

Feature Request: Helper to get link to previous page

Hello my meteor friends!

First of all: Thanks for this awesome router to both of you guys. Tom knows me because of our quite active email conversations and me being a bit of a pain in the ass for him! haha! :-) So thanks again Tom for all your help!!

I've got a little feature request: Could you build in something like Meteor.Router.previousPage() or something like this? (+ a handlebars helper to put this directly into the href of a standard link.)
Right now I need to do a little work around by setting a Session var "backlink" onclick of every link which leads to a page which can be accessed from different pages. This works but of course is not a good solution.
So I would something like history.back() put as a proper routed link (history.back() works but reloads the page instead of just showing the other template again - obviously).
Did you ever think of something like this? I think it would come in handy for many users!

I absolutely love that there are people like you out there who try to bring the whole Meteor project forward!
Cheers guys!

Basic example shows no items

So I downloaded the cloned the meteor-iron-router repo, changed directory to examples/basic, ran mrt add iron-router and then mrt to run the project. I could transition between home and items correctly, but the seed data did not show.

When I run Subscriptions.items.ready() in the console in the first couple of seconds it's false and then changes to true, as expect.

After changing the Meteor.isServer block to Meteor.startup(function () {
if(Items.find().count() > 0){
return;
}

for (var i = 0; i < 100; i++) {
  Items.insert({body: 'Item ' + i});
}

I did find data in the meteor.items collection, and could query it in the console with Items.findOne(), but it still doesn't show any data. Should there be a template helper for the items template to populate the items collection?

Installing iron-router breaks parts of accounts-ui

After installing iron-router, certain templates from the builtin accounts-ui package fail to display at all when Meteor tries to display them. This makes (for example) configuring Facebook login impossible.

Try this simple example:

mrt create test
cd test
mrt add accounts-ui
mrt add accounts-facebook
mrt add iron-router

add to test.html just before <h1>:

  {{loginButtons}}

add this to test.js in the isClient block:

  Router.map(function () {
    this.route('hello', {path: '/'});
  });

Start the app and you'll notice that clicking "Configure Facebook login" doesn't pop up the normal Facebook login window.

I think this is due to the <body> tag in accounts-ui-unstyled/login_buttons_dialogs.html and I can work around it by adding the contents of that tag to my layout.html:

  {{> _resetPasswordDialog}}
  {{> _enrollAccountDialog}}
  {{> _justVerifiedEmailDialog}}
  {{> _configureLoginServiceDialog}}
  {{> _loginButtonsMessagesDialog}}

How can we have a static element in dom ?

How can we have a static html element in dom with { autoRender: false } ?

I was using Tom's router before, after i switched to iron-router my notification plugin is broken because i can't maintain any static elements in dom that i can use as a container for notifications.

Filters don't properly protect pages

I'm using a before hook to filter pages when users aren't logged in. Basically like

Router.configure({
  before: function() {
    var user = Meteor.user();
    if (! user) {
      this.render(Meteor.loggingIn() ? 'loading' : 'login');
      return this.stop();
    }
  }
});

This way I assume I can access properties of Meteor.user() within my pages with impunity as I can guarantee they are logged in.

However, when I call Meteor.logout() I am seeing errors on my (filtered) pages about undefined users.

Haven't looked closely at this, but my initial guess would be the separated .flush() for data context changes. Will try to come up with a reproduction.

Is there a way to pre-set a session variable?

A common use case is needing to set a variable when routing to the page, but NOT when:

  • re-rendering
  • HCR

I'm guessing we get the first with a non-reactive before, but we'd need explicit support for the second.

What do you think?

Feature Request: Page Transitions

Hi guys!
Hey, this is really exciting to hear that mini-pages and router are being merged into a super package! Awesome!

Could I please make a request on behalf of countless people out there in the Meteor community? Could you all please provide an example pattern on how to implement a page transition during routing? I'm asking on behalf of posts like the following, which I've ran into a few of:

https://groups.google.com/forum/#!searchin/meteor-talk/page$20transition/meteor-talk/J2RbFEpFmec/FA_8QONWID4J

I don't know how much you all are familiar with routing and page transitions, but the current frameworks like jQuery Mobile are implementing them as .css based transitions, like so:

https://github.com/jquery/jquery-mobile/wiki/Page-Transition-Plugins

Now then, these CSS based transitions work just fine if a developer doesn't use a router and doesn't worry about assigning URLs to pages. The problem is using the page transitions and getting a URL at the same time. And that's what the person in the thread above was talking about with regards to prefetching.

Is onBeforeRun an appropriate place to call something like $('#newPage').addClass('slide.in');? Would the #newPage element in the template being routed to be loaded in the DOM yet, ready for a transition?

Any thoughts on this? There's lots of people who would be very interested in this feature!
Thanks,
Abigail :)

Proposal: Change extend to inherit

All of this various terminology for inheritance vs. adding properties to objects is very confusing. I'd like to propose that we be explicit about the javascript inheritance mechanism. If you call inherit on RouteController that means you're inheriting from it. Right now there are multiple confusing meanings for things across libraries:

  • _.extends: merge one object with another in underscore.js
  • extend: inherit from RouteController
  • extends: in coffeescript used as a keyword to mean inheritance. also reserved as a keyword in javascript (presumably for inheritance).

{{renderRouter}} does not render template for route

With Iron Router 0.5.3 the {{renderRouter}} appears to be broken (assuming it worked before). In a very basic app with one route here's what happens:

iron_test.html contains:

<head>
  <title>iron_test</title>
</head>

<body>
  {{renderRouter}}
</body>

<template name="home">
  <h1>Hello World!</h1>
  {{greeting}}
  <input type="button" value="Click" />
</template>

and iron_test.js contains:

if (Meteor.isClient) {
  Template.home.greeting = function () {
    return "Welcome to iron_test.";
  };

  Template.home.events({
    'click input' : function () {
      // template data, if any, is available in 'this'
      if (typeof console !== 'undefined')
        console.log("You pressed the button");
    }
  });

  Router.map(function() {
    this.route('home', {
      path: '/'
    });
  });

  Router.configure({
    autoRender: false
  });

}

if (Meteor.isServer) {
  Meteor.startup(function () {
    // code to run on server at startup
  });
}

The result is a blank home page; nothing renders and the <body> is empty.

If I change autoRender to true (even if {{renderRouter}} remains in the body where it is. The home template is properly rendered.

Also, when autoRender is false, and I replace {{renderRouter}} by {{> home}} as in:

<head>
  <title>iron_test</title>
</head>

<body>
  {{> home}}
</body>

<template name="home">
  <h1>Hello World!</h1>
  {{greeting}}
  <input type="button" value="Click" />
</template>

Everything renders fine. But, when the <body> contains {{renderRouter}} and autoRender is set to false, the home template is not rendered.

If I'm doing something wrong in this simple test, please point it out; otherwise it appears that {{renderRouter}} is broken.

Prevent named yields from getting redrawn after any given route is run?

I feel like there should be more control over which yields are redrawn when a route is run. In other words, lets say you have an app with a named header yield, that for 4 out of the 5 pages on the app, stays there. Then maybe you have an admin page where the header yield changes. I don't really see any reason to redraw that header yield every time a route is run since it persist throughout the majority of the app.

Another example: an app that I'm working on right now has a side bar that persist throughout the app. When the app is first accessed via url entry or page reload, the sidebar slides out using a mix of js and CSS3 transformations. It would be nice to render it one time when the app is first accessed and not have it redraw every time a route is run. And then, if at some point, I did want to swap that yield out, I could just call the render method as usual. And the render method would check to see if that yield is already occupied, if it is, call the clear method, then render the new yield.

I seems like this might allow for more flexible app development.

Thanks,
Scott.

Filters for login

Is there a filter method for routes so that you can require the user to be logged in in order to go to a template?

Add notFoundDataProperty to RouteController

We discovered in EventedMind that we often want to have multiple properties on data (sort of like helpers). For example:

data: {
  posts: function () {},

  somethingElse: function () {}
}

In this case the data property (or function) does not return a falsey value so there is no way for the render method to render the notFoundTemplate unless you do it manually in a controller action.

So to avoid that, I'd like to add a property called notFoundDataProperty so the user can specify which data property to use to decide whether no data exists for the given route.

cc @tmeasday

Trying to integrate a paging class with an extended RouteController

I have server side paging class p which supplies correct skip and limit attributes in a publication via client method calls generated on the click handlers of 4 buttons on the client ( firstpage, lastpage, prevpage, nextpage. ) The publication correctly filters mongo and returns a cursor with rows appropriate to the required button response. So far, so good. Now to the Client-side - and the problem...

My routed {{#forEach}} Template initially shows the first filtered rowset (say rows 0 to 11) as expected.

The last line of each click handler ( Template.mytemplate.events() ) subscribes to the published collection in order to force the newly populated server cursor across to the client. However, in response to a nextpage click the client collection (which I expect to hold the next 12 rows(12 .. 23), now contains 24 rows (0..23) and is rendered as such.

It would seem that client-side subscription collections in meteor can only grow, not be replaced by, a dynamic puplication. Is this really so or am I missing something?
I did try a subscribe(mycollection).stop() before the subscribe but it makes no difference. Please note, as a result of the nextpage method call to the pager p on the server, the published cursor correctly shows 12 rows (rows 12..23) so
the problem really is on the client.

Any advice here appreciated.

Controller level layout, that overrides configure.

Being able to have a number of different layouts would be very useful. The configure layout option does not even take a function, as far as I could tell, so I could not even fake controller overrides.

Also I have a layout that depends on a the users collection so when they log out everything goes nuts. I don't even need a layout on the login page. I would like to say something to the effect of layout: false.

Global namespace cleanup

There are too many globals. Also, it's not clear we really need a ClientRouter and a ServerRouter since it's basically the same class, except one runs on the client and one on the server. Should probably follow the Meteor style of making it the same class, with some functionality on server, and some on client.

autoRender should append to document.body

Currently, autoRender causes the body contents to be wiped out, then the Router is rendered into the body. It doesn't need to be this way as we can just append to the body. Also, the current behavior breaks accounts-ui.

See: #62

Race condition when data changes after routing.

I don't have time tonight to create a complete reduction, but I will tomorrow if the problem / fix isn't obvious to you.

Here's the basic scenario:

  1. I'm on an edit page for an item.
  2. I hit submit, which runs something like
Posts.update(post._id, {$set: something});
Router.to('showPost', post);
  1. The following happens (haven't traced exactly why)

    i. onRender fires for showPost (when the .go() is called).
    ii. The server returns the updated post, triggering editPost's onRender to fire.

I'm not sure if the bug is evident without using a transitioner, but I would guess it is. Will follow up tomorrow.

Additional test cleanup

Including:

  • server side tests
  • Router.go
  • Moving some client side tests into the base router tests file

Some design considerations

Hey,
I'm using this router for two days now and I really like it. Coming from a very new and promising PHP Framework I really would like to see some functionality I'm used to:

When I'm creating a e.g. PostController with a showAction, a route called "post.show" should be created automatically that renders the "post.show" template with the route path "post/show". After executing the action method "this.render('post.show')" should also be called automatically if not already done in the method. That way we have a cleaner separation and less clutter. Providing template data could be realized by calling "this.view.assign(key, value)" or "this.view.assign({key1: value1, key2: value2})".

Also it would be nice to have simply declare the dynamic route parts as parameters of the action method:

declaring "showAction(postId)" would create a route with the path "post/show/:postId". And the method is called with the correct parameters.

What do you think about that?

I actually implemented all of that behavior already and could provide the code if you like.

I think I didn't understand how RouteController works with the template key

Hi cmather,

I have this config:

Router.map(function () {
    this.route('launch', {path: '/'});
    this.route('unsubscribe', {
        controller: 'UnsubscribeController',
        path: '/unsubscribe/:coderId/:email',
        action: 'unsubscribe'
    });
});

if (Meteor.isClient) {
    Router.configure({
        layout: 'layout'
    });

    UnsubscribeController = RouteController.extend({
        template: 'unsubscribe',
        unsubscribe: function () {
            var email = decodeURIComponent(this.params.email);
            Meteor.call('unsubscribe', this.params.coderId, email, function (err, res) {
                Session.set('email', email);
                if (err) {
                    Session.set('error', true);
                } else {
                    Session.set('success', true);
                }
            });
        }
    });
}

unsubscribe.html:

<template name="unsubscribe">
    <h1>AFF</h1>
    <div class="row-fluid">
        <div class="page-description span6">
            <p>Hello</p>
            {{#if error}}
            <p>
                Sorry but we couldn't found the e-mail {{email}} so we can't unsubscribe it :(
            </p>
            {{/if}}
            {{#if success}}
            <p>
                E-mail {{email}} unsubscribed successfully.
            </p>
            {{/if}}
        </div>
    </div>
</template>

But I think I don't know how it's working. It's not inserting the template unsubscribe into the {{yield}} of the layout.
If I remove the controller and the action from the route it works fine:

Router.map(function () {
    this.route('launch', {path: '/'});
    this.route('unsubscribe', {
        path: '/unsubscribe/:id/:email',
    });
});

What am I missing ?
Thanks

Add redirect example in README

You can redirect inside a RouteController action like this:

myAction: function () {
  this.redirect('someOtherRoute');
}

This stops the current controller (stops all downstream filters (or the action itself if the redirect happens in a filter) and redirects to the given path or route name. The parameters are the same as those to Router.go.

waitOn with no loadingTemplate

Hi Chris,
Awesome stuff here. I think this router is going to help me clean up a lot of my application's code. My question:
When waiting on subscriptions before navigating to a new page, I see a flicker during which no template is rendered into my main yield. I didn't define a loadingTemplate because I'd like the previous template to just remain there until the subscription is ready. Is this behavior supported?

Prevent named yields from getting redrawn?

Is there any way to prevent a named yield from getting re-drawn everytime a new page gets rendered. I have a navigation that slide out when the app is first accessed and I don't wan't it to slide out everytime a new page within the app is rendered?

Multiply level inheritance chain is broken.

Encountered in new version of EventedMind. It is currently inherited one level up, but it is broken two level up.

It should be :
Child -> Super -> RouteController
postEdit -> postShow -> RouteController

Currently:
Child -> Super -> empty
postEdit -> postShow -> empty

Router not working in produciton...

Using Demeteorizer. When deployed to Modulus, I'm seeing this error log. Deploying to XXX.meteor.com, no problem with the router. Demeteorizer issue?

}).run();
   ^
Error: a route URL prefix must begin with a slash
    at _.extend.declare (packages/routepolicy.js:112:13)
    at new StreamServer (packages/livedata.js:557:37)
    at new Server (packages/livedata.js:1712:24)
    at Package (packages/livedata.js:3872:19)
    at packages/livedata.js:3907:4
    at packages/livedata.js:3918:3
    at mains (/mnt/data/1/programs/server/boot.js:153:10)
    at Array.forEach (native)
    at Function._.each._.forEach (/mnt/data/1/node_modules/underscore/underscore.js:79:11)
    at /mnt/data/1/programs/server/boot.js:80:5
[2013-08-21T04:07:26.565Z] Application initialized with pid undefined

onClick event sometimes conflicts with local links

Not sure this is a bug per se, but need to take a closer look at this. I've already run into a tough to track down issue where the router is responding to a click on an A tag but it's not associated with a particular route.

Filling out the README

I would like to fill out portions of the README as I use iron router in my code and read through your code comments. I have a couple of questions:

  • What is Meteor 0.7.0 referring to? What branch/tag in the meteor repo does this correspond to and should I be actively using that? Is it designed to work with linker or devel?
  • Any other information references / usage examples other than comments in the code itself?

Reactivity breaks contentFor

Reproduction:

  1. Clone https://github.com/tmeasday/ir-reactivity-problem, run against iron-router
  2. Open in browser, change the 'foo' session variable.
  3. You should see:
Session.set('foo', 'bar')
undefined
Exception from Deps recompute: Error: You called contentFor outside of a        Controller._CurrentPartials.withPartials callback
    at assert (http://localhost:3010/packages/controller/lib/controller.js?eea9e49991ca8bc77186103b536d7d8378591fc1:3:11)
    at Object.Helpers.contentFor (http://localhost:3010/packages/controller/lib/controller.js?eea9e49991ca8bc77186103b536d7d8378591fc1:55:5)
    at apply (http://localhost:3010/packages/handlebars/evaluate.js?742a34cf3479d95600582786665b53c0eba4f7d9:232:24)
    at invoke (http://localhost:3010/packages/handlebars/evaluate.js?742a34cf3479d95600582786665b53c0eba4f7d9:257:12)
    at http://localhost:3010/packages/handlebars/evaluate.js?742a34cf3479d95600582786665b53c0eba4f7d9:341:27
    at Object.Spark.labelBranch (http://localhost:3010/packages/spark/spark.js?4af332696fb84f1c71f2e678ad0a267755b2b828:1114:14)
    at branch (http://localhost:3010/packages/handlebars/evaluate.js?742a34cf3479d95600582786665b53c0eba4f7d9:311:20)
    at http://localhost:3010/packages/handlebars/evaluate.js?742a34cf3479d95600582786665b53c0eba4f7d9:340:20
    at Array.forEach (native)
    at Function._.each._.forEach (http://localhost:3010/packages/underscore/underscore.js?ed2d2b960c0e746b3e4f9282d5de66ef7b1a2b4d:78:11) 

basic example fails to show loading... and fails to display 100 docs in the items template

When clicking the Items link the items page shows the 2 navigation links, the Items Items Aside template, a Posts page header but no items list, and the Items Footer template.

No Loading ... template was shown at startup.

Just in case I installed it wrongly, here is what I did.

Created a new meteor project "iron-router", mrt add iron-router, meteor remove auto-publish. Then removed the project's html, css and js files and copied the 3 example basic.* files from packages/iron-router/examples/basic into my project's root.

Did a test on the Server side to make sure mongo was loaded with the seed (100 docs) and this was OK.

I am using Apple PowerMac OS X Lion 10.7.5 , Chrome and Firefox

Uncaught Error: _id not found in params (problem with parsing url parameters)

Hi again,
Following the instructions on the Iron Router, and it doesn't seem to be parsing parameters after a ? character. :(

As I mentioned in the other thread, I'm working on this OAuth project. Without going into all the details, suffice it to say that the external server (stripe.com) is doing a redirect to a page on my server, and is handing off a parameterrized URL which I'm trying to parse. Here's the basic scenario:

// I specified the following URL redirect route as part of setting up OAuth
localhost:3600/stripe

// and the oauth authentication process successfully redirects to the following URL
localhost:3600/stripe?scope=read_only&code=ac_2QGZP0nOBmb0Lxk9q3pMzaRvOi4fMU8j

// with the following parameterized tokens I need to use for future API calls
?scope=read_only&code=ac_2QGZP0nOBmb0Lxk9q3pMzaRvOi4fMU8j

So far, so good. Mostly, I'm just interested in getting that code ac_2QGZP0nOBmb0Lxk9q3pMzaRvOi4fMU8j, which changes at every login, and which I need as a security token to use the rest of the API. So, here's what I'm trying to do, and the error messages it's giving me:

Router.map(function() {
    this.route('home', {path: '/'});
    this.route('stripeConnect', {path: '/connect'});
    this.route('aboutUs');
    this.route('charge');

    // so, i tried to set up a route, as per the basic instructions, and it generates the following error:
    // Uncaught Error: _id not found in params 
    this.route('stripeRedirect', {
      path: '/stripe/:_id',
      data: function() { //return Posts.findOne(this.params._id); 
        return true;
      }
    });

    // bah.  so, I tried dozens of other changes; lots of stuff that looks like this. 
    // same basic error though - Uncaught Error: slug not found in params 
    this.route('stripeRedirect', {
          path:'/stripe/:slug'}
    ), function(){
        console.log(this.params.code);
        console.log(this.params.slug);
    };

   // then, I thought I'd be really clever, and do something like this, but no luck
   // Uncaught Error: _id not found in params 
   this.route('stripeRedirect', {
        path: '/stripe?scope=read_only&code=:_id'},
        function(){
        console.log(this.params._id);
        }
    );

    // another failed attempt
    this.route('stripeRedirect', {
            path: '/stripe'},
        function(){
            console.log(this.params.code);
        }
    );


});

As far as I can tell, it seems to have something to do with the router not parsing the :slug component in the path lines, like so path:'/stripe/:slug'.

Any thoughts on how to proceed? Thanks in advance for any suggestions!
Abigail

Overriding layout in route

Is there a way to change the layout based on the route? Currently, we're only managing to use the default (configured) layout.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.