summaryrefslogtreecommitdiff
path: root/download/build.js
diff options
context:
space:
mode:
authormattkae <mattkae@protonmail.com>2022-10-22 17:15:20 -0400
committermattkae <mattkae@protonmail.com>2022-10-22 17:15:20 -0400
commit9032a5ce5d55ec392b1328ac6d8b28a546405074 (patch)
treed1f210854293327ff752cd97925e8f9a7fd1851c /download/build.js
parent0b48323783a37059c9af13a5bda403465b1fea14 (diff)
Updated resume, and now it automatically generates
Diffstat (limited to 'download/build.js')
-rw-r--r--download/build.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/download/build.js b/download/build.js
new file mode 100644
index 0000000..7e18973
--- /dev/null
+++ b/download/build.js
@@ -0,0 +1,38 @@
+
+
+const fs = require('fs');
+const childProcess = require('child_process');
+
+const resumeHtml = fs.readFileSync('../resume.html').toString();
+const resumeCss = fs.readFileSync('./resume_dl.css').toString();
+
+function getRidofTagsBetween(start, end, html) {
+ let si = newHtml.indexOf(start);
+ let ei = newHtml.indexOf(end, si) + end.length;
+ return html.substring(0, si) + newHtml.substring(ei);
+}
+
+const newHeader = `
+ <head>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+ <meta charset="UTF-8" />
+ <script src="https://twemoji.maxcdn.com/2/twemoji.min.js?11.2"></script>
+ <script>window.onload = function () { twemoji.parse(document.body);}</script>
+<style>
+${resumeCss}
+</style>
+</head>
+`
+
+const startHead = resumeHtml.indexOf('<head>');
+const endHead = resumeHtml.indexOf('</head>') + '</head>'.length;
+
+let newHtml = resumeHtml.substring(0, startHead) + newHeader + resumeHtml.substring(endHead);
+
+newHtml = getRidofTagsBetween('<header>', '</header>', newHtml);
+newHtml = getRidofTagsBetween(`<div id='resume_button_container'>`, '</div>', newHtml);
+
+fs.writeFileSync('./resume_dl.html', newHtml);
+
+childProcess.exec('wkhtmltopdf --encoding \'UTF-8\' ./resume_dl.html cv.pdf ')