mirror of
https://github.com/vale981/Vulcan
synced 2025-03-05 17:41:43 -05:00
lots of minor changes
This commit is contained in:
parent
2c2a6bf7ef
commit
2cf101735a
11 changed files with 87 additions and 22 deletions
|
@ -9,5 +9,6 @@
|
|||
{{> selected_comment}}
|
||||
{{> signin}}
|
||||
{{> signup}}
|
||||
{{> submit}}
|
||||
<div class="overlay hidden"></div>
|
||||
</body>
|
||||
|
|
|
@ -20,6 +20,12 @@ Template.nav.events = {
|
|||
Session.set('previous_state', Session.get('state'));
|
||||
Session.set('state', 'signin');
|
||||
}
|
||||
|
||||
, 'click .user-nav #submit': function(event){
|
||||
event.preventDefault();
|
||||
Session.set('previous_state', Session.get('state'));
|
||||
Session.set('state', 'submit');
|
||||
}
|
||||
};
|
||||
|
||||
Template.nav.logged_in = function(){
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<li class="post-more mobile"><a class="more-link"><i class="icon-share"></i><span class="action">Text </span></a></li>
|
||||
</ul>
|
||||
<div class="post-content">
|
||||
<span class="post-rank">1</span>
|
||||
<span class="post-rank">{{rank}}</span>
|
||||
<div class="post-upvote">
|
||||
{{#if voted}}
|
||||
<a class="upvote-link voted"><i class="icon-check"></i><span>Upvote</span></a>
|
||||
|
@ -27,11 +27,11 @@
|
|||
</div>
|
||||
<div class="post-info">
|
||||
<h3 class="post-heading">
|
||||
<a href="/" class="post-title">{{headline}}</a>
|
||||
<span class="post-domain">news.ycombinator.com</span>
|
||||
<a href="{{url}}" class="post-title">{{headline}}</a>
|
||||
<span class="post-domain">{{domain}}</span>
|
||||
</h3>
|
||||
<p class="post-meta"><span class="points">{{votes}} <span class="unit">points </span></span>by <a class="post-author">{{submitter}}</a> <span class="post-time">{{ago}}</span><span class="comments">, <a href="/posts/503d8b390000007629000002">{{comments}} comments</a></span></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
|
|
@ -10,6 +10,10 @@ Template.post.events = {
|
|||
}
|
||||
};
|
||||
|
||||
Template.post.rank = function(){
|
||||
return 1;
|
||||
};
|
||||
|
||||
Template.post.ago = function(){
|
||||
var submitted = new Date(this.submitted);
|
||||
return submitted.toString();
|
||||
|
@ -21,3 +25,9 @@ Template.post.voted = function(){
|
|||
var myvote = MyVotes.findOne({post: this._id, user: user._id});
|
||||
return !!myvote;
|
||||
};
|
||||
|
||||
Template.post.domain = function(){
|
||||
var a = document.createElement('a');
|
||||
a.href = this.url;
|
||||
return a.hostname;
|
||||
};
|
||||
|
|
|
@ -5,15 +5,8 @@ Template.selected_comment.events = {
|
|||
var post = Session.get('selected_post');
|
||||
var parentComment = Session.get('selected_comment');
|
||||
var $comment = $('#comment');
|
||||
var comment = {
|
||||
post: post._id
|
||||
, parent: parentComment._id
|
||||
, body: $comment.val()
|
||||
, submitter: Meteor.user().username
|
||||
, submitted: new Date().getTime()
|
||||
};
|
||||
Meteor.call('comment', post, parentComment, $comment.val());
|
||||
|
||||
Comments.insert(comment);
|
||||
Session.set('selected_comment', null);
|
||||
Session.set('state', 'view_post');
|
||||
}
|
||||
|
|
|
@ -4,14 +4,7 @@ Template.selected_post.events = {
|
|||
|
||||
var post = Session.get('selected_post');
|
||||
var $comment = $('#comment');
|
||||
var comment = {
|
||||
post: post._id
|
||||
, body: $comment.val()
|
||||
, submitter: Meteor.user().username
|
||||
, submitted: new Date().getTime()
|
||||
};
|
||||
|
||||
Comments.insert(comment);
|
||||
Meteor.call('comment', post, null, $comment.val());
|
||||
$comment.val('');
|
||||
}
|
||||
};
|
||||
|
|
15
client/templates/submit.html
Normal file
15
client/templates/submit.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
<template name="submit">
|
||||
{{#if show}}
|
||||
<div class="grid submit">
|
||||
<div>
|
||||
<label id="title">Title: <input type="text" value="" /></label>
|
||||
</div>
|
||||
<div>
|
||||
<label id="url">Url: <input type="text" value="" /></label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Submit" />
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</template>
|
27
client/templates/submit.js
Normal file
27
client/templates/submit.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
Template.submit.events = {
|
||||
'click input[type=submit]': function(){
|
||||
if(!Meteor.user()) throw 'You must be logged in.';
|
||||
|
||||
var title= $('#title input').val();
|
||||
var url = $('#url input').val();
|
||||
|
||||
var postId = Posts.insert({
|
||||
headline: title
|
||||
, url: url
|
||||
, submitter: Meteor.user().username
|
||||
, submitted: new Date().getTime()
|
||||
, votes: 0
|
||||
, comments: 0
|
||||
});
|
||||
var post = Posts.findOne(postId);
|
||||
|
||||
Meteor.call('voteForPost', post);
|
||||
|
||||
Session.set('selected_post', post);
|
||||
Session.set('state', 'view_post');
|
||||
}
|
||||
};
|
||||
|
||||
Template.submit.show = function(){
|
||||
return Session.equals('state', 'submit');
|
||||
};
|
2
server/bootstrap.js
vendored
2
server/bootstrap.js
vendored
|
@ -6,6 +6,7 @@ function prepopulateDatabase(){
|
|||
, submitter: 'Sacha'
|
||||
, submitted: new Date(2012, 7, 22).getTime()
|
||||
, votes: 0
|
||||
, comments: 0
|
||||
}
|
||||
, {
|
||||
headline: 'Another post to fill the page up a little'
|
||||
|
@ -13,6 +14,7 @@ function prepopulateDatabase(){
|
|||
, submitter: 'Sacha'
|
||||
, submitted: new Date(2012, 7, 22).getTime()
|
||||
, votes: 0
|
||||
, comments: 0
|
||||
}
|
||||
].forEach(function(post){
|
||||
Posts.insert(post);
|
||||
|
|
18
server/comment.js
Normal file
18
server/comment.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
Meteor.methods({
|
||||
comment: function(post, parentComment, text){
|
||||
var user = Meteor.users.findOne(this.userId());
|
||||
|
||||
var comment = {
|
||||
post: post._id
|
||||
, body: text
|
||||
, submitter: user.username
|
||||
, submitted: new Date().getTime()
|
||||
};
|
||||
if(parentComment)
|
||||
comment.parent = parentComment._id;
|
||||
|
||||
Comments.insert(comment);
|
||||
Posts.update(post._id, {$inc: {comments: 1}});
|
||||
return true;
|
||||
}
|
||||
});
|
|
@ -8,7 +8,7 @@ Meteor.publish('posts', function() {
|
|||
|
||||
Meteor.startup(function(){
|
||||
Posts.allow({
|
||||
insert: function(){ return true; }
|
||||
insert: function(){ return true; } //TODO: change to false
|
||||
, update: function(){ return false; }
|
||||
, remove: function(){ return false; }
|
||||
});
|
||||
|
@ -24,7 +24,7 @@ Meteor.publish('comments', function() {
|
|||
|
||||
Meteor.startup(function(){
|
||||
Comments.allow({
|
||||
insert: function(){ return true; }
|
||||
insert: function(){ return false; }
|
||||
, update: function(){ return false; }
|
||||
, remove: function(){ return false; }
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue