Skip to content

Commit 6713e6e

Browse files
committed
Refactor application file structure
1 parent fba120a commit 6713e6e

File tree

11 files changed

+199
-201
lines changed

11 files changed

+199
-201
lines changed

History.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v0.10.2 / 29-11-2013
2+
3+
* Refactor application file structure
4+
15
## v0.10.1 / 28-11-2013
26

37
* Scroll window to top of article when article opened

client/client.js

Lines changed: 1 addition & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function done(err, result){
77
console.log(err);
88
} else if(result) {
99
console.log(result);
10-
}
10+
};
1111
};
1212

1313
Deps.autorun(function(){
@@ -20,98 +20,4 @@ Deps.autorun(function(){
2020
});
2121

2222

23-
/// feeds ///
2423

25-
Template.feeds.feedList = function(){
26-
return Feeds.find();
27-
};
28-
29-
Template.feeds.current = function(){
30-
return Session.equals('current_feed', this._id);
31-
};
32-
33-
Template.feeds.events({
34-
'click #addFeed': function(){
35-
Meteor.call('addFeed', $('#feedUrl').val(), done);
36-
$("#feedUrl").val("");
37-
},
38-
'click span.removeFeed': function(){
39-
Meteor.call('removeFeed', this, done);
40-
Session.set('current_feed', null);
41-
},
42-
'click .feed': function(){
43-
Session.set('current_feed', this._id);
44-
Meteor.call('refreshFeed', this, done);
45-
},
46-
'click span.markRead': function(){
47-
Meteor.call('markAllRead', this, done);
48-
}
49-
});
50-
51-
/// article ///
52-
function articleClick(article){
53-
var articleOpen = Session.get('article_open');
54-
55-
Meteor.call('markRead', articleOpen, done);
56-
57-
if (articleOpen === article._id){
58-
Session.set('article_open', null);
59-
} else {
60-
Session.set('previous_article', articleOpen);
61-
62-
Session.set('article_open', article._id);
63-
};
64-
};
65-
66-
Template.article.open = function(){
67-
return Session.equals('article_open', this._id) ? "open" : "";
68-
};
69-
70-
Template.article.events({
71-
'click .articletitle': function(){
72-
articleClick(this, done);
73-
},
74-
'click .markedRead': function(){
75-
Meteor.call('markUnread', this._id, done);
76-
}
77-
});
78-
79-
Template.article.helpers({
80-
timestamp: function(){
81-
var date = this.date;
82-
return moment(date).format("MMM Do YYYY, HH:mm");
83-
}
84-
});
85-
86-
/// overview ///
87-
88-
Template.overview.articles = function(){
89-
return Articles.find({feedId: Session.get('current_feed')},
90-
{ sort: [['read', 'asc'],["date", "desc"]] });
91-
};
92-
93-
Template.overview.events({
94-
'click input.removeArticle': function(){
95-
Articles.remove(this._id);
96-
},
97-
'click input.removeAll': function(){
98-
Meteor.call('removeAll', done);
99-
},
100-
// 'keydown input' : function(event){
101-
// console.log('key', event);
102-
// if(event.which == 13){
103-
// Session.set('previous_article', Session.get('article_open'));
104-
// Meteor.call('markRead', Session.get('article_open'), done);
105-
// Session.set('article_open', $( "#"+Session.get('article_open').next().id() ));
106-
// }
107-
108-
// $('body').on('keydown',function(){
109-
// console.log('key pressed');
110-
// });
111-
// }
112-
});
113-
114-
Template.overview.rendered = function(){
115-
var divId = '#' + Session.get('article_open');
116-
$('html, body').scrollTop($(divId).offset().top - 50);
117-
};
File renamed without changes.

client/meteor-rss.html

Lines changed: 0 additions & 106 deletions
This file was deleted.

client/templates/article.html

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<template name="article">
2+
<div class="article {{open}}" id="{{_id}}">
3+
<div class="row {{#if read}}read{{/if}} clearfix">
4+
<h5 class="articletitle">
5+
{{#if open}}
6+
<a href="{{link}}">{{title}}</a>
7+
{{else}}
8+
{{title}}
9+
{{/if}}
10+
</h5>
11+
12+
<small>{{author}} | {{timestamp}}</small>
13+
14+
{{#if read}}
15+
<span class="label alert right markedRead">Read</span>
16+
{{/if}}
17+
</div>
18+
19+
{{#if open}}
20+
<div class="article_content">
21+
{{{content}}}
22+
</div>
23+
<footer>
24+
<a href="{{link}}" />
25+
</footer>
26+
<hr />
27+
{{/if}}
28+
29+
</div>
30+
</template>

client/templates/articlelist.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<template name="articleList">
2+
<div class="large-8 columns">
3+
{{#each articles}}
4+
{{> article }}
5+
{{/each}}
6+
</div>
7+
</template>

client/templates/feedList.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<template name="feedList">
2+
<div class="large-4 columns">
3+
<ul class="side-nav">
4+
<li class="heading">Feeds</li>
5+
6+
<div class="row collapse">
7+
<div class="small-9 columns">
8+
<input type="url" placeholder="Feed Url" id="feedUrl" />
9+
</div>
10+
<div class="small-3 columns">
11+
<a href="#" class="button postfix" id="addFeed"><small>Add Feed</small></a>
12+
</div>
13+
</div>
14+
<li class="divider"></li>
15+
{{#each feedList}}
16+
<li class="{{#if current}}active{{/if}} feed">
17+
<a href="#">{{title}} <span class="label">{{unread}} </span>
18+
{{#if unread}}
19+
<span class="success label markRead">Mark Read</span>
20+
{{/if}}
21+
<span class="alert label removeFeed">Remove</span>
22+
</a>
23+
</li>
24+
<li class="divider"></li>
25+
{{/each}}
26+
</ul>
27+
</div>
28+
</template>

client/templates/meteor-rss.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
<head>
3+
<title>Meteor-RSS</title>
4+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
5+
</head>
6+
7+
<body>
8+
<nav class="top-bar">
9+
<ul class="title-area">
10+
<li class="name">
11+
<h1><a href="#">Meteor-RSS</a></h1>
12+
</li>
13+
</ul>
14+
15+
<section class="top-bar-section">
16+
<ul class="left">
17+
<li>{{loginButtons}}</li>
18+
</ul>
19+
</section>
20+
</nav>
21+
22+
23+
<div class="row">
24+
{{#if currentUser}}
25+
{{> feeds}}
26+
{{> overview}}
27+
{{else}}
28+
<h1 class="text-center">Welcome to Meteor-RSS</h1>
29+
<p class="text-center">Please Sign In at top right</p>
30+
<br />
31+
<p class="text-center">Copyright (c) 2013 <a href="http://davidbeath.com">David Beath</a></p>
32+
<p class="text-center">Source: <a href="http://github.com/DBeath/meteor-rss">Meteor-RSS</a></p>
33+
{{/if}}
34+
</div>
35+
36+
</body>

client/views/article.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/// article ///
2+
function articleClick(article){
3+
var articleOpen = Session.get('article_open');
4+
5+
Meteor.call('markRead', articleOpen, done);
6+
7+
if (articleOpen === article._id){
8+
Session.set('article_open', null);
9+
} else {
10+
Session.set('previous_article', articleOpen);
11+
12+
Session.set('article_open', article._id);
13+
};
14+
};
15+
16+
Template.article.open = function(){
17+
return Session.equals('article_open', this._id) ? "open" : "";
18+
};
19+
20+
Template.article.events({
21+
'click .articletitle': function(){
22+
articleClick(this, done);
23+
},
24+
'click .markedRead': function(){
25+
Meteor.call('markUnread', this._id, done);
26+
}
27+
});
28+
29+
Template.article.helpers({
30+
timestamp: function(){
31+
var date = this.date;
32+
return moment(date).format("MMM Do YYYY, HH:mm");
33+
}
34+
});

client/views/articlelist.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/// articleList ///
2+
3+
Template.articleList.articles = function(){
4+
return Articles.find({feedId: Session.get('current_feed')},
5+
{ sort: [['read', 'asc'],["date", "desc"]] });
6+
};
7+
8+
Template.articleList.events({
9+
'click input.removeArticle': function(){
10+
Articles.remove(this._id);
11+
},
12+
'click input.removeAll': function(){
13+
Meteor.call('removeAll', done);
14+
},
15+
// 'keydown input' : function(event){
16+
// console.log('key', event);
17+
// if(event.which == 13){
18+
// Session.set('previous_article', Session.get('article_open'));
19+
// Meteor.call('markRead', Session.get('article_open'), done);
20+
// Session.set('article_open', $( "#"+Session.get('article_open').next().id() ));
21+
// }
22+
23+
// $('body').on('keydown',function(){
24+
// console.log('key pressed');
25+
// });
26+
// }
27+
});
28+
29+
Template.articleList.rendered = function(){
30+
var divId = '#' + Session.get('article_open');
31+
$('html, body').scrollTop($(divId).offset().top - 50);
32+
};

0 commit comments

Comments
 (0)