refactor channel middleware to top-level integration

master
rob 2 years ago
parent b024961695
commit 24eb90a444

@ -25,7 +25,6 @@ class ContentReportController extends SiteController {
const router = express.Router();
dtp.app.use('/content-report', router);
router.use(this.dtp.services.gabTV.channelMiddleware());
router.use(async (req, res, next) => {
res.locals.currentView = 'content-report';
return next();

@ -23,9 +23,6 @@ class HomeController extends SiteController {
const router = express.Router();
dtp.app.use('/', router);
router.use(this.dtp.services.gabTV.channelMiddleware());
router.use(this.dtp.services.venue.channelMiddleware());
router.use(async (req, res, next) => {
res.locals.currentView = 'home';
return next();

@ -21,9 +21,6 @@ class PageController extends SiteController {
const router = express.Router();
dtp.app.use('/page', router);
router.use(this.dtp.services.gabTV.channelMiddleware());
router.use(this.dtp.services.venue.channelMiddleware());
router.use(async (req, res, next) => {
res.locals.currentView = 'page';
return next();

@ -36,9 +36,6 @@ class PostController extends SiteController {
return next();
}
router.use(this.dtp.services.gabTV.channelMiddleware());
router.use(this.dtp.services.venue.channelMiddleware());
router.use(async (req, res, next) => {
res.locals.currentView = 'home';
return next();

@ -18,8 +18,6 @@ class VenueController extends SiteController {
const router = express.Router();
router.use(this.dtp.services.venue.channelMiddleware());
this.dtp.app.use('/venue', async (req, res, next) => {
res.locals.currentView = 'venue';
return next();

@ -1,4 +1,5 @@
mixin renderVenueChannelCard (channel)
mixin renderVenueChannelCard (channel, options)
- options = Object.assign({ withDescription: false }, options);
.uk-card.uk-card-default.uk-card-small.uk-card-hover.uk-margin
if channel.currentStatus && channel.currentStatus.liveThumbnail
@ -12,9 +13,13 @@ mixin renderVenueChannelCard (channel)
if channel.currentStatus && channel.currentStatus.liveEpisode && channel.currentStatus.liveEpisode.title
.uk-card-body
.uk-text-bold.uk-text-truncate
.uk-text-bold.uk-text-truncate(style="font-size: 1.2em; line-height: 1;")
a(href="/venue", uk-tooltip= `Watch "${channel.currentStatus.liveEpisode.title}" now!`)= channel.currentStatus.liveEpisode.title
.uk-text-small
if options.withDescription
.uk-margin(style="font-size: 1em; line-height: 1.2; max-height: 4.8em; overflow: auto;")!= marked.parse(channel.currentStatus.liveEpisode.description)
.uk-text-small.uk-article-meta
div(uk-grid).uk-grid-small.uk-flex-between
.uk-width-auto
div Started: #{moment(channel.currentStatus.liveEpisode.created).fromNow()}

@ -1,10 +1,11 @@
include ./channel-card
include ./channel-list-item
mixin renderVenueChannelGrid (channels)
mixin renderVenueChannelGrid (channels, options)
-
var onlineChannels = channels.filter((channel) => channel.currentStatus && (channel.currentStatus.status === 'live'))
var offlineChannels = channels.filter((channel) => !channel.currentStatus || (channel.currentStatus.status !== 'live'))
options = Object.assign({ withDescription: false }, options);
div(uk-grid)
div(class="uk-width-1-1 uk-width-2-3@s")
@ -14,7 +15,7 @@ mixin renderVenueChannelGrid (channels)
div(uk-grid).uk-grid-small
each channel of onlineChannels
div(class="uk-width-1-1 uk-width-1-2@s uk-width-1-3@l")
+renderVenueChannelCard(channel)
+renderVenueChannelCard(channel, options)
else
div There are no live channels. Please check back later!
@ -25,6 +26,6 @@ mixin renderVenueChannelGrid (channels)
ul.uk-list.uk-list-divider
each channel of offlineChannels
li
+renderVenueChannelListItem(channel)
+renderVenueChannelListItem(channel, options)
else
div There are no offline channels.

@ -8,4 +8,4 @@ block content
.uk-container.uk-container-expand
.uk-margin-large
+renderVenueChannelGrid(channels)
+renderVenueChannelGrid(channels, { withDescription: true })

@ -24,12 +24,17 @@ module.config = {
registerMiddleware: async (dtp, app) => {
module.log.info('registering Page service middleware');
const { page: pageService } = module.services;
const { siteLink: siteLinkService } = module.services;
const {
gabTV: gabTvService,
page: pageService,
siteLink: siteLinkService,
venue: venueService,
} = module.services;
app.use(
pageService.menuMiddleware.bind(pageService),
siteLinkService.middleware(),
venueService.channelMiddleware(),
gabTvService.channelMiddleware()
);
},
};

Loading…
Cancel
Save