-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Built a made up project with a bunch of hooks
- Loading branch information
Showing
10 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/Users/tom/Development/Meteor/iron-location-single-page/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
preserve-inputs | ||
iron-router | ||
accounts-password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.7.1.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* CSS declarations go here */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<head> | ||
<title>hooks</title> | ||
</head> | ||
|
||
<template name="loading"> | ||
Loading template | ||
</template> | ||
|
||
<template name="404"> | ||
404 | ||
</template> | ||
|
||
<template name="adminRequired"> | ||
ADMIN REQUIRED! | ||
</template> | ||
|
||
<template name="login"> | ||
{{loginButtons}} | ||
</template> | ||
|
||
<template name="userPage"> | ||
Hey, you've logged in, here's your dashboard | ||
</template> | ||
|
||
<template name="adminPage"> | ||
This is an admin only page! | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
var ScrollPositions = new Meteor.Collection(null); | ||
|
||
Router.map(function() { | ||
this.route('userPage', { | ||
path: '/', | ||
|
||
// 9. Redirecting | ||
before: function() { | ||
if (Meteor.user() && Meteor.user().admin) | ||
this.redirect('adminPage'); | ||
} | ||
}); | ||
|
||
// if someone wants to explicitly go there | ||
this.route('login', { | ||
path: '/login', | ||
// 7. Session vars | ||
load: function() { | ||
Session.set('somethingExpanded', false); | ||
} | ||
}); | ||
|
||
this.route('adminPage', { | ||
path: '/admin', | ||
|
||
// 10. 3rd party API calls that are similar to waitOns: | ||
waitOn: function() { | ||
return { | ||
// this is made up but I do have code conceptually similar to this | ||
ready: promiseToReady(GoogleApi.call('/foo/bar')); | ||
} | ||
} | ||
}); | ||
|
||
this.route('post', { | ||
path: '/posts/:_id', | ||
// 2. subscribing | ||
waitOn: function() { return Meteor.subscribe('post', this.params._id); }, | ||
data: function() { return Posts.findOne(this.params._id); }, | ||
|
||
before: function() { | ||
// 2.b. complex subscription (join) | ||
if (this.data()) | ||
this.subscribe('author', this.data().authorId).wait(); | ||
} | ||
}); | ||
}); | ||
|
||
// 1. waiting filter | ||
Router.before(function() { | ||
if (! this.ready()) | ||
this.render('loading') | ||
}); | ||
|
||
// 3. Tracking page views | ||
Router.load(function() { | ||
mixpanel.track(this.path()); | ||
}); | ||
|
||
// 4. 404 filter | ||
Router.before(function() { | ||
if (this.ready() && ! this.data()) | ||
this.render('404'); | ||
}, {only: 'post'}); | ||
|
||
// 5. login filter | ||
Router.before(function() { | ||
if (! Meteor.loggingIn() && ! Meteor.user()) { | ||
this.render('login'); | ||
} | ||
}, {except: 'login'}); | ||
|
||
|
||
// 6. admin filter | ||
Router.before(function() { | ||
if (! Metoer.user() || ! Metoer.user().admin) | ||
this.render('accessDenied'); | ||
}, {only: 'adminPage'}); | ||
|
||
|
||
// 8. scroll to top of screen | ||
Router.before(function() { | ||
$(window).scrollTop(0); | ||
}); | ||
|
||
// 11. recording views | ||
Router.load(function() { | ||
Views.insert(this.path()); | ||
}); | ||
|
||
// 12. recording scroll position | ||
Router.unload(function() { | ||
ScrollPositions.insert({ path: this.path(), position: $(window).scrollTop() }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/iron-router | ||
/blaze-layout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"meteor": { | ||
"git": "https://github.com/meteor/meteor.git", | ||
"branch": "shark" | ||
}, | ||
"packages": { | ||
"iron-router": { | ||
"path": "../../" | ||
}, | ||
"blaze-layout": { | ||
"git": "https://github.com/EventedMind/blaze-layout.git", | ||
"branch": "devel" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"meteor": { | ||
"git": "https://github.com/meteor/meteor.git", | ||
"branch": "shark", | ||
"commit": "5671eaa2b77eae2c63f6c179b65ade1e85211a63" | ||
}, | ||
"dependencies": { | ||
"basePackages": { | ||
"iron-router": { | ||
"path": "../.." | ||
}, | ||
"blaze-layout": { | ||
"git": "https://github.com/EventedMind/blaze-layout.git", | ||
"branch": "devel" | ||
} | ||
}, | ||
"packages": { | ||
"iron-router": { | ||
"path": "../.." | ||
}, | ||
"blaze-layout": { | ||
"git": "https://github.com/EventedMind/blaze-layout.git", | ||
"branch": "devel", | ||
"commit": "91f3948edac11c28328630c6a7ab769d34fb35a0" | ||
} | ||
} | ||
} | ||
} |