2018-10-31 17:00:31 +01:00
|
|
|
var express = require('express');
|
|
|
|
var router = express.Router();
|
|
|
|
var Models = require('../../models');
|
2019-01-12 20:07:08 +01:00
|
|
|
var config = require('../../../config/site-settings.json');
|
2018-10-31 17:00:31 +01:00
|
|
|
module.exports = function (session) {
|
|
|
|
//--------------------------
|
|
|
|
// Index
|
|
|
|
//--------------------------
|
|
|
|
router.get('/:page?', function (req, res) {
|
|
|
|
|
|
|
|
if (req.params.page == null || req.params.page == "") {
|
|
|
|
Models.FolioProject.findAll({
|
|
|
|
limit: 5,
|
|
|
|
order: [
|
|
|
|
['id', 'DESC']
|
|
|
|
]
|
|
|
|
}).then(entries => {
|
|
|
|
Models.Post.findAll({
|
|
|
|
limit: 5,
|
|
|
|
order: [
|
|
|
|
['id', 'DESC']
|
|
|
|
]
|
|
|
|
}).then(posts => {
|
|
|
|
Models.Bookmark.findAll({
|
|
|
|
limit: 5,
|
|
|
|
order: [
|
|
|
|
['id', 'DESC']
|
|
|
|
]
|
|
|
|
}).then(saved => {
|
|
|
|
res.render(config.theme + '/index', {
|
|
|
|
theme: config.theme,
|
|
|
|
title: 'The Twelfth House | Home of creative technologist, beat maker and over-thinker, Ro',
|
|
|
|
user_status: "What up, random person",
|
|
|
|
mode: 'index',
|
|
|
|
folio: entries,
|
|
|
|
posts: posts,
|
|
|
|
bookmarks: saved
|
|
|
|
});
|
|
|
|
|
|
|
|
}).catch(err => {
|
|
|
|
console.log(err);
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}).then(function (value) {
|
|
|
|
//console.log(value);
|
|
|
|
}).catch(function (err) {
|
|
|
|
console.log(err);
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
switch (req.params.page) {
|
|
|
|
case "dashboard":
|
|
|
|
console.log('here')
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
console.log(req.params.page)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
return router;
|
|
|
|
}
|