Skip to content

Commit

Permalink
rewrite iron-router from scratch
Browse files Browse the repository at this point in the history
  • Loading branch information
cmather committed Jul 17, 2014
1 parent a974cf0 commit 6866776
Show file tree
Hide file tree
Showing 59 changed files with 2,575 additions and 0 deletions.
Empty file added CONTRIBUTING.md
Empty file.
130 changes: 130 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
## vNEXT

## v0.7.2
* Integrate iron-layout for new Blaze.View work
* Only use one main computation in _run instead of one for each thing
* Fix clearUnusedRegion bug
* Fix ie9 omits leading slash in pathname on click handler
* Dont call unnecessary stop() in client router when browsing away
* Examples corrections

Contributors:
Chris Mather
Dan Dascalescu
David Gomes
Tom Coleman

## v0.7.1
* Fix dataNotFoundHook
* Bump blaze-layout to 0.2.4
* Better error message for {{yield}} vs {{> yield}}
* Make parent data context available inside Layout when using Layout manually
* Remove Handlebars symbol from helpers.js
* Fix client helpers processArgs bug
* Don't call the data() function until controller is ready

## v0.7.0
* Blaze rendering with the [blaze-layout](https://github.com/eventedmind/blaze-layout) package.
* Layouts are only taken off the DOM (re-rendered) if the layout changes.
* Templates are only taken off the DOM (re-rendered) if the template changes.
* Data contexts change independently from rendering.
* {{yield}} is now {{> yield}} and {{yield 'footer'}} is now {{> yield region='footer'}}
* {{#contentFor region='footer'}}footer content goes here{{/contentFor}} is supported again!
* Router supports a uiManager api that can be used to plug in other ui managers (in addition to blaze-layout)
* RouteController API cleanup
* Hook name changes (legacy supported until 1.0)
* before -> onBeforeAction
* after -> onAfterAction
* load -> onRun
* unload -> onStop
* No more getData and setData methods on RouteController instances. Just use `this.data()` to call the controller's wrapped data function.
* run method changes
* Changed run to _run to indicate privacy
* A RouteController is in a running state or a stopped state. You cannot run a controller that is already running.
* You cannot call `stop()` inside of a run. Use `pause()` for hooks now instead. see below.
* Order of operations:
1. Clear the waitlist
2. Set the layout
3. Run the onRun hooks in a computation
4. Run the waitOn function in a computation, populating the waitlist
5. Set the global data context using the controller's wrapped data function
6. Run the action in a computation in this order: onBeforeAction, action, onAfterAction
* Hook api changes
* You can no longer call `this.stop()` in a hook. Use `pause()` instead which is the first parameter passed to the hook function. This stops downstream hooks from running. For example the loading hook uses pause() to stop the action function from rendering the main template.
* No hooks are included in your controllers by default. If you want to add them you can do it like this:
* `Router.onBeforeAction('loading')`
* `Router.onBeforeAction('dataNotFound')`
* Package authors can include their own hooks in the lookup chain by adding them to the `Router.hooks` namespace. Then users can add them by name like this: `Router.onBeforeAction('customhook');`
* See lib/client/hooks.js for example.
* Hooks are now called in a different order by popular demand:
1. controller options
2. controller prototype
3. controller object
4. route option hooks
5. router global

* Helpers cleanup
* `{{link}}` helper is no longer included by default. These types of helpers can be implemented in separate packages.
* `{{renderRouter}}` is gone for now.
* `{{pathFor}}` and `{{urlFor}}` still work with some api changes:
* {{pathFor 'routeName' params=this query="key=value&key2=value2" hash="somehash" anotherparam="anothervalue"}}
* same for {{urlFor}}

* IronLocation changes
* The router now sets up the link handler for much more consistency between `Router.go` and clicks on links.
* The location URL changes in between stopping the old route and starting the new one, so `onStop` and `onRun` behave as you'd expect.
* `location` is now an option to configure so you can use a custom location manager (apart from IronLocation).

## v0.6.2
* Bug fix: couldn't go back after page reload. Thanks @apendua!
* Added ability to customize IronLocation link selector. Thanks @nathan-muir
* Fixed a problem with child hooks running multiple times. Thanks @jagi!
* Fixed a problem with stopping the process when redirecting
* Fixed issues with optional paths, thanks @mitar
* Fixed problem on Android 2.3



## v0.6.1
* Bug fix: notFound template rendered with layout
* Bug fix: loading and notFound render yeilds again
* Bug fix: IE8 issue with 'class' property name on link handlebars helper
* Bug fix: Global hook regression
* Readme fixes

## v0.6.0
* **WARNING:** Breaking Changes
* The `layout` option is now called `layoutTemplate`
* The `renderTemplates` option is now called `yieldTemplates`
* RouteController `onBefore..` and `onAfter..` methods removed (now just use
`before` and `after`)
* `Router.current()` now returns a `RouteController` instance
* data option now applies only to the Route or RouteController, not to the render method
* pathFor and urlFor semantics have changed slightly (hash and query params can now be the key value pairs of the Handlebars expression)
1. `{{pathFor contextObject queryKey=queryValue hash=anchorTag}}`
or
2. ```
{{#with contextObject}}
{{pathFor queryKey=queryValue hash=anchorTag}}
{{/with}}
```
* Route and RouteController level layouts
* Support for url hash fragments
* Better support for query string parameters
* PageManager class for handling layout and template rendering and storing a global data context
* Layouts and templates now only re-render if the actual template has changed (allows for maintaining a layout/template across routes with no flicker)
* Data context is set/get globally on/from the Router
* See the lib/client/page_controller.js file for details
* No more silly RouteContext; all this stuff is in the RouteController instance
* Partial support for IE8-9. Pages make a server request if pushState is not supported by the browser. This is a performance penalty, but it works
* Cleaned up API signatures and passing of options from Router->Route->RouteController
* Fix onclick handler and moved into lib/client/location.js
* Client and Server Router now inherit from IronRouter
* Client and Server RouteController now inherit from IronRouterController
* Removed unnecessary global symbol exports (still accessible through Package['iron-router'] namespace)
* Global `notFoundTemplate` will render if a route is not found.
* Added `load` hook which fires exactly once per route load (and respects hot-code-reload!)
* Added `Router.before()` and friends which let you add global hooks with a bit more subtlety.
## v0.5.4
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2013 Chris Mather <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Iron.Router
==============================================================================

## License
MIT
1 change: 1 addition & 0 deletions examples/basic/.meteor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local
1 change: 1 addition & 0 deletions examples/basic/.meteor/identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6l3fq3iso6eb1u25omo
10 changes: 10 additions & 0 deletions examples/basic/.meteor/packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Meteor packages used by this project, one per line.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

standard-app-packages
autopublish
insecure
iron:router

1 change: 1 addition & 0 deletions examples/basic/.meteor/release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.8.1.3
42 changes: 42 additions & 0 deletions examples/basic/basic.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<head>
<title>basic</title>
</head>

<body>
</body>

<template name="Home">
{{> Nav}}

<h1>Home</h1>

<p>
Data Title: {{title}}
</p>
</template>

<template name="One">
{{> Nav}}

<h1>Page One</h1>
</template>

<template name="Two">
{{> Nav}}

<h1>Page Two</h1>
</template>

<template name="Nav">
<ul>
<li>
<a href="/">Home</a>
</li>
<li>
<a href="/one">Page One</a>
</li>
<li>
<a href="/two">Page Two</a>
</li>
</ul>
</template>
10 changes: 10 additions & 0 deletions examples/basic/basic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Router.route('/', function () {
// render the Home template with a custom data context
this.render('Home', {data: {title: 'My Title'}});
});

// when you navigate to "/one" automatically render the template named "One".
Router.route('/one');

// when you navigate to "/two" automatically render the template named "Two".
Router.route('/two');
1 change: 1 addition & 0 deletions examples/data_not_found_plugin/.meteor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local
1 change: 1 addition & 0 deletions examples/data_not_found_plugin/.meteor/identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sfnw7e1pu12bl1xv8k6i
11 changes: 11 additions & 0 deletions examples/data_not_found_plugin/.meteor/packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Meteor packages used by this project, one per line.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

standard-app-packages
autopublish
insecure
bootstrap
iron:router

1 change: 1 addition & 0 deletions examples/data_not_found_plugin/.meteor/release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
none
18 changes: 18 additions & 0 deletions examples/data_not_found_plugin/data_not_found_plugin.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<head>
<title>data_not_found_hook</title>
</head>

<body>
</body>

<template name="Home">
<h1>My Home Page</h1>

<p>
Data is: {{title}}
</p>
</template>

<template name="DataNotFound">
<h1>Sorry, couldn't find this data!</h1>
</template>
20 changes: 20 additions & 0 deletions examples/data_not_found_plugin/data_not_found_plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Router.configure({
// optionally specify a not found template for the dataNotFound hook.
notFoundTemplate: 'DataNotFound'
});

Router.plugin('dataNotFound');

Router.route('/', {
name: 'home',

data: function () {

/**
* To render the normal template change to:
*
* return { title: 'Some title' };
*/
return null;
}
});
1 change: 1 addition & 0 deletions examples/link_helpers/.meteor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local
1 change: 1 addition & 0 deletions examples/link_helpers/.meteor/identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
19qsffs7evr6l8x9vyt
Loading

0 comments on commit 6866776

Please sign in to comment.