Permalink
Browse files

Switch to iron-router

  • Loading branch information...
1 parent 120c4d7 commit 1264d5c02daf010bf9cdfb834446b1cf7f5df1c1 @oliversong committed Oct 21, 2013
View
@@ -8,6 +8,6 @@ preserve-inputs
bootstrap
coffeescript
errors
-router
spin
cron-tick
+iron-router
@@ -1,23 +1,28 @@
-Meteor.Router.add
- '/': {to: 'landingPage', as: 'landing'}
+Router.configure
+ before: clearErrors
+ loadingTemplate: 'loading'
+ layoutTemplate: 'layout'
- '/box/:_id':
- to: (id)->
- box = Boxes.findOne id
- if box
- # if the box exists, then redirect to it
- Session.set 'currentBoxId', id
- 'boxPage'
- else
- # if not, then redirect to the sorry page
- 'sorryPage'
+Router.map ()->
+ @route('landingPage', {
+ path: '/'
+ })
+ @route('boxPage', {
+ path: '/box/:_id',
+ waitOn: ()->
+ Meteor.subscribe('box', @params._id)
+ notFoundTemplate: 'sorryPage'
+ data: ()->
+ _id = @params._id
+ Boxes.findOne({_id: _id})
+ before: ()->
+ Session.set('currentBoxId', @params._id)
+ })
- '*': 'not_found'
+ @route('not_found', {
+ path: '*'
+ })
-Meteor.Router.filters
- 'clearErrors': (page)->
- Errors.clearSeen()
- return page
-
-Meteor.Router.filter('clearErrors')
+clearErrors = ()->
+ Errors.clearSeen()
View
@@ -1,3 +1,2 @@
Meteor.subscribe 'notifications'
Meteor.subscribe 'filecount'
-Meteor.subscribe 'boxes'
View
@@ -8,14 +8,15 @@
<script type="text/javascript" src="//use.typekit.net/bpf7vbp.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
</head>
-<body>
+
+<template name="layout">
<div class="wrap">
<div class="topBar"></div>
<div class="container">
{{> header}}
{{> meteorErrors}}
<div id="main" class="row-fluid">
- {{renderPage}}
+ {{ yield }}
</div>
<div class="push"></div>
</div>
@@ -26,4 +27,4 @@
</div>
</div>
{{> analytics}}
-</body>
+</template>
@@ -1,7 +1,7 @@
<template name="header">
<div class="row-fluid space-above-small">
<div class="span12">
- <a class="brand" href="{{landingPath}}">OneTimeBox<span class="beta">beta</span></a>
+ <a class="brand" href="{{ pathFor 'landingPage' }}">OneTimeBox<span class="beta">beta</span></a>
</div>
</div>
</template>
@@ -14,8 +14,8 @@ Template.landingPage.events(
Errors.throw(error.reason)
if error.error is 302
- Meteor.Router.to('landingPage', error.details)
- Meteor.Router.to('/box/'+id)
+ Router.go('landingPage', error.details)
+ Router.go('/box/'+id)
)
numberWithCommas = (x)->
View
@@ -5,3 +5,4 @@ spin
page-js-ie-support
HTML5-History-API
cron-tick
+iron-router
@@ -1,8 +1,8 @@
Meteor.publish 'files', (boxId)->
return Files.find({boxId:boxId})
-Meteor.publish 'boxes', ()->
- return Boxes.find()
+Meteor.publish 'box', (boxId)->
+ return Boxes.find({_id: boxId})
# server: publish the current size of a collection
Meteor.publish 'filecount', () ->
View
@@ -1,9 +1,12 @@
{
"packages": {
- "router": {},
"errors": {},
"accounts-ui-bootstrap-dropdown": {},
"spin": {},
- "cron-tick": {}
+ "cron-tick": {},
+ "iron-router": {
+ "git": "https://github.com/EventedMind/iron-router.git",
+ "branch": "dev"
+ }
}
}
View
@@ -2,18 +2,16 @@
"meteor": {},
"dependencies": {
"basePackages": {
- "router": {},
"errors": {},
"accounts-ui-bootstrap-dropdown": {},
"spin": {},
- "cron-tick": {}
+ "cron-tick": {},
+ "iron-router": {
+ "git": "https://github.com/EventedMind/iron-router.git",
+ "branch": "dev"
+ }
},
"packages": {
- "router": {
- "git": "https://github.com/tmeasday/meteor-router.git",
- "tag": "v0.5.4.1",
- "commit": "d00e380dda2184b70e909fc4a0fb5358d602c586"
- },
"errors": {
"git": "https://github.com/tmeasday/meteor-errors.git",
"tag": "v0.2.0",
@@ -34,15 +32,10 @@
"tag": "v0.0.4",
"commit": "44cff9116af510fe53704fdeeff57c444ceb75ba"
},
- "page-js-ie-support": {
- "git": "https://github.com/tmeasday/meteor-page-js-ie-support.git",
- "tag": "v1.3.5",
- "commit": "b99ed8380aefd10b2afc8f18d9eed4dd0d8ea9cb"
- },
- "HTML5-History-API": {
- "git": "https://github.com/tmeasday/meteor-HTML5-History-API.git",
- "tag": "v4.0.0",
- "commit": "dc4965f1424cfca625ec3fbea17eace03f8e32c5"
+ "iron-router": {
+ "git": "https://github.com/EventedMind/iron-router.git",
+ "branch": "dev",
+ "commit": "238cce9055ee7d89ff8c20b8df373637f7be191e"
}
}
}

0 comments on commit 1264d5c

Please sign in to comment.