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.

186 lines
4.7 KiB

6 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. - whiskers
  71. - node-pandoc
  72. ```
  73. ## Color scheme
  74. The color scheme has been changing a lot recently.
  75. [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)
  76. current:
  77. top 2C3E50
  78. secondary 498FBE
  79. highlight:00F0E1, 88BAFF
  80. ## Image Optimization
  81. Stuff for automated image compression
  82. ```
  83. apt-get install jpegoptim
  84. apt-get install optipng
  85. ./optimizeImages.sh
  86. ```
  87. ## NGINX Configuration
  88. ```
  89. #jrtechs.net.conf
  90. server
  91. {
  92. listen 80;
  93. server_name www.jrtechs.net jrtechs.net;
  94. # redirect http requests to https
  95. return 301 https://jrtechs.net$request_uri;
  96. }
  97. server
  98. {
  99. listen 443 ssl http2;
  100. server_name jrtechs.net;
  101. ssl_certificate /etc/letsencrypt/live/jrtechs.net/cert.pem;
  102. ssl_certificate_key /etc/letsencrypt/live/jrtechs.net/privkey.pem;
  103. location / {
  104. proxy_pass http://localhost:8000;
  105. proxy_http_version 1.1;
  106. proxy_set_header Upgrade $http_upgrade;
  107. proxy_set_header Connection 'upgrade';
  108. proxy_set_header Host $host;
  109. proxy_cache_bypass $http_upgrade;
  110. }
  111. }
  112. ```
  113. ## Projects Sites
  114. 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.
  115. I simply want the project site to be accessible under https://jrtechs.net/project_name.
  116. ### State Diagram of Plan
  117. ![diagram](docs/projectsSites.svg)
  118. # DB Backup and Restore
  119. This will dump everything in the database to a plain text file. A base SQL schema can be found in docs//sqlConfig.md
  120. ```
  121. sudo mysqldump -u [user] -p [database_name] > [filename].sql
  122. ```
  123. This will take a database dump and load it into a active mysql instance.
  124. Note: the database (can be empty) must already exist.
  125. ```
  126. sudo mysql -u [user] -p [database_name] < [filename].sql
  127. ```