serve overboard(catalog) as json

jschan
Thomas Lynch 3 years ago
parent 1206b5ae4f
commit ed75519a7b
  1. 4
      controllers/pages.js
  2. 23
      models/pages/overboard.js
  3. 26
      models/pages/overboardcatalog.js

@ -38,8 +38,8 @@ router.get('/news.html', news);
router.get('/boards.(html|json)', boardlist);
//overboard
router.get('/overboard.html', overboard); //overboard
router.get('/catalog.html', overboardCatalog); //overboard catalog view
router.get('/overboard.(html|json)', overboard); //overboard
router.get('/catalog.(html|json)', overboardCatalog); //overboard catalog view
//board pages
router.get('/:board/:page(1[0-9]{1,}|[2-9][0-9]{0,}|index).(html|json)', Boards.exists, board); //index

@ -53,13 +53,20 @@ module.exports = async (req, res, next) => {
res
.set('Cache-Control', 'public, max-age=60')
.render('overboard', {
threads,
includeDefault,
addBoards,
removeBoards,
selectedBoards,
cacheQueryString,
});
if (req.path === '/overboard.html') {
res.json({
threads,
});
} else {
res.render('overboard', {
threads,
includeDefault,
addBoards,
removeBoards,
selectedBoards,
cacheQueryString,
});
}
}

@ -6,7 +6,7 @@ const { Posts, Boards } = require(__dirname+'/../../db/')
module.exports = async (req, res, next) => {
const { overboardCatalogLimit } = config.get;
const { overboardCatalogLimit, allowCustomOverboard } = config.get;
let selectedBoards = [];
const addList = (req.query.add ? (typeof req.query.add === 'string' ? req.query.add.split(',') : req.query.add) : [])
@ -50,13 +50,21 @@ module.exports = async (req, res, next) => {
res
.set('Cache-Control', 'public, max-age=60')
.render('overboardcatalog', {
threads,
includeDefault,
addBoards,
removeBoards,
selectedBoards,
cacheQueryString,
});
if (req.path === '/catalog.html') {
res.json({
threads,
});
} else {
res.render('overboardcatalog', {
threads,
includeDefault,
addBoards,
removeBoards,
selectedBoards,
cacheQueryString,
});
}
}

Loading…
Cancel
Save