A simple and easy to setup node.js blog template. For the casual blogger.
Pull request Compare This branch is 105 commits behind jawerty:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
node_modules
public
routes
views
.gitignore
LICENSE.md
README.md
blog.js
db.js
package.json

README.md

Node2Blog

Node2Blog is a simple and easy to use blog template for the casual blogger. For those who wish to setup an operable blog in minutes, this is the project for you. The blog is built with Node.js, Express.js, and Mongodb (with the mongoose driver). The instructions for building a blog with the Node2Blog template is shown below.

Prerequisites

  1. Node.js (version 0.8 or above, download here)
  2. Express.js (version 3 or above, and will be install with npm)
  3. A recent version of Mongodb (download here)
  4. Mongoose (will be installed with npm)

Setting it up

In your terminal, 'cd' to the directory where you want to develop the blog and do the following commands

$ git clone git@github.com:jawerty/Node2Blog.git blog-folder-name
$ cd blog-folder-name
$ npm install .

In order to initiate the blog server on your local machine, do the following command (You need node.js to run the following command)

$ 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').

When successfully logged in, your navigation bar should have three new options appended to it...

  1. Admin-New (create a new post)
  2. Admin-Delete (delete a post
  3. Admin-Logout (log out of admin view)

Creating 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.


a(href="/new-page-name")
    li new_page_name

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


extends layout

block wrapper_content
    .container
        h1 new_page_name
        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('/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});
});

///////////////////

You should now be able to go the the '/new-page-name' route and have a view similar to what is below

Congratulations you now have a working blog suitable to your basic blogger needs.


Contact the developer here
Email: jawerty210@gmail.com
Website: http://wrightdev.herokuapp.com

MIT LICENSE

The MIT License (MIT) Copyright (c) 2012 Jared Wright

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.