Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Upgraded express to 3.x

  • Loading branch information...
commit 37986074d43d2194f8e6c5f3234e9a7f1c88ede4 1 parent fd422ff
@mikevalstar authored
View
24 addUser.js
@@ -16,17 +16,17 @@ var db = new Database();
db.connect('mongodb://localhost/mv');
if(process.argv.length == 4){
- // 0 will be node, 1 will be the script
-
- var au = db.model('adminUser');
- var usr = new au({login: process.argv[2], password: hashString(process.argv[3]) });
- usr.save(function(err){
- console.log("User added to database");
- process.exit(0); // Success
- });
-
+ // 0 will be node, 1 will be the script
+
+ var au = db.model('adminUser');
+ var usr = new au({login: process.argv[2], password: hashString(process.argv[3]) });
+ usr.save(function(err){
+ console.log("User added to database");
+ process.exit(0); // Success
+ });
+
}else{
- console.error("Script requires exactly 2 arguments");
- console.error("Usage: node addUser.js <email> <password>");
- process.exit(1); // Failure
+ console.error("Script requires exactly 2 arguments");
+ console.error("Usage: node addUser.js <email> <password>");
+ process.exit(1); // Failure
}
View
55 app.js
@@ -3,26 +3,29 @@
*/
process.env.TZ = 'GMT';
var express = require('express')
- , mongoStore = require('session-mongoose');
-
-var app = module.exports = express.createServer();
+ , http = require('http')
+ , path = require('path')
+ , mongoStore = require('session-mongoose');
+
+var app = express();
// Configuration
app.configure(function(){
- app.set('views', __dirname + '/views');
- app.set('view engine', 'jade');
- app.use(express.bodyParser());
- app.use(express.methodOverride());
- app.use(express.cookieParser());
-
- var mongooseSessionStore = new mongoStore({
- url: "mongodb://localhost/mv",
- interval: 1200000
- });
-
- app.use(express.session( {cookie: {maxAge: 1200000}, store: mongooseSessionStore, secret: "mv secret" }));
- app.use(app.router);
- app.use(express.static(__dirname + '/htdocs'));
+ app.set('views', __dirname + '/views');
+ app.set('view engine', 'jade');
+ app.use(express.bodyParser());
+ app.use(express.methodOverride());
+ app.use(express.cookieParser());
+ app.use(require('less-middleware')({ src: __dirname + '/htdocs' }));
+
+ var mongooseSessionStore = new mongoStore({
+ url: "mongodb://localhost/mv",
+ interval: 1200000
+ });
+
+ app.use(express.session( {cookie: {maxAge: 1200000}, store: mongooseSessionStore, secret: "mv secret" }));
+ app.use(app.router);
+ app.use(express.static(path.join(__dirname, 'htdocs')));
});
// Error Handling
@@ -30,12 +33,15 @@ var error = require('./lib/ErrorHandler');
app.configure('development', function(){
//app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
- app.use(error({ showMessage: true, dumpExceptions: true, showStack: true, logErrors: __dirname + '/log/error_log' }));
+ app.set('port', process.env.PORT || 3000);
+ app.use(express.logger('dev'));
+ app.use(error({ showMessage: true, dumpExceptions: true, showStack: true, logErrors: __dirname + '/log/error_log' }));
});
app.configure('production', function(){
//app.use(express.errorHandler());
- app.use(error());
+ app.set('port', process.env.PORT || 80);
+ app.use(error());
});
// Database
@@ -58,18 +64,19 @@ pp.initPages(app, db);
// 404 Page
app.use(function(req, res, next){
- res.render('404.jade', {title: "404 - Page Not Found", showFullNav: false, status: 404, url: req.url });
+ res.render('404.jade', {title: "404 - Page Not Found", showFullNav: false, status: 404, url: req.url });
});
// Example error pages
app.get('/ErrorExample', function(req, res, next){
- next(new Error('keyboard cat!')); // trigger an error
+ next(new Error('keyboard cat!')); // trigger an error
});
app.get('/ErrorExample2', function(req, res){
- res.render('404.jade'); // force an error.. we did not set the title
+ res.render('404.jade'); // force an error.. we did not set the title
});
-app.listen(3000);
-console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
+http.createServer(app).listen(app.get('port'), function(){
+ console.log("Express server listening on port %d in %s mode.\n", app.get('port'), app.settings.env);
+});
View
456 lib/AdminPages.js
@@ -11,234 +11,234 @@ var AdminPages = module.exports = function AdminPages(){};
AdminPages.prototype = {
- db: null
+ db: null
- , initPages: function(app, db){
-
- this.db = db;
- var self = this;
-
- // login related
- app.get ('/Admin/Login', function(req, res) { self.pageLogin(req, res); } );
- app.post('/Admin/Login', function(req, res) { self.pageLoginPost(req, res); } );
- app.get ('/Admin/Logout', function(req, res) { self.pageLogout(req, res); } );
-
- // post related
- app.get ('/Admin/PostList', function(req, res) { self.pagePostList(req, res); } );
- app.get ('/Admin/NewPost', function(req, res) { self.pagePost(req, res); } );
- app.post('/Admin/Post', function(req, res) { self.pagePostPost(req, res); } );
- app.get ('/Admin/Post/:id', function(req, res) { self.pagePost(req, res); } );
-
- // misc.
- app.get ('/Admin', function(req, res) { self.pageIndex(req, res); } );
- }
-
- , _checkLogin: function(req, res){
- if(req.session && req.session.loggedIn === true)
- return true;
+ , initPages: function(app, db){
+
+ this.db = db;
+ var self = this;
+
+ // login related
+ app.get ('/Admin/Login', function(req, res) { self.pageLogin(req, res); } );
+ app.post('/Admin/Login', function(req, res) { self.pageLoginPost(req, res); } );
+ app.get ('/Admin/Logout', function(req, res) { self.pageLogout(req, res); } );
+
+ // post related
+ app.get ('/Admin/PostList', function(req, res) { self.pagePostList(req, res); } );
+ app.get ('/Admin/NewPost', function(req, res) { self.pagePost(req, res); } );
+ app.post('/Admin/Post', function(req, res) { self.pagePostPost(req, res); } );
+ app.get ('/Admin/Post/:id', function(req, res) { self.pagePost(req, res); } );
+
+ // misc.
+ app.get ('/Admin', function(req, res) { self.pageIndex(req, res); } );
+ }
+
+ , _checkLogin: function(req, res){
+ if(req.session && req.session.loggedIn === true)
+ return true;
- res.redirect('/Admin/Login');
- return false;
- }
-
- , pageLogin: function(req, res){
- res.render('admin/login', {
- title: 'Login',
- showFullNav: false
- });
- }
-
- , pageLogout: function(req, res){
- delete req.session.loggedIn;
- res.redirect('/Admin/Login');
- }
-
- , pageLoginPost: function(req, res){
- if(req.body && req.body.password && req.body.email){
- var adminuser = this.db.model('adminUser');
- adminuser.findOne(
- { login: req.body.email
- , password: hashString(req.body.password) }
- , function(err, row){
-
- if(err){
- res.render('admin/login', {
- title: 'Login',
- showFullNav: false,
- error_text: err
- });
- }else{
- if(row){
- req.session.loggedIn = true; // register user is logged in
- res.redirect('/Admin');
- }else{
- res.render('admin/login', {
- title: 'Login',
- showFullNav: false,
- error_text: 'User not found, Please try again',
- email: req.body.email
- });
- }
- }
- });
- }else{
- res.render('admin/login', {
- title: 'Login',
- showFullNav: false,
- error_text: 'Error processing login.'
- });
- }
- }
-
- , pageIndex: function(req, res){
- if( !this._checkLogin(req, res) ) return;
-
- res.render('admin/index', {
- title: 'Admin Index',
- showFullNav: false
- });
- }
-
- /* Blog post related */
- , pagePostList: function(req, res){ // List of blog posts
- if( !this._checkLogin(req, res) ) return;
-
- var blogpost = this.db.model('blogPost');
-
- var query = blogpost.find().sort("posted", -1).limit(1000).exec(function(err, docs){
- res.render('admin/postlist', {
- title: 'Post Listing',
- posts: docs,
- showFullNav: false
- });
- });
- }
-
- , pagePost: function(req, res){ // Edit/New Page
- if( !this._checkLogin(req, res) ) return;
-
- if(req.params.id){ // Old Post
-
- var blogpost = this.db.model('blogPost');
- blogpost.findOne({sid: req.params.id}, function(err, row){
- if(!row){
- res.redirect('/Admin/NewPost');
- return;
- }
-
- res.render('admin/post', {
- title: req.params.id + ' - ' + row.title,
- post: row,
- showFullNav: false
- });
- });
-
- }else{ // New Post
- var newid = 1;
- var blogpost = this.db.model('blogPost');
- blogpost.find().sort("sid", -1).limit(1).exec(function(err, doc){
- if(err)
- console.info(err);
-
- if(!doc || doc.length == 0){
- newid = 1;
- }else{
- newid = doc[0].sid + 1;
- }
-
- res.render('admin/post', {
- title: 'New Blog Post',
- post: { id : "",
- sid : newid,
- author : "mikevalstar@gmail.com",
- title : "",
- img_lg : "",
- img_sm : "",
- content : "",
- short : "",
- group : "",
- ext_link: "",
- posted : "",
- edited : "",
- },
- showFullNav: false
- });
- });
- }
- }
-
- , pagePostPost: function(req, res){
- if( !this._checkLogin(req, res) ) return;
-
- if(req.body.id && req.body.id != ""){
- // old page
- var blogpost = this.db.model('blogPost');
-
- blogpost.update(
- {_id: req.body.id},
- {
- sid : req.body.sid,
- title : req.body.title,
- img_lg : req.body.img_lg,
- img_sm : req.body.img_sm,
- content : req.body.content,
- short : req.body.short,
- group : req.body.group,
- ext_link: req.body.ext_link,
- },
- { multi: false },
- function(err, numrows){
- if(err){
- console.log(err);
- }else{
- console.log("Updated ("+numrows+") blog post(s) at internal id: " + req.body.id);
- }
-
- res.redirect('/Admin/Post/' + req.body.sid);
- });
-
- }else{
- // new page
- var blogpost = this.db.model('blogPost');
-
- // max id + 1
- var newid = 1;
- blogpost.find().sort("sid", -1).limit(1).exec(function(err, doc){
- if(err)
- console.info(err);
-
- if(!doc || doc.length == 0){
- newid = 1;
- }else{
- newid = doc[0].sid + 1;
- }
-
- // new blog post
- var post = new blogpost({
- sid : req.body.sid == "" ? parseInt(newid) : req.body.sid,
- author : "mikevalstar@gmail.com",
- title : req.body.title,
- img_lg : req.body.img_lg,
- img_sm : req.body.img_sm,
- content : req.body.content,
- short : req.body.short,
- group : req.body.group,
- ext_link: req.body.ext_link,
- });
-
- post.save(function(err){
- if(err){
- console.log(err);
- }else{
- console.log("Inserted new blog post at sid: " + post.sid + " at internal id: " + post.id);
- }
-
- res.redirect('/Admin/Post/' + post.sid);
- });
-
- });
-
- }
- }
-
+ res.redirect('/Admin/Login');
+ return false;
+ }
+
+ , pageLogin: function(req, res){
+ res.render('admin/login', {
+ title: 'Login',
+ showFullNav: false
+ });
+ }
+
+ , pageLogout: function(req, res){
+ delete req.session.loggedIn;
+ res.redirect('/Admin/Login');
+ }
+
+ , pageLoginPost: function(req, res){
+ if(req.body && req.body.password && req.body.email){
+ var adminuser = this.db.model('adminUser');
+ adminuser.findOne(
+ { login: req.body.email
+ , password: hashString(req.body.password) }
+ , function(err, row){
+
+ if(err){
+ res.render('admin/login', {
+ title: 'Login',
+ showFullNav: false,
+ error_text: err
+ });
+ }else{
+ if(row){
+ req.session.loggedIn = true; // register user is logged in
+ res.redirect('/Admin');
+ }else{
+ res.render('admin/login', {
+ title: 'Login',
+ showFullNav: false,
+ error_text: 'User not found, Please try again',
+ email: req.body.email
+ });
+ }
+ }
+ });
+ }else{
+ res.render('admin/login', {
+ title: 'Login',
+ showFullNav: false,
+ error_text: 'Error processing login.'
+ });
+ }
+ }
+
+ , pageIndex: function(req, res){
+ if( !this._checkLogin(req, res) ) return;
+
+ res.render('admin/index', {
+ title: 'Admin Index',
+ showFullNav: false
+ });
+ }
+
+ /* Blog post related */
+ , pagePostList: function(req, res){ // List of blog posts
+ if( !this._checkLogin(req, res) ) return;
+
+ var blogpost = this.db.model('blogPost');
+
+ var query = blogpost.find().sort("posted", -1).limit(1000).exec(function(err, docs){
+ res.render('admin/postlist', {
+ title: 'Post Listing',
+ posts: docs,
+ showFullNav: false
+ });
+ });
+ }
+
+ , pagePost: function(req, res){ // Edit/New Page
+ if( !this._checkLogin(req, res) ) return;
+
+ if(req.params.id){ // Old Post
+
+ var blogpost = this.db.model('blogPost');
+ blogpost.findOne({sid: req.params.id}, function(err, row){
+ if(!row){
+ res.redirect('/Admin/NewPost');
+ return;
+ }
+
+ res.render('admin/post', {
+ title: req.params.id + ' - ' + row.title,
+ post: row,
+ showFullNav: false
+ });
+ });
+
+ }else{ // New Post
+ var newid = 1;
+ var blogpost = this.db.model('blogPost');
+ blogpost.find().sort("sid", -1).limit(1).exec(function(err, doc){
+ if(err)
+ console.info(err);
+
+ if(!doc || doc.length == 0){
+ newid = 1;
+ }else{
+ newid = doc[0].sid + 1;
+ }
+
+ res.render('admin/post', {
+ title: 'New Blog Post',
+ post: { id : "",
+ sid : newid,
+ author : "mikevalstar@gmail.com",
+ title : "",
+ img_lg : "",
+ img_sm : "",
+ content : "",
+ short : "",
+ group : "",
+ ext_link: "",
+ posted : "",
+ edited : "",
+ },
+ showFullNav: false
+ });
+ });
+ }
+ }
+
+ , pagePostPost: function(req, res){
+ if( !this._checkLogin(req, res) ) return;
+
+ if(req.body.id && req.body.id != ""){
+ // old page
+ var blogpost = this.db.model('blogPost');
+
+ blogpost.update(
+ {_id: req.body.id},
+ {
+ sid : req.body.sid,
+ title : req.body.title,
+ img_lg : req.body.img_lg,
+ img_sm : req.body.img_sm,
+ content : req.body.content,
+ short : req.body.short,
+ group : req.body.group,
+ ext_link: req.body.ext_link,
+ },
+ { multi: false },
+ function(err, numrows){
+ if(err){
+ console.log(err);
+ }else{
+ console.log("Updated ("+numrows+") blog post(s) at internal id: " + req.body.id);
+ }
+
+ res.redirect('/Admin/Post/' + req.body.sid);
+ });
+
+ }else{
+ // new page
+ var blogpost = this.db.model('blogPost');
+
+ // max id + 1
+ var newid = 1;
+ blogpost.find().sort("sid", -1).limit(1).exec(function(err, doc){
+ if(err)
+ console.info(err);
+
+ if(!doc || doc.length == 0){
+ newid = 1;
+ }else{
+ newid = doc[0].sid + 1;
+ }
+
+ // new blog post
+ var post = new blogpost({
+ sid : req.body.sid == "" ? parseInt(newid) : req.body.sid,
+ author : "mikevalstar@gmail.com",
+ title : req.body.title,
+ img_lg : req.body.img_lg,
+ img_sm : req.body.img_sm,
+ content : req.body.content,
+ short : req.body.short,
+ group : req.body.group,
+ ext_link: req.body.ext_link,
+ });
+
+ post.save(function(err){
+ if(err){
+ console.log(err);
+ }else{
+ console.log("Inserted new blog post at sid: " + post.sid + " at internal id: " + post.id);
+ }
+
+ res.redirect('/Admin/Post/' + post.sid);
+ });
+
+ });
+
+ }
+ }
+
};
View
88 lib/Database.js
@@ -5,49 +5,49 @@ var Schema = mongoose.Schema
var Database = module.exports = function Database(){};
Database.prototype = {
-
- _collections: {
- adminUser: {
- login : String
- , password : String
- },
- blogPost:{
- sid : { type: Number, required: true, unique: true, index: true },
- author : { type: String },
- title : { type: String },
- img_lg : { type: String },
- img_sm : { type: String },
- content : { type: String },
- short : { type: String },
- group : { type: String },
- ext_link: { type: String },
- posted : { type: Date, index: true, default: Date.now },
- edited : { type: Date, default: Date.now },
- },
- }
-
- , _db: null
- , _schema: {}
- , _model: {}
-
- , connect: function(url){
- mongoose.connect(url);
-
- this._schema.adminUser = new Schema(this._collections.adminUser);
- this._model.adminUser = mongoose.model('adminUser', this._schema.adminUser);
-
- this._schema.blogPost = new Schema(this._collections.blogPost);
- this._model.blogPost = mongoose.model('blogPost', this._schema.blogPost);
-
- }
-
- , model: function(mod){
- switch (mod){
- case 'adminUser':
- return this._model.adminUser;
- case 'blogPost':
- return this._model.blogPost;
- }
- }
+
+ _collections: {
+ adminUser: {
+ login : String
+ , password : String
+ },
+ blogPost:{
+ sid : { type: Number, required: true, unique: true, index: true },
+ author : { type: String },
+ title : { type: String },
+ img_lg : { type: String },
+ img_sm : { type: String },
+ content : { type: String },
+ short : { type: String },
+ group : { type: String },
+ ext_link: { type: String },
+ posted : { type: Date, index: true, default: Date.now },
+ edited : { type: Date, default: Date.now },
+ },
+ }
+
+ , _db: null
+ , _schema: {}
+ , _model: {}
+
+ , connect: function(url){
+ mongoose.connect(url);
+
+ this._schema.adminUser = new Schema(this._collections.adminUser);
+ this._model.adminUser = mongoose.model('adminUser', this._schema.adminUser);
+
+ this._schema.blogPost = new Schema(this._collections.blogPost);
+ this._model.blogPost = mongoose.model('blogPost', this._schema.blogPost);
+
+ }
+
+ , model: function(mod){
+ switch (mod){
+ case 'adminUser':
+ return this._model.adminUser;
+ case 'blogPost':
+ return this._model.blogPost;
+ }
+ }
};
View
110 lib/ErrorHandler.js
@@ -30,63 +30,63 @@
var fs = require('fs');
exports = module.exports = function errorHandler(options){
- options = options || {};
- // defaults
- var showStack = options.showStack
- , showMessage = options.showMessage
- , dumpExceptions = options.dumpExceptions
- , logErrors = options.logErrors
- , logErrorsStream = false;
-
- if(options.logErrors)
- logErrorsStream = fs.createWriteStream(logErrors, {'flags': 'a', encoding: 'utf-8', mode: 0666});
+ options = options || {};
+ // defaults
+ var showStack = options.showStack
+ , showMessage = options.showMessage
+ , dumpExceptions = options.dumpExceptions
+ , logErrors = options.logErrors
+ , logErrorsStream = false;
+
+ if(options.logErrors)
+ logErrorsStream = fs.createWriteStream(logErrors, {'flags': 'a', encoding: 'utf-8', mode: 0666});
- return function errorHandler(err, req, res, next){
- res.statusCode = 500;
+ return function errorHandler(err, req, res, next){
+ res.statusCode = 500;
- if(dumpExceptions) console.error(err.stack);
+ if(dumpExceptions) console.error(err.stack);
- if(logErrors){
- var now = new Date();
- logErrorsStream.write(now.toJSON() + ' - Error Happened: \n' + err.stack + "\n");
- }
+ if(logErrors){
+ var now = new Date();
+ logErrorsStream.write(now.toJSON() + ' - Error Happened: \n' + err.stack + "\n");
+ }
- var accept = req.headers.accept || '';
- if(showStack) {
- // html
- if (~accept.indexOf('html')) {
- res.render('error.jade', {
- layout: false
- , stack: err.stack || ''
- , error: err.toString()
- });
- // json
- } else if (~accept.indexOf('json')) {
- var json = JSON.stringify({ error: err });
- res.setHeader('Content-Type', 'application/json');
- res.end(json);
- // plain text
- } else {
- res.writeHead(500, { 'Content-Type': 'text/plain' });
- res.end(err.stack);
- }
- }else{
- // public error page render
- // html
- if (~accept.indexOf('html')) {
- res.render('error.jade', {
- layout: false
- });
- // json
- } else if (~accept.indexOf('json')) {
- var json = JSON.stringify({ error: "There was a server error generating the content." });
- res.setHeader('Content-Type', 'application/json');
- res.end(json);
- // plain text
- } else {
- res.writeHead(500, { 'Content-Type': 'text/plain' });
- res.end("500 - Server Error");
- }
- }
- };
+ var accept = req.headers.accept || '';
+ if(showStack) {
+ // html
+ if (~accept.indexOf('html')) {
+ res.render('error.jade', {
+ layout: false
+ , stack: err.stack || ''
+ , error: err.toString()
+ });
+ // json
+ } else if (~accept.indexOf('json')) {
+ var json = JSON.stringify({ error: err });
+ res.setHeader('Content-Type', 'application/json');
+ res.end(json);
+ // plain text
+ } else {
+ res.writeHead(500, { 'Content-Type': 'text/plain' });
+ res.end(err.stack);
+ }
+ }else{
+ // public error page render
+ // html
+ if (~accept.indexOf('html')) {
+ res.render('error.jade', {
+ layout: false
+ });
+ // json
+ } else if (~accept.indexOf('json')) {
+ var json = JSON.stringify({ error: "There was a server error generating the content." });
+ res.setHeader('Content-Type', 'application/json');
+ res.end(json);
+ // plain text
+ } else {
+ res.writeHead(500, { 'Content-Type': 'text/plain' });
+ res.end("500 - Server Error");
+ }
+ }
+ };
};
View
274 lib/PublicPages.js
@@ -6,143 +6,143 @@ var PublicPages = module.exports = function PublicPages(){};
PublicPages.prototype = {
- db: null
+ db: null
- , initPages: function(app, db){
- this.db = db;
- var self = this;
-
- app.get('/', function(req, res) { self.pageIndex(req, res, true); });
- app.get('/Blog', function(req, res) { self.pageIndex(req, res, false); });
- app.get('/Blog/:page([0-9]+)', function(req, res) { self.pageIndex(req, res, {page: req.params.page}); });
- app.get('/Blog/:year([0-9]+)/:month([0-9]+)', function(req, res) { self.pageIndex(req, res, {year: req.params.year, month: req.params.month}); });
- //app.get('/Blog/:group', function(req, res) { self.pageIndex(req, res, {group: req.params.group}); });
- app.get('/Blog/s/:topic', function(req, res) { self.pageIndex(req, res, {search: req.params.topic}); });
- app.get('/Blog/:id/:title', function(req, res) { self.pageBlogPost(req, res); });
-
- app.get('/RSS', function(req, res) { self.RSS(req, res); });
- }
-
- , pageIndex: function(req, res, nav){
- var perpage = (!nav || nav.page) ? 10 : 100; // show 100 items for month or search, otherwise 10
- var blogpost = this.db.model('blogPost');
- var page = (nav && nav.page) ? nav.page - 1 : 0;
- var query = {};
- if(nav && nav.search) query = {title: {$regex: new RegExp('.*' + Util.escapeRegEx(nav.search) + '.*', 'i')}};
- if(nav && nav.group) query = {group: nav.group};
- if(nav && nav.year){
- var start = new Date(nav.year, nav.month, 1);
- var end = new Date(nav.year, start.getMonth() + 1, 1);
- query = {posted: { $gte: start, $lt: end }};
- }
+ , initPages: function(app, db){
+ this.db = db;
+ var self = this;
+
+ app.get('/', function(req, res) { self.pageIndex(req, res, true); });
+ app.get('/Blog', function(req, res) { self.pageIndex(req, res, false); });
+ app.get('/Blog/:page([0-9]+)', function(req, res) { self.pageIndex(req, res, {page: req.params.page}); });
+ app.get('/Blog/:year([0-9]+)/:month([0-9]+)', function(req, res) { self.pageIndex(req, res, {year: req.params.year, month: req.params.month}); });
+ //app.get('/Blog/:group', function(req, res) { self.pageIndex(req, res, {group: req.params.group}); });
+ app.get('/Blog/s/:topic', function(req, res) { self.pageIndex(req, res, {search: req.params.topic}); });
+ app.get('/Blog/:id/:title', function(req, res) { self.pageBlogPost(req, res); });
+
+ app.get('/RSS', function(req, res) { self.RSS(req, res); });
+ }
+
+ , pageIndex: function(req, res, nav){
+ var perpage = (!nav || nav.page) ? 10 : 100; // show 100 items for month or search, otherwise 10
+ var blogpost = this.db.model('blogPost');
+ var page = (nav && nav.page) ? nav.page - 1 : 0;
+ var query = {};
+ if(nav && nav.search) query = {title: {$regex: new RegExp('.*' + Util.escapeRegEx(nav.search) + '.*', 'i')}};
+ if(nav && nav.group) query = {group: nav.group};
+ if(nav && nav.year){
+ var start = new Date(nav.year, nav.month, 1);
+ var end = new Date(nav.year, start.getMonth() + 1, 1);
+ query = {posted: { $gte: start, $lt: end }};
+ }
- var query = blogpost.find(query);
-
- query.sort("posted", -1).skip(page * perpage).limit(perpage).exec(function(err, docs){
-
- for ( var k in docs ){
- docs[k].link_title = Util.link_title(docs[k].title);
- var new_short = jade.compile(docs[k].short);
- docs[k].short = new_short();
- docs[k].posted_human = Util.human_date(docs[k].posted);
- }
-
- query.count(function(err, postcount){
- var totalpages = Math.ceil(postcount / perpage);
- var nextpage = totalpages > page ? page + 2 : false;
- var prevpage = page > 0 ? page : false;
-
- var render_page = function(monthlist){
- res.render('index', {
- title: 'Blog',
- posts: docs,
- nextpage: nextpage,
- prevpage: prevpage,
- months: monthlist,
- month_names: new Array("January","February","March","April","May","June","July","August","September","October","November","December"),
- showFullNav: nav
- });
- }
-
- // Production of month groups for Archive
- var map = function(){
- emit( this.posted.getFullYear() + '-' + this.posted.getMonth() , { count: 1, year: this.posted.getFullYear(), month: this.posted.getMonth() } );
- };
-
- var reduce = function(key, values){
- var result = {
- count: values.length,
- month: values[0].month,
- year: values[0].year
- };
- return result;
- };
-
- blogpost.collection.mapReduce(
- map.toString()
- , reduce.toString()
- , {out: { inline: 1 }}
- , function(err, monthlist){
- monthlist.reverse();
- render_page(monthlist);
- }
- );
- });
- });
-
- }
-
- , pageBlogPost: function(req, res){
- var blogpost = this.db.model('blogPost');
- blogpost.findOne({sid: req.params.id}, function(err, row){
- if(!row){
- res.redirect('/404');
- return;
- }
-
- row.link_title = Util.link_title(row.title);
- var new_short = jade.compile(row.short);
- row.short = new_short();
- var new_content = jade.compile(row.content);
- row.content = new_content();
- row.posted_human = Util.human_date(row.posted);
- row.edited_human = Util.human_date(row.edited);
-
- res.render('post', {
- title: row.title,
- post: row,
- showFullNav: false
- });
- });
- }
-
- , RSS: function(req, res){
- var blogpost = this.db.model('blogPost');
- var query = blogpost.find().sort("posted", -1).limit(30).exec(function(err, docs){
-
- for ( var k in docs ){
- docs[k].title = docs[k].title;
- var new_short = jade.compile(docs[k].short);
- docs[k].description = new_short();
- docs[k].pubDate = docs[k].posted;
- docs[k].link = (docs[k].ext_link != '') ?
- docs[k].ext_link :
- 'http://mikevalstar.com/Blog/' + docs[k].sid + "/" + Util.link_title(docs[k].title);
- docs[k].guid = 'http://mikevalstar.com/Blog/' + docs[k].sid + "/" + Util.link_title(docs[k].title);
- docs[k].isPermaLink = true;
- }
-
- res.header('Content-Type', 'application/xml');
- res.render('rss2.0.template.jade', {
- dateFormat: Util.GetRFC822Date
- , channel: {
- title: "Mike Valstar's Blog"
- , link: "http://mikevalstar.com"
- , description: "WEB DEVELOPMENT, PROGRAMMING, RANDOM THOUGHTS"
- }
- , items: docs
- , layout: false
- });
- });
- }
+ var query = blogpost.find(query);
+
+ query.sort("-posted").skip(page * perpage).limit(perpage).exec(function(err, docs){
+
+ for ( var k in docs ){
+ docs[k].link_title = Util.link_title(docs[k].title);
+ var new_short = jade.compile(docs[k].short);
+ docs[k].short = new_short();
+ docs[k].posted_human = Util.human_date(docs[k].posted);
+ }
+
+ query.count(function(err, postcount){
+ var totalpages = Math.ceil(postcount / perpage);
+ var nextpage = totalpages > page ? page + 2 : false;
+ var prevpage = page > 0 ? page : false;
+
+ var render_page = function(monthlist){
+ res.render('index', {
+ title: 'Blog',
+ posts: docs,
+ nextpage: nextpage,
+ prevpage: prevpage,
+ months: monthlist,
+ month_names: new Array("January","February","March","April","May","June","July","August","September","October","November","December"),
+ showFullNav: nav
+ });
+ }
+
+ // Production of month groups for Archive
+ var map = function(){
+ emit( this.posted.getFullYear() + '-' + this.posted.getMonth() , { count: 1, year: this.posted.getFullYear(), month: this.posted.getMonth() } );
+ };
+
+ var reduce = function(key, values){
+ var result = {
+ count: values.length,
+ month: values[0].month,
+ year: values[0].year
+ };
+ return result;
+ };
+
+ blogpost.collection.mapReduce(
+ map.toString()
+ , reduce.toString()
+ , {out: { inline: 1 }}
+ , function(err, monthlist){
+ monthlist.reverse();
+ render_page(monthlist);
+ }
+ );
+ });
+ });
+
+ }
+
+ , pageBlogPost: function(req, res){
+ var blogpost = this.db.model('blogPost');
+ blogpost.findOne({sid: req.params.id}, function(err, row){
+ if(!row){
+ res.redirect('/404');
+ return;
+ }
+
+ row.link_title = Util.link_title(row.title);
+ var new_short = jade.compile(row.short);
+ row.short = new_short();
+ var new_content = jade.compile(row.content);
+ row.content = new_content();
+ row.posted_human = Util.human_date(row.posted);
+ row.edited_human = Util.human_date(row.edited);
+
+ res.render('post', {
+ title: row.title,
+ post: row,
+ showFullNav: false
+ });
+ });
+ }
+
+ , RSS: function(req, res){
+ var blogpost = this.db.model('blogPost');
+ var query = blogpost.find().sort("-posted").limit(30).exec(function(err, docs){
+
+ for ( var k in docs ){
+ docs[k].title = docs[k].title;
+ var new_short = jade.compile(docs[k].short);
+ docs[k].description = new_short();
+ docs[k].pubDate = docs[k].posted;
+ docs[k].link = (docs[k].ext_link != '') ?
+ docs[k].ext_link :
+ 'http://mikevalstar.com/Blog/' + docs[k].sid + "/" + Util.link_title(docs[k].title);
+ docs[k].guid = 'http://mikevalstar.com/Blog/' + docs[k].sid + "/" + Util.link_title(docs[k].title);
+ docs[k].isPermaLink = true;
+ }
+
+ res.header('Content-Type', 'application/xml');
+ res.render('rss2.0.template.jade', {
+ dateFormat: Util.GetRFC822Date
+ , channel: {
+ title: "Mike Valstar's Blog"
+ , link: "http://mikevalstar.com"
+ , description: "WEB DEVELOPMENT, PROGRAMMING, RANDOM THOUGHTS"
+ }
+ , items: docs
+ , layout: false
+ });
+ });
+ }
};
View
40 lib/StaticPages.js
@@ -2,24 +2,24 @@ var StaticPages = module.exports = function StaticPages(){};
StaticPages.prototype = {
- initPages: function(app){
-
- // Routes
- app.get('/Projects', function(req, res){
- res.render('projects', {
- title: 'Home',
- showFullNav: false
- });
- });
-
- app.get('/About', function(req, res){
- res.render('about', {
- title: 'Home',
- showFullNav: false
- });
- });
-
- }
-
-
+ initPages: function(app){
+
+ // Routes
+ app.get('/Projects', function(req, res){
+ res.render('projects', {
+ title: 'Home',
+ showFullNav: false
+ });
+ });
+
+ app.get('/About', function(req, res){
+ res.render('about', {
+ title: 'Home',
+ showFullNav: false
+ });
+ });
+
+ }
+
+
};
View
114 lib/Util.js
@@ -1,62 +1,62 @@
var dateFormat = require('dateformat');
var Util = module.exports = {
-
- escapeRegEx: function(str) {
- return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
- }
-
- , link_title: function(title){
- return title
- .replace(/ /gi, " ")
- .replace(/ /gi, "_")
- .replace(/'/gi, "")
- .replace(/;/gi, "")
- .replace(/:/gi, "")
- .replace(/\./gi, "")
- .replace(/__/gi, "_");
- }
-
- , human_date: function(dt){
- return dateFormat(dt, "mmmm d, yyyy - h:MM TT");
- }
-
- , GetRFC822Date: function(oDate){
-
- // allow for empty request
- if(typeof(oDate) == "undefined" || !oDate) oDate = new Date();
-
- //Pads numbers with a preceding 0 if the number is less than 10.
- var LZ = function(val){ return (parseInt(val) < 10) ? "0" + val : val; }
-
- /* accepts the client's time zone offset from GMT in minutes as a parameter. returns the timezone offset in the format [+|-}DDDD */
- var getTZOString = function(timezoneOffset){
- var hours = Math.floor(timezoneOffset/60);
- var modMin = Math.abs(timezoneOffset%60);
- var s = new String();
- s += (hours > 0) ? "-" : "+";
- var absHours = Math.abs(hours)
- s += (absHours < 10) ? "0" + absHours :absHours;
- s += ((modMin == 0) ? "00" : modMin);
- return(s);
- }
-
- var aMonths = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
- var aDays = new Array( "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
- var dtm = new String();
-
- dtm = aDays[oDate.getDay()] + ", ";
- dtm += LZ(oDate.getDate()) + " ";
- dtm += aMonths[oDate.getMonth()] + " ";
- dtm += oDate.getFullYear() + " ";
- dtm += LZ(oDate.getHours()) + ":";
- dtm += LZ(oDate.getMinutes()) + ":";
- dtm += LZ(oDate.getSeconds()) + " " ;
- dtm += getTZOString(oDate.getTimezoneOffset());
- return dtm;
- }
-
-
+
+ escapeRegEx: function(str) {
+ return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
+ }
+
+ , link_title: function(title){
+ return title
+ .replace(/ /gi, " ")
+ .replace(/ /gi, "_")
+ .replace(/'/gi, "")
+ .replace(/;/gi, "")
+ .replace(/:/gi, "")
+ .replace(/\./gi, "")
+ .replace(/__/gi, "_");
+ }
+
+ , human_date: function(dt){
+ return dateFormat(dt, "mmmm d, yyyy - h:MM TT");
+ }
+
+ , GetRFC822Date: function(oDate){
+
+ // allow for empty request
+ if(typeof(oDate) == "undefined" || !oDate) oDate = new Date();
+
+ //Pads numbers with a preceding 0 if the number is less than 10.
+ var LZ = function(val){ return (parseInt(val) < 10) ? "0" + val : val; }
+
+ /* accepts the client's time zone offset from GMT in minutes as a parameter. returns the timezone offset in the format [+|-}DDDD */
+ var getTZOString = function(timezoneOffset){
+ var hours = Math.floor(timezoneOffset/60);
+ var modMin = Math.abs(timezoneOffset%60);
+ var s = new String();
+ s += (hours > 0) ? "-" : "+";
+ var absHours = Math.abs(hours)
+ s += (absHours < 10) ? "0" + absHours :absHours;
+ s += ((modMin == 0) ? "00" : modMin);
+ return(s);
+ }
+
+ var aMonths = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
+ var aDays = new Array( "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
+ var dtm = new String();
+
+ dtm = aDays[oDate.getDay()] + ", ";
+ dtm += LZ(oDate.getDate()) + " ";
+ dtm += aMonths[oDate.getMonth()] + " ";
+ dtm += oDate.getFullYear() + " ";
+ dtm += LZ(oDate.getHours()) + ":";
+ dtm += LZ(oDate.getMinutes()) + ":";
+ dtm += LZ(oDate.getSeconds()) + " " ;
+ dtm += getTZOString(oDate.getTimezoneOffset());
+ return dtm;
+ }
+
+
-
+
}
View
3  package.json
@@ -3,11 +3,12 @@
, "version": "0.0.3"
, "private": true
, "dependencies": {
- "express": ">=2.5.0 <3.0"
+ "express": "3.x"
, "jade": ">= 0.0.1"
, "markdown-js": ">= 0.0.1"
, "mongoose": ">= 2.4.0"
, "session-mongoose": ">= 0.0.1"
, "dateformat": ">= 0.0.1"
+ , "less-middleware": "*"
}
}
View
8 views/404.jade
@@ -1,3 +1,7 @@
-h2 404
+extends layout
-h3 Page Not Found
+block content
+
+ h2 404
+
+ h3 Page Not Found
View
62 views/about.jade
@@ -1,30 +1,34 @@
-h2 About
+extends layout
-#aboutContent
- h3 Contact Me
-
- p
- span.b Mike Valstar
- br
- a(href="mailto:mikevalstar@gmail.com") mikevalstar@gmail.com
- br
- | #1074 209 Fort York Blvd.
- br
- | Toronto, Ontario
- br
- | M5V 4A1
-
-
-#aboutFindMe
- h3 Find me on:
- ul
- li: a.twitter(href="http://twitter.com/#!/mikevalstar"): span Twitter
- li: a.google(href="https://plus.google.com/107235391839316017795r"): span Google+
- li: a.github(href="https://github.com/mikevalstar"): span GitHub
- li: a.stackoverflow(href="http://stackoverflow.com/users/197338/mike-valstar"): span StackOverflow
- li: a.reddit(href="http://www.reddit.com/user/mikevalstar/"): span Reddit
- li: a.facebook(href="https://www.facebook.com/mvalstar"): span Facebook
- li: a.flickr(href="http://www.flickr.com/photos/thrasher7/"): span Flickr
- li: a.linkedin(href="http://www.linkedin.com/profile/view?id=82063648"): span LinkedIn
-
-.clear
+block content
+
+ h2 About
+
+ #aboutContent
+ h3 Contact Me
+
+ p
+ span.b Mike Valstar
+ br
+ a(href="mailto:mikevalstar@gmail.com") mikevalstar@gmail.com
+ br
+ | #1074 209 Fort York Blvd.
+ br
+ | Toronto, Ontario
+ br
+ | M5V 4A1
+
+
+ #aboutFindMe
+ h3 Find me on:
+ ul
+ li: a.twitter(href="http://twitter.com/#!/mikevalstar"): span Twitter
+ li: a.google(href="https://plus.google.com/107235391839316017795r"): span Google+
+ li: a.github(href="https://github.com/mikevalstar"): span GitHub
+ li: a.stackoverflow(href="http://stackoverflow.com/users/197338/mike-valstar"): span StackOverflow
+ li: a.reddit(href="http://www.reddit.com/user/mikevalstar/"): span Reddit
+ li: a.facebook(href="https://www.facebook.com/mvalstar"): span Facebook
+ li: a.flickr(href="http://www.flickr.com/photos/thrasher7/"): span Flickr
+ li: a.linkedin(href="http://www.linkedin.com/profile/view?id=82063648"): span LinkedIn
+
+ .clear
View
14 views/admin/index.jade
@@ -1,7 +1,11 @@
-h2 Admin
+extends layout
-h3 You are logged in
+block content
-ul
- li
- a(href="/Admin/PostList") Blog Posts
+ h2 Admin
+
+ h3 You are logged in
+
+ ul
+ li
+ a(href="/Admin/PostList") Blog Posts
View
44 views/admin/login.jade
@@ -1,21 +1,25 @@
-h2 Admin - Login
+extends layout
-div.loginform
- form(method="post", action="/Admin/Login")
- h3 Login
-
- - if(typeof(error_text) != 'undefined')
- div.error
- span=error_text
-
- span Login
- - if(typeof(email) != 'undefined')
- input(type="text", name="email", value=email)
- - else
- input(type="text", name="email")
- br
- span Password
- input(type="password", name="password")
- br
- span &nbsp;
- input(type="submit", value="Login")
+block content
+
+ h2 Admin - Login
+
+ div.loginform
+ form(method="post", action="/Admin/Login")
+ h3 Login
+
+ - if(typeof(error_text) != 'undefined')
+ div.error
+ span=error_text
+
+ span Login
+ - if(typeof(email) != 'undefined')
+ input(type="text", name="email", value=email)
+ - else
+ input(type="text", name="email")
+ br
+ span Password
+ input(type="password", name="password")
+ br
+ span &nbsp;
+ input(type="submit", value="Login")
View
48 views/admin/post.jade
@@ -1,23 +1,27 @@
-h2 Edit Post
- span.postid= post.id
+extends layout
-form(method="post", action="/Admin/Post")
- input(type="hidden", name="id", value=post.id)
- h3 ID
- input(type="text", name="sid", value=post.sid)
- h3 Title
- input(type="text", name="title", style="width: 100%;", value=post.title)
- h3 Group
- input(type="text", name="group", style="width: 100%;", value=post.group)
- h4 Image Large
- input(type="text", name="img_lg", style="width: 50%;", value=post.img_lg)
- h4 Image Small
- input(type="text", name="img_sm", style="width: 50%;", value=post.img_sm)
- h3 Content
- textarea(name="short", style="width: 100%; height: 5em;")= post.short
- textarea(name="content", style="width: 100%; height: 20em;")= post.content
- span.i All content is in jade format
- h4 Link to external content
- input(type="text", name="ext_link", style="width: 100%;", value=post.ext_link)
- br
- input(type="submit", value="Save")
+block content
+
+ h2 Edit Post
+ span.postid= post.id
+
+ form(method="post", action="/Admin/Post")
+ input(type="hidden", name="id", value=post.id)
+ h3 ID
+ input(type="text", name="sid", value=post.sid)
+ h3 Title
+ input(type="text", name="title", style="width: 100%;", value=post.title)
+ h3 Group
+ input(type="text", name="group", style="width: 100%;", value=post.group)
+ h4 Image Large
+ input(type="text", name="img_lg", style="width: 50%;", value=post.img_lg)
+ h4 Image Small
+ input(type="text", name="img_sm", style="width: 50%;", value=post.img_sm)
+ h3 Content
+ textarea(name="short", style="width: 100%; height: 5em;")= post.short
+ textarea(name="content", style="width: 100%; height: 20em;")= post.content
+ span.i All content is in jade format
+ h4 Link to external content
+ input(type="text", name="ext_link", style="width: 100%;", value=post.ext_link)
+ br
+ input(type="submit", value="Save")
View
48 views/admin/postlist.jade
@@ -1,24 +1,28 @@
-h2 Admin - Post Listing
+extends layout
-table.aPostList
- thead
- tr
- th Post ID
- th Title
- th Int/Ext
- th Posted
- tbody
- - posts.forEach(function(item){
- tr
- td= item.sid
- td: a(href="/Admin/Post/" + item.sid)= item.title
- td
- - if(item.ext_link != ""){
- | External
- - }else{
- | Internal
- - }
- td: time= item.posted
- - })
+block content
-a(href="/Admin/NewPost") Create a new post
+ h2 Admin - Post Listing
+
+ table.aPostList
+ thead
+ tr
+ th Post ID
+ th Title
+ th Int/Ext
+ th Posted
+ tbody
+ - posts.forEach(function(item){
+ tr
+ td= item.sid
+ td: a(href="/Admin/Post/" + item.sid)= item.title
+ td
+ - if(item.ext_link != ""){
+ | External
+ - }else{
+ | Internal
+ - }
+ td: time= item.posted
+ - })
+
+ a(href="/Admin/NewPost") Create a new post
View
96 views/error.jade
@@ -1,56 +1,56 @@
!!! 5
html(lang="en")
head
- title Error - Mike Valstar - Programming &amp; Web Development
- link(rel='stylesheet', href='/css/css.css')
-
- script(src='http://code.jquery.com/jquery-1.7.min.js', type='text/javascript')
- script(src='/js/jquery.tweet.js', type='text/javascript')
- script(src='/js/jquery.ba-hashchange.min.js', type='text/javascript')
- script(src='/js/script.min.js', type='text/javascript')
- script(src='/js/mikevalstar.js', type='text/javascript')
-
- //if lt IE 9
- script(src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js")
+ title Error - Mike Valstar - Programming &amp; Web Development
+ link(rel='stylesheet', href='/css/css.css')
+
+ script(src='http://code.jquery.com/jquery-1.7.min.js', type='text/javascript')
+ script(src='/js/jquery.tweet.js', type='text/javascript')
+ script(src='/js/jquery.ba-hashchange.min.js', type='text/javascript')
+ script(src='/js/script.min.js', type='text/javascript')
+ script(src='/js/mikevalstar.js', type='text/javascript')
+
+ //if lt IE 9
+ script(src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js")
- script(type="text/javascript")
- var _gaq = _gaq || [];
- _gaq.push(['_setAccount', 'UA-1984894-13']);
-
- (function() {
- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
- })();
+ script(type="text/javascript")
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-1984894-13']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
body#mikevalstar
- #O
-
- #H
- h1: a(href="http://mikevalstar.com/") Mike Valstar
- #social
- //- a(href="#"): img(src="/img/rss.png", alt="RSS")
- a(href="https://github.com/mikevalstar"): img(src="/img/github.png", alt="Github")
- a(href="https://plus.google.com/107235391839316017795"): img(src="/img/google-plus.png", alt="Google+")
- a(href="http://twitter.com/#!/mikevalstar"): img(src="/img/twitter.png", alt="Twitter")
+ #O
+
+ #H
+ h1: a(href="http://mikevalstar.com/") Mike Valstar
+ #social
+ //- a(href="#"): img(src="/img/rss.png", alt="RSS")
+ a(href="https://github.com/mikevalstar"): img(src="/img/github.png", alt="Github")
+ a(href="https://plus.google.com/107235391839316017795"): img(src="/img/google-plus.png", alt="Google+")
+ a(href="http://twitter.com/#!/mikevalstar"): img(src="/img/twitter.png", alt="Twitter")
- h2 Web Development, Programming, Random Thoughts
-
- #Nav
- ul
- li#NBlog: a(href="/Blog") Blog
- li#NProjects: a(href="/Projects") Projects
- li#NAbout: a(href="/About") About
- li#NTwitter: div Twitter Feed
- div.clear
-
- #C
- #CC
- h2 500 Error
+ h2 Web Development, Programming, Random Thoughts
+
+ #Nav
+ ul
+ li#NBlog: a(href="/Blog") Blog
+ li#NProjects: a(href="/Projects") Projects
+ li#NAbout: a(href="/About") About
+ li#NTwitter: div Twitter Feed
+ div.clear
+
+ #C
+ #CC
+ h2 500 Error
- - if(typeof(stack) != 'undefined')
- pre: code.stack!=stack
- - else
- There was an error rendering this page. Sorry for the inconvenience.
-
- #F Mike Valstar &copy; 2011
+ - if(typeof(stack) != 'undefined')
+ pre: code.stack!=stack
+ - else
+ There was an error rendering this page. Sorry for the inconvenience.
+
+ #F Mike Valstar &copy; 2011
View
116 views/index.jade
@@ -1,56 +1,60 @@
-#blogtoolbar
- h3 Archive
-
- ul
- - if(months && months.length > 0){
- - months.forEach(function(item){
- li
- a(href="/Blog/#{item.value.year}/#{item.value.month}") #{item.value.year} - #{month_names[item.value.month]}
- small &nbsp;(#{item.value.count})
- - });
- - }
-
- .clear
-
-h2 Blog
-
-- if(posts && posts.length > 0){
- - posts.forEach(function(item){
- .blogMini
- h3
- - if(item.ext_link != ""){
- a(href=item.ext_link) #{item.title}
- - }else{
- a(href="/Blog/#{item.sid}/#{item.link_title}") #{item.title}
- - }
- h5 Posted on
- time(datetime=item.posted) #{item.posted_human}
-
- - if(item.img_sm != '')
- div.tc: img(src=item.img_sm)
-
- !=item.short
-
- - if(item.ext_link != ""){
- p.tr.small: a(href="/Blog/#{item.sid}/#{item.link_title}") Permalink
- - }else{
- p.tr: a(href="/Blog/#{item.sid}/#{item.link_title}") Read More…
- - }
-
- - })
-
- - if(nextpage){
- .fr
- a(href="/Blog/#{nextpage}") Next &raquo;
- - }
-
- - if(prevpage){
- .fl
- a(href="/Blog/#{prevpage}") &laquo; Previous
- - }
-
- .clear
-
-- }else{
-em No posts could be found.
-- }
+extends layout
+
+block content
+
+ #blogtoolbar
+ h3 Archive
+
+ ul
+ - if(months && months.length > 0){
+ - months.forEach(function(item){
+ li
+ a(href="/Blog/#{item.value.year}/#{item.value.month}") #{item.value.year} - #{month_names[item.value.month]}
+ small &nbsp;(#{item.value.count})
+ - });
+ - }
+
+ .clear
+
+ h2 Blog
+
+ - if(posts && posts.length > 0){
+ - posts.forEach(function(item){
+ .blogMini
+ h3
+ - if(item.ext_link != ""){
+ a(href=item.ext_link) #{item.title}
+ - }else{
+ a(href="/Blog/#{item.sid}/#{item.link_title}") #{item.title}
+ - }
+ h5 Posted on
+ time(datetime=item.posted) #{item.posted_human}
+
+ - if(item.img_sm != '')
+ div.tc: img(src=item.img_sm)
+
+ !=item.short
+
+ - if(item.ext_link != ""){
+ p.tr.small: a(href="/Blog/#{item.sid}/#{item.link_title}") Permalink
+ - }else{
+ p.tr: a(href="/Blog/#{item.sid}/#{item.link_title}") Read More…
+ - }
+
+ - })
+
+ - if(nextpage){
+ .fr
+ a(href="/Blog/#{nextpage}") Next &raquo;
+ - }
+
+ - if(prevpage){
+ .fl
+ a(href="/Blog/#{prevpage}") &laquo; Previous
+ - }
+
+ .clear
+
+ - }else{
+ em No posts could be found.
+ - }
View
105 views/layout.jade
@@ -1,56 +1,57 @@
!!! 5
html(lang="en")
- head
- title #{title} - Mike Valstar - Programming &amp; Web Development
-
- link(href="/RSS", rel="alternate", type="application/rss+xml", title="Mike Valstar - Programming &amp; Web Development")
-
- link(rel='stylesheet', href='/css/css.css')
-
- script(src='http://code.jquery.com/jquery-1.7.min.js', type='text/javascript')
- script(src='/js/jquery.tweet.js', type='text/javascript')
- script(src='/js/jquery.ba-hashchange.min.js', type='text/javascript')
- script(src='/js/script.min.js', type='text/javascript')
- script(src='/js/mikevalstar.js', type='text/javascript')
-
- //if lt IE 9
- script(src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js")
+ head
+ title #{title} - Mike Valstar - Programming &amp; Web Development
+
+ link(href="/RSS", rel="alternate", type="application/rss+xml", title="Mike Valstar - Programming &amp; Web Development")
+
+ link(rel='stylesheet', href='/css/css.css')
+
+ script(src='http://code.jquery.com/jquery-1.7.min.js', type='text/javascript')
+ script(src='/js/jquery.tweet.js', type='text/javascript')
+ script(src='/js/jquery.ba-hashchange.min.js', type='text/javascript')
+ script(src='/js/script.min.js', type='text/javascript')
+ script(src='/js/mikevalstar.js', type='text/javascript')
+
+ //if lt IE 9
+ script(src="http://css3-mediaqueries-js.googlecode.com/svn/trunk/css3-mediaqueries.js")
- script(type="text/javascript")
- var _gaq = _gaq || [];
- _gaq.push(['_setAccount', 'UA-1984894-13']);
-
- (function() {
- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
- })();
+ script(type="text/javascript")
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-1984894-13']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
- body#mikevalstar
- #O
-
- #H
- h1: a(href="http://mikevalstar.com/") Mike Valstar
- #social
- //- a(href="#"): img(src="/img/rss.png", alt="RSS")
- a(href="https://github.com/mikevalstar"): img(src="/img/github.png", alt="Github")
- a(href="https://plus.google.com/107235391839316017795"): img(src="/img/google-plus.png", alt="Google+")
- a(href="http://twitter.com/#!/mikevalstar"): img(src="/img/twitter.png", alt="Twitter")
-
- h2 Web Development, Programming, Random Thoughts
-
- - var nclass = (showFullNav ? 'ex' : '')
- #Nav(class=nclass)
-
- ul
- li#NBlog: a(href="/Blog") Blog
- li#NProjects: a(href="/Projects") Projects
- li#NAbout: a(href="/About") About
- li#NTwitter: div Twitter Feed
- div.clear
-
- - var cclass = (showFullNav ? 'hide' : '')
- #C(class=cclass)
- #CC!= body
-
- #F Mike Valstar &copy; 2011
+ body#mikevalstar
+ #O
+
+ #H
+ h1: a(href="http://mikevalstar.com/") Mike Valstar
+ #social
+ //- a(href="#"): img(src="/img/rss.png", alt="RSS")
+ a(href="https://github.com/mikevalstar"): img(src="/img/github.png", alt="Github")
+ a(href="https://plus.google.com/107235391839316017795"): img(src="/img/google-plus.png", alt="Google+")
+ a(href="http://twitter.com/#!/mikevalstar"): img(src="/img/twitter.png", alt="Twitter")
+
+ h2 Web Development, Programming, Random Thoughts
+
+ - var nclass = (showFullNav ? 'ex' : '')
+ #Nav(class=nclass)
+
+ ul
+ li#NBlog: a(href="/Blog") Blog
+ li#NProjects: a(href="/Projects") Projects
+ li#NAbout: a(href="/About") About
+ li#NTwitter: div Twitter Feed
+ div.clear
+
+ - var cclass = (showFullNav ? 'hide' : '')
+ #C(class=cclass)
+ #CC
+ block content
+
+ #F Mike Valstar &copy; 2011
View
84 views/post.jade
@@ -1,42 +1,46 @@
-.blogPost
-
- h2
- a(href="/Blog/#{post.sid}/#{post.link_title}") #{post.title}
- h5 Posted on
- time(datetime=post.posted) #{post.posted_human}
-
- - if(post.img_lg != '')
- div.tc: img(src=post.img_lg)
-
- - if(post.content == ''){
- !=post.short
- - } else {
- !=post.content
- - }
-
- - if(post.ext_link != "")
- .ext_link Read more:
- a(href=post.ext_link) #{post.ext_link}
-
-#disqus_identity bp_#{post.sid}
-#disqus_permalink
- a(href="http://mikevalstar.com/Blog/#{post.sid}/#{post.link_title}") http://mikevalstar.com/Blog/#{post.sid}/#{post.link_title}
-#disqus_thread
+extends layout
-script(type="text/javascript")
- /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
- var disqus_shortname = 'mikevalstar'; // required: replace example with your forum shortname
- disqus_identifier = $('#disqus_identity').html();
- disqus_url = $('#disqus_permalink a').attr('href');
-
- /* * * DON'T EDIT BELOW THIS LINE * * */
- (function() {
- var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
- dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
- (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
- })();
+block content
-noscript Please enable JavaScript to view the
- a(href="http://disqus.com/?ref_noscript") comments powered by Disqus.
-a.dsq-brlink(href="http://disqus.com")blog comments powered by
- span.logo-disqus Disqus
+ .blogPost
+
+ h2
+ a(href="/Blog/#{post.sid}/#{post.link_title}") #{post.title}
+ h5 Posted on
+ time(datetime=post.posted) #{post.posted_human}
+
+ - if(post.img_lg != '')
+ div.tc: img(src=post.img_lg)
+
+ - if(post.content == ''){
+ !=post.short
+ - } else {
+ !=post.content
+ - }
+
+ - if(post.ext_link != "")
+ .ext_link Read more:
+ a(href=post.ext_link) #{post.ext_link}
+
+ #disqus_identity bp_#{post.sid}
+ #disqus_permalink
+ a(href="http://mikevalstar.com/Blog/#{post.sid}/#{post.link_title}") http://mikevalstar.com/Blog/#{post.sid}/#{post.link_title}
+ #disqus_thread
+
+ script(type="text/javascript")
+ /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
+ var disqus_shortname = 'mikevalstar'; // required: replace example with your forum shortname
+ disqus_identifier = $('#disqus_identity').html();
+ disqus_url = $('#disqus_permalink a').attr('href');
+
+ /* * * DON'T EDIT BELOW THIS LINE * * */
+ (function() {
+ var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
+ dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
+ (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
+ })();
+
+ noscript Please enable JavaScript to view the
+ a(href="http://disqus.com/?ref_noscript") comments powered by Disqus.
+ a.dsq-brlink(href="http://disqus.com")blog comments powered by
+ span.logo-disqus Disqus
View
14 views/projects.jade
@@ -1,7 +1,11 @@
-h2 Projects
+extends layout
-p Coming soon…
+block content
-p Please check out my
- a.github(href="https://github.com/mikevalstar") github page
- | for some of my current projects
+ h2 Projects
+
+ p Coming soon…
+
+ p Please check out my
+ a.github(href="https://github.com/mikevalstar") github page
+ | for some of my current projects
View
216 views/rss2.0.template.jade
@@ -3,112 +3,112 @@
//- Category Domains
!!! xml
rss(version="2.0")
- channel
- //- Required channel elements
- title=channel.title
- link=channel.link
- description=channel.description
-
- //- Optional Cheannel Elements
- - if(typeof(channel.ttl) != 'undefined')
- ttl=channel.ttl
- - if(typeof(channel.rating) != 'undefined')
- rating=channel.rating
- - if(typeof(channel.skipHours) != 'undefined')
- skipHours=channel.skipHours
- - if(typeof(channel.skipDays) != 'undefined')
- skipDays=channel.skipDays
- - if(typeof(channel.language) != 'undefined')
- language=channel.language
- - if(typeof(channel.copyright) != 'undefined')
- copyright=channel.copyright
- - if(typeof(channel.generator) != 'undefined')
- generator=channel.generator
- - if(typeof(channel.managingEditor) != 'undefined')
- managingEditor=channel.managingEditor
- - if(typeof(channel.webMaster) != 'undefined')
- webMaster=channel.webMaster
-
- //- Image object: {url, title, link, width, height}
- - if(typeof(channel.image) != 'undefined')
- image
- url=channel.image.url
- title=channel.image.title
- link=channel.image.link
- - if(typeof(channel.image.width) != 'undefined')
- width=channel.image.width
- - if(typeof(channel.image.height) != 'undefined')