A web application allowing people to create an account, configure a profile, and share a list of URLs on that profile.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

51 lines
1.3 KiB

// site-controller.js
// Copyright (C) 2021 Digital Telepresence, LLC
// License: Apache-2.0
'use strict';
const path = require('path');
const { SiteCommon } = require(path.join(__dirname, 'site-common'));
const { SiteLog } = require(path.join(__dirname, 'site-log'));
class SiteController extends SiteCommon {
constructor (dtp, name) {
super(dtp);
this.name = name;
this.log = new SiteLog(dtp, `ctrl:${name}`);
}
async loadChild (filename) {
let child = await require(filename)(this.dtp);
return await child.start();
}
getPaginationParameters (req, maxPerPage) {
const pagination = {
p: parseInt(req.query.p || '1', 10),
cpp: parseInt(req.query.cpp || maxPerPage.toString(), 10),
};
if (pagination.p < 1) {
pagination.p = 1;
}
if (pagination.cpp > maxPerPage) {
pagination.cpp = maxPerPage;
}
pagination.skip = (pagination.p - 1) * pagination.cpp;
return pagination;
}
createDisplayList (name) {
const { displayEngine: displayEngineService } = this.dtp.services;
return displayEngineService.createDisplayList(name);
}
async createCsrfToken (req, name) {
const { csrfToken } = this.dtp.platform.services;
return csrfToken.create(req, { name });
}
}
module.exports.SiteController = SiteController;