@@ -56,116 +67,107 @@
$ node blog
The blog should be running on your localhost at the 3000 port; go to http://localhost:3000 to view it. And it should look similar to the screenshot below.
-
+
-If you would like to make a post, go to the the url http://localhost:3000/admin in order to log in and use the admin settings. The password is 'narwhal' by default . To change the password, go to the file 'blog.js' and change the p variable at the top to your desired password.
-*Note: Change the t variable in 'blog.js' to your blog title (i.e t = 'Jared's Tech Blog'). Also, Change the st variable in 'blog.js' to whatever you would like your subtitle to be (i.e st = 'I am an App developer').
+If you would like to make a post, go to the the url http://localhost:3000/admin in order to log in and use the admin settings.
+The password is 'Your mongoDB password' by default . To change the password, go to the file /config/blogConfig.json
+and change the 'password' value
-
+*Note: You can also change the subtitle and title of the blog in the /config/blogConfig.json file (i.e st = 'Exploring the path of the Hackuto-Shinken').
+
+
When successfully logged in, your navigation bar should have three new options appended to it...
- Admin-New (create a new post)
- Admin-Delete (delete a post)
- Admin-Logout (log out of admin view)
+ Create Post
+ Edit/Delete Post
+ Log out
-
+
-Creating and deleting posts should be self-explanatory; however, creating a new static page similar to the default 'about' page is detailed below.
+Creating, editing and deleting posts should be self-explanatory.
+However, creating a new static page similar to the default 'about' page is detailed below.
Adding a static page
-To create a new page, first you must go to the 'layout.jade' file in the /views folder. Add the following code under the about 'li' tag which is in the 'ol' tag in the #nav div.
+To create a new page, first you must go to the 'default-layout.jade' file in the /views folder.
+Add the following code under the "About" 'a' tag which is in the div with the id 'widget-pages'
+
-a(href="/new-page-name")
- li new_page_name
+ #widgets
+ #widget-pages
+ h3.widget-title Pages
+ a.widget-section-link(href="/") Home
+ a.widget-section-link(href="/about") About
+ a.widget-section-link(href="/newPage") New Page
+
-Now create a new view with whatever name you want (i.e. new_page_name.jade) in the /views folder. Add the following code to your new view
+Now create a new view with whatever name you want (i.e. newPage.jade) in the /views folder.
+Add the following code to your new view
-extends layout
+extends default-layout
+
-block wrapper_content
- .container
- h1 new_page_name
- br
- p random information
+block blog-content
+ .container
+ h1 This is the new page
+ br
+ p Random information
Now modify the get functions in the 'blog.js' file.
The new modified code
-////////get////////
app.get('/', home.index);
-app.get('/admin/delete', admin.delete);
-app.get('/admin/new', admin.new);
-app.get('/post/:id', post.post_view);
-app.get('/admin' || '/admin/', admin.admin_check);
-app.get('/admin/logout', function(req,res){
- delete req.session.admin;
- console.log('logged-out')
- res.redirect('/');
-});
+app.get('/post/:id/:title', post.get);
+app.get('/about', function (req, res) {
+ res.render('about', {title: blogConfig.title + " - About", admin: req.session.admin});
-app.get('/about', function(req, res) {
- res.render('about', { title: t, admin:req.session.admin});
-
});
-//The code you added
-app.get('/new-page-name', function(req, res) {
- res.render('new_page_name', { title: t, admin:req.session.admin});
+
+// The code you added
+app.get('/newPage', function(req, res){
+ res.render("newPage", {title: "New Page", admin: req.session.admin});
});
-///////////////////
-You should now be able to go the the '/new-page-name' route and have a view similar to what is below
+You should now be able to go the the '/newPage' route and have a view similar to what is below
-
+
Adding a side widget
-In order to add a side widget, or simply a box under the "Latest Posts" box, you must go to the file 'layout.jade' and insert this line
+In order to add a side widget, you must go to the file 'default-layout.jade' and insert your widget inside
+the div with id "widgets"
-.widget
-
+ #widgets
-Exactly where it is inserted below
+
+
+
+
+For instance the "Latest Posts widgets looks like this
-#box
- #content
- #wrapper
- block wrapper_content
- if(typeof posts == 'undefined')
- .widget
- a(href='/') Back to home
- else
- .widget
- p(style='font-size: 150%; font-weight:bold; border-bottom: 1px solid #b1b1b1;padding-bottom: 5px;margin-bottom: 4px;') Latest Posts
- br
- pre
- for post in posts
- table(id='post_table', style='padding-top:10px;border-bottom:1px solid #ddd')
- tr
- td
- #left
- label(style='font-size: 130%;') -  
- td
- #right
- a(href='/post/#{post._id}/#{post.title_sub}', style='font-size: 130%;')= post.title
- tr(style='height:10px;')
- .widget //the inserted code
+ #widget-posts
+ h3.widget-title Latest Posts
+ for post in posts
+ a.widget-section-link(href="/post/#{post._id}/#{post.friendly_link_title}") #{post.title}
-Now you can input any sort of information you'd like in your new widget box.*Note: Without any posts on your blog, the widget boxes will not be positioned adequately.
-
+
+Now you can input any sort of information you'd like in your new widget box. Remember that you can add any style
+you want to your widgets by editing the style.css file
+
-
Congratulations you now have a working blog suitable to your basic blogger needs.
+Congratulations! You now have a working blog suitable to your basic blogger needs.
+
Optional: Heroku Setup
*Note: You must have a heroku account along with the Heroku Toolbelt to follow this part of the tutorial
Simply follow the directions on this page to deploy the blog with heroku. However, in order to use MongoDB, you must enter the following command in the directory of your project
@@ -175,8 +177,24 @@ $ heroku addons:add mongohq:sandbox
This addon is a free starter package for running a server with a MongoDB backend by MongoHQ. This is essentially all you need to setup the basic functions to your new blog.
+
+Contributors
+
+
Contact
-Contact the developer here Email: jawerty210@gmail.com Website: http://wrightdev.herokuapp.com
+Contact the developers here
+
+
+Email: jawerty210@gmail.com , website: http://jawerty.github.io
+
+
+Email: kenshiro@kenshiro.me , website: http://kenshiro.me
+
+
MIT LICENSE
The MIT License (MIT) Copyright (c) 2012 Jared Wright
diff --git a/blog.js b/blog.js
index 0052201..3a75ba3 100644
--- a/blog.js
+++ b/blog.js
@@ -1,87 +1,121 @@
- t = 'Node2Blog';
- st = 'A simple blog made in Node.js'
- p = 'narwhal';
-/**
- * Module dependencies.
- */
-var mongoose = require('mongoose');
-var db = require('./db');
-var post = mongoose.model('post');
+var blogConfig = require("./config/blogConfig"),
+ postCache = require("./cache/postCache"),
+ db = require('./db/dbConnection');
+console.log("Blog config loaded [name=%s, subtitle=%s]", blogConfig.title, blogConfig.subTitle);
- //change t to whatever you want your blog to be called
- //change p to whatever you want your password to be
+p = blogConfig.password;
- admin = null;
- var error;
+admin = null;
+var error;
-var express = require('express')
- , home = require('./routes/home')
- , admin = require('./routes/admin')
- , post = require('./routes/post')
- , http = require('http')
- , path = require('path');
+
+var express = require('express'),
+ home = require('./routes/home'),
+ admin = require('./routes/admin'),
+ post = require('./routes/post'),
+ misc = require("./routes/misc"),
+ http = require('http'),
+ path = require('path');
var app = express();
var store = new express.session.MemoryStore;
//MIDDLEWARE
-app.configure(function(){
+app.configure(function () {
app.use(express.logger('dev'));
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
- app.use(express.favicon());
+ app.use(express.favicon(path.join(__dirname, 'public/favicon.ico')));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser());
app.use(express.session({ secret: 'ar4452ihbb34y2b3hu4kvk2u34vu23y4yu324k',
- store: store
- }));
+ store: store
+ }));
app.use(express.static(path.join(__dirname, 'public')));
app.use(app.router);
+
+ //Handling of 404 and 500 pages
+ app.use(function(req, res){
+ res.status(400);
+ res.render("404", {title: "Page not found"});
+ });
});
-app.configure('development', function(){
+app.configure('development', function () {
app.use(express.errorHandler());
});
+//Setting up "global locals" that will be used across the whole application
+app.locals = ({
+ blogTitle: blogConfig.title,
+ blogSubtitle: blogConfig.subTitle,
+ fbAppId: blogConfig.facebookAppId,
+ blogSite: blogConfig.siteUrl
+});
-////////get methods////////
+/***********************************************************************************************************************
+ ************************************************ GET HANDLERS *********************************************************
+ ***********************************************************************************************************************/
app.get('/', home.index);
-app.get('/admin/delete', admin.delete);
+app.get('/post/:title', post.get);
+app.get('/about', function (req, res) {
+ res.render('about', {title: blogConfig.title + " - About", admin: req.session.admin});
+
+});
+app.get('/projects', function (req, res) {
+ res.render('projects', {title: blogConfig.title + " - Projects", admin: req.session.admin});
+
+});
+
+app.get('/admin/editOrDelete', admin.showPostsToEditOrDelete);
app.get('/admin/new', admin.new);
-app.get('/post/:id/:title', post.post_view);
app.get('/admin' || '/admin/', admin.admin_check);
app.get('/admin/:id/edit', admin.admin_edit);
-app.get('/admin/logout', function(req,res){
+app.get('/admin/logout', function (req, res) {
delete req.session.admin;
console.log('logged-out')
res.redirect('/');
});
-app.get('/about', function(req, res) {
- res.render('about', { title: t, subTitle:st, admin:req.session.admin});
-
-});
-///////////////////////////
+app.get('/rss.xml', misc.getRss);
-///////post methods////////
-app.post('/admin/delete', admin.delete_post_handler);
-app.post('/admin/new', admin.new_post_handler);
+
+/**********************************************************************************************************************
+*********************************************** POST HANDLERS *********************************************************
+***********************************************************************************************************************/
+app.post('/admin/delete/:id', admin.deletePost);
+app.post('/admin/new', admin.createNewPost);
app.post('/admin' || '/admin/', admin.admin_check_post_handler);
-app.post('/admin/:id/edit', admin.admin_edit_post_handler);
+app.post('/admin/edit/:id', admin.showPostToEdit);
+app.post("/admin/postEdit/:id", admin.editAndSavePost);
app.post('/', home.home_post_handler);
-app.post('/post/:id/:title', post.post_view_post_handler);
-///////////////////////////
+app.post('/post/:id/:friendlyLink', post.saveComment);
+
+
+
+//Load the latest posts
+postCache.setApp(app);
+postCache.loadPosts(function(err, posts){
+ if(err){
+ //Cannot start the server as an error occured loading posts
+ console.log("An error occurred while trying to load posts [error=%s]", err);
+ throw new Error("" + err);
+ }else{
+ console.log("Loaded %d posts", posts.length);
+ //Server start
+ var serverPort = blogConfig.port;
+ http.createServer(app).listen(serverPort, function () {
+ console.log("Your blog is running on port " + serverPort);
+ });
+ }
+})
-//Server start
-http.createServer(app).listen(app.get('port'), function(){
- console.log("Your blog is running on port " + app.get('port'));
-});
diff --git a/cache/postCache.js b/cache/postCache.js
new file mode 100644
index 0000000..31e67df
--- /dev/null
+++ b/cache/postCache.js
@@ -0,0 +1,36 @@
+var PostModel = require('./../db/model/post');
+
+function PostCache(){}
+
+PostCache.prototype = {}
+
+var app = null;
+var posts = null;
+
+PostCache.prototype.loadPosts = function(callback){
+ PostModel.find({}).sort({date: "desc"}).execFind(function(err, blogPosts){
+ if(err){
+ process.nextTick(function(){
+ callback(true);
+ })
+ }else{
+ posts = blogPosts ? blogPosts : [];
+ if(app){
+ app.locals.posts = posts;
+ }
+ callback(false, posts);
+ }
+ });
+}
+
+PostCache.prototype.setApp = function (application){
+ app = application;
+}
+
+PostCache.prototype.get = function(){
+ return posts;
+}
+
+var cache = new PostCache();
+
+module.exports = cache;
diff --git a/config/blogConfig.json b/config/blogConfig.json
new file mode 100644
index 0000000..5f1c94c
--- /dev/null
+++ b/config/blogConfig.json
@@ -0,0 +1,11 @@
+{
+ "author": "Your blog author's name",
+ "siteUrl": "Your blog's URL (must finish with a '/' character)",
+ "iconUrl": "Your blog's icon URL",
+ "name": "Your blog name",
+ "subTitle": "Your blog subtitle name",
+ "password": "Your mongoDB password",
+ "port": "Your blog port" ,
+ "facebookAppId": "Your Facebook APP ID",
+ "facebookAppSecret": "your facebook APP Secret"
+}
\ No newline at end of file
diff --git a/db.js b/db.js
deleted file mode 100644
index 8d58bb0..0000000
--- a/db.js
+++ /dev/null
@@ -1,34 +0,0 @@
-//PREREQUISITES
-var mongoose = require('mongoose')
-var Schema = mongoose.Schema
- ,ObjectId = Schema.ObjectId;
-
-
-//process.env.MONGOHQ_URL is for deploying on heroku
-//node2blog can be chagens to whatever you want your local database to be called i.e. 'my database'
-var db_url = process.env.MONGOHQ_URL || "mongodb://localhost:27017/your_database_name",
- db = mongoose.connect(db_url);
-
-//The MongoDB Schema for your posts
-
-var postSchema = new Schema({
- id: ObjectId,
- title: String,
- title_sub: String,
- content: String,
- date: String
-})
-
-//The MongoDB Schema for your each post's comments
-var commentSchema = new Schema({
- id: ObjectId,
- postid: String,
- title_sub: String,
- name: String,
- comment: String,
- date: String
-})
-
-
-var post = db.model('post', postSchema);
-var comment = db.model('comment', commentSchema);
\ No newline at end of file
diff --git a/db/dbConnection.js b/db/dbConnection.js
new file mode 100644
index 0000000..6a50bc9
--- /dev/null
+++ b/db/dbConnection.js
@@ -0,0 +1,10 @@
+//PREREQUISITES
+var mongoose = require('mongoose'),
+ Schema = mongoose.Schema;
+
+
+//process.env.MONGOHQ_URL is for deploying on heroku
+//node2blog can be changed to whatever you want your local database to be called i.e. 'my database'
+var db_url = process.env.MONGOHQ_URL || "mongodb://localhost:27017/your_database_name",
+db = mongoose.connect(db_url);
+
diff --git a/db/model/comment.js b/db/model/comment.js
new file mode 100644
index 0000000..2694d99
--- /dev/null
+++ b/db/model/comment.js
@@ -0,0 +1,11 @@
+var mongoose = require("mongoose"),
+ ObjectId = mongoose.Schema.ObjectId;
+
+var commentSchema = new mongoose.Schema({
+ post_id: {type: ObjectId, ref: "post"},
+ name: {type: String, require: true},
+ comment: {type: String, required: true},
+ date: {type: Date, default: new Date()}
+});
+
+module.exports = mongoose.model("comment", commentSchema);
\ No newline at end of file
diff --git a/db/model/post.js b/db/model/post.js
new file mode 100644
index 0000000..3062584
--- /dev/null
+++ b/db/model/post.js
@@ -0,0 +1,11 @@
+var mongoose = require("mongoose"),
+ ObjectId = mongoose.Schema.ObjectId;
+
+var PostSchema = new mongoose.Schema({
+ title: {type: String, required: true, index: {unique: true}},
+ friendly_link_title: {type: String, required: true},
+ content: {type: String, required: true},
+ date: {type: Date, default: new Date()}
+});
+
+module.exports = mongoose.model("post", PostSchema);
\ No newline at end of file
diff --git a/docs/node2blog_admin_page.png b/docs/node2blog_admin_page.png
new file mode 100644
index 0000000..9d1240f
Binary files /dev/null and b/docs/node2blog_admin_page.png differ
diff --git a/docs/node2blog_admin_page_login_screen.png b/docs/node2blog_admin_page_login_screen.png
new file mode 100644
index 0000000..2bbb5f4
Binary files /dev/null and b/docs/node2blog_admin_page_login_screen.png differ
diff --git a/docs/node2blog_main_screen.png b/docs/node2blog_main_screen.png
new file mode 100644
index 0000000..9b8718a
Binary files /dev/null and b/docs/node2blog_main_screen.png differ
diff --git a/docs/node2blog_new_page.png b/docs/node2blog_new_page.png
new file mode 100644
index 0000000..e71a3e9
Binary files /dev/null and b/docs/node2blog_new_page.png differ
diff --git a/package.json b/package.json
index 5856291..f4f6fdb 100644
--- a/package.json
+++ b/package.json
@@ -1,25 +1,26 @@
{
"name": "Node2Blog",
- "description": "Simple and easy to use blog template for your casual blogger.",
- "version": "0.2.0",
+ "description": "Simple and easy to use blog template for the casual blogger.",
+ "version": "1.0.0",
"author": {
- "name": "Jared Wright",
- "email": "jawerty210@gmail.com",
- "url": "http://wrightdev.herokuapp.com"
+ "name": "kenshiro-o",
+ "email": "kenshiro@kenshiro.me",
+ "url": "http://kenshiro.me"
},
"private": true,
"engines": {
- "node": "0.8.x",
- "npm": "1.1.x"
+ "node": ">=0.8.x",
+ "npm": ">=1.1.x"
},
"scripts": {
"start": "node blog"
},
"dependencies": {
- "express": "3.0.0rc5",
+ "express": "*",
"jade": "*",
- "mongoose":"*",
- "mongodb":"*"
+ "mongoose": "*",
+ "mongodb": "*",
+ "rss": "0.2.0"
}
}
diff --git a/public/favicon.ico b/public/favicon.ico
new file mode 100644
index 0000000..6048013
Binary files /dev/null and b/public/favicon.ico differ
diff --git a/public/images/HokutoNoKen.jpg b/public/images/HokutoNoKen.jpg
new file mode 100644
index 0000000..f6de01b
Binary files /dev/null and b/public/images/HokutoNoKen.jpg differ
diff --git a/public/images/kenshiro.jpg b/public/images/kenshiro.jpg
new file mode 100644
index 0000000..a8cca41
Binary files /dev/null and b/public/images/kenshiro.jpg differ
diff --git a/public/images/node-js-logo.jpeg b/public/images/node-js-logo.jpeg
new file mode 100644
index 0000000..bc52a44
Binary files /dev/null and b/public/images/node-js-logo.jpeg differ
diff --git a/public/javascripts/nicEdit.js b/public/javascripts/nicEdit.js
index 9a9951a..57515ec 100755
--- a/public/javascripts/nicEdit.js
+++ b/public/javascripts/nicEdit.js
@@ -28,7 +28,7 @@ var nicEditorConfig = bkClass.extend({
'outdent' : {name : __('Remove Indent'), command : 'outdent', noActive : true},
'hr' : {name : __('Horizontal Rule'), command : 'insertHorizontalRule', noActive : true}
},
- iconsPath : '../images/nicEditorIcons.gif',
+ iconsPath : '/images/nicEditorIcons.gif',
buttonList : ['save','bold','italic','underline','left','center','right','justify','ol','ul','fontSize','fontFamily','fontFormat','indent','outdent','image','upload','link','unlink','forecolor','bgcolor'],
iconList : {"bgcolor":1,"forecolor":2,"bold":3,"center":4,"hr":5,"indent":6,"italic":7,"justify":8,"left":9,"ol":10,"outdent":11,"removeformat":12,"right":13,"save":24,"strikethrough":15,"subscript":16,"superscript":17,"ul":18,"underline":19,"image":20,"link":21,"unlink":22,"close":23,"arrow":25}
diff --git a/public/stylesheets/footer.css b/public/stylesheets/footer.css
index 893b60b..5bb36f4 100644
--- a/public/stylesheets/footer.css
+++ b/public/stylesheets/footer.css
@@ -1,12 +1,37 @@
-#footer {
- width: 97.5%;
- text-align: center;
- float: left;
- padding: 15px;
- font-size: 17px;
- font-family: sans-serif;
- color: #393939;
- z-index: -1;
+#footerContainer {
+
+ /* IE10 Consumer Preview */
+ background-image: -ms-linear-gradient(bottom, #111 0%, #444 100%);
+
+ /* Mozilla Firefox */
+ background-image: -moz-linear-gradient(bottom, #111 0%, #444 100%);
+
+ /* Opera */
+ background-image: -o-linear-gradient(bottom, #111 0%, #444 100%);
+
+ /* Webkit (Safari/Chrome 10) */
+ background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #111), color-stop(1, #444));
+
+ /* Webkit (Chrome 11+) */
+ background-image: -webkit-linear-gradient(bottom, #111 0%, #444 100%);
+
+ /* W3C Markup, IE10 Release Preview */
+ background-image: linear-gradient(to top, #111 0%, #444 100%);
+
+ clear: both;
+ width: 100%;
+ text-align: center;
+ float: left;
+ padding: 15px;
+ font-size: 17px;
+ font-family: sans-serif;
+ color: #fff;
+ z-index: -1;
margin: 0 auto;
-
+
+ background-color: #000000;
+}
+
+#footerContainer p {
+ color: #FFF;
}
\ No newline at end of file
diff --git a/public/stylesheets/header.css b/public/stylesheets/header.css
index c450020..1c01cd9 100644
--- a/public/stylesheets/header.css
+++ b/public/stylesheets/header.css
@@ -1,41 +1,53 @@
@font-face {
- font-family: telegrafico;
- src: url("../images/telegrafico.ttf");
+ font-family: telegrafico;
+ src: url("../images/telegrafico.ttf");
}
+
#header {
- /*background:url('../images/micro_carbon.png');*/
-
- /* IE10 Consumer Preview */
- background-image: -ms-linear-gradient(bottom, #111 0%, #444 100%);
+ background: url('../images/micro_carbon.png');
+
+ /* IE10 Consumer Preview */
+ background-image: -ms-linear-gradient(bottom, #111 0%, #444 100%);
+
+ /* Mozilla Firefox */
+ background-image: -moz-linear-gradient(bottom, #111 0%, #444 100%);
+
+ /* Opera */
+ background-image: -o-linear-gradient(bottom, #111 0%, #444 100%);
- /* Mozilla Firefox */
- background-image: -moz-linear-gradient(bottom, #111 0%, #444 100%);
+ /* Webkit (Safari/Chrome 10) */
+ background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #111), color-stop(1, #444));
- /* Opera */
- background-image: -o-linear-gradient(bottom, #111 0%, #444 100%);
+ /* Webkit (Chrome 11+) */
+ background-image: -webkit-linear-gradient(bottom, #111 0%, #444 100%);
- /* Webkit (Safari/Chrome 10) */
- background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #111), color-stop(1, #444));
+ /* W3C Markup, IE10 Release Preview */
+ background-image: linear-gradient(to top, #111 0%, #444 100%);
+ height: 25%;
+ margin: 0;
+ border-bottom: 1px solid #555;
+}
- /* Webkit (Chrome 11+) */
- background-image: -webkit-linear-gradient(bottom, #111 0%, #444 100%);
+#titleContainer {
+ max-width: 1000px;
+ margin: 0 auto;
+}
- /* W3C Markup, IE10 Release Preview */
- background-image: linear-gradient(to top, #111 0%, #444 100%);
- height: 100%;
- margin: 0;
- border-bottom: 1px solid #555;
+.title {
+ font-size: 1.9em;
+ font-family: "Lato", "HelveticaNeue-Light", "Helvetica", "sans-serif";
+ color: #fff;
+ font-weight: bold;
}
-#title {
- max-width: 1000px;
- font-size: 500%;
- color: #fff;
- margin: 0 auto;
- font-family: telegrafico;
+
+#subTitleContainer {
+ max-width: 1000px;
+ margin: 0 auto;
+ margin-bottom: 15px;
}
-#subTitle {
- max-width: 1000px;
- font-size: 130%;
- margin: 0 auto;
- margin-bottom: 15px;
+
+.subTitle {
+ font-size: 1.5em;
+ font-style: italic;
+ color: #cbd9df;
}
\ No newline at end of file
diff --git a/public/stylesheets/nav.css b/public/stylesheets/nav.css
index bb6e81a..b2380a7 100644
--- a/public/stylesheets/nav.css
+++ b/public/stylesheets/nav.css
@@ -1,49 +1,52 @@
#nav {
- width: 100%;
- height: 45px;
- margin: 0px 0px 20px 0px;
-/* IE10 Consumer Preview */
-background-image: -ms-linear-gradient(bottom, #444 0%, #858585 100%);
+ width: 100%;
+ height: 45px;
+ margin: 0px 0px 20px 0px;
+ /* IE10 Consumer Preview */
+ background-image: -ms-linear-gradient(bottom, #444 0%, #858585 100%);
-/* Mozilla Firefox */
-background-image: -moz-linear-gradient(bottom, #444 0%, #858585 100%);
+ /* Mozilla Firefox */
+ background-image: -moz-linear-gradient(bottom, #444 0%, #858585 100%);
-/* Opera */
-background-image: -o-linear-gradient(bottom, #444 0%, #858585 100%);
+ /* Opera */
+ background-image: -o-linear-gradient(bottom, #444 0%, #858585 100%);
-/* Webkit (Safari/Chrome 10) */
-background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #444), color-stop(1, #858585));
+ /* Webkit (Safari/Chrome 10) */
+ background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #444), color-stop(1, #858585));
-/* Webkit (Chrome 11+) */
-background-image: -webkit-linear-gradient(bottom, #444 0%, #858585 100%);
+ /* Webkit (Chrome 11+) */
+ background-image: -webkit-linear-gradient(bottom, #444 0%, #858585 100%);
-/* W3C Markup, IE10 Release Preview */
-background-image: linear-gradient(to top, #444 0%, #858585 100%);
+ /* W3C Markup, IE10 Release Preview */
+ background-image: linear-gradient(to top, #444 0%, #858585 100%);
}
-#nav ol{
-
- max-width: 1000px;
- margin: 0 auto;
+#nav ol {
+
+ max-width: 1000px;
+ margin: 0 auto;
}
-#nav li{
- vertical-align: middle;
- text-align: center;
+
+#nav li {
+ vertical-align: middle;
+ text-align: center;
}
-#nav a{
- float:left;
- display:block;
- opacity:.9999;
- text-decoration: none;
- color: #fff;
- margin-right: 2%;
- margin-top: 1%;
- margin-bottom: 1%;
- font-size: 150%;
- font-family: verdana;
+
+#nav a {
+ float: left;
+ display: block;
+ opacity: .9999;
+ text-decoration: none;
+ color: #fff;
+ margin-right: 2%;
+ margin-top: 1%;
+ margin-bottom: 1%;
+ font-size: 1.5em;
+ font-family: "Helvetica", "HelveticaNeue-Light", "sans-serif";
}
-#nav a:hover{
- color: #888;
+
+#nav a:hover {
+ color: #888;
}
\ No newline at end of file
diff --git a/public/stylesheets/reset.css b/public/stylesheets/reset.css
index ac280c4..b6cd5aa 100644
--- a/public/stylesheets/reset.css
+++ b/public/stylesheets/reset.css
@@ -1,57 +1,66 @@
-body, html, div, blockquote, img, label, p, h1, h2, h3, h4, h5, h6, pre, ul, ol,
-li, dl, dt, dd, form, a, fieldset, input, th, td
-{
-margin: 0; padding: 0; border: 0; outline: none;
-}
-body
-{
-line-height: 1;
-font-size: 100%;
-background-color: #EEE;
-margin: 0 auto;
-height:100%;
-}
-h1, h2, h3, h4, h5, h6, p, label
-{
-font-size: 100%;
-margin: 0px;
-}
-h1{
- padding-top: 10px;
- padding-bottom: 20px;
-}
-ul, ol
-{
-list-style: none;
-}
-a
-{
-font-family: verdana;
-color: #505050;
-text-decoration: none;
-}
-a:hover
-{
-color: #808080;
-cursor: pointer;
-}
-p
-{
-font-size: 120%;
-font-family: sans-serif;
-color: #505050;
-}
-label
-{
-font-family:sans-serif;
-font-style: italic;
-color: #505050;
-}
-
-#box{
- max-width: 100%;
- min-width:100%;
- margin: 0 auto;
+html, body {
+ height: 100%;
+}
+
+body, html, div, blockquote, img, label, p, h1, h2, h3, h4, h5, h6, pre, ul, ol,
+li, dl, dt, dd, form, a, fieldset, input, th, td {
+ margin: 0;
+ padding: 0;
+ border: 0;
+ outline: none;
+}
+
+body {
+ line-height: 1;
+ font-size: 100%;
+ background-color: #FFFFFF;
+ margin: 0 auto;
+ height: 100%;
+}
+
+h1, h2, h3, h4, h5, h6, p, label {
+ font-size: 100%;
+ margin: 0px;
+}
+
+h1 {
+ padding-top: 10px;
+ padding-bottom: 20px;
+}
+
+ul, ol {
+ list-style: none;
+}
+
+a {
+ font-family: verdana;
+ color: #505050;
+ text-decoration: none;
+}
+
+a:hover {
+ color: #808080;
+ cursor: pointer;
+}
+
+p {
+ font-size: 120%;
+ font-family: sans-serif;
+ color: #505050;
+}
+
+label {
+ font-family: sans-serif;
+ font-style: italic;
+ color: #505050;
+}
+
+#box {
+ max-width: 100%;
+ min-width: 100%;
+ min-height: 100%;
+ height: auto !important;
+ margin: 0 auto -4em;
}
diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css
new file mode 100644
index 0000000..f100488
--- /dev/null
+++ b/public/stylesheets/style.css
@@ -0,0 +1,452 @@
+html, body{
+ font-family: Helvetica, Arial,sans-serif;
+ height: 100%;
+ width: 100%;
+}
+
+body:before {
+ content:"";
+ height:100%;
+ float:left;
+ width:0;
+ margin-top:-32767px;
+}
+
+h1{
+ margin: 2px;
+}
+
+h2{
+ margin: 2px;
+}
+
+h3{
+ margin: 2px;
+}
+
+h4{
+ margin: 2px;
+}
+
+h5{
+ margin: 2px;
+}
+
+h6{
+ margin: 2px;
+}
+
+#page-wrapper{
+ min-height: 100%;
+}
+
+header{
+ min-width: 940px;
+ width: 100%;
+ display: block;
+ text-align: center;
+ background-color: #131313;
+ color: #FFF;
+
+}
+
+#blog-main-title{
+ margin: 2px 0 2px 0;
+ font: "Lato", "HelveticaNeue-Light", "Helvetica", "sans-serif";
+}
+
+#blog-sub-title{
+ margin: 0 0 5px 0;
+ font-style: italic;
+}
+
+
+#content{
+ padding-top: 20px;
+ margin-left: auto;
+ margin-right: auto;
+ /*margin-top: 10px;*/
+ padding-bottom: 150px;
+
+ width: 940px;
+ overflow:auto;
+
+/*border: 1.5px solid #100d2c;*/
+ border-radius: 5px;
+ background-color: #FFF;
+}
+
+#main-content{
+ width: 70%;
+ margin: 5px 10px 0px 5px;
+ float: left;
+ background-color: #FFF;
+}
+
+#social-media-container{
+ width: 100%;
+ margin: 10px 5px;
+}
+
+.fb-like{
+ width: 100px;
+}
+
+.tweetbtn{
+ width: 100px;
+ display: inline;
+}
+
+
+/***********************************************************************************************************************
+****************************************************** POSTS ***********************************************************
+************************************************************************************************************************/
+
+.post-extract{
+ max-height: 110px;
+ overflow-y: hidden;
+ margin-bottom: 20px;
+ box-shadow: 2px 2px 2px 2px #131313;
+ border-radius: 5px;
+ padding-left: 2px;
+ padding-bottom: 5px;
+}
+
+.post-full{
+ box-shadow: 2px 2px 2px 2px #131313;
+ border-radius: 5px;
+ padding-left: 2px;
+ padding-right: 2px;
+ padding-bottom: 5px;
+}
+
+.post-title{
+ color: #2227a9;
+}
+
+.post-date{
+ color: #817c7f;
+ margin-bottom: 10px;
+}
+
+.post-title > a:link{
+ text-decoration: none;
+ color: #2227a9;
+}
+
+.post-title > a:visited{
+ text-decoration: none;
+ color: #2227a9;
+}
+
+.post-title > a:hover{
+ text-decoration: none;
+ color: #7b3ab7;
+}
+
+.post-title > a:active{
+ text-decoration: none;
+ color: #7b3ab7;
+}
+
+.post-content{
+ font-family: Tahoma, Arial, Helvetica, sans-serif;
+ font-size: 1em;
+ color: #000;
+}
+
+/*We are hacking forcefully overriding the inline style set by nicEdit*/
+.post-content > span{
+ font-family: Tahoma, Arial, Helvetica, sans-serif !important;
+ font-size: 1em !important;
+}
+
+.post-content > p{
+ font-family: Tahoma, Arial, Helvetica, sans-serif !important;
+ font-size: 1em !important;
+}
+
+/*We are hacking forcefully overriding the inline style set by nicEdit*/
+.post-content > div{
+ font-family: Tahoma, Arial, Helvetica, sans-serif !important;
+ font-size: 1em !important;
+}
+.post-comments{
+ margin-top: 10px;
+ padding-top: 5px;
+ border-top: 1px solid #000;
+}
+
+#comment-form{
+ width: 60%;
+ margin-left: 2px;
+}
+
+.commenter-name-input{
+ display: block;
+ width: 50%;
+ margin: 5px 0;
+ border-radius: 5px;
+}
+
+.comment-area{
+ display: block;
+ width: 80%;
+ margin: 0;
+ border-radius: 5px;
+}
+
+.submit-comment-button{
+ margin: 5px 0;
+ padding: 3px 5px;
+ background-color: #0dd257;
+ border-radius: 5px;
+ font-weight: bold;
+}
+
+.post-comment-container{
+ width: 100%;
+ padding-top: 3px;
+ margin: 5px 0;
+ background-color: #e6e6e6;
+}
+
+.post-comment{
+ margin-bottom: 3px;
+ margin-top: 2px;
+ font-size: 0.9em;
+ color: #131313;
+}
+
+.comment-signature{
+ margin: 0;
+ color: #100d2c;
+ font-size: 0.8em;
+ font-style: italic;
+}
+
+/***********************************************************************************************************************
+****************************************************** ADMIN ***********************************************************
+************************************************************************************************************************/
+
+#admin-bar{
+ width: 95%;
+ border: 2px solid black;
+ border-radius: 5px;
+ margin-left: 5px;
+ margin-bottom: 5px;
+}
+
+#admin-bar > ol > li{
+ display: inline;
+ padding: 5px;
+ font-size: 1.1em;
+ font-weight: bold;
+}
+
+
+.post-new-edit{
+ width: 100%;
+ padding-left: 5px;
+}
+
+#new-edit-post-header{
+ margin-bottom: 10px;
+ margin-top: 2px;
+ margin-left: 5px ;
+}
+
+#new-edit-post-form{
+ width: 95%;
+ padding-left: 5px;
+}
+
+#post-title-box{
+ width: 40%;
+ height: 1.5em;
+ border: 1px solid #DDD;
+ font-size: 1em;
+ margin-bottom: 10px;
+ border-radius: 5px;
+}
+
+#post-new-edit-content{
+ width: 100%;
+ min-height: 500px;
+ margin-bottom: 15px;
+}
+
+
+#submit-post-btn{
+ margin-top: 10px;
+ height: 2em;
+ font-size: 1.1em;
+ border-radius: 5px;
+ padding: 2px 5px 5px 2px;
+ border: 1px solid #DDD;
+ background-color: #0dd257;
+}
+
+#submit-edit-post-btn{
+ margin-top: 10px;
+ height: 2em;
+ font-size: 1.1em;
+ border-radius: 5px;
+ padding: 2px 5px 5px 2px;
+ border: 1px solid #DDD;
+ background-color: #2227a9;
+ color: #FFF;
+}
+
+
+
+.post-edit-form{
+ display: inline;
+ margin-right: 10px;
+}
+
+.post-delete-form{
+ display: inline;
+ margin-right: 10px;
+}
+
+.post-delete-button{
+ margin: 5px 0;
+ padding: 3px 5px;
+ background-color: #a90005;
+ border-radius: 5px;
+ font-weight: bold;
+ color: #FFF;
+}
+
+.post-edit-button{
+ margin: 5px 0;
+ padding: 3px 5px;
+ background-color: #2227a9;
+ border-radius: 5px;
+ font-weight: bold;
+ color: #FFF;
+}
+
+
+
+/***********************************************************************************************************************
+***************************************************** WIDGETS **********************************************************
+************************************************************************************************************************/
+
+#widgets{
+ width: 20%;
+ float: left;
+ background-color: #FFF;
+ margin-top: 5px;
+}
+
+
+#widget-pages{
+ border: 1px solid #100d2c;
+ border-radius: 5px;
+ margin-bottom: 10px;
+ background-color: #131313;
+ color: #FFF;
+ text-align: center;
+ box-shadow: 2px 2px 2px 2px #131313;
+}
+
+.widget-title{
+ text-align: center;
+ border-bottom: 1px solid #000000;
+}
+
+a.widget-section-link{
+ display: block;
+ border-bottom: 1px solid #d9d4d7;
+ margin: 0;
+
+ font-size: 1em;
+}
+
+a.widget-section-link:last-of-type{
+ border-bottom: none;
+ color: #FFF;
+}
+
+a.widget-section-link:link{
+ text-decoration: none;
+ color: #FFF;
+}
+
+a.widget-section-link:visited{
+ text-decoration: none;
+ color: #FFF;
+}
+
+a.widget-section-link:hover{
+ text-decoration: none;
+ color: #131313;
+ background-color: #FFF;
+}
+
+a.widget-section-link:active{
+ text-decoration: none;
+ color: #131313;
+ background-color: #FFF;
+}
+
+#widget-pages > h4:last-of-type{
+ border-bottom: none;
+}
+
+#widget-posts{
+ border: 1px solid #100d2c;
+ border-radius: 5px;
+ margin-bottom: 10px;
+ background-color: #131313;
+ color: #FFF;
+ text-align: left;
+ box-shadow: 2px 2px 2px 2px #131313;
+}
+
+footer{
+ position: relative;
+ margin-top: -150px;
+ height: 150px;
+ clear:both;
+
+ width: 100%;
+ /*box-shadow: 0px -2px 2px 2px #817c7f;*/
+ border-bottom: none;
+ margin-bottom: 0;
+ text-align: center;
+
+ background-color: #131313;
+ color: #FFF;
+}
+
+.footer-note{
+ padding-top: 30px;
+ font-size: 1em;
+ font-weight: bold;
+}
+
+
+/* Misc */
+
+a.no-link:link{
+ color: #2227a9;
+ text-decoration: none;
+}
+
+a.no-link:visited{
+ color: #2227a9;
+ text-decoration: none;
+}
+
+a.no-link:hover{
+ color: #7b3ab7;
+ text-decoration: none;
+}
+
+a.no-link:active{
+ color: #7b3ab7;
+ text-decoration: none;
+}
\ No newline at end of file
diff --git a/public/stylesheets/wrapper.css b/public/stylesheets/wrapper.css
index 9287873..d049aa6 100644
--- a/public/stylesheets/wrapper.css
+++ b/public/stylesheets/wrapper.css
@@ -1,192 +1,211 @@
-#content{
- width:100%;
- height: 100%;
- margin: 0 auto;
- max-width: 1000px;
+#content {
+ width: 100%;
+ height: 100%;
+ margin: 0 auto;
+ max-width: 1000px;
}
+
#wrapper {
- float:left;
- background-color: #f0f0f0;
- border: 1px solid #ddd;
- border-radius: 5px;
- width: 71.3%;
- height: 100%;
- padding: 25px;
- margin-bottom: 50px;
-
+ float: left;
+ background-color: #f0f0f0;
+ border: 1px solid #ddd;
+ border-radius: 5px;
+ width: 71.3%;
+ height: 100%;
+ padding: 25px;
+ margin-bottom: 50px;
}
+
.nicEdit-selected {
- border: 1px solid #ddd !important;
+ border: 1px solid #ddd !important;
}
+
.nicEdit-main {
- background-color: #fefefe;
+ background-color: #fefefe;
}
-
+
.nicEdit-button {
- background-color: #fff !important;
+ background-color: #fff !important;
}
+
iframe::-webkit-scrollbar {
width: 10px;
-
+
}
-
+
iframe::-webkit-scrollbar-track {
- -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
+ -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
border-radius: 3px;
background-color: #E9E9E9;
}
-
+
iframe::-webkit-scrollbar-thumb {
border-radius: 3px;
background-color: #555;
}
-.widget{
- float:right;
- background-color: #f0f0f0;
- border: 1px solid #ddd;
- border-radius: 5px;
- width: 16%;
-
- height: 100%;
- padding: 25px;
- margin-bottom: 20px;
- margin-left: 18px;
- white-space: pre-wrap; /* CSS3 */
- white-space: -moz-pre-wrap; /* Firefox */
- white-space: -pre-wrap; /* Opera <7 */
- white-space: -o-pre-wrap; /* Opera 7 */
- word-wrap: break-word; /* IE */
+.widget {
+ float: right;
+ background-color: #f0f0f0;
+ border: 1px solid #ddd;
+ border-radius: 5px;
+ width: 16%;
+
+ height: 100%;
+ padding: 25px;
+ margin-bottom: 20px;
+ margin-left: 18px;
+ white-space: pre-wrap; /* CSS3 */
+ white-space: -moz-pre-wrap; /* Firefox */
+ white-space: -pre-wrap; /* Opera <7 */
+ white-space: -o-pre-wrap; /* Opera 7 */
+ word-wrap: break-word; /* IE */
}
+
.container {
- white-space: pre-wrap; /* CSS3 */
- white-space: -moz-pre-wrap; /* Firefox */
- white-space: -pre-wrap; /* Opera <7 */
- white-space: -o-pre-wrap; /* Opera 7 */
- word-wrap: break-word; /* IE */
+ white-space: pre-wrap; /* CSS3 */
+ white-space: -moz-pre-wrap; /* Firefox */
+ white-space: -pre-wrap; /* Opera <7 */
+ white-space: -o-pre-wrap; /* Opera 7 */
+ word-wrap: break-word; /* IE */
}
+
.container h1 {
- font-size: 70px;
- font-family: sans-serif;
- color: #505050;
+ font-size: 1.5em;
+ font-family: sans-serif;
+ color: #505050;
}
+
.container p {
- font-size: 20px;
- font-family: sans-serif;
- color: #393939;
+ font-size: 20px;
+ font-family: sans-serif;
+ color: #393939;
}
-#formNew{
- margin-left: 20px;
- color:505050;
+
+#formNew {
+ margin-left: 20px;
+ color: 505050;
}
+
#formNew input[type='text'] {
- border: 1px solid #ddd;
- border-radius: 5px;
- width: 300px;
- height: 40px;
- font-size: 20px;
- padding-left: 10px;
- color:#505050;
+ border: 1px solid #ddd;
+ border-radius: 5px;
+ width: 300px;
+ height: 40px;
+ font-size: 20px;
+ padding-left: 10px;
+ color: #505050;
}
+
#formNew input[type='submit'] {
- border: 1px solid #A0A0A0;
- border-radius: 5px;
- width: 200px;
- height: 60px;
- font-size: 25px;
- background-color: #858585;
- color: #fff;
+ border: 1px solid #A0A0A0;
+ border-radius: 5px;
+ width: 200px;
+ height: 60px;
+ font-size: 25px;
+ background-color: #858585;
+ color: #fff;
}
-#formNew input[type='submit']:active{
- color:#858585;
- background-color: #f6f6f6;
+
+#formNew input[type='submit']:active {
+ color: #858585;
+ background-color: #f6f6f6;
}
+
#formNewTextarea {
- border-radius: 5px;
- border: 1px solid #ddd;
- width: 98%;
- height: 450px;
- font-size: 25px;
- padding: 10px;
- resize:none;
- outline:0px !important;
- -webkit-appearance:none;
+ border-radius: 5px;
+ border: 1px solid #ddd;
+ width: 98%;
+ height: 450px;
+ font-size: 25px;
+ padding: 10px;
+ resize: none;
+ outline: 0px !important;
+ -webkit-appearance: none;
background: #fff;
- color:#505050;
-}
-#post_table{
-
-}
-.post{
- border: 1px solid #ccc;
- background: #f7f7f7;
- padding: 25px;
- margin-bottom: 10px;
- white-space: pre-wrap; /* CSS3 */
- white-space: -moz-pre-wrap; /* Firefox */
- white-space: -pre-wrap; /* Opera <7 */
- white-space: -o-pre-wrap; /* Opera 7 */
- word-wrap: break-word; /* IE */
-}
-#left{
- float:left;
- width:20px;
-}
-#right{
- float:left;
- width: 140px;
-}
-#comment_form{
- border: 1px solid #ccc;
- border-radius: 5px;
- width: 500px;
- height: 80px;
- font-size: 20px;
- padding: 10px;
- resize:none;
- outline:0px !important;
- -webkit-appearance:none;
-}
-
-#submitComment{
- border: 1px solid #A0A0A0;
- border-radius: 5px;
- width: 130px;
- height: 30px;
- font-size: 20px;
- background-color: #858585;
- color: #fff;
-}
-#submitComment:active{
- color:#858585;
- background-color: #f6f6f6;
-
-}
-#nameComment{
- border: 1px solid #ccc;
- border-radius: 5px;
- width: 200px;
- height: 20px;
- font-size:20px;
- padding: 10px;
- resize:none;
- outline:0px !important;
- -webkit-appearance:none;
-}
-#admin_check{
- border: 1px solid #ccc;
- border-radius: 5px;
- width: 300px;
- height: 40px;
- font-size:25px;
- padding: 10px;
- resize:none;
- outline:0px !important;
- -webkit-appearance:none;
+ color: #505050;
+}
+
+#post_table {
+
+}
+
+.post {
+ border: 1px solid #ccc;
+ background: #f7f7f7;
+ padding: 25px;
+ margin-bottom: 10px;
+ white-space: pre-wrap; /* CSS3 */
+ white-space: -moz-pre-wrap; /* Firefox */
+ white-space: -pre-wrap; /* Opera <7 */
+ white-space: -o-pre-wrap; /* Opera 7 */
+ word-wrap: break-word; /* IE */
+}
+
+#left {
+ float: left;
+ width: 20px;
+}
+
+#right {
+ float: left;
+ width: 140px;
+}
+
+#comment_form {
+ border: 1px solid #ccc;
+ border-radius: 5px;
+ width: 500px;
+ height: 80px;
+ font-size: 20px;
+ padding: 10px;
+ resize: none;
+ outline: 0px !important;
+ -webkit-appearance: none;
+}
+
+#submitComment {
+ border: 1px solid #A0A0A0;
+ border-radius: 5px;
+ width: 130px;
+ height: 30px;
+ font-size: 20px;
+ background-color: #858585;
+ color: #fff;
+}
+
+#submitComment:active {
+ color: #858585;
+ background-color: #f6f6f6;
+
+}
+
+#nameComment {
+ border: 1px solid #ccc;
+ border-radius: 5px;
+ width: 200px;
+ height: 20px;
+ font-size: 20px;
+ padding: 10px;
+ resize: none;
+ outline: 0px !important;
+ -webkit-appearance: none;
+}
+
+#admin_check {
+ border: 1px solid #ccc;
+ border-radius: 5px;
+ width: 300px;
+ height: 40px;
+ font-size: 25px;
+ padding: 10px;
+ resize: none;
+ outline: 0px !important;
+ -webkit-appearance: none;
}
diff --git a/routes/admin.js b/routes/admin.js
index 943b89e..d2520bb 100644
--- a/routes/admin.js
+++ b/routes/admin.js
@@ -1,99 +1,121 @@
//Prerequisites
var mongoose = require('mongoose');
-var db = require('../db');
-var post = mongoose.model('post');
+var PostModel = require('./../db/model/post');
+var CommentModel = require("./../db/model/comment");
+var postCache = require("./../cache/postCache");
+
var error;
var date = new Date();
-//var post = mongoose.model( 'Post' );
//new post functions
exports.new = function(req, res){
if(req.session.admin == 'true'){
- post.find({}).sort('-_id').execFind(function(err, posts){
- if(posts){
- res.render('admin', { title: t, subTitle:st, posts:posts, admin:req.session.admin});
- }else{
- res.render('admin', { title: t, subTitle:st, posts:null, admin:req.session.admin })
- }
- });
+ res.render("admin_view", {admin:req.session.admin});
}else{
res.redirect('/')
}
};
-exports.new_post_handler = function(req, res){
-
- //specific time
- var hours = date.getHours();
- var minutes = date.getMinutes();
- var seconds = date.getSeconds();
- //date
- var month = date.getMonth() + 1;
- var year = date.getFullYear();
- var day = date.getDate();
-
- function formatAMPM(date) {
- var hours = date.getHours();
- var minutes = date.getMinutes();
- var ampm = hours >= 12 ? 'pm' : 'am';
- hours = hours % 12;
- hours = hours ? hours : 12; // the hour '0' should be '12'
- minutes = minutes < 10 ? '0'+minutes : minutes;
- var strTime = hours + ':' + minutes + ' ' + ampm;
- return strTime;
- }
- //organize time so it looks nice
- var time = month + '/' + day + '/' + year + " at " + formatAMPM(date);
+
+
+exports.createNewPost = function(req, res){
var title = req.body.title;
- var title_sub = title.split(' ').join('-');
-
+ if(!title || title.length == 0){
+ console.log("Post title provided is either null or empty. Returning an error message");
+ res.status(500);
+ res.render("500", {title: "Error"});
+ return;
+ }
+
+ var friendly_link_title = title.split(" ").join("-");
+ friendly_link_title = encodeURI(friendly_link_title);
var body = req.body.body;
+ if(!body || body.length == 0){
+ console.log("Post content provided is either null or empty. Returning an error message");
+ res.status(500);
+ res.render("500", {title: "Error"});
+ return;
+ }
//Submitting to database
- var newPost = post({
+ var newPost = new PostModel({
title: title,
- title_sub: title_sub,
- content: body,
- date: time
+ friendly_link_title: friendly_link_title,
+ content: body
+ });
+
+ newPost.save(function(err){
+ if(err){
+ console.log("An error occurred while trying to save post [post-title=%s, error=%s]", title, err);
+ res.status(500);
+ res.render("500", {title: "Error"});
+ }else{
+ console.log("Successfully saved new post [post-title=%s]", title);
+ postCache.loadPosts(function(err, posts){
+ if(err){
+ console.log("Unable to reload posts after saving a new one [error=%s]", err);
+ res.status(500);
+ res.render("500", {title: "Error"});
+ }else{
+ console.log("Successfully reloaded posts [number-of-posts=%d]", posts.length);
+ res.redirect('/');
+ }
+ });
+
+ }
});
- newPost.save();
- //redirecting to homepage
- res.redirect('/');
};
//deleting posts functions
-exports.delete = function(req, res){
+exports.showPostsToEditOrDelete = function(req, res){
if (req.session.admin == 'true'){
- post.find({}).sort('-_id').execFind(function(err, posts){
- if(posts){
- res.render('admin_delete', { title: t, subTitle:st, posts:posts, admin:req.session.admin});
- }else{
- res.render('admin_delete', { title: t, subTitle:st, posts:null, admin:req.session.admin })
- }
- });
+ res.render('admin_edit_delete', { title: "Edit Or Delete Posts", subTitle: "Edit Or Delete Posts", posts: postCache.get(), admin:req.session.admin});
}else{
res.redirect('/')
}
};
-exports.delete_post_handler = function(req, res){
- var title = req.body.title;
- var time = req.body.time;
- console.log(title);
- post.findOne({"title": title , "date":time}, function(err, match){
- if(match){
- match.remove()
- console.log('removed')
- res.redirect('/admin/delete')
- }else{
- res.redirect('/')
- }
+
+
+exports.deletePost = function(req, res){
+ var identifier = mongoose.Types.ObjectId(req.params.id);
+ if(!identifier){
+ res.status(500);
+ res.render("500", {title: "Error while trying to delete post."});
+ return;
+ }
+
+ var postToDelete = postCache.get().filter(function(post){
+ return post._id.equals(identifier);
});
+
+ if(!postToDelete || postToDelete.length != 1){
+ res.status(500);
+ res.render("500", {title: "Error: post to delete not found"});
+ }else{
+ postToDelete = postToDelete[0];
+ CommentModel.remove({post_id: identifier}, function(err){
+ if(err){
+ console.log("An error occurred while trying to delete comments [error=" + err + "]");
+ }
+ //Now delete the post
+ postToDelete.remove(function(err){
+ if(err){
+ console.log("Unable to remove post [id=" + identifier + "]");
+ }else{
+ console.log("Succesfully deleted post with title: " + postToDelete.title);
+ }
+ postCache.loadPosts(function(err, postsLoaded){
+ res.redirect("/");
+ });
+ });
+ });
+ }
};
exports.admin_edit = function(req, res){
if (req.session.admin == 'true'){
- post.findOne({_id: req.params.id}, function(err, post){
+ PostModel.findOne({_id: req.params.id}, function(err, post){
if(post){
res.render('admin_edit', {title: t, subTitle:st, post:post, admin:req.session.admin})
}else{
@@ -104,17 +126,60 @@ exports.admin_edit = function(req, res){
res.redirect('/')
}
};
-exports.admin_edit_post_handler = function(req, res){
- body = req.body.body;
- title = req.body.title;
-
- post.findOne({title: title}, function(err, post){
- post.content = body;
- post.save()
- console.log('edited post complete')
- res.redirect('/')
- })
+
+exports.editAndSavePost = function(req, res){
+ var identifier = mongoose.Types.ObjectId(req.params.id);
+ if(!identifier){
+ res.status(500);
+ res.render("500", {title: "Error while trying to edit post."});
+ return;
+ }
+
+ PostModel.update({_id: identifier}, {$set: { content: req.body.body }}, function(err){
+ if(err){
+ console.log("An error occurred when trying to update document [id= " + identifier + "]");
+ res.status(500);
+ res.render("500", {title: "Error while trying to save edited post."});
+ return;
+ }else{
+ console.log("Successfully updated post with [id=" + identifier + "]")
+ postCache.loadPosts(function(err, posts){
+ if(err){
+ console.log("Unable to reload posts after saving a new one [error=%s]", err);
+ res.status(500);
+ res.render("500", {title: "Error"});
+ }else{
+ console.log("Successfully reloaded posts [number-of-posts=%d]", posts.length);
+ res.redirect('/');
+ }
+ });
+ }
+ }) ;
+
}
+
+exports.showPostToEdit = function(req, res){
+ var identifier = mongoose.Types.ObjectId(req.params.id);
+ if(!identifier){
+ res.status(500);
+ res.render("500", {title: "Error while trying to edit post."});
+ return;
+ }
+
+ var postToEdit = postCache.get().filter(function(post){
+ return post._id.equals(identifier);
+ });
+
+ if(!postToEdit || postToEdit.length != 1){
+ res.status(500);
+ res.render("500", {title: "Error: post to edit not found"});
+ }else{
+ postToEdit = postToEdit[0];
+ res.render("admin_edit", {post: postToEdit});
+ }
+}
+
+
//admin check functions
exports.admin_check_post_handler = function(req, res){
var password1 = req.body.password;
diff --git a/routes/home.js b/routes/home.js
index d997273..ff3a47f 100644
--- a/routes/home.js
+++ b/routes/home.js
@@ -1,20 +1,13 @@
-//PREREQUISITES
-var mongoose = require('mongoose');
-var db = require('../db');
-var post = mongoose.model('post');
+/*
+ Homepage functions
+ */
-//Homepage functions
-exports.index = function(req, res){
-
- post.find({}).sort('-_id').execFind(function(err, posts){
- if(posts){
- res.render('home', { title: t, subTitle:st, posts:posts, admin:req.session.admin});
- }else{
- res.render('home', { title: t, subTitle:st, posts:null, admin:req.session.admin })
- }
- });
+exports.index = function(req, res){
+ res.render("index", {title: "Kenshiro's Hackuto blog - Home"});
};
+
+
exports.home_post_handler = function(req, res){
diff --git a/routes/misc.js b/routes/misc.js
new file mode 100644
index 0000000..3889f8d
--- /dev/null
+++ b/routes/misc.js
@@ -0,0 +1,40 @@
+var rss = require("rss"),
+ blogConfig = require("./../config/blogConfig"),
+ postCache = require("./../cache/postCache");
+
+//Refreshing the feed every 10 minutes (in
+var RSS_REFRESH_TIME_IN_MILLIS = 60 * 10 * 1000;
+var feedLastRefreshTime = null;
+var lastProducedXMLFeed = null;
+
+
+exports.getRss = function(req, res){
+ //TODO: This is actually inefficient. Instead register for an event that is fired upon PostCache update and only then refresh the feed
+ var now = new Date();
+ if(!feedLastRefreshTime || now.getTime() - feedLastRefreshTime.getTime() >= RSS_REFRESH_TIME_IN_MILLIS){
+ var feed = new rss({
+ title: blogConfig.title,
+ description: blogConfig.subTitle,
+ feed_url: blogConfig.siteUrl + "rss.xml",
+ site_url: blogConfig.siteUrl,
+ image_url: blogConfig.iconUrl,
+ author: blogConfig.author
+ });
+
+ var posts = postCache.get();
+ posts.forEach(function(post){
+ var dateOnly = post.date.toDateString();
+ feed.item({
+ title: post.title,
+ description: post.content,
+ url: blogConfig.siteUrl + "post" + "/" + post._id + "/" + post.friendly_link_title,
+ date: dateOnly
+ });
+ });
+
+ lastProducedXMLFeed = feed.xml();
+ feedLastRefreshTime = now;
+ }
+
+ res.send(lastProducedXMLFeed);
+};
\ No newline at end of file
diff --git a/routes/post.js b/routes/post.js
index 07651d4..9bb78f2 100644
--- a/routes/post.js
+++ b/routes/post.js
@@ -1,62 +1,91 @@
//PREREQUISITES
var mongoose = require('mongoose');
-var db = require('../db');
-var post = mongoose.model('post');
-var commentss = mongoose.model('comment');
-var date = new Date();
+var CommentModel = require('./../db/model/comment');
+var postCache = require("./../cache/postCache");
//Single post view
-exports.post_view = function(req, res){
-
- id = req.params.id;
- post.find({'_id': id}, function(err, post){
- if(post){
- commentss.find({'postid': id}, function(err, comment){
- if(comment){
- res.render('post_view', {title:t, subTitle:st, post:post, comment:comment, admin:req.session.admin})
- }else{
- res.render('post_view', {title:t, subTitle:st, post:post, comment:null, admin:req.session.admin})
- }
- });
-
- }else{
- res.render('post_view', {title:t, subTitle:st, post:null, comment:null, admin:req.session.admin})
- }
- });
+exports.get = function(req, res){
+ var friendLinkTitle = req.params.title;
+ var posts = postCache.get();
+ var matchedPosts = posts.filter(function(post){
+ return post.friendly_link_title === friendLinkTitle;
+ });
+
+ if (matchedPosts.length == 0){
+ console.log("Unable to retrieve post [post-link=%s]", friendLinkTitle);
+ //Post does not exist - return 404
+ res.status(400);
+ res.render("404", {title: "Page not found"});
+ }else{
+ var post = matchedPosts[0];
+ CommentModel.find({'post_id': post._id}).sort({date: "desc"}).exec(function(err, comments){
+ if(err){
+ console.log("An error occurred when trying to retrieve comments [post-id=%s, error=%s]", req.params.id, err);
+ res.status(500);
+ res.render("500", {title: "Error"});
+
+ } else{
+ comments = comments ? comments : [];
+ res.render("post", {title :post.title, post: post, comments: comments, admin:req.session.admin});
+ }
+ });
+ }
}
-exports.post_view_post_handler = function(req, res){
- id = req.params.id;
- title_sub = req.params.title;
- name = req.body.name || 'anon';
- comment = req.body.comment || 'Nothing';
- console.log(name + ' said ' + comment);
- console.log(id);
-
-
- //specific time
- var hours = date.getHours();
- var minutes = date.getMinutes();
- var seconds = date.getSeconds();
- //date
- var month = date.getMonth() + 1;
- var year = date.getFullYear();
- var day = date.getDate();
-
-
- //organize time so it looks nice
- var time = month + '/' + day + '/' + year + ' at ' + hours + ':' + minutes + ':' + seconds;
-
-
- //Submitting to database
- var newComment = commentss({
- postid: id,
- title_sub: title_sub,
- name: name,
- comment: comment,
- date: time
- });
- newComment.save();
-
- //redirecting to homepage
- res.redirect('/post/' + id + '/' + title_sub);
+
+
+exports.saveComment = function(req, res){
+ var postId = req.params.id;
+
+ if(!postId){
+ console.log("No post id provided to save commentWritten");
+ res.status(500);
+ res.render("500", {title: "Error"});
+
+ return;
+ }
+
+ var commentWritten = req.body.comment;
+ if(!commentWritten){
+ console.log("No comment has been sent [post-id=%s]", postId);
+ res.status(500);
+ res.render("500", {title: "Error"});
+
+ return;
+ }
+
+ var commenterName = req.body.name;
+ if(!commenterName){
+ console.log("No name was sent [post-id=%s]", postId);
+ res.status(500);
+ res.render("500", {title: "Error"});
+
+ return;
+ }
+
+
+ postId = mongoose.Types.ObjectId(postId);
+
+ console.log("New commentWritten [post-id=%s, commenter-name=%s, commentWritten=%s]", postId,
+ commenterName, commentWritten);
+
+ //Submitting to database
+ var newComment = CommentModel({
+ post_id: postId,
+ name: commenterName,
+ comment: commentWritten
+ });
+ newComment.save(function(err){
+ if(err){
+ console.log("Unable to save new commentWritten [post-id=%s, error=%s]", req.params.id, err)
+ res.status(500);
+ res.render("500", {title: "Error"});
+
+ }else{
+ //redirecting to post where the comment was just made
+ console.log("Successfully saved a comment for post [post-id=%s, commenter-name=%s]", req.params.id, commenterName)
+ res.redirect('/post/' + req.params.id + '/' + req.params.friendlyLink);
+ }
+
+ });
+
}
\ No newline at end of file
diff --git a/views/404.jade b/views/404.jade
new file mode 100644
index 0000000..eaa5e2e
--- /dev/null
+++ b/views/404.jade
@@ -0,0 +1,7 @@
+extends default-layout
+
+
+block blog-content
+ #page-error-container
+ h2 Page Not Found
+ p The page you are looking for does not exist.
\ No newline at end of file
diff --git a/views/500.jade b/views/500.jade
new file mode 100644
index 0000000..3bc81b9
--- /dev/null
+++ b/views/500.jade
@@ -0,0 +1,8 @@
+extends default-layout
+
+
+block wrapper_content
+ #page-error-container
+ h2 Error
+ p An error occured on the previous page! I will sort this out as soon as possible with some awesome Hackuto trick!
+ img(src="/images/kenshiro.jpg", width="300px", height="250px")
diff --git a/views/about.jade b/views/about.jade
index ca26cc9..dc183a8 100644
--- a/views/about.jade
+++ b/views/about.jade
@@ -1,8 +1,22 @@
-extends layout
-
-
-block wrapper_content
- .container
- h1 About page
- br
- p Stuff about me
\ No newline at end of file
+extends default-layout
+
+
+block blog-content
+ .post-full
+ h2 About Me
+ p
+ | I am Kenshiro. The goal of this blog is to share my musings and projects with the rest of the connected world.
+ p
+ | I hope you will enjoy reading my posts and commenting. I am currently mastering the deadly arts of Node.js & Google Go (I already am lethal on Core Java).
+ p
+ | I am also reachable via email on kenshiro@kenshiro.me : drop me a line and I'll make sure to respond!
+
+ h2 What is Hackuto-Shinken?
+ p
+ em Hackuto-Shinken
+ | is a variant of the mighty Hokuto Shinken
+
+ | , an invincible fictional Martial Arts, which can only be passed down to one heir (and... his name is Kenshiro;) ).
+ p
+ | Hackuto-Shinken is the collection of techniques that I have gleaned on my journey as a hacker and wannabe tech entrepreneur. I hope you will all embrace the path of the Hackuto!
+ img(src="/images/HokutoNoKen.jpg", width="300px", height="250px")
\ No newline at end of file
diff --git a/views/admin.jade b/views/admin.jade
index 2e584dd..5e6e4bd 100644
--- a/views/admin.jade
+++ b/views/admin.jade
@@ -1,8 +1,8 @@
extends layout
block wrapper_content
- script(src="../javascripts/nicEdit.js", type="text/javascript")
- script(type='text/javascript')
+ script(src="/javascripts/nicEdit.js", type="text/javascript")
+ script(type='text/javascript').
bkLib.onDomLoaded(nicEditors.allTextAreas);
.container
diff --git a/views/admin_delete.jade b/views/admin_delete.jade
deleted file mode 100644
index 5ae3c72..0000000
--- a/views/admin_delete.jade
+++ /dev/null
@@ -1,15 +0,0 @@
-extends layout
-
-block wrapper_content
- .container
- h1 Delete A Post
- for post in posts
- form(method='post')
- .post
- h1(style='font-size: 150%;')= post.title
- label(style='font-size: 100%;font-weight:normal;') Created on -> #{post.date}
- input(type='hidden', name='title', value='#{post.title}')
- input(type='hidden', name='time', value='#{post.date}')
- br
- br
- input(type='submit', id='delete_btn', value='DELETE POST')
\ No newline at end of file
diff --git a/views/admin_edit.jade b/views/admin_edit.jade
index d24fb13..8af6b31 100644
--- a/views/admin_edit.jade
+++ b/views/admin_edit.jade
@@ -1,21 +1,23 @@
-extends layout
+extends default-layout
-block wrapper_content
- script(src="../javascripts/nicEdit.js", type="text/javascript")
- script(type='text/javascript')
- bkLib.onDomLoaded(nicEditors.allTextAreas);
-
- .container
-
- #formNew
- h1 Edit Post
- form(method='post')
- input(type='text', name='title', value='#{post.title}',placeholder='Title (do not change)')
- label do not change title!!
- br
- br
- textarea(id='formNewTextarea', name='body', placeholder='Write your post here') #{post.content}
- br
- br
- input(type="submit", value="Create")
+block blog-content
+ script(src="/javascripts/nicEdit.js", type="text/javascript")
+ script(type='text/javascript')
+ bkLib.onDomLoaded(nicEditors.allTextAreas);
+ #admin-bar
+ ol
+ li
+ a(href="/admin/new") Create Post
+ li
+ a(href="/admin/editOrDelete") Edit/Delete Post
+ li
+ a(href="/admin/logout") Log out
+
+ .post-new-edit
+ h2#new-edit-post-header Edit Post
+ form(id="new-edit-post-form", method="post", action="/admin/postEdit/#{post._id}")
+ input(id="post-title-box" ,type="text", name="title", readonly="true", value="#{post.title}")
+ textarea(id="post-new-edit-content", name="body") #{post.content}
+
+ input(id="submit-edit-post-btn", type="submit", value="Edit")
\ No newline at end of file
diff --git a/views/admin_edit_delete.jade b/views/admin_edit_delete.jade
new file mode 100644
index 0000000..de4b42e
--- /dev/null
+++ b/views/admin_edit_delete.jade
@@ -0,0 +1,11 @@
+extends default-layout
+
+block blog-content
+ for post in posts
+ .post-extract
+ h2.post-title #{post.title}
+ h5.post-date #{post.date.toDateString()}
+ form.post-edit-form(method='post', action="/admin/edit/#{post._id}")
+ input.post-edit-button(type="submit", value="EDIT POST")
+ form.post-delete-form(method='post', action="/admin/delete/#{post._id}")
+ input.post-delete-button(type="submit", value="DELETE POST")
diff --git a/views/admin_view.jade b/views/admin_view.jade
new file mode 100644
index 0000000..83fa5f3
--- /dev/null
+++ b/views/admin_view.jade
@@ -0,0 +1,22 @@
+extends default-layout
+
+block blog-content
+ script(src="/javascripts/nicEdit.js", type="text/javascript")
+ script(type='text/javascript')
+ bkLib.onDomLoaded(nicEditors.allTextAreas);
+
+ #admin-bar
+ ol
+ li
+ a(href="/admin/new") Create Post
+ li
+ a(href="/admin/editOrDelete") Edit/Delete Post
+ li
+ a(href="/admin/logout") Log out
+
+ .post-new-edit
+ h2#new-edit-post-header New Post
+ form(id="new-edit-post-form", method="post")
+ input(id="post-title-box" ,type="text", name="title", placeholder="Title")
+ textarea(id="post-new-edit-content", name="body", placeholder="Write your post here")
+ input(id="submit-post-btn", type="submit", value="Create")
\ No newline at end of file
diff --git a/views/default-layout.jade b/views/default-layout.jade
new file mode 100644
index 0000000..beedb53
--- /dev/null
+++ b/views/default-layout.jade
@@ -0,0 +1,57 @@
+doctype
+html(lang="en")
+ head
+ title= title
+ link(rel="stylesheet", type="text/css", href="http://fonts.googleapis.com/css?family=Lato")
+ link(rel="stylesheet", href="/stylesheets/style.css")
+ script.
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+ })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
+
+ ga('create', 'UA-43277669-1', 'kenshiro.me');
+ ga('send', 'pageview');
+
+
+ #fb-root
+ script.
+ (function(d, s, id) {
+ var js, fjs = d.getElementsByTagName(s)[0];
+ if (d.getElementById(id)) return;
+ js = d.createElement(s); js.id = id;
+ js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=#{fbAppId}";
+ fjs.parentNode.insertBefore(js, fjs);
+ }(document, 'script', 'facebook-jssdk'));
+
+ body
+ #page-wrapper
+ header
+ h1#blog-main-title= blogTitle
+ h2#blog-sub-title= blogSubtitle
+
+
+ #content
+ #main-content
+ block blog-content
+
+
+ #widgets
+ #widget-pages
+ h3.widget-title Pages
+ a.widget-section-link(href="/") Home
+ a.widget-section-link(href="/about") About
+ a.widget-section-link(href="/projects") Projects
+
+
+ #widget-posts
+ h3.widget-title Latest Posts
+ for post in posts
+ a.widget-section-link(href="/post/#{post.friendly_link_title}") #{post.title}
+
+
+ footer
+ p.footer-note Powered by
+ a.no-link(href="https://github.com/kenshiro-o/Node2Blog") Node2Blog
+ .footer-logos
+ img(src="/images/node-js-logo.jpeg", alt="node.js official logo")
\ No newline at end of file
diff --git a/views/home.jade b/views/home.jade
deleted file mode 100644
index 2ded3e7..0000000
--- a/views/home.jade
+++ /dev/null
@@ -1,38 +0,0 @@
-extends layout
-
-
-block wrapper_content
-
- .container
- for post in posts
-
- if post.content.length < 200
- - var content = post.content;
- else
- - var content = post.content.substring(0, 200) + '...';
- .post
- h1
- a(href='post/#{post._id}/#{post.title_sub}')= post.title
- br
- iframe(id='#{post._id}', scrolling="auto", frameborder="0", style='width:100%;height:70px;')
- label(value='#{content}', name='#{post._id}')
- script(type='text/javascript')
- c = stripScripts($('[name="#{post._id}"]').attr('value'))
- var iframe = document.getElementById('#{post._id}')
- var doc = iframe.document;
- if(iframe.contentDocument)
- doc = iframe.contentDocument;
- else if(iframe.contentWindow)
- doc = iframe.contentWindow.document;
- doc.open()
-
- doc.writeln(c)
- doc.close()
-
- br
- br
- label Created at: #{post.date}
- br
- br
- if(typeof admin != 'undefined')
- a(href='/admin/#{post._id}/edit') Edit Post
\ No newline at end of file
diff --git a/views/index.jade b/views/index.jade
new file mode 100644
index 0000000..0a108c9
--- /dev/null
+++ b/views/index.jade
@@ -0,0 +1,13 @@
+extends default-layout
+
+block blog-content
+ for post in posts
+ .post-extract
+ h2.post-title
+ a(href="/post/#{post.friendly_link_title}") #{post.title}
+ h5.post-date #{post.date.toDateString()}
+ - var content = post.content
+ .post-content!= content
+
+
+
diff --git a/views/layout.jade b/views/layout.jade
deleted file mode 100644
index 7ec4ead..0000000
--- a/views/layout.jade
+++ /dev/null
@@ -1,72 +0,0 @@
-doctype 5
-html
- head
- title= title
- link(rel='stylesheet', href='/stylesheets/reset.css')
- link(rel='stylesheet', href='/stylesheets/header.css')
- link(rel='stylesheet', href='/stylesheets/wrapper.css')
- link(rel='stylesheet', href='/stylesheets/footer.css')
- link(rel='stylesheet', href='/stylesheets/nav.css')
- script(type='text/javascript', src='/javascripts/main.js')
- script(type='text/javascript', src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js')
-
- body
- div(id="fb-root")
- script
- (function(d, s, id) {
- var js, fjs = d.getElementsByTagName(s)[0];
- if (d.getElementById(id)) return;
- js = d.createElement(s); js.id = id;
- js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=388558531205027";
- fjs.parentNode.insertBefore(js, fjs);
- }(document, 'script', 'facebook-jssdk'));
-
- #header
- #title
- h1= title
- #subTitle
- label= subTitle
- #nav
- ol
- a(href="/")
- li Home
- a(href="/about")
- li About
- if(typeof admin == 'undefined')
- - null
- else
- a(href="/admin/new")
- li Admin-New
- a(href="/admin/delete")
- li Admin-Delete
- a(href="/admin/logout")
- li Admin-Logout
-
-
- #box
- #content
- #wrapper
- block wrapper_content
- if(typeof posts == 'undefined')
- .widget
- a(href='/') Back to home
- else
- .widget
- p(style='font-size: 150%; font-weight:bold; border-bottom: 1px solid #b1b1b1;padding-bottom: 5px;margin-bottom: 4px;') Latest Posts
- br
- pre
- for post in posts
- table(id='post_table', style='padding-top:10px;border-bottom:1px solid #ddd')
- tr
- td
- #left
- label(style='font-size: 130%;') -  
- td
- #right
- a(href='/post/#{post._id}/#{post.title_sub}', style='font-size: 130%;')= post.title
- tr(style='height:10px;')
-
- #footer
- #footer_text
- p
- | Using the Node2Blog template and running on a Node.js server
\ No newline at end of file
diff --git a/views/post.jade b/views/post.jade
new file mode 100644
index 0000000..7e0cdb1
--- /dev/null
+++ b/views/post.jade
@@ -0,0 +1,29 @@
+extends default-layout
+
+block blog-content
+
+ .post-full
+ h2.post-title #{post.title}
+ h6.post-date #{post.date.toDateString()}
+ - var content = post.content
+ .post-content!= content
+ .post-comments
+ - var commentStr = comments.length == 1 ? "Comment" : "Comments"
+ h4 #{comments.length} #{commentStr}
+
+ form#comment-form(method="post", action="/post/#{post._id}/#{post.friendly_link_title}")
+ input.commenter-name-input(name="name", type="text", placeholder="name")
+ textarea.comment-area(name="comment", placeholder="comment", rows="5")
+ input.submit-comment-button(type="submit", value="Submit comment")
+
+ for comment in comments
+ .post-comment-container
+ p.post-comment #{comment.comment}
+ p.comment-signature #{comment.name} on #{comment.date.toDateString()} at #{comment.date.toLocaleTimeString()}
+
+ #social-media-container
+ .fb-like(data-href="#{blogSite}post/#{post.friendly_link_title}", data-width="100px", data-show-faces="false", data-send="false", data-layout="button_count")
+ .tweetbtn
+ a(href="https://twitter.com/share", class="twitter-share-button", data-size="medium") Tweet
+ script.
+ !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
diff --git a/views/projects.jade b/views/projects.jade
new file mode 100644
index 0000000..9ad571f
--- /dev/null
+++ b/views/projects.jade
@@ -0,0 +1,20 @@
+extends default-layout
+
+
+block blog-content
+ .post-full
+ h2 Projects
+ p
+ | I have a couple of projects hosted on github .
+ | They are all currently using node.js but I will also add Go and Java projects soon too.
+
+ h2 Project List
+
+ p
+ | login-utils : login-utils is a very simple user authentication library. The library has a default User MangoDB model (using mongoose). Moreover, the encryption of the password is performed using bcrypt.
+
+ p
+ | RapGenius-js : rapgenius-js is a simple client that enables you to query RapGenius and retrieve information about rap artists and songs.
+
+ p
+ | wikipedia-js : wikipedia-js is a simple client that enables you to query Wikipedia articles in english. The format of the result is among json, jsonfm, wddx, wddxfm, xml, rawfm. In the case of html the result is formatted in basic HTML. You can retrieve either a summary of an article (i.e. before the table of contents) or a full article.
\ No newline at end of file
diff --git a/views/this.html b/views/this.html
deleted file mode 100644
index f258e46..0000000
--- a/views/this.html
+++ /dev/null
@@ -1,9 +0,0 @@
-
- YouTwitFace
- YouTwitFace
- 'This is a site'
-
- Welcome to YouTwitFace, this is an awesome website for a lot of things and such. I am Jared, and I am awesome.
-
- Google
-
\ No newline at end of file