You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Fipamo/brain/routes/front/fipamo.js

46 lines
1.6 KiB
JavaScript

var express = require('express');
var router = express.Router();
var Models = require('../../models');
var config = require('../../../config.json');
router.get('/:page_num?', function (req, res) {
var page_num = req.params.page_num;
var pageNum = page_num;
if (page_num == null)
pageNum = 1
Models.Bookmark.findAll({
order: [['id', 'DESC']]
}).then(function (bookmarks) {
//console.log("num: "+pageNum);
//real page count
var count = Math.floor(bookmarks.length / 10);
var pageItems = [];
var itemLimit = 10;
var rangeStart = (pageNum * itemLimit) - itemLimit;
//console.log("RANGE START "+rangeStart);
for (var i = 0; i < itemLimit; i++) {
try {
if (bookmarks[i + rangeStart].id != null) {
//console.log(bookmarks[i+rangeStart]._id )
pageItems.push(bookmarks[i + rangeStart]);
}
} catch (e) {
//console.log(e)
}
}
//console.log("items count: "+pageItems.length)
res.render(config.theme+'/fipamo', {
theme: config.theme,
title: 'The Twelfth House | Fipamo',
page_index: pageNum,
page_count: Math.round(bookmarks.length / 10),
items: pageItems,
mode: 'bookmarks'
});
}).then(function (value) {
//console.log(value);
}).catch(function (err) {
console.log(err);
})
});
router.get('/:id', function (req, res) {});
module.exports = router;