add guestbook
This commit is contained in:
parent
8bad9f7c83
commit
4f12994bca
|
@ -1,9 +1,2 @@
|
|||
# homepage.js
|
||||
This is a rewrite of my current website to Express.JS.
|
||||
|
||||
# This was aborted.
|
||||
With focusing on code structure & performance, I decided
|
||||
to rewrite the website into JavaScript, but as it turned out,
|
||||
i can't provide enough for my satisfaction with ExpressJS.
|
||||
|
||||
I am re writing this to Go & atreugo
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
{
|
||||
"development": {
|
||||
"username": "root",
|
||||
"password": null,
|
||||
"database": "database_development",
|
||||
"host": "127.0.0.1",
|
||||
"dialect": "mysql"
|
||||
"username": "homepage",
|
||||
"password": "homepage",
|
||||
"database": "homepage",
|
||||
"host": "db",
|
||||
"dialect": "postgres"
|
||||
},
|
||||
"test": {
|
||||
"username": "root",
|
||||
"password": null,
|
||||
"database": "database_test",
|
||||
"host": "127.0.0.1",
|
||||
"dialect": "mysql"
|
||||
"username": "homepage",
|
||||
"password": "homepage",
|
||||
"database": "homepage",
|
||||
"host": "db",
|
||||
"dialect": "postgres"
|
||||
},
|
||||
"production": {
|
||||
"username": "root",
|
||||
"password": null,
|
||||
"database": "database_production",
|
||||
"host": "127.0.0.1",
|
||||
"dialect": "mysql"
|
||||
"username": "homepage",
|
||||
"password": "homepage",
|
||||
"database": "homepage",
|
||||
"host": "db",
|
||||
"dialect": "postgres"
|
||||
}
|
||||
}
|
||||
|
|
7
index.js
7
index.js
|
@ -1,7 +1,12 @@
|
|||
|
||||
// do startup jobs
|
||||
require('./startup');
|
||||
if (process.env.APP_DEBUG == 'true') process.env.DEBUG = '*/*';
|
||||
if (process.env.APP_DEBUG == 'true') {
|
||||
process.env.DEBUG = '*/*';
|
||||
process.env.NODE_ENV = 'development';
|
||||
} else {
|
||||
process.env.NODE_ENV = 'production';
|
||||
}
|
||||
|
||||
const express = require('express');
|
||||
const app = express();
|
||||
|
|
|
@ -1,27 +1,45 @@
|
|||
'use strict';
|
||||
/** @type {import('sequelize-cli').Migration} */
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
async up(queryInterface, DataTypes) {
|
||||
await queryInterface.createTable('Guestbooks', {
|
||||
id: {
|
||||
allowNull: false,
|
||||
autoIncrement: true,
|
||||
type: DataTypes.BIGINT(11),
|
||||
primaryKey: true,
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
id: {
|
||||
type: Sequelize.BIGINT
|
||||
autoIncrement: true,
|
||||
allowNull: false
|
||||
},
|
||||
name: {
|
||||
type: Sequelize.TEXT
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: false
|
||||
},
|
||||
email: DataTypes.TEXT,
|
||||
text: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: false
|
||||
},
|
||||
hidemail: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
allowNull: false
|
||||
},
|
||||
ip: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: false
|
||||
},
|
||||
hidden: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
allowNull: false
|
||||
},
|
||||
time: {
|
||||
type: DataTypes.BIGINT
|
||||
},
|
||||
createdAt: {
|
||||
allowNull: false,
|
||||
type: Sequelize.DATE
|
||||
type: DataTypes.DATE
|
||||
},
|
||||
updatedAt: {
|
||||
allowNull: false,
|
||||
type: Sequelize.DATE
|
||||
type: DataTypes.DATE
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
|
@ -5,10 +5,24 @@ const path = require('path');
|
|||
const Sequelize = require('sequelize');
|
||||
const process = require('process');
|
||||
const basename = path.basename(__filename);
|
||||
const env = process.env.NODE_ENV || 'development';
|
||||
const config = require(__dirname + '/../config/config.json')[env];
|
||||
const env = process.env.NODE_ENV || 'production';
|
||||
let config = require(__dirname + '/../config/config.json')[env];
|
||||
const db = {};
|
||||
|
||||
const {
|
||||
DB_PASSWORD,
|
||||
DB_USERNAME,
|
||||
DB_DATABASE,
|
||||
DB_HOSTNAME
|
||||
} = process.env;
|
||||
config = {
|
||||
...config,
|
||||
username: DB_USERNAME || config.username,
|
||||
password: DB_PASSWORD || config.password,
|
||||
database: DB_DATABASE || config.database,
|
||||
host: DB_HOSTNAME || config.host
|
||||
}
|
||||
|
||||
let sequelize;
|
||||
if (config.use_env_variable) {
|
||||
sequelize = new Sequelize(process.env[config.use_env_variable], config);
|
||||
|
|
|
@ -43,7 +43,9 @@ a:visited {
|
|||
list-style: none;
|
||||
padding: 0;
|
||||
font-size: 11pt;
|
||||
padding-top: 32px;
|
||||
padding-top: 36px;
|
||||
padding-left: 4px;
|
||||
line-height: 125%;
|
||||
}
|
||||
.main_contents {
|
||||
padding: 16px 12px;
|
||||
|
@ -63,3 +65,11 @@ hr {
|
|||
border: 0;
|
||||
border-bottom: 1px solid #C2C4C2;
|
||||
}
|
||||
|
||||
a {
|
||||
font-weight: bold;
|
||||
font-size: 95%;
|
||||
text-decoration: none;
|
||||
color:#2353ad;
|
||||
font-family: 'Open Sans' 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
const Helpers = require('../helpers');
|
||||
const Sequelize = require('../models');
|
||||
|
||||
async function handler(req, res, next) {
|
||||
try {
|
||||
|
@ -32,6 +33,8 @@ async function submit(req, res) {
|
|||
name, email, message, hidemail
|
||||
});
|
||||
|
||||
// console.log(Sequelize.Guestbook);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,9 @@ block root
|
|||
let routes = {
|
||||
"Main page": '/',
|
||||
"Projects": "/project",
|
||||
"About me": "/about"
|
||||
"About me": "/about",
|
||||
"hr": "hr",
|
||||
"Guestbook": "/guestbook"
|
||||
}
|
||||
|
||||
doctype html
|
||||
|
@ -24,11 +26,14 @@ html
|
|||
hr(class='flag_hr')
|
||||
ul
|
||||
each route, name in routes
|
||||
li
|
||||
if current_route == route
|
||||
| > #{name}
|
||||
else
|
||||
a(href=route) #{name}
|
||||
if (route == 'hr')
|
||||
li <hr/>
|
||||
else
|
||||
li(style='padding-left:4px')
|
||||
if current_route == route
|
||||
| > #{name}
|
||||
else
|
||||
a(href=route) #{name}
|
||||
td(class='main_contents')
|
||||
block content
|
||||
block foot
|
||||
|
|
Loading…
Reference in New Issue