Personal blog written from scratch using Node.js, Bootstrap, and MySQL. https://jrtechs.net
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

188 lines
4.7 KiB

7 years ago
6 years ago
  1. # NodeJSBlog
  2. This is a personal blog where I write about everything from projects to tutorials on sophisticated machine learning algorithms.
  3. If you want to stay up to date with new posts, subscribe to my [RSS feed](https://jrtechs.net/rss).
  4. This project is a custom express application that uses pandoc to render latex/markdown files as HTML pages.
  5. This site has its very own admin portal to manage posts and downloads.
  6. ![Posts Page](docs/postsPage.png)
  7. ## Dependencies
  8. - mysql
  9. - node + npm
  10. - pandoc
  11. - nxinx (for https)
  12. ## Running
  13. Installing the node-dependencies is as easy as running the npn install command:
  14. ```
  15. npm install
  16. ```
  17. All configurations are currentl found in the config.json file.
  18. In this file you specify things like port, sql connection, etc.
  19. There is a provided bash script that will run the application
  20. ```
  21. chmod +x run.sh
  22. ./run.sh
  23. ```
  24. For deployment I used a [Nginx](https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04)
  25. proxy to expose the node application running on port 8000 to port 80. This proxy is necessary
  26. because you can't run a node application as port 80 unless you are root, which would be a
  27. security vulnerability.
  28. ### Running with Docker
  29. To simplify development and deployment you can run the entire node blog and mysql server from docker using docker-compose.
  30. ```bash
  31. docker-compose up
  32. ```
  33. or
  34. ```bash
  35. docker-compose up db
  36. docker-compose up blog
  37. ```
  38. To Access mysql server of docker daemon for maintenence. Note: you need to configure username and password in docker-compose.yml and config.json.
  39. ```bash
  40. mysql --port=3306 --host=127.0.0.1 -u root --password=password
  41. ```
  42. ## Legal
  43. **Unless otherwise stated**, everything in this repository can be
  44. assumed to fall under these two licenses depending on what type of file it is.
  45. #### Code, scripts
  46. All code, scripts, or other technical / programmatic items in this repo are
  47. assumed fall under the [Mozilla Public License 2.0](https://www.mozilla.org/en-US/MPL/)
  48. unless otherwise stated.
  49. #### Guides, articles, posts, misc. content
  50. ![Creative Commons Attribution-ShareAlike 4.0 International License](https://i.creativecommons.org/l/by-sa/4.0/88x31.png)
  51. All guides, scripts, posts, or otherwise non-programmatic content in this
  52. repo is assumed to fall under
  53. the [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/)
  54. unless otherwise stated.
  55. ## Node Dependencies
  56. ```bash
  57. - express
  58. - express-session
  59. - mysql
  60. - sanitizer
  61. - promise
  62. - highlight
  63. - crypto
  64. - remarkable
  65. - markdown
  66. - highlight.js
  67. - compression
  68. - memory-cache --save
  69. - request
  70. - nodemailer
  71. - nodemailer-smtp-transport
  72. - whiskers
  73. - node-pandoc
  74. ```
  75. ## Color scheme
  76. The color scheme has been changing a lot recently.
  77. [Adobe Color Wheel](https://color.adobe.com/create/color-wheel/?copy=true&base=2&rule=Custom&selected=4&name=Copy%20of%20Site&mode=cmyk&rgbvalues=0.17254901960784313,0.24313725490196078,0.3137254901960784,0.28627450980392155,0.5607843137254902,0.7450980392156863,0.5329137283008958,0.7301501780381741,1,0.8235294117647058,0.7529411764705882,1,0.042420144797897574,0,0.17000000000000004&swatchOrder=0,1,2,3,4)
  78. current:
  79. top 2C3E50
  80. secondary 498FBE
  81. highlight:00F0E1, 88BAFF
  82. ## Image Optimization
  83. Stuff for automated image compression
  84. ```
  85. apt-get install jpegoptim
  86. apt-get install optipng
  87. ./optimizeImages.sh
  88. ```
  89. ## NGINX Configuration
  90. ```
  91. #jrtechs.net.conf
  92. server
  93. {
  94. listen 80;
  95. server_name www.jrtechs.net jrtechs.net;
  96. # redirect http requests to https
  97. return 301 https://jrtechs.net$request_uri;
  98. }
  99. server
  100. {
  101. listen 443 ssl http2;
  102. server_name jrtechs.net;
  103. ssl_certificate /etc/letsencrypt/live/jrtechs.net/cert.pem;
  104. ssl_certificate_key /etc/letsencrypt/live/jrtechs.net/privkey.pem;
  105. location / {
  106. proxy_pass http://localhost:8000;
  107. proxy_http_version 1.1;
  108. proxy_set_header Upgrade $http_upgrade;
  109. proxy_set_header Connection 'upgrade';
  110. proxy_set_header Host $host;
  111. proxy_cache_bypass $http_upgrade;
  112. }
  113. }
  114. ```
  115. ## Projects Sites
  116. 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.
  117. I simply want the project site to be accessible under https://jrtechs.net/project_name.
  118. ### State Diagram of Plan
  119. ![diagram](docs/projectsSites.svg)
  120. # DB Backup and Restore
  121. This will dump everything in the database to a plain text file. A base SQL schema can be found in docs//sqlConfig.md
  122. ```
  123. sudo mysqldump -u [user] -p [database_name] > [filename].sql
  124. ```
  125. This will take a database dump and load it into a active mysql instance.
  126. Note: the database (can be empty) must already exist.
  127. ```
  128. sudo mysql -u [user] -p [database_name] < [filename].sql
  129. ```