started removing all postgress dependencies
parent
255c70d403
commit
327cb7a25d
@ -1,37 +0,0 @@
|
||||
module.exports = function(sequelize, DataTypes) {
|
||||
var FreshPost = sequelize.define(
|
||||
'FreshPost',
|
||||
{
|
||||
post: {
|
||||
type: DataTypes.JSONB
|
||||
}
|
||||
},
|
||||
{
|
||||
timestamps: false,
|
||||
|
||||
// don't delete database entries but set the newly added attribute deletedAt
|
||||
// to the current date (when deletion was done). paranoid will only work if
|
||||
// timestamps are enabled
|
||||
paranoid: false,
|
||||
|
||||
// don't use camelcase for automatically added attributes but underscore style
|
||||
// so updatedAt will be updated_at
|
||||
underscored: true,
|
||||
|
||||
// disable the modification of table names; By default, sequelize will automatically
|
||||
// transform all passed model names (first parameter of define) into plural.
|
||||
// if you don't want that, set the following
|
||||
freezeTableName: false,
|
||||
|
||||
// define the table's name
|
||||
tableName: 'FreshPosts',
|
||||
|
||||
// Enable optimistic locking. When enabled, sequelize will add a version count attriubte
|
||||
// to the model and throw an OptimisticLockingError error when stale instances are saved.
|
||||
// Set to true or a string with the attribute name you want to use to enable.
|
||||
version: false
|
||||
}
|
||||
);
|
||||
|
||||
return FreshPost;
|
||||
};
|
@ -1,84 +0,0 @@
|
||||
module.exports = function (sequelize, DataTypes) {
|
||||
var Post = sequelize.define('Post', {
|
||||
uuid: {
|
||||
type: DataTypes.STRING(50),
|
||||
unique: true,
|
||||
allowNull: false
|
||||
},
|
||||
title: {
|
||||
type: DataTypes.STRING(500),
|
||||
allowNull: true
|
||||
},
|
||||
slug: {
|
||||
type: DataTypes.STRING(500),
|
||||
unique: false,
|
||||
allowNull: true
|
||||
},
|
||||
tags: {
|
||||
type: DataTypes.STRING(2000),
|
||||
unique: false,
|
||||
allowNull: true
|
||||
},
|
||||
entry_html: {
|
||||
type: DataTypes.TEXT,
|
||||
unique: false,
|
||||
allowNull: true
|
||||
},
|
||||
entry_plaintext: {
|
||||
type: DataTypes.TEXT,
|
||||
unique: false,
|
||||
allowNull: true
|
||||
},
|
||||
feature_image: {
|
||||
type: DataTypes.STRING,
|
||||
unique: false,
|
||||
allowNull: true
|
||||
},
|
||||
page: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
unique: false,
|
||||
allowNull: true
|
||||
},
|
||||
featured: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
unique: false,
|
||||
allowNull: true
|
||||
},
|
||||
author_id: {
|
||||
type: DataTypes.INTEGER,
|
||||
unique: false,
|
||||
allowNull: true
|
||||
},
|
||||
origin_date: {
|
||||
type: DataTypes.INTEGER,
|
||||
unique: false,
|
||||
allowNull: true
|
||||
}
|
||||
}, {
|
||||
timestamps: true,
|
||||
|
||||
// don't delete database entries but set the newly added attribute deletedAt
|
||||
// to the current date (when deletion was done). paranoid will only work if
|
||||
// timestamps are enabled
|
||||
paranoid: true,
|
||||
|
||||
// don't use camelcase for automatically added attributes but underscore style
|
||||
// so updatedAt will be updated_at
|
||||
underscored: true,
|
||||
|
||||
// disable the modification of table names; By default, sequelize will automatically
|
||||
// transform all passed model names (first parameter of define) into plural.
|
||||
// if you don't want that, set the following
|
||||
freezeTableName: false,
|
||||
|
||||
// define the table's name
|
||||
tableName: 'Posts',
|
||||
|
||||
// Enable optimistic locking. When enabled, sequelize will add a version count attriubte
|
||||
// to the model and throw an OptimisticLockingError error when stale instances are saved.
|
||||
// Set to true or a string with the attribute name you want to use to enable.
|
||||
version: true
|
||||
});
|
||||
|
||||
return Post;
|
||||
};
|
@ -1,55 +0,0 @@
|
||||
module.exports = function (sequelize, DataTypes) {
|
||||
var User = sequelize.define('User', {
|
||||
avatar: {
|
||||
type: DataTypes.STRING,
|
||||
unique: false,
|
||||
allowNull: true
|
||||
},
|
||||
handle: {
|
||||
type: DataTypes.STRING,
|
||||
unique: true,
|
||||
allowNull: true
|
||||
},
|
||||
email: {
|
||||
type: DataTypes.STRING,
|
||||
unique: false,
|
||||
allowNull: true
|
||||
},
|
||||
role: {
|
||||
type: DataTypes.STRING,
|
||||
unique: false,
|
||||
allowNull: true
|
||||
},
|
||||
password: {
|
||||
type: DataTypes.STRING,
|
||||
unique: true,
|
||||
allowNull: false
|
||||
}
|
||||
}, {
|
||||
timestamps: true,
|
||||
|
||||
// don't delete database entries but set the newly added attribute deletedAt
|
||||
// to the current date (when deletion was done). paranoid will only work if
|
||||
// timestamps are enabled
|
||||
paranoid: true,
|
||||
|
||||
// don't use camelcase for automatically added attributes but underscore style
|
||||
// so updatedAt will be updated_at
|
||||
underscored: true,
|
||||
|
||||
// disable the modification of table names; By default, sequelize will automatically
|
||||
// transform all passed model names (first parameter of define) into plural.
|
||||
// if you don't want that, set the following
|
||||
freezeTableName: false,
|
||||
|
||||
// define the table's name
|
||||
tableName: 'Users',
|
||||
|
||||
// Enable optimistic locking. When enabled, sequelize will add a version count attriubte
|
||||
// to the model and throw an OptimisticLockingError error when stale instances are saved.
|
||||
// Set to true or a string with the attribute name you want to use to enable.
|
||||
version: true
|
||||
});
|
||||
|
||||
return User;
|
||||
};
|
@ -1,36 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const Sequelize = require('sequelize');
|
||||
const basename = path.basename(__filename);
|
||||
const env = process.env.NODE_ENV || 'development';
|
||||
const config = require(__dirname + '/../../config/config.json')[env];
|
||||
const db = {};
|
||||
|
||||
let sequelize;
|
||||
if (config.use_env_variable) {
|
||||
sequelize = new Sequelize(process.env[config.use_env_variable], config);
|
||||
} else {
|
||||
sequelize = new Sequelize(config.database, config.username, config.password, config);
|
||||
}
|
||||
|
||||
fs.readdirSync(__dirname)
|
||||
.filter(file => {
|
||||
return file.indexOf('.') !== 0 && file !== basename && file.slice(-3) === '.js';
|
||||
})
|
||||
.forEach(file => {
|
||||
const model = sequelize['import'](path.join(__dirname, file));
|
||||
db[model.name] = model;
|
||||
});
|
||||
|
||||
Object.keys(db).forEach(modelName => {
|
||||
if (db[modelName].associate) {
|
||||
db[modelName].associate(db);
|
||||
}
|
||||
});
|
||||
|
||||
db.sequelize = sequelize;
|
||||
db.Sequelize = Sequelize;
|
||||
|
||||
module.exports = db;
|
@ -1,46 +0,0 @@
|
||||
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;
|
@ -1,17 +0,0 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
//var Models = require('../../models');
|
||||
var config = require('../../../config/site-settings.json');
|
||||
module.exports = function() {
|
||||
//--------------------------
|
||||
// Index
|
||||
//--------------------------
|
||||
router.get('/:page?', function(req, res) {
|
||||
res.render(config.theme + '/index', {
|
||||
theme: config.theme,
|
||||
title: config.title,
|
||||
user_status: 'What up, random person'
|
||||
});
|
||||
});
|
||||
return router;
|
||||
};
|
@ -1,68 +0,0 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
var Models = require('../../models');
|
||||
var config = require('../../../config.json');
|
||||
router.get('/', function(req, res) {
|
||||
res.redirect('/blog/page/1');
|
||||
});
|
||||
|
||||
router.get('/page/:page_num?', function (req, res) {
|
||||
var page_num = req.params.page_num;
|
||||
var pageNum = page_num;
|
||||
if (page_num == null)
|
||||
pageNum = 1
|
||||
Models.Post.findAll({
|
||||
order: [['id', 'DESC']]
|
||||
}).then(function (post) {
|
||||
//console.log("num: "+pageNum);
|
||||
//real page count
|
||||
var count = Math.floor(post.length / 6);
|
||||
var pageItems = [];
|
||||
var itemLimit = 6;
|
||||
var rangeStart = (pageNum * itemLimit) - itemLimit;
|
||||
//console.log("RANGE START "+rangeStart);
|
||||
for (var i = 0; i < itemLimit; i++) {
|
||||
try {
|
||||
if (post[i + rangeStart].id != null) {
|
||||
pageItems.push(post[i + rangeStart]);
|
||||
}
|
||||
} catch (e) {
|
||||
//console.log(e)
|
||||
}
|
||||
}
|
||||
//console.log("items count: "+pageItems.length)
|
||||
res.render(config.theme+'/blog', {
|
||||
theme: config.theme,
|
||||
title: 'The Twelfth House | Thoughts and Such',
|
||||
page_index: pageNum,
|
||||
page_count: Math.round(post.length / 6),
|
||||
items: pageItems,
|
||||
mode: 'blog'
|
||||
});
|
||||
}).then(function (value) {
|
||||
//console.log(value);
|
||||
}).catch(function (err) {
|
||||
console.log(err);
|
||||
})
|
||||
});
|
||||
|
||||
router.get('/:id', function(req, res) {
|
||||
Models.Post.findOne({where:{slug: req.params.id}}).then((post) => {
|
||||
console.log(post.feature_image)
|
||||
|
||||
|
||||
res.render(config.theme+'/blog-post', {
|
||||
theme: config.theme,
|
||||
title: post.title,
|
||||
entry: post.entry_html,
|
||||
feature_image: JSON.parse(post.feature_image),
|
||||
mode:'blog'
|
||||
});
|
||||
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
module.exports = router;
|
@ -1,37 +0,0 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
var Models = require('../../models');
|
||||
var config = require('../../../config.json');
|
||||
router.get('/', function(req, res) {
|
||||
Models.FolioProject.findAll({order:[['sortIndex', 'DESC']]}).then(projects=> {
|
||||
res.render(config.theme+'/work', {
|
||||
theme: config.theme,
|
||||
title: 'The Twelfth House | Creative Works and Projects',
|
||||
projects: projects,
|
||||
mode: 'projects'
|
||||
});
|
||||
}).then(function(value) {
|
||||
//console.log(value);
|
||||
}).catch(function(err) {
|
||||
//next(err);
|
||||
})
|
||||
});
|
||||
|
||||
router.get('/:id', function(req, res) {
|
||||
Models.FolioProject.findOne({where:{slug: req.params.id}}).then((project) => {
|
||||
res.render(config.theme+'/work-project', {
|
||||
title: project.title,
|
||||
type: project.type,
|
||||
desc: project.description,
|
||||
images: JSON.parse(project.images),
|
||||
mode:'folio',
|
||||
url:project.url
|
||||
});
|
||||
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
module.exports = router;
|
Loading…
Reference in New Issue