From 00301734db0e9492ac636f8e99db65b34542224d Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Thu, 11 Nov 2021 09:42:32 +0330 Subject: changes the layout of the blog --- Dockerfile | 1 + css/master.css | 3 ++- docker-compose-test.yaml | 17 +++++++++++++++++ docker-compose.yaml | 7 ++++++- server.js | 48 ++++++++++++++++++++++++++++++++++++++---------- static/about.html | 23 +++++++++++++++++++++++ views/archive.ejs | 19 +++++++++++++++++++ views/index.ejs | 9 ++------- 8 files changed, 108 insertions(+), 19 deletions(-) create mode 100644 docker-compose-test.yaml create mode 100644 static/about.html create mode 100644 views/archive.ejs diff --git a/Dockerfile b/Dockerfile index fd5dd0b..f7697b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,7 @@ COPY ./package.* /server/ RUN cd /server && npm install --production COPY ./css /server/css/ COPY ./views /server/views/ +COPY ./static /server/static/ COPY ./mds /server/mds/ COPY ./server.js /server/ ENTRYPOINT ["/server/server.js"] diff --git a/css/master.css b/css/master.css index 0f819e3..fd79a28 100644 --- a/css/master.css +++ b/css/master.css @@ -17,7 +17,8 @@ body { font-family: "DejaVuSansMono NF", Helvetica, monospace; overflow-wrap: break-word; float: left; - width: 78%; + /* width: 78%; */ + width: 95%; } .sidenav { diff --git a/docker-compose-test.yaml b/docker-compose-test.yaml new file mode 100644 index 0000000..73981ef --- /dev/null +++ b/docker-compose-test.yaml @@ -0,0 +1,17 @@ +version: "3.7" +services: + web: + image: web + build: + context: ./ + networks: + - webnet + ports: + - "19009:9000" + cap_drop: + - ALL + environment: + - SERVER_DEPLOYMENT_TYPE=test + - SERVER_LISTEN_PORT=9000 +networks: + webnet: diff --git a/docker-compose.yaml b/docker-compose.yaml index 1c70974..8eb2079 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -8,8 +8,13 @@ services: - webnet restart: unless-stopped ports: - - "9000:9000" + - "19009:9000" volumes: - /etc/letsencrypt/archive/blog.terminaldweller.com/:/certs/ + cap_drop: + - ALL + environment: + - SERVER_DEPLOYMENT_TYPE=deployment + - SERVER_LISTEN_PORT=9000 networks: webnet: diff --git a/server.js b/server.js index 0c245a3..94a6082 100755 --- a/server.js +++ b/server.js @@ -23,6 +23,7 @@ const spdy = require("spdy"); const app = express(); app.use(express.static(path.join(__dirname, "css"))); +app.use(express.static(path.join(__dirname, "static"))); app.set("views", path.join(__dirname, "views")); app.set("view engine", "ejs"); app.engine("ejs", require("ejs").__express); @@ -60,6 +61,21 @@ app.get("/health", (req, res) => { res.send(response); }); +app.get("/about", (req, res) => { + res.type("text/html"); + res.sendFile(path.join(__dirname, "static/about.html")); +}); + +app.get("/archive", (req, res) => { + res.type("text/html"); + res.render("archive", { + cache: true, + data: { + mds: fs.readdirSync(path.join(__dirname, "mds"), "utf-8"), + }, + }); +}); + app.get("/robots.txt", (req, res) => { res.type("text/plain"); let robots_txt = "Sitemap: http://blog.terminaldweller.com\n"; @@ -84,7 +100,7 @@ async function enumerateDir() { return await fs.readdirSync(path.join(__dirname, "mds")); } -app.use(sitemap(enumerateDir, "http://blog.terminaldweller.com")); +app.use(sitemap(enumerateDir, "https://blog.terminaldweller.com")); app.use((req, res) => { return res.status(404).send({ message: "Path" + req.url + "not found!" }); @@ -94,12 +110,24 @@ app.use((err, req, res) => { return res.status(500).send({ error: err }); }); -spdy - .createServer( - { - key: fs.readFileSync("/certs/privkey1.pem", "utf-8"), - cert: fs.readFileSync("/certs/fullchain1.pem", "utf-8"), - }, - app - ) - .listen(9000); +if (process.env.SERVER_DEPLOYMENT_TYPE == "deployment") { + spdy + .createServer( + { + key: fs.readFileSync("/certs/privkey1.pem", "utf-8"), + cert: fs.readFileSync("/certs/fullchain1.pem", "utf-8"), + }, + app + ) + .listen(process.env.SERVER_LISTEN_PORT || 9000); +} else if (process.env.SERVER_DEPLOYMENT_TYPE == "test") { + spdy + .createServer( + { + key: fs.readFileSync("/certs/server.key", "utf-8"), + cert: fs.readFileSync("/certs/server.cert", "utf-8"), + }, + app + ) + .listen(process.env.SERVER_LISTEN_PORT || 9000); +} diff --git a/static/about.html b/static/about.html new file mode 100644 index 0000000..ad9ed10 --- /dev/null +++ b/static/about.html @@ -0,0 +1,23 @@ + + + + + + About + + + +

Email: thabogre@gmail.com

+

+ You can find my github + here +

+ + diff --git a/views/archive.ejs b/views/archive.ejs new file mode 100644 index 0000000..36191de --- /dev/null +++ b/views/archive.ejs @@ -0,0 +1,19 @@ + + + + + + Archive + + + + +
+ <% data.mds.forEach(function(md) { %> + + <% }) %> +
+ + diff --git a/views/index.ejs b/views/index.ejs index 8c2fe43..7ce83a8 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -8,15 +8,10 @@ -
- <% data.mds.forEach(function(md) { %> - - <% }) %> -
<%- data.blogHttp %> + About + Archive
-- cgit v1.2.3