Personal blog written from scratch using Node.js, Bootstrap, and MySQL. https://jrtechs.net
Je kunt niet meer dan 25 onderwerpen selecteren Onderwerpen moeten beginnen met een letter of nummer, kunnen streepjes bevatten ('-') en kunnen maximaal 35 tekens lang zijn.
 
 
Jeffery Russell dbdef35655
Merge pull request #110 from jrtechs/sql-refactor
2 jaren geleden
.github/ISSUE_TEMPLATE Created a template for creating blog post issues on git repository. 5 jaren geleden
.idea Added a sitemap generator 6 jaren geleden
admin Refactored out mysql for sqlite 2 jaren geleden
blog Refactored out mysql for sqlite 2 jaren geleden
content Refactored blogContent to just content 2 jaren geleden
docs added image for readme update 3 jaren geleden
includes Removed traffic logging logic and removed unused email config 2 jaren geleden
photography Worked on implementing photo post pages. 4 jaren geleden
routes Refactored out mysql for sqlite 2 jaren geleden
sites Refactored blogContent to just content 2 jaren geleden
templates Refactored out mysql for sqlite 2 jaren geleden
utils Refactored out mysql for sqlite 2 jaren geleden
.gitignore Refactored out mysql for sqlite 2 jaren geleden
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md 5 jaren geleden
Dockerfile Refactored out mysql for sqlite 2 jaren geleden
LICENSE Updated License 5 jaren geleden
README.md Removed unused send email logic and dependency 2 jaren geleden
config.json Refactored out mysql for sqlite 2 jaren geleden
docker-compose.yml Refactored out mysql for sqlite 2 jaren geleden
jrtechs.service Created systemd script to run blog. 5 jaren geleden
optimizeImages.sh Created admin server and fixed code highlighting. 5 jaren geleden
package.json Refactored out mysql for sqlite 2 jaren geleden
previewer.js Got the photos post to have their write up display above the photos. 4 jaren geleden
robots.txt added meta stuff for google 6 jaren geleden
run Finished vim configuration post. 5 jaren geleden
server.js Refactored out mysql for sqlite 2 jaren geleden
sitemap.txt Refactored out mysql for sqlite 2 jaren geleden

README.md

NodeJSBlog

This is a personal blog where I write about everything from projects to tutorials on sophisticated machine learning algorithms. If you want to stay up to date with new posts, subscribe to my RSS feed.

This project is a custom express application that uses pandoc to render latex/markdown files as HTML pages. This site has its very own admin portal to manage posts and downloads.

Posts Page

Dependencies

  • mysql
  • node + npm
  • pandoc
  • nxinx (for https)

Running

Installing the node-dependencies is as easy as running the npn install command:

npm install

All configurations are currentl found in the config.json file. In this file you specify things like port, sql connection, etc.

There is a provided bash script that will run the application

chmod +x run.sh
./run.sh

For deployment I used a Nginx proxy to expose the node application running on port 8000 to port 80. This proxy is necessary because you can't run a node application as port 80 unless you are root, which would be a security vulnerability.

Running with Docker

To simplify development and deployment you can run the entire node blog and mysql server from docker using docker-compose.

docker-compose up

or

docker-compose up db
docker-compose up blog

To Access mysql server of docker daemon for maintenence. Note: you need to configure username and password in docker-compose.yml and config.json.

mysql --port=3306 --host=127.0.0.1 -u root --password=password

Unless otherwise stated, everything in this repository can be assumed to fall under these two licenses depending on what type of file it is.

Code, scripts

All code, scripts, or other technical / programmatic items in this repo are assumed fall under the Mozilla Public License 2.0 unless otherwise stated.

Guides, articles, posts, misc. content

Creative Commons Attribution-ShareAlike 4.0 International License

All guides, scripts, posts, or otherwise non-programmatic content in this repo is assumed to fall under the Creative Commons Attribution-ShareAlike 4.0 International unless otherwise stated.

Node Dependencies

- express
- express-session
- mysql
- sanitizer
- promise
- highlight
- crypto
- remarkable
- markdown
- highlight.js
- compression
- memory-cache --save
- request
- whiskers
- node-pandoc

Color scheme

The color scheme has been changing a lot recently.

Adobe Color Wheel

current: top 2C3E50 secondary 498FBE highlight:00F0E1, 88BAFF

Image Optimization

Stuff for automated image compression

apt-get install jpegoptim
apt-get install optipng

./optimizeImages.sh

NGINX Configuration

#jrtechs.net.conf
server 
{
    listen 80;
    server_name www.jrtechs.net jrtechs.net;

    # redirect http requests to https
    return 301 https://jrtechs.net$request_uri;
}

server 
{
    listen 443 ssl http2;

    server_name jrtechs.net;

    ssl_certificate /etc/letsencrypt/live/jrtechs.net/cert.pem;
    ssl_certificate_key /etc/letsencrypt/live/jrtechs.net/privkey.pem;

    location / {
        proxy_pass http://localhost:8000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

Projects Sites

As I develop more projects I would like an easy way to add and host them on my website without having to create another sub-domain and generate more ssl certs. I simply want the project site to be accessible under https://jrtechs.net/project_name.

State Diagram of Plan

diagram

DB Backup and Restore

This will dump everything in the database to a plain text file. A base SQL schema can be found in docs//sqlConfig.md

sudo mysqldump -u [user] -p [database_name] > [filename].sql

This will take a database dump and load it into a active mysql instance. Note: the database (can be empty) must already exist.

sudo mysql -u [user] -p [database_name] < [filename].sql