Browse Source

sidebar service; new logged-out home design

pull/1/head
Rob Colbert 3 years ago
parent
commit
7b183e7350
  1. 8
      app/controllers/home.js
  2. 35
      app/services/sidebar.js
  3. 25
      app/views/index.pug
  4. BIN
      client/img/altmedia.png
  5. BIN
      client/img/default-poster.jpg
  6. BIN
      client/img/header-sample.png
  7. BIN
      client/img/logo.png
  8. BIN
      client/img/lra-logo.png
  9. BIN
      client/img/social-cards/altmedia.tv.png
  10. BIN
      client/img/social-cards/shing.tv.png

8
app/controllers/home.js

@ -18,7 +18,7 @@ class HomeController extends SiteController {
async start ( ) {
const { dtp } = this;
const { limiter: limiterService } = dtp.services;
const { limiter: limiterService, sidebar: sidebarService } = dtp.services;
const router = express.Router();
dtp.app.use('/', router);
@ -37,6 +37,7 @@ class HomeController extends SiteController {
router.get('/',
limiterService.create(limiterService.config.home.getHome),
sidebarService.middleware(),
this.getHome.bind(this),
);
}
@ -70,14 +71,11 @@ class HomeController extends SiteController {
}
async getHome (req, res, next) {
const { link: linkService, user: userService } = this.dtp.services;
const { link: linkService } = this.dtp.services;
try {
res.locals.pagination = this.getPaginationParameters(req, 20);
if (req.user) {
res.locals.links = await linkService.getForUser(req.user, res.locals.pagination);
res.locals.recentLinks = await linkService.getRecent(3);
res.locals.popularLinks = await linkService.getPopular(3);
res.locals.recentUsers = await userService.getRecent(3);
res.render('index-logged-in');
} else {
res.render('index');

35
app/services/sidebar.js

@ -0,0 +1,35 @@
// sidebar.js
// Copyright (C) 2021 Digital Telepresence, LLC
// License: Apache-2.0
'use strict';
const { SiteService } = require('../../lib/site-lib');
class SidebarService extends SiteService {
constructor (dtp) {
super(dtp, module.exports);
}
middleware ( ) {
return async (req, res, next) => {
const { link: linkService, user: userService } = this.dtp.services;
try {
res.locals.popularLinks = await linkService.getPopular(3);
res.locals.recentLinks = await linkService.getRecent(3);
res.locals.recentUsers = await userService.getRecent(3);
return next();
} catch (error) {
this.log.error('failed to populate sidebar', { error });
return next(error);
}
};
}
}
module.exports = {
slug: 'sidebar',
name: 'sidebar',
create: (dtp) => { return new SidebarService(dtp); },
};

25
app/views/index.pug

@ -1,18 +1,15 @@
extends layouts/main
extends layouts/main-sidebar
block content
section.uk-section.uk-section-default
.uk-container
.uk-margin.uk-text-center
h1.uk-margin-remove= site.name
.uk-text-lead= site.description
.sr-only
h1.uk-margin-remove= site.name
.uk-text-lead= site.description
p #{site.name} provides a landing page people can use to display a collection of links. These can be used for people to help others find them on social media, ways to donate and support them, and more.
p We do not allow the promotion of pornography or linking to it. This is otherwise a free-speech online service and will not ban people for their social or political views.
.uk-margin
img(src=`/img/social-cards/${site.domainKey}.png`).responsive.uk-border-rounded
div(uk-grid)
.uk-width-1-2
a(href="/welcome/signup").uk-button.dtp-button-primary.uk-display-block Sign Up
.uk-width-1-2
a(href="/welcome/login").uk-button.dtp-button-default.uk-display-block Login
.uk-margin
div #{site.name} provides a landing page you configure with your links on it. Use it as a springboard into all your social media profiles, streaming channels, websites, podcasts, stores, blogs, and whatever else you can link to using a valid URL.
.uk-margin
a(href="/welcome").uk-button.dtp-button-primary.uk-display-block Get Started

BIN
client/img/altmedia.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 664 KiB

BIN
client/img/default-poster.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 KiB

BIN
client/img/header-sample.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

BIN
client/img/logo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 248 KiB

BIN
client/img/lra-logo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

BIN
client/img/social-cards/altmedia.tv.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

BIN
client/img/social-cards/shing.tv.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 860 KiB

Loading…
Cancel
Save