N O D E P O S T
Setup & Deploy your Blogging System in less than one minute
NodePost is a static Distributed Blogging System, with High Scalability & Deployability.
Clone the application + install requirements
// clone the repository from github
git clone https://github.com/k-five/nodepost
// change directory & install the dependencies
cd nodepost && npm install
Setup your posts' title
Create / Update posts.json file.
// just modify posts.json file in database directory
// the file looks like:
{
"home": {
"Back end": {
"Node.js": "",
"Express.js": "",
"JSON": ""
},
"Front end": {
"JavaScript": "",
"HTML": "",
"CSS": ""
}
}
}
Run the application
// You will have several choices
// 1. run the server manually NOT recommended since it does not auto restart
node nodepost.js
// 2. using node-dev symbolic link
./node-dev nodepost.js
// 3. or using npm start (? it is a little bit slow)
npm start
Strengths:
Auto directory posts management
There is no need to be worried about Create or Delete a directory manually. It is done automatically whenever you modify the posts.json file.
// if this is your posts.json file
{
"home": {
"My Job": "",
"About Me": "",
"Projects": ""
}
}
Adding a new title's post, will create new files / directories and removing a title's post will delete the files / directories.
// if this is your posts.json file
{
"home": {
# My Job will be deleted
"About Me": "",
"Projects": {
"2010": "", # will be created
"2015": "", # will be created
"2020" "" # will be created
}
}
}
Auto route management
Thanks to the Recursive Algorithm, the posts.json file will be converted to an appropriate routes and is used by the Web Server.
Auto link management
Links related between a Parent and its Children directories (= sub-posts) are handled automatically.
Auto cache management
If you modify a file, the first request to the file will be from file-system and others will be cached. Modifying a file, repeats this process, first from file-system, an other requests will be from cache.
Auto Time Update
There is no need to add Last Update Time manually to your posts. It is done automatically if a user adds this format: DD_MM_YYYYY in its post's file
Auto "Edit on Github"
If a user adds its Github's account name and a repository name, then, a link to each post is added automatically for editing on github.
Easy Performance Test
After each update on posts.json file, the route.dirs file will be updated too.
The file contains all the valid requests by a client, thus, for example a user can simply run Apache Benchmark tool (= ab) to get a test:
// usually it is available on Linux Machines
/*
ab -h
Usage: ab [options] [http[s]://]hostname[:port]/path
Options are:
-n requests Number of requests to perform
-c concurrency Number of multiple requests to make at a time
...
...
*/
// Sending 100 requests to each path
xargs -I xxx ab -n 100 http://localhost:1400xxx < database/route.dirs
// output
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient).....done
Server Software:
Server Hostname: localhost
Server Port: 1400
Document Path: /home
Document Length: 1468 bytes
Concurrency Level: 1
Time taken for tests: 0.145 seconds
Complete requests: 100
Failed requests: 0
Total transferred: 167100 bytes
HTML transferred: 146800 bytes
Requests per second: 692.01 [#/sec] (mean)
Time per request: 1.445 [ms] (mean)
Time per request: 1.445 [ms] (mean, across all concurrent requests)
Transfer rate: 1129.25 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 0
Processing: 1 1 1.0 1 9
Waiting: 1 1 0.9 1 9
Total: 1 1 1.0 1 9
Easy Monitoring
All request to the server will be logged in JSON format and a user can see / read it very easily.
It simply saves:
- Last Visitor's IP address | NOT if localhost is used!
- Most Visited IP address | NOT if localhost is used!
- Max Number of Request
If you run the application locally, try reading stat.json in the database directory.
it is also available live, if you visit http://localhost:1400/stat address.
A user can make this path private so others not be able to see it..
And for a deployed blog we can use curl like so:
// send GET request to /stat
curl -sL http://jsfun.ir/stat
// a JSON file will be returned
Light weight
The source code + comments is less and 500 lines of code using JavaScript so any JavaScript developer can read / update the code.
Unlimited nesting posts
There is no limitations for adding nested post. As many as a user wants, is possible.
As a microservice
Since the Server itself (= Node.js) is part of the application and can be:
- deployed
- debugged
- managed
as well as
- light weight
- easy to use and update
and running multi-instances of it is possible, why not using it as a micro-server / service!
Click the buttons below to see it in action
Each of this sub-path is an instance of nodepost.
Weaknesses:
Commenting
Adding comment to each post is not supported right now, but there is a plan for adding this feature.
Edit-on-Github may be an alternative till supporting this feature.
In Action
Distributed Blogging System
Unlike other static Blogging Systems:
that the Server is a separate manger (a parser) for creating pages and posts, nodepost server is the main part of the application alongside its path-manger.
While other Blogging Systems see the concept of Blogging as a markdown-parser / markup-generator, nodepost sees it as a hierarchy of posts that all together forms a System and this system's responsibility is Blogging.
Thus, anyone can fork / clone my blog (jsfun.ir which is a nodepost on github) and starts to add more posts to it.
Then they can grow it to create their own blog and deploy it on their own Server or push it back to jsfun.ir's repository - as a pull-request - on github so my blog will get updated.
It has the same workflow as any project on github has.
NOTE.1 this distribution is optional and no one has to do it!
NOTE.2 Edit-on-Github is a different feature, it is not the same as this one!
Target users
Software Developers that want to write articles / tutorials about coding & programming.
Thus basic knowledge of JS, HTML, CSS is required.
Stack
Back-end: Node.js, Express.js, JSON.
Fron-end: JS, HTML, CSS, prism for Syntax Highlighting with TWLIGHT theme.
Application Workflow
