made non-blog content be removed by html class instead of by regex
Web/pipeline/head This commit looks good Details

This commit is contained in:
Ell 2020-09-23 04:23:40 +02:00
parent 73cc32dc62
commit fb7c50f3e5
2 changed files with 115 additions and 111 deletions

View File

@ -83,92 +83,92 @@
<script src="scripts/cookieinfo.js"></script> <script src="scripts/cookieinfo.js"></script>
<div id="main"> <div id="main">
<!-- NOBLOG --> <div class="no-blog">
<!-- Home --> <!-- Home -->
<div class="jumbotron"> <div class="jumbotron">
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-md-auto"> <div class="col-md-auto">
<img src="res/me.png" class="rounded-circle" width="200" height="200" id="navbar-image"> <img src="res/me.png" class="rounded-circle" width="200" height="200" id="navbar-image">
</div> </div>
<div class="col"> <div class="col">
<h1 class="display-4" id="intro-text"></h1> <h1 class="display-4" id="intro-text"></h1>
<script src="scripts/greet.js"></script> <script src="scripts/greet.js"></script>
<p class="lead">Welcome to my little website! I'm Ellpeck, a student and programmer from Germany. I do a lot of stuff, actually. My life is pretty busy.</p> <p class="lead">Welcome to my little website! I'm Ellpeck, a student and programmer from Germany. I do a lot of stuff, actually. My life is pretty busy.</p>
<p>Look around this website to find out more about my projects and other places you can find me!</p> <p>Look around this website to find out more about my projects and other places you can find me!</p>
</div>
</div> </div>
</div> </div>
</div> </div>
</div>
<!-- Projects --> <!-- Projects -->
<a class="anchor" id="projects"></a> <a class="anchor" id="projects"></a>
<div class="list-display rounded"> <div class="list-display rounded">
<h1>Projects</h1> <h1>Projects</h1>
<p> <p>
Here is a list of some of the things that you might know me from. If you want to have a more in-depth look at everything I do, check out some of the sites linked in the <a href="#social">Social</a> section. Here is a list of some of the things that you might know me from. If you want to have a more in-depth look at everything I do, check out some of the sites linked in the <a href="#social">Social</a> section.
</p> </p>
<div id="project-list"> <div id="project-list">
<em>The content that should be here is dynamically generated. Please enable JavaScript if you see this.</em>
</div>
<script src="scripts/projects.js"></script>
</div>
<!-- Social -->
<a class="anchor" id="social"></a>
<div class="list-display rounded">
<h1>Social</h1>
<p>
These are other websites where you can find me and the things I do, including the pages where I publish my code and games and where I sometimes stream and upload videos. This list also includes a lot of ways to reach me.
</p>
<div class="row">
<div class="col">
<div id="social-list">
<em>The content that should be here is dynamically generated. Please enable JavaScript if you see this.</em>
</div>
Additionally, here are some miscellaneous platforms:
<ul>
<li>My Nintendo Switch friend code is <strong>SW-5281-8834-6801</strong></li>
<li>If you want to play my Mario Maker 2 levels, my ID is <strong>8BH-566-4WF</strong></li>
<li>If you play The Sims 4, you can check out my builds on the gallery by searching for <strong>Ellpeck</strong></li>
</ul>
</div>
<div class="col-md-auto" id="discord-div">
<em>The content that should be here is dynamically generated. Please enable JavaScript if you see this.</em> <em>The content that should be here is dynamically generated. Please enable JavaScript if you see this.</em>
</div> </div>
<script src="scripts/projects.js"></script>
</div> </div>
<script src="scripts/social.js"></script> <!-- Social -->
</div> <a class="anchor" id="social"></a>
<div class="list-display rounded">
<h1>Social</h1>
<p>
These are other websites where you can find me and the things I do, including the pages where I publish my code and games and where I sometimes stream and upload videos. This list also includes a lot of ways to reach me.
</p>
<div class="row">
<div class="col">
<div id="social-list">
<em>The content that should be here is dynamically generated. Please enable JavaScript if you see this.</em>
</div>
<!-- About --> Additionally, here are some miscellaneous platforms:
<a class="anchor" id="about"></a> <ul>
<div class="list-display rounded"> <li>My Nintendo Switch friend code is <strong>SW-5281-8834-6801</strong></li>
<h1>About</h1> <li>If you want to play my Mario Maker 2 levels, my ID is <strong>8BH-566-4WF</strong></li>
<p> <li>If you play The Sims 4, you can check out my builds on the gallery by searching for <strong>Ellpeck</strong></li>
Sometimes, some people ask me some questions about myself or my projects, so I decided to compile a list of some of the answers in a Q&A-like fashion so that I don't have to keep repeating them. If you're curious about me, this might be interesting to you! </ul>
</p> </div>
<div id="about-list"> <div class="col-md-auto" id="discord-div">
<em>The content that should be here is dynamically generated. Please enable JavaScript if you see this.</em> <em>The content that should be here is dynamically generated. Please enable JavaScript if you see this.</em>
</div>
</div>
<script src="scripts/social.js"></script>
</div> </div>
<script src="scripts/about.js"></script>
</div>
<!-- Blog --> <!-- About -->
<a class="anchor" id="blog"></a> <a class="anchor" id="about"></a>
<div class="list-display rounded"> <div class="list-display rounded">
<h1>Blog</h1> <h1>About</h1>
<p> <p>
Occasionally I enjoy writing stuff. So here's some of the stuff I've written. Just click on any of the headers to open the post. Alternatively, you can subscribe to this blog using <a href="/rss.xml">RSS</a>, <a href="/atom.xml">Atom</a> or <a href="/feed.json">JSON</a>. Sometimes, some people ask me some questions about myself or my projects, so I decided to compile a list of some of the answers in a Q&A-like fashion so that I don't have to keep repeating them. If you're curious about me, this might be interesting to you!
</p> </p>
<div id="about-list">
<div id="blog-list"> <em>The content that should be here is dynamically generated. Please enable JavaScript if you see this.</em>
<em>The content that should be here is dynamically generated. Please enable JavaScript if you see this.</em> </div>
<script src="scripts/about.js"></script>
</div>
<!-- Blog -->
<a class="anchor" id="blog"></a>
<div class="list-display rounded">
<h1>Blog</h1>
<p>
Occasionally I enjoy writing stuff. So here's some of the stuff I've written. Just click on any of the headers to open the post. Alternatively, you can subscribe to this blog using <a href="/rss.xml">RSS</a>, <a href="/atom.xml">Atom</a> or <a href="/feed.json">JSON</a>.
</p>
<div id="blog-list">
<em>The content that should be here is dynamically generated. Please enable JavaScript if you see this.</em>
</div>
<script src="scripts/blog.js"></script>
</div> </div>
<script src="scripts/blog.js"></script>
</div> </div>
<!-- /NOBLOG -->
</div> </div>
</div> </div>
@ -182,40 +182,40 @@
</div> </div>
</div> </div>
<!-- NOBLOG --> <div class="no-blog">
<!-- Commissions --> <!-- Commissions -->
<div class="modal fade" id="commissions-modal" tabindex="-1"> <div class="modal fade" id="commissions-modal" tabindex="-1">
<div class="modal-dialog modal-lg"> <div class="modal-dialog modal-lg">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h1 class="modal-title">Ellpeck's Minecraft Mod Commissions</h1> <h1 class="modal-title">Ellpeck's Minecraft Mod Commissions</h1>
<button type="button" class="close" data-dismiss="modal">&times;</button> <button type="button" class="close" data-dismiss="modal">&times;</button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p>If you need a small to medium sized Minecraft mod for a modpack, a video or for personal use, you can contact me to make it for you.</p> <p>If you need a small to medium sized Minecraft mod for a modpack, a video or for personal use, you can contact me to make it for you.</p>
<p>Here is all the information you need if you want to commission me to make a mod for you:</p> <p>Here is all the information you need if you want to commission me to make a mod for you:</p>
<ul> <ul>
<li>Minecraft Forge mods only</li> <li>Minecraft Forge mods only</li>
<li>Minecraft Versions 1.12.2 and upwards only</li> <li>Minecraft Versions 1.12.2 and upwards only</li>
<li>No ports of existing mods or content</li> <li>No ports of existing mods or content</li>
<li>No content that can't be created using "traditional" Java code (coremods)</li> <li>No content that can't be created using "traditional" Java code (coremods)</li>
<li>I charge between 10€ ($11) and 30€ ($33) an hour <li>I charge between 10€ ($11) and 30€ ($33) an hour
<ul> <ul>
<li>I estimate the total amount of time it will take based on the size and complexity of the mod beforehand</li> <li>I estimate the total amount of time it will take based on the size and complexity of the mod beforehand</li>
<li>The amount I estimate will be what you pay for, no matter how much longer or shorter it actually takes. This usually works out in your favor</li> <li>The amount I estimate will be what you pay for, no matter how much longer or shorter it actually takes. This usually works out in your favor</li>
<li>I request half of the amount to be paid before I start working on the mod, the other half once I'm finished. That way, there's security for both of us</li> <li>I request half of the amount to be paid before I start working on the mod, the other half once I'm finished. That way, there's security for both of us</li>
</ul> </ul>
</li> </li>
<li>You will have the choice of whether you want to receive the source code privately or whether I should publish it on GitHub</li> <li>You will have the choice of whether you want to receive the source code privately or whether I should publish it on GitHub</li>
<li>You will have the choice of whether you want to be sent the mod jar or whether I should publish the mod on CurseForge. If the mod is published on CurseForge, you will get up to 50% of the share of Curse Points generated through the mod</li> <li>You will have the choice of whether you want to be sent the mod jar or whether I should publish the mod on CurseForge. If the mod is published on CurseForge, you will get up to 50% of the share of Curse Points generated through the mod</li>
<li>After the mod is completed, bug fixes are included for free, but feature updates and Minecraft version updates are not. They can be requested at a later date for a small fee though</li> <li>After the mod is completed, bug fixes are included for free, but feature updates and Minecraft version updates are not. They can be requested at a later date for a small fee though</li>
</ul> </ul>
<p>If you're interested, you can either <a href="mailto:me@ellpeck.de">send me an email</a>, but better yet, <a href="https://ellpeck.de/discord">join my Discord server</a> and message me privately from there so we can talk about the details.</p> <p>If you're interested, you can either <a href="mailto:me@ellpeck.de">send me an email</a>, but better yet, <a href="https://ellpeck.de/discord">join my Discord server</a> and message me privately from there so we can talk about the details.</p>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!-- /NOBLOG -->
<!-- Impressum --> <!-- Impressum -->
<div class="modal fade" id="impressum-modal" tabindex="-1"> <div class="modal fade" id="impressum-modal" tabindex="-1">

View File

@ -7,23 +7,27 @@ const converter = require("./showdown")(2);
let folder = __dirname + "/../"; let folder = __dirname + "/../";
console.log("Refreshing blog sub-sites..."); console.log("Refreshing blog sub-sites...");
fs.readFile(folder + "index.html", function (_, data) { fs.readFile(folder + "index.html", function (_, html) {
// this can probably be done a lot easier but regex is hard ok let templateDom = new JSDOM(html);
var template = data.toString().replace(/<!-- ?NOBLOG ?-->([^](?!<!-- ?NOBLOG ?-->))*<!-- ?\/NOBLOG ?-->/g, ""); let noBlog = templateDom.window.document.getElementsByClassName("no-blog");
while (noBlog.length > 0)
noBlog[0].parentNode.removeChild(noBlog[0]);
let template = templateDom.serialize();
fs.readFile(folder + "blog/posts.json", function (_, data) { fs.readFile(folder + "blog/posts.json", function (_, data) {
let json = JSON.parse(data); let json = JSON.parse(data);
for (let i = 0; i < json.length; i++) { for (let i = 0; i < json.length; i++) {
let post = json[i]; let post = json[i];
fs.readFile(folder + "blog/" + post.id + ".md", function (_, content) { fs.readFile(folder + "blog/" + post.id + ".md", function (_, content) {
let dom = new JSDOM(template); let dom = new JSDOM(template);
var document = dom.window.document; 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[property="og:title"]').setAttribute("content", post.name);
document.querySelector('meta[name="description"]').setAttribute("content", post.summary); document.querySelector('meta[name="description"]').setAttribute("content", post.summary);
document.querySelector('meta[property="og:description"]').setAttribute("content", post.summary); document.querySelector('meta[property="og:description"]').setAttribute("content", post.summary);
var nav = ""; let nav = "";
nav += '<a class="nav-item nav-link" href="/#blog">Back to Main Page</a>'; nav += '<a class="nav-item nav-link" href="/#blog">Back to Main Page</a>';
let last = getAdjacentPost(json, i, -1); let last = getAdjacentPost(json, i, -1);
if (last) if (last)
@ -33,7 +37,7 @@ fs.readFile(folder + "index.html", function (_, data) {
nav += '<a class="nav-item nav-link" href="/blog-' + next.id + '">Next Post</a>'; nav += '<a class="nav-item nav-link" href="/blog-' + next.id + '">Next Post</a>';
document.getElementById("nav-items").innerHTML = nav; document.getElementById("nav-items").innerHTML = nav;
var c = ""; let c = "";
c += '<div class="list-display rounded">'; c += '<div class="list-display rounded">';
c += '<div class="blog-isolated">' c += '<div class="blog-isolated">'
c += '<h1>' + post.name + '</h1>'; c += '<h1>' + post.name + '</h1>';
@ -48,8 +52,8 @@ fs.readFile(folder + "index.html", function (_, data) {
c += '</div></div>'; c += '</div></div>';
document.getElementById("main").innerHTML = c; document.getElementById("main").innerHTML = c;
let html = dom.serialize(); let ret = dom.serialize();
fs.writeFile(folder + "blog-" + post.id + ".html", html, function (_, _) {}); fs.writeFile(folder + "blog-" + post.id + ".html", ret, function (_, _) {});
}); });
} }
}); });