Added the Unified Feed to Newsroom

master
rob 1 year ago
parent 748095e2cf
commit d162f83b73

@ -28,6 +28,8 @@ class NewsroomController extends SiteController {
router.param('feedId', this.populateFeedId.bind(this));
router.get('/feed', this.getUnifiedFeed.bind(this));
router.get('/:feedId',
limiterService.createMiddleware(limiterService.config.newsroom.getFeedView),
this.getFeedView.bind(this),
@ -53,6 +55,21 @@ class NewsroomController extends SiteController {
}
}
async getUnifiedFeed (req, res) {
const { feed: feedService } = this.dtp.services;
try {
res.locals.pagination = this.getPaginationParameters(req, 20);
res.locals.newsroom = await feedService.getNewsfeed(res.locals.pagination);
res.render('newsroom/unified-feed');
} catch (error) {
this.log.error('failed to present newsfeed JSON', { error });
res.status(error.statusCode || 500).json({
success: false,
message: error.message,
});
}
}
async getFeedView (req, res, next) {
const { feed: feedService } = this.dtp.services;
try {

@ -6,7 +6,13 @@ block content
section.uk-section.uk-section-default.uk-section-small
.uk-container
h1 #{site.name} Newsroom
.uk-margin
div(uk-grid).uk-flex-middle
.uk-width-expand
h1.uk-margin-remove #{site.name} Newsroom
.uk-width-auto
a(href="/newsroom/feed").uk-button.dtp-button-primary.uk-button-small.uk-border-rounded View All
if Array.isArray(newsroom.feeds) && (newsroom.feeds.length > 0)
div(uk-grid).uk-grid-match
each feed in newsroom.feeds

@ -0,0 +1,27 @@
extends ../layouts/main
block content
include ../components/pagination-bar
section.uk-section.uk-section-default
.uk-container
article.uk-article
.uk-margin
h1.uk-article-title.uk-margin-remove #{site.name} News Feed
.uk-text-bold #{formatCount(newsroom.totalFeedEntryCount)} articles indexed by #{site.name} in one chronological feed.
.uk-margin
if Array.isArray(newsroom.entries) && (newsroom.entries.length > 0)
ul.uk-list.uk-list-divider
each entry in newsroom.entries
li
.uk-text-large.uk-text-bold.uk-margin-small
a(href= entry.link, target="_blank")= entry.title
.uk-margin-small= entry.description
.uk-text-small source: #[a(href= entry.feed.link, target="_blank")= entry.feed.title]
else
div There are no news feed entries.
.uk-margin
+renderPaginationBar(`/newsroom/feed`, newsroom.totalFeedEntryCount)
Loading…
Cancel
Save