Skip to content

Commit

Permalink
Ravens desire to inflict pensive depression.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewyatesg committed Apr 8, 2018
1 parent fefdc7c commit 451c1e3
Show file tree
Hide file tree
Showing 44 changed files with 1,091 additions and 2,376 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
.idea/
*.log.*
uploads/
uploads/
package-lock.json
99 changes: 0 additions & 99 deletions assets/css/common.css

This file was deleted.

Binary file removed assets/img/classroom.jpeg
Binary file not shown.
1,967 changes: 0 additions & 1,967 deletions assets/img/classroom.svg

This file was deleted.

Binary file removed assets/img/howls_moving_castle.png
Binary file not shown.
Binary file removed assets/img/mountains.png
Binary file not shown.
Binary file removed assets/img/parrot.png
Binary file not shown.
54 changes: 0 additions & 54 deletions assets/js/api.js

This file was deleted.

10 changes: 0 additions & 10 deletions assets/js/constants.js

This file was deleted.

5 changes: 0 additions & 5 deletions assets/js/utils.js

This file was deleted.

6 changes: 2 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="utf-8">
<title>Image Board</title>
<link rel="stylesheet" type="text/css" href="/assets/css/common.css"></link>
<link rel="stylesheet" type="text/css" href="/src/assets/css/common.css">
</head>

<body>
Expand All @@ -13,9 +13,7 @@
<script src="//unpkg.com/axios/dist/axios.min.js"></script>
<script src="//unpkg.com/vue-router/dist/vue-router.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/zenscroll/4.0.0/zenscroll-min.js"></script>
<script src="/assets/js/constants.js"></script>
<script src="/assets/js/api.js"></script>
<script src="/assets/js/utils.js"></script>
<script src="/src/assets/js/api.js"></script>
<script src="/dist/build.js"></script>
</body>

Expand Down
13 changes: 9 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const express = require('express'),
cookieParser = require('cookie-parser'),
PropertiesReader = require('properties-reader'),
multer = require('multer'),
path = require('path'),
passport = require('passport');
const app = express();

Expand All @@ -15,7 +16,7 @@ app.use(session({
secret: 'erferfre234324reevvfe',
resave: false,
saveUninitialized: true,
cookie: { secure: false, maxAge: Number(100000) }
cookie: { secure: false, maxAge: Number(100000000) }
}));
app.use(passport.initialize());
app.use(passport.session());
Expand All @@ -30,15 +31,15 @@ global._isProd = _env === 'production';

console.info = function(message) {
console.log('[INFO] ' + message);
}
};

console.debug = function(message) {
console.log('[DEBUG] ' + message);
}
};

console.critical = function(message) {
console.log('[!!! CRITICAL !!!] ' + message);
}
};

const setUpDatabase = require(_base + 'services/SetupDatabaseService');
const setUpPassport = require(_base + 'services/SetUpPassport');
Expand All @@ -49,6 +50,10 @@ setUpPassport();
routescan(app, {
ignoreInvalid: true
});
app.use('/dist', express.static('dist'));
app.use('/src/assets', express.static('src/assets'));
app.use('/uploads', express.static('uploads'));
app.use((req, res) => res.sendFile(path.join(_base, '/index.html')));

app.use(function (err, req, res, next) {
console.debug('Error encountered: ' + err.message);
Expand Down
4 changes: 2 additions & 2 deletions middleware/ensureAuthenticity.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ module.exports = function(req, res, next) {
if(req.isAuthenticated()) {
next();
} else {
res.redirect("/login");
next(new Error('Not logged in.'));
}
}
};
2 changes: 1 addition & 1 deletion models/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ let mongoose = require("mongoose");

let boardSchema = new mongoose.Schema({

categoryName: { type: String, required: true, unique: true },
categoryName: { type: String, required: true },
name: { type: String, required: true, unique: true },
letter: { type: String, required: true, unique: true },
favIcon: { type: String }
Expand Down
43 changes: 32 additions & 11 deletions models/mod.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,43 @@
let mongoose = require("mongoose"),
// bcrypt = require("bcrypt"),
bcrypt = require("bcrypt-nodejs"),
shortid = require("shortid");

const SALT_FACTOR = 4;

let modSchema = new mongoose.Schema({
_id: { type: String, required: true, default: shortid.generate },
email: { type: String, required: true },
username: { type: String, required: true },
password: { type: String, required: true }
}, { collection: _db.get("db.collection.mods") });

// TODO: implement check password method
// modSchema.methods.checkPassword = function(guess, done) {
// bcrypt.compare(guess, this.password, function(err, match) {
// done(err, match);
// });
// };
// TODO: remove this test implementation of the checkPassword method
function noop() {};

modSchema.pre('save', function (done) {
let user = this; //Reference to user model

if (!user.isModified("password")) {
return done();
}

bcrypt.genSalt(SALT_FACTOR, function (err, salt) {
if (err) {
return done(err);
}
bcrypt.hash(user.password, salt, noop, function (err, hashedPassword) {
if (err) {
return done(err);
}
user.password = hashedPassword;
done();
});
});
});

modSchema.methods.checkPassword = function(guess, done) {
done(null, true);
}
bcrypt.compare(guess, this.password, function(err, isMatch) {
done(err, isMatch);
});
};

let Mod = mongoose.model('Mod', modSchema);
module.exports = Mod;
6 changes: 5 additions & 1 deletion models/reply.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ let shortid = require("shortid");
let replySchema = new mongoose.Schema({
_id: { type: String, required: true, default: shortid.generate },
time: { type: Date, required: true, default: Date.now },
ip: { type: String, required: true }
ip: { type: String, required: true },
attachment_path: { type: String, required: false },
attachment_name: { type: String, required: false },
threadId: { type: String, required: true },
content: { type: String, required: false }
});

let Reply = mongoose.model("Reply", replySchema);
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"server": "pm2 start index.js --watch --name server --ignore-watch 'uploads'",
"vue": "cross-env NODE_ENV=development pm2 start webpack-dev-server --name vue -- --open --hot --inline --port 3002",
"start": "npm run server | npm run vue",
"vue": "cross-env NODE_ENV=development pm2 start webpack-dev-server --name vue -- --open --hot --inline --port 3002 --host 0.0.0.0",
"start": "npm run server | npm run build",
"stop": "pm2 stop all",
"log": "pm2 log",
"restart": "npm run stop | npm run start | npm run log",
Expand All @@ -26,14 +26,18 @@
"express-session": "^1.15.6",
"express-validator": "^5.0.3",
"googleapis": "^27.0.0",
"ipaddr.js": "^1.6.0",
"mongoose": "^5.0.9",
"multer": "^1.3.0",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"properties-reader": "0.0.16",
"recaptcha": "^1.2.1",
"request-ip": "^2.0.2",
"shortid": "^2.2.8",
"string-format": "^0.5.0",
"striptags": "^3.1.1",
"transform-runtime": "0.0.0",
"validator": "^9.4.1",
"vue": "^2.5.11",
"vue-router": "^3.0.1"
Expand All @@ -49,6 +53,7 @@
"vue-loader": "^13.0.5",
"vue-template-compiler": "^2.4.4",
"webpack": "^3.6.0",
"webpack-cli": "^2.0.14",
"webpack-dev-server": "^2.9.1"
}
}
2 changes: 1 addition & 1 deletion routes/create/ban.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ module.exports = {
}
}

}
};
Loading

0 comments on commit 451c1e3

Please sign in to comment.