Really ugly progress commit

This commit is contained in:
Timothy Warren 2016-06-14 10:51:48 -04:00
parent 0eb0d18755
commit 719776e862
16 changed files with 434 additions and 554 deletions

View File

@ -1,3 +1,6 @@
# ProgBlog # ProgBlog
A simple node blog with built-in code snippet highlighting A simple node blog with built-in code snippet highlighting
[![Build Status](https://jenkins.timshomepage.net/buildStatus/icon?job=ProgBlog)](https://jenkins.timshomepage.net/job/ProgBlog/)
## Setup

View File

@ -83,7 +83,6 @@ class Container {
return this._require(name); return this._require(name);
} }
/** /**
* Get a base library instance * Get a base library instance
* *

View File

@ -2,9 +2,14 @@
const container = require('../Container'); const container = require('../Container');
const Model = container.getBase('Model'); const Model = container.getBase('Model');
const Config = container.getBase('Config');
class DBModel extends Model { class DBModel extends Model {
constructor() {
super();
this.db = Config.get('database');
}
} }
module.exports = DBModel; module.exports = DBModel;

View File

@ -4,7 +4,6 @@
* Base Class for wrapping HTTP/HTTPS servers * Base Class for wrapping HTTP/HTTPS servers
*/ */
class Server { class Server {
constructor() {}
/** /**
* Event listener for HTTP(s) server "error" event. * Event listener for HTTP(s) server "error" event.
* *

4
app/bootstrap.js vendored
View File

@ -7,7 +7,7 @@ const path = container.get('path');
const Controller = container.get('base/Controller'); const Controller = container.get('base/Controller');
const Config = container.get('base/Config'); const Config = container.get('base/Config');
module.exports = (function () { module.exports = (() => {
const baseRoutePath = path.join(__dirname, 'controllers'); const baseRoutePath = path.join(__dirname, 'controllers');
// Set up templating // Set up templating
@ -28,4 +28,4 @@ module.exports = (function () {
return app; return app;
}()); })();

View File

@ -6,7 +6,7 @@ const knexConn = knexConfig.connection;
const params = { const params = {
driver: knexConfig.client, driver: knexConfig.client,
connection: (knexConfig.client == "sqlite3") ? knexConn.filename : knexConn, connection: (knexConfig.client == 'sqlite3') ? knexConn.filename : knexConn,
}; };
const nodeQuery = require('ci-node-query')(params); const nodeQuery = require('ci-node-query')(params);

View File

@ -25,4 +25,30 @@ module.exports = {
}, },
}, },
'/user/list': {
get: (req, res) => {
},
},
'/user/edit': {
get: (req, res) => {
},
post: (req, res) => {
},
},
'/user/add': {
get: (req, res) => {
},
post: (req, res) => {
},
},
}; };

13
app/models/Blog.js Normal file
View File

@ -0,0 +1,13 @@
'use strict';
const Container = require('../../Container');
const Config = container.get('Config');
const DBModel = container.getBase('DBModel');
class BlogModel extends DBModel {
constructor() {
super();
}
}
module.exports = new BlogModel();

View File

@ -1,4 +1,23 @@
'use strict'; 'use strict';
const container = require('../Container'); const container = require('../Container');
const Config = container.get('Config');
const DBModel = container.getBase('DBModel');
class UserModel extends DBModel {
constructor() {
super();
}
getAll() {
return this.db.get('users');
}
getUserById(userId) {
return this.db.from('users')
.where('id', userId)
.get();
}
}
module.exports = new UserModel();

View File

@ -65,6 +65,7 @@ Javascript has several ways of making a self-executing function.
<div class="cell cell-1of2 edit-right" id="preview"> <div class="cell cell-1of2 edit-right" id="preview">
</div> </div>
</section> </section>
<button type="submit">Save</button>
</section> </section>
<footer> <footer>
<p>&copy; Timothy J. Warren</p> <p>&copy; Timothy J. Warren</p>

View File

@ -0,0 +1,2 @@
<form action="/admin/user/add" method="post">
</form>

View File

@ -1,10 +1,10 @@
{ {
"author": "Timothy J. Warren", "author": "Timothy J. Warren",
"dependencies": { "dependencies": {
"axios": "^0.9.1", "axios": "^0.12.0",
"body-parser": "~1.13.2", "body-parser": "~1.15.1",
"ci-node-query": "^4.0.0", "ci-node-query": "^4.0.0",
"cookie-parser": "~1.3.5", "cookie-parser": "~1.4.3",
"debug": "~2.2.0", "debug": "~2.2.0",
"dotenv": "^2.0.0", "dotenv": "^2.0.0",
"errors": "^0.3.0", "errors": "^0.3.0",
@ -14,16 +14,16 @@
"express-negotiate": "0.0.5", "express-negotiate": "0.0.5",
"express-session": "^1.13.0", "express-session": "^1.13.0",
"getargs": "0.0.8", "getargs": "0.0.8",
"glob": "^6.0.4", "glob": "^7.0.3",
"helmet": "^1.1.0", "helmet": "^2.1.1",
"highlight.js": "^9.1.0", "highlight.js": "^9.1.0",
"jscs": "^2.11.0", "knex": "^0.11.5",
"knex": "^0.10.0",
"lodash": "^4.5.0", "lodash": "^4.5.0",
"markdown-it": "^6.0.0", "markdown-it": "^6.0.0",
"moment": "^2.11.2", "moment": "^2.11.2",
"morgan": "~1.6.1", "morgan": "~1.7.0",
"nodemon": "^1.9.0", "nodemon": "^1.9.0",
"npm-run-all": "^2.1.2",
"nsp": "^2.4.0", "nsp": "^2.4.0",
"scrypt": "^6.0.1", "scrypt": "^6.0.1",
"sqlite3": "^3.1.1", "sqlite3": "^3.1.1",
@ -31,7 +31,7 @@
}, },
"description": "A simple blog with built-in code snippet functionality", "description": "A simple blog with built-in code snippet functionality",
"devDependencies": { "devDependencies": {
"apidoc": "^0.15.1", "apidoc": "^0.16.1",
"chai": "^3.5.0", "chai": "^3.5.0",
"chai-as-promised": "^5.3.0", "chai-as-promised": "^5.3.0",
"documentation": "^4.0.0-beta1", "documentation": "^4.0.0-beta1",
@ -40,7 +40,6 @@
"istanbul": "0.4.*", "istanbul": "0.4.*",
"jscs": "^3.0.0", "jscs": "^3.0.0",
"mocha": "^2.4.5", "mocha": "^2.4.5",
"npm-run-all": "^1.6.0",
"nsp": "^2.2.1", "nsp": "^2.2.1",
"parallelshell": "^2.0.0", "parallelshell": "^2.0.0",
"pre-commit": "^1.1.2", "pre-commit": "^1.1.2",
@ -72,6 +71,7 @@
"audit": "nsp check", "audit": "nsp check",
"build": "npm-run-all --parallel lint:src lint:tests docs:src docs:api coverage", "build": "npm-run-all --parallel lint:src lint:tests docs:src docs:api coverage",
"coverage": "istanbul cover ./node_modules/mocha/bin/_mocha", "coverage": "istanbul cover ./node_modules/mocha/bin/_mocha",
"css": "postcss -c postcss.config.json -w",
"default": "npm-run-all --parallel audit lint:src lint:tests test", "default": "npm-run-all --parallel audit lint:src lint:tests test",
"docs": "npm-run-all --parallel docs:src docs:api", "docs": "npm-run-all --parallel docs:src docs:api",
"docs:api": "apidoc -i ./app/ -o ./public/api-docs/", "docs:api": "apidoc -i ./app/ -o ./public/api-docs/",

5
postcss.config.json Normal file
View File

@ -0,0 +1,5 @@
{
"use": "postcss-cssnext",
"input": "public/assets/css/blog.myth.css",
"output": "public/assets/css/blog.css"
}

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,8 @@
-ms-overflow-style: -ms-autohiding-scrollbar; -ms-overflow-style: -ms-autohiding-scrollbar;
overflow-y: scroll; overflow-y: scroll;
text-rendering: optimizeLegibility; text-rendering: optimizeLegibility;
text-size-adjust: 100% text-size-adjust: 100%;
scroll-behavior: smooth;
} }
* { * {

View File

@ -31,14 +31,14 @@ function normalizePort(val) {
} }
// Create HTTP Server // Create HTTP Server
if (true === config.get('http')) { if (config.get('http') === true) {
let port = normalizePort(config.get('http-port')); let port = normalizePort(config.get('http-port'));
app.set('port', port); app.set('port', port);
container.set('http-server', new HttpServer(app, port)); container.set('http-server', new HttpServer(app, port));
} }
// Create HTTPs Server // Create HTTPs Server
if (true === config.get('https')) { if (config.get('https') === true) {
const httpsPort = normalizePort(config.get('https-port')); const httpsPort = normalizePort(config.get('https-port'));
const httpsConfig = { const httpsConfig = {
key: fs.readFileSync(config.get('https-config-key')), key: fs.readFileSync(config.get('https-config-key')),