About creating and publishing this website.
About
The source code found here isn’t the actual code I wrote.
I’m running a Node.js server locally and using wget
command to make a snapshot of the website.
The command I use is:
wget --mirror --convert-links --adjust-extension --page-requisites --no-parent -e robots=off http://localhost:3000
Then I just copy the files with rsync
excluding some of the files I don’t want to change:
rsync -av --delete --exclude=.git --exclude=CNAME --exclude=robots.txt "./localhost:3000/" "./website"
A static site generated like that is published through GitHub pages.
This has several advantages:
- Faster loading - the site is already generated as static HTML files
- Vulnerabilities in Node.js or other packages I use don’t affect this site
- I can see all the files that get published, no way to leak the source code
- Don’t need to pay for VPS to host this site
For example, the body of the gallery page looks like this in Node.js:
<body>
<%- include('../partials/header') %>
<div class="container main-container">
<div class="gallery" id="gallery">
<% for(var i=1; i < files.length; i++) {%>
<% let image = "images/privatePhotos/small/" + files[i]["image"] %>
<% let thumbnail = "images/privatePhotos/thumbnails/" + thumbnails[i] %>
<div class="mb-3 pics animation all 2">
<a href="<%= image %>"
data-pswp-width="<%= files[i]["width"] %>"
data-pswp-height="<%= files[i]["height"] %>">
<img class="img-fluid" src="<%= thumbnail %>" alt="" />
</a>
</div>
<% } %>
</div>
</div>
<%- include('../partials/footer') %>
</body>
which results in this static file