serve overboard(catalog) as json

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

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

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

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

Loading…
Cancel
Save