-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Zoltan Olah
committed
Oct 27, 2014
1 parent
877b94c
commit b0b4ef6
Showing
9 changed files
with
70 additions
and
4 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,15 @@ | ||
<template name="admin"> | ||
{{#if isAdmin}} | ||
<h1>Admin</h1> | ||
|
||
<a href="/">Home</a> | ||
|
||
<form> | ||
<label>Latest News</label> | ||
<input name="text" type="text" value="{{latestNews.text}}" /> | ||
<button type="submit">Save</button> | ||
</form> | ||
{{else}} | ||
<h1>Forbidden</h1> | ||
{{/if}} | ||
</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,20 @@ | ||
Template.admin.helpers({ | ||
isAdmin: function() { | ||
return Meteor.user() && Meteor.user().admin; | ||
}, | ||
|
||
latestNews: function() { | ||
return News.latest(); | ||
} | ||
}); | ||
|
||
Template.admin.events({ | ||
'submit form': function(event) { | ||
event.preventDefault(); | ||
|
||
var text = $(event.target).find('[name=text]').val(); | ||
News.insert({ text: text, date: new Date }); | ||
|
||
alert('Saved latest news'); | ||
} | ||
}) |
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
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
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
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
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
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
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,10 @@ | ||
Accounts.onCreateUser(function(options, user) { | ||
if (options.profile) | ||
user.profile = options.profile; | ||
|
||
// If this is the first user going into the database, make them an admin | ||
if (Meteor.users.find().count() === 0) | ||
user.admin = true; | ||
|
||
return user; | ||
}); |