Skip to content

Commit aeeebed

Browse files
Merge branch 'master' into develop
2 parents a195b76 + 31b907b commit aeeebed

3 files changed

Lines changed: 51 additions & 117 deletions

File tree

‎client/javascripts/components/modules/loadStories.js‎

Lines changed: 23 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -37,50 +37,32 @@ JS.Modules.LoadStories = (function() {
3737

3838
var _appendStories = function(data) {
3939
var stories = data.flow,
40-
lastDay = _settings.$button.data('last-day'),
4140
markup = '';
4241

43-
for (group in stories) {
44-
45-
if ( lastDay !== group ) {
46-
markup +=
47-
'<li class="list-item list-item--header bdrbl pbs">' +
48-
'<span class="mrs por pot2n">' +
49-
'<span class="srt">calendar</span>' +
50-
'<svg class="icon" width="16" height="16">' +
51-
'<use xlink:href="#icon-calendar"></use>' +
52-
'</svg>' +
53-
'</span>' +
54-
'<span>' + group + '</span>' +
55-
'</li>';
56-
}
57-
58-
stories[group].forEach(function(story) {
59-
markup +=
60-
'<li class="list-item">' +
61-
'<article class="bucket">' +
62-
'<div class="bucket-media">' +
63-
'<img class="thumb" src="' + story.avatar_url + '" width="50"/>' +
64-
'</div>' +
65-
'<div class="bucket-content">' +
66-
'<h2 class="h h--3">' +
67-
'<a class="externalLink tct twb" href="' + story.url + '"> + story.title +
68-
'<svg width="16" height="16" class="icon externalLink-icon">' +
69-
'<use xlink:href="#icon-external"/>' +
70-
'</svg>' +
71-
'</a>' +
72-
'</h2>' +
73-
'<p class="tcs tfh">' +
74-
'via ' + '<span class="twsb">' + story.name + '</span>' +
75-
' | ' + '<a class="' + commentClass(story.comment_count) + '" href="/news/' + story.slug + '#comments">View Discussion ' + commentNumber(story.comment_count) + '</a>' +
76-
'</p>' +
77-
'<p class="tcs tfh">' + story.body + '</p>' +
78-
'</div>' +
79-
'</article>' +
80-
'</li>';
81-
});
42+
stories.forEach(function(story) {
43+
markup +=
44+
'<li class="list-item">' +
45+
'<article class="bucket">' +
46+
'<div class="bucket-media">' +
47+
'<img class="thumb" src="' + story.avatar_url + '" width="50"/>' +
48+
'</div>' +
49+
'<div class="bucket-content">' +
50+
'<h2 class="h h--4">' +
51+
'<a class="externalLink tct twb" href="' + story.url + '"> + story.title +
52+
'<svg width="16" height="16" class="icon externalLink-icon">' +
53+
'<use xlink:href="#icon-external"/>' +
54+
'</svg>' +
55+
'</a>' +
56+
'</h2>' +
57+
'<p class="mbf tcs tfh tss">' +
58+
'via ' + '<span class="twsb">' + story.name + '</span>' +
59+
' | ' + '<a class="' + commentClass(story.comment_count) + '" href="/news/' + story.slug + '#comments">View Discussion ' + commentNumber(story.comment_count) + '</a>' +
60+
'</p>' +
61+
'</div>' +
62+
'</article>' +
63+
'</li>';
64+
});
8265

83-
}
8466

8567
_settings.$list.append(markup);
8668
};

‎server/routes/news.js‎

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ var Akismetor = require(path.join(__dirname, '..', 'services', 'akismetor'));
1010
var moment = require('moment');
1111
var pluralize = require('pluralize');
1212
var expressValidator = require('express-validator');
13-
var _ = require('lodash');
1413
var config = require(path.join(__dirname, '..', '..', 'config'));
1514

16-
1715
var csrfProtection = csrf();
1816
var parseForm = bodyParser.urlencoded({ extended: false });
1917
var parseJson = bodyParser.json();
@@ -136,63 +134,23 @@ router.
136134
if (offset) {
137135
Articles.paginated(offset, function(all) {
138136
Articles.totalPublished(function(total) {
139-
var lastDay;
140-
// TODO: Move date functionality into a serivce. It'll be used practically
141-
// everywhere. Oh, and refactor this blasphemy.
142-
//
143-
// TODO: We shouldn't be needing to use moment in order to make the time
144-
// UTC. There's an issue with pg and it's parsing the dates from the db
145-
// incorrectly. This is a temporary fix until I can snipe the bug.
146-
all.map(function(item){
147-
item.date = moment.utc(item.published_at).format('LL');
148-
if (item.date == moment.utc(Date.now()).format('LL')){
149-
item.date = 'Today'
150-
} else if (item.date == moment.utc(Date.now()).subtract(1, 'days').format('LL')){
151-
item.date = 'Yesterday'
152-
}else{
153-
item.date = moment(item.date).format('dddd, LL');
154-
}
155-
});
156-
// There are strings and integers here - not so good.
157-
if (all.length) {
158-
lastDay = all[all.length - 1].date;
159-
}
160137
more = (all.length == (total[0].count - offset )) ? false : true;
161-
all = _.groupBy(all, 'date');
162-
res.json({flow: all, more: more, lastDay: lastDay});
138+
res.json({flow: all, more: more});
163139
});
164140
});
165141
}else{
166142
Articles.recent(function(all) {
167143
Articles.totalPublished(function(total) {
168-
var flow = [], news = [], lastDay;
169-
// TODO: Move date functionality into a serivce. It'll be used practically
170-
// everywhere. Oh, and refactor this blasphemy.
171-
//
172-
// TODO: We shouldn't be needing to use moment in order to make the time
173-
// UTC. There's an issue with pg and it's parsing the dates from the db
174-
// incorrectly. This is a temporary fix until I can snipe the bug.
144+
var flow = [], news = [];
175145
all.map(function(item){
176-
item.date = moment.utc(item.published_at).format('LL');
177-
if (item.date == moment.utc(Date.now()).format('LL')){
178-
item.date = 'Today'
179-
} else if (item.date == moment.utc(Date.now()).subtract(1, 'days').format('LL')){
180-
item.date = 'Yesterday'
181-
}else{
182-
item.date = moment(item.date).format('dddd, LL');
183-
}
184146
if (item.news){
185147
news.push(item);
186148
}else{
187149
flow.push(item);
188150
}
189151
});
190-
if(flow.length){
191-
lastDay = flow[flow.length - 1].date;
192-
}
193152
more = (flow.length === parseInt(total[0].count)) ? false : true;
194-
flow = _.groupBy(flow, 'date');
195-
res.render('news/index', {flow_collection: flow, news_collection: news, more: more, lastDay: lastDay });
153+
res.render('news/index', {flow_collection: flow, news_collection: news, more: more});
196154
});
197155
});
198156
}

‎server/views/news/index.jade‎

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,40 +41,34 @@ block content
4141
a.btn.btn--a.db.dib--s.fr--l(href='/news/new') New Post
4242

4343
.mbxl.js-loadFeed
44-
ul.list.list--l.list--divided.list--divided--l.js-loadFeed-list
45-
46-
- for group, title in flow_collection
47-
48-
- dateText = title
49-
include /views/news/_data_separator
50-
51-
- for story in group
52-
53-
li.list-item
54-
article.bucket
55-
.bucket-media
56-
img.thumb(src=story.avatar_url width='50')
57-
.bucket-content
58-
h2.h.h--3
59-
a.externalLink.tct.twb(href=story.url target='_blank')
60-
= story.title
61-
- iconPartial = { name: 'external', className: 'externalLink-icon', size: 16 }
62-
include /views/partials/_icon
63-
p.tcs.tfh
64-
| via
65-
span.twsb= story.name
66-
| |
67-
a(href='/news/' + story.slug + '#comments')
68-
| View Discussion
69-
if story.comment_count > 0
70-
| (
71-
= story.comment_count
72-
| )
73-
p.mbf= story.body
44+
ul.list.list--divided.js-loadFeed-list
45+
46+
- for story in flow_collection
47+
48+
li.list-item
49+
article.bucket
50+
.bucket-media
51+
img.thumb(src=story.avatar_url width='50')
52+
.bucket-content
53+
h2.h.h--4
54+
a.externalLink.tct.twb(href=story.url target='_blank')
55+
= story.title
56+
- iconPartial = { name: 'external', className: 'externalLink-icon', size: 16 }
57+
include /views/partials/_icon
58+
p.mbf.tcs.tfh.tss
59+
| via
60+
span.twsb= story.name
61+
| |
62+
a(href='/news/' + story.slug + '#comments')
63+
| View Discussion
64+
if story.comment_count > 0
65+
| (
66+
= story.comment_count
67+
| )
7468

7569
if more
7670
.well.well--l.mbl.mbxl--m.bdrtl.ptl.tac
77-
button.btn.js-loadFeed-btn(data-last-day=lastDay) Load More
71+
button.btn.js-loadFeed-btn Load More
7872

7973
.g-b.g-b--m--2of5.sector.sector--b
8074
.well.well--l.well--m--xl

0 commit comments

Comments
 (0)