From ee5c7b64f0bbbbad6608a62e5b8cd92e3315420b Mon Sep 17 00:00:00 2001
From: Ellpeck
diff --git a/node/blog.js b/node/blog.js index c14d534..a5f83fc 100644 --- a/node/blog.js +++ b/node/blog.js @@ -4,10 +4,10 @@ const { const fs = require("fs"); const converter = require("./showdown")(2); -let folder = __dirname + "/../"; +let folder = `${__dirname}/../`; console.log("Refreshing blog sub-sites..."); -fs.readFile(folder + "index.html", function (_, html) { +fs.readFile(`${folder}index.html`, function (_, html) { let templateDom = new JSDOM(html); // remove all non-blog stuff from the template (which is just our index.html) let noBlog = templateDom.window.document.getElementsByClassName("no-blog"); @@ -18,53 +18,50 @@ fs.readFile(folder + "index.html", function (_, html) { for (let i = 0; i < elements.length; i++) { let element = elements[i]; if (element.src && element.src.startsWith("./")) - element.src = "../" + element.src.substring(2); + element.src = `../${element.src.substring(2)}`; if (element.href && element.href.startsWith("./")) - element.href = "../" + element.href.substring(2); + element.href = `../${element.href.substring(2)}`; } let template = templateDom.serialize(); - fs.readFile(folder + "blog/src/posts.json", function (_, data) { - let json = JSON.parse(data); + fs.readFile(`${folder}blog/src/posts.json`, function (_, data) { + let json = JSON.parse(data.toString()); for (let i = 0; i < json.length; i++) { let post = json[i]; - fs.readFile(folder + "blog/src/" + post.id + ".md", function (_, content) { + fs.readFile(`${folder}blog/src/${post.id}.md`, function (_, content) { let dom = new JSDOM(template); let document = dom.window.document; - document.title += " - " + post.name; + document.title += ` - ${post.name}`; document.querySelector('meta[property="og:title"]').setAttribute("content", post.name); document.querySelector('meta[name="description"]').setAttribute("content", post.summary); document.querySelector('meta[property="og:description"]').setAttribute("content", post.summary); - let nav = ""; - nav += 'Back to Main Page'; let last = getAdjacentPost(json, i, -1); - if (last) - nav += 'Previous ' + post.cat + ' Post'; let next = getAdjacentPost(json, i, 1); - if (next) - nav += 'Next ' + post.cat + ' Post'; - document.getElementById("nav-items").innerHTML = nav; + document.getElementById("nav-items").innerHTML = /*html*/ ` + Back to Main Page + ${last ? /*html*/ `Previous ${post.cat} Post` : ""} + ${next ? /*html*/ `Next ${post.cat} Post` : ""} + `; - let c = ""; - c += '
This post has been archived.
" - c += converter.makeHtml(content.toString()); - c += 'This post has been archived.
` : ""} + ${converter.makeHtml(content.toString())} +]*>)?[\n\s]?]*)>/gi, function (match, pre, codeClass) {
if (pre) {
- return '';
+ return ``;
} else {
return ' ';
}
diff --git a/node/rss.js b/node/rss.js
index e4e8c4a..1c9ebfc 100644
--- a/node/rss.js
+++ b/node/rss.js
@@ -4,12 +4,12 @@ const {
const fs = require("fs");
const converter = require("./showdown")(1);
-let folder = __dirname + "/../";
+let folder = `${__dirname}/../`;
console.log("Refreshing feeds...");
createFeed(function (feed) {
- fs.writeFile(folder + "feed.json", feed.json1(), function (_, _) {});
- fs.writeFile(folder + "rss.xml", feed.rss2(), function (_, _) {});
- fs.writeFile(folder + "atom.xml", feed.atom1(), function (_, _) {});
+ fs.writeFile(`${folder}feed.json`, feed.json1(), function (_) {});
+ fs.writeFile(`${folder}rss.xml`, feed.rss2(), function (_) {});
+ fs.writeFile(`${folder}atom.xml`, feed.atom1(), function (_) {});
});
function createFeed(callback) {
@@ -33,17 +33,17 @@ function createFeed(callback) {
}
});
- fs.readFile(__dirname + "/../blog/src/posts.json", function (_, data) {
+ fs.readFile(`${__dirname}/../blog/src/posts.json`, function (_, data) {
let json = JSON.parse(data);
for (let i = json.length - 1; i >= 0; i--) {
let post = json[i];
let date = new Date(post.date);
- fs.readFile(__dirname + "/../blog/src/" + post.id + ".md", function (_, content) {
+ fs.readFile(`${__dirname}/../blog/src/${post.id}.md`, function (_, content) {
let html = converter.makeHtml(content.toString());
feed.addItem({
- title: post.name + (post.archived ? " (Archived)" : ""),
- link: "https://ellpeck.de/blog/" + post.id,
+ title: `${post.name}${post.archived ? " (Archived)" : ""}`,
+ link: `https://ellpeck.de/blog/${post.id}`,
description: post.summary,
content: html,
date: date,
@@ -55,9 +55,8 @@ function createFeed(callback) {
if (feed.categories.indexOf(post.cat) < 0)
feed.addCategory(post.cat);
- if (i == 0) {
+ if (i === 0)
callback(feed);
- }
});
}
});
diff --git a/scripts/about.js b/scripts/about.js
index 80db7c3..e811edb 100644
--- a/scripts/about.js
+++ b/scripts/about.js
@@ -22,7 +22,7 @@ const facts = [
const questions = [{
q: 'How old are you?',
- a: "I'm " + getAge() + " years old. This automatically updates now, too, so I won't ever forget to update it again!"
+ a: `I'm ${getAge()} years old. This automatically updates now, too, so I won't ever forget to update it again!`
},
{
q: 'Where are you from?',
@@ -71,11 +71,13 @@ const questions = [{
];
let a = '';
-for (question of questions) {
- a += '';
- a += 'Q: ' + question.q + '
';
- a += 'A: ' + question.a;
- a += '
';
+for (let question of questions) {
+ a += /*html*/ `
+
+ Q: ${question.q}
+ A: ${question.a}
+
+ `;
}
$('#about-list').html(a);
diff --git a/scripts/blog.js b/scripts/blog.js
index 34e1872..82cefa7 100644
--- a/scripts/blog.js
+++ b/scripts/blog.js
@@ -24,17 +24,19 @@ function populateBlog(json, cat) {
addCatButton(json, cats, "All");
for (let i = json.length - 1; i >= 0; i--) {
- var obj = json[i];
+ let obj = json[i];
addCatButton(json, cats, obj.cat);
- if (cat == "All" || obj.cat == cat) {
- let p = "";
- p += '';
- p += '';
- p += '' + obj.name + '
';
- p += '' + obj.summary + '';
- p += '' + obj.date + "";
- p += '' + obj.cat + "";
- p += '';
+ if (cat === "All" || obj.cat === cat) {
+ let p = /*html*/ `
+
+
+
+ `;
if (obj.archived) {
archive.append(p);
} else {
@@ -47,7 +49,7 @@ function populateBlog(json, cat) {
function addCatButton(json, cats, cat) {
let catAnchor = `blog-cat-${cat.toLowerCase().replace(" ", "_")}`;
if (!$(`#${catAnchor}`).length) {
- cats.append(``);
+ cats.append( /*html*/ ``);
$(`#${catAnchor}`).on('click', function () {
populateBlog(json, cat);
});
diff --git a/scripts/cookieinfo.js b/scripts/cookieinfo.js
index 779166d..6b50f98 100644
--- a/scripts/cookieinfo.js
+++ b/scripts/cookieinfo.js
@@ -1,13 +1,14 @@
if (getCookie("notification") !== "true") {
- let notif = "";
- notif += '';
- notif += "This site uses cookies to store information about your browsing activity.";
- notif += "
For more information, check out the privacy policy.";
- notif += "
Have a nice day!";
- notif += '';
- document.write(notif);
+ document.write( /*html*/ `
+
+ This site uses cookies to store information about your browsing activity.
+
For more information, check out the privacy policy.
+
Have a nice day!
+
+
+ `);
$("#notif-close").on("click", function () {
setCookie("notification", "true", 365);
diff --git a/scripts/main.js b/scripts/main.js
index e5c8216..9cb85f5 100644
--- a/scripts/main.js
+++ b/scripts/main.js
@@ -1,13 +1,13 @@
const dark = getCookie("dark") === "true";
-const pride = new Date().getMonth() == 5;
+const pride = new Date().getMonth() === 5;
const loc = $("script").last().attr("src").split("/")[0];
if (dark) {
- document.write(``)
- document.write(``)
+ document.write( /*html*/ ``);
+ document.write( /*html*/ ``);
}
if (pride)
- document.write(``)
+ document.write( /*html*/ ``);
$(function () {
let openModals = function (hash) {
@@ -20,7 +20,7 @@ $(function () {
openModals(window.location.hash);
$('a').on('click', function () {
openModals($(this).attr('href'));
- });;
+ });
$('.navbar-collapse a').on('click', function () {
$('.navbar-collapse').collapse('hide');
diff --git a/scripts/projects.js b/scripts/projects.js
index 6046153..8eb2f86 100644
--- a/scripts/projects.js
+++ b/scripts/projects.js
@@ -66,23 +66,23 @@ const projects = [{
];
let p = '';
-for (project of projects) {
- p += '';
- p += '';
- p += '';
-
- p += '' + project.name + '
';
- p += '' + project.desc + '
';
- if (project.status)
- p += '' + project.status + '';
-
+for (let project of projects) {
+ let links = "";
if (project.links) {
- for (let name in project.links) {
- p += '' + name + '';
- }
+ for (let name in project.links)
+ links += /*html*/ `${name}`;
}
- p += '';
- p += '';
+ p += /*html*/ `
+
+
+
+ ${project.name}
+ ${project.desc}
+ ${project.status ? /*html*/ `${project.status}` : ""}
+ ${links}
+
+
+ `;
}
$('#project-list').html(p);
\ No newline at end of file
diff --git a/scripts/quote.js b/scripts/quote.js
index 7065f4e..285e66a 100644
--- a/scripts/quote.js
+++ b/scripts/quote.js
@@ -341,4 +341,4 @@ const quotes = [
"Dann sagt ihr schau, the end is near, bitte face your final curtain",
"Diese Geister singen schief und sind nicht einfach auszutreiben"
];
-$('#quote-text').html('🎵 ' + quotes[Math.floor(Math.random() * quotes.length)] + '');
\ No newline at end of file
+$('#quote-text').html(`🎵 ${quotes[Math.floor(Math.random() * quotes.length)]}`);
\ No newline at end of file
diff --git a/scripts/social.js b/scripts/social.js
index f2da2f4..09fe81f 100644
--- a/scripts/social.js
+++ b/scripts/social.js
@@ -36,17 +36,20 @@ const socials = [{
];
let s = '';
-for (social of socials) {
- s += '';
+for (let social of socials) {
let icon = social.name.toLowerCase();
if (dark && social.darkIcon)
icon += '_dark';
- s += '';
- s += social.name;
- s += ''
+ s += /*html*/ `
+
+ ${social.name}
+
+ `;
}
$('#social-list').html(s);
-var disc = $("#discord-div");
-var theme = dark ? "dark" : "light";
-disc.html('');
\ No newline at end of file
+let disc = $("#discord-div");
+let theme = dark ? "dark" : "light";
+disc.html( /*html*/ `
+
+`);
\ No newline at end of file
diff --git a/scripts/util.js b/scripts/util.js
index b3100e0..fb97f90 100644
--- a/scripts/util.js
+++ b/scripts/util.js
@@ -2,21 +2,21 @@ function getCookie(key) {
let c = document.cookie;
if (!c)
return undefined;
- let start = c.indexOf(key + "=") + key.length + 1;
+ let start = c.indexOf(`${key}=`) + key.length + 1;
let end = c.indexOf(";", start);
return c.substring(start, end < 0 ? c.length : end);
}
function setCookie(key, value, days) {
- var date = new Date();
+ let date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
- document.cookie = key + "=" + value + "; expires=" + date.toUTCString();
+ document.cookie = `${key}=${value}; expires=${date.toUTCString()}`;
}
function forceToAnchor() {
// this is probably a terrible hack
if (window.location.hash.startsWith("#")) {
- var anchor = $(window.location.hash);
+ let anchor = $(window.location.hash);
if (anchor.length) {
$('html, body').animate({
scrollTop: anchor.offset().top