derive Gab TV channel username/slug from URL in settings

master
rob 2 years ago
parent c33744d047
commit 5984b237ee

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

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

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

@ -31,7 +31,7 @@ class PostController extends SiteController {
const router = express.Router();
dtp.app.use('/post', router);
router.use(this.dtp.services.gabTV.channelMiddleware('mrjoeprich'));
router.use(this.dtp.services.gabTV.channelMiddleware());
router.use(async (req, res, next) => {
res.locals.currentView = 'home';
return next();

@ -16,13 +16,19 @@ class GabTVService extends SiteService {
super(dtp, module.exports);
}
channelMiddleware (channelSlug) {
channelMiddleware ( ) {
return async (req, res, next) => {
try {
if (!res.locals.site || !res.locals.site.gabtvUrl) {
return next();
}
this.log.debug('GabTV URL', { url: res.locals.site.gabtvUrl });
const urlParts = res.locals.site.gabtvUrl.split('/');
const channelSlug = urlParts[urlParts.length - 1];
res.locals.gabTvChannel = await this.getChannelEpisodes(channelSlug, { allowCache: true });
return next();
} catch (error) {
this.log.error('failed to populdate Gab TV channel', { channelSlug, error });
this.log.error('failed to populdate Gab TV channel', { error });
return next();
}
};

@ -12,17 +12,18 @@ mixin renderSidebarEpisode(episode)
mixin renderPageSidebar ( )
//- Gab TV 3 Most Recent Episodes
.uk-margin
+renderSectionTitle('Gab TV', {
label: 'Visit Channel',
title: gabTvChannel.title,
url: gabTvChannel.home_page_url,
})
if gabTvChannel
.uk-margin
+renderSectionTitle('Gab TV', {
label: 'Visit Channel',
title: gabTvChannel.title,
url: gabTvChannel.home_page_url,
})
ul.uk-list
each episode in gabTvChannel.items.slice(0, 3)
li
+renderSidebarEpisode(episode)
ul.uk-list
each episode in gabTvChannel.items.slice(0, 3)
li
+renderSidebarEpisode(episode)
//- Newsletter Signup
div(uk-sticky={ offset: 60, bottom: '#dtp-content-grid' }, style="z-index: initial;")
@ -31,7 +32,7 @@ mixin renderPageSidebar ( )
form(method="post", action="/newsletter", onsubmit="return dtp.app.submitForm(event, 'Subscribe to newsletter');").uk-form
.uk-card.uk-card-secondary.uk-card-small
.uk-card-body
p Join the #{site.name} FREE newsletter to get show updates in your inbox.
p Join the #{site.name} FREE newsletter to get news and updates in your inbox.
.uk-margin
label(for="email").uk-form-label.sr-only Email Address
input(id="email", name="email", type="email", placeholder="johnsmith@example.com").uk-input

Loading…
Cancel
Save