Upgrade to template v3

This commit is contained in:
Florine W. Dekker 2022-11-21 22:08:43 +01:00
parent 51f1fd8485
commit a9575921b5
Signed by: FWDekker
GPG Key ID: D3DCFAA8A4560BE0
6 changed files with 41 additions and 68 deletions

View File

@ -7,16 +7,13 @@ module.exports = grunt => {
default: ["dist/"], default: ["dist/"],
}, },
copy: { copy: {
css: {
files: [{expand: true, cwd: "src/main/", src: "**/*.css", dest: "dist/", flatten: true}]
},
html: { html: {
files: [{expand: true, cwd: "src/main/", src: "**/*.html", dest: "dist/", flatten: true}] files: [{expand: true, cwd: "src/main/", src: "**/*.html", dest: "dist/", flatten: true}]
}, },
}, },
focus: { focus: {
dev: { dev: {
include: ["css", "html", "js"], include: ["html", "js"],
}, },
}, },
replace: { replace: {
@ -42,10 +39,6 @@ module.exports = grunt => {
}, },
}, },
watch: { watch: {
css: {
files: ["src/main/**/*.css"],
tasks: ["copy:css"],
},
html: { html: {
files: ["src/main/**/*.html"], files: ["src/main/**/*.html"],
tasks: ["copy:html"], tasks: ["copy:html"],
@ -95,7 +88,6 @@ module.exports = grunt => {
// Pre // Pre
"clean", "clean",
// Copy files // Copy files
"copy:css",
"copy:html", "copy:html",
// Compile JS // Compile JS
"webpack:dev", "webpack:dev",
@ -106,7 +98,6 @@ module.exports = grunt => {
// Pre // Pre
"clean", "clean",
// Copy files // Copy files
"copy:css",
"copy:html", "copy:html",
// Compile JS // Compile JS
"webpack:deploy", "webpack:deploy",

BIN
package-lock.json generated

Binary file not shown.

View File

@ -1,6 +1,6 @@
{ {
"name": "tools", "name": "tools",
"version": "1.1.6", "version": "1.1.7",
"description": "Main page for the /tools directory.", "description": "Main page for the /tools directory.",
"author": "Florine W. Dekker", "author": "Florine W. Dekker",
"browser": "dist/bundle.js", "browser": "dist/bundle.js",
@ -16,15 +16,15 @@
"deploy": "grunt deploy" "deploy": "grunt deploy"
}, },
"devDependencies": { "devDependencies": {
"grunt": "^1.4.1", "grunt": "^1.5.3",
"grunt-cli": "^1.4.3", "grunt-cli": "^1.4.3",
"grunt-contrib-clean": "^2.0.0", "grunt-contrib-clean": "^2.0.1",
"grunt-contrib-copy": "^1.0.0", "grunt-contrib-copy": "^1.0.0",
"grunt-contrib-watch": "^1.1.0", "grunt-contrib-watch": "^1.1.0",
"grunt-focus": "^1.0.0", "grunt-focus": "^1.0.0",
"grunt-text-replace": "^0.4.0", "grunt-text-replace": "^0.4.0",
"grunt-webpack": "^5.0.0", "grunt-webpack": "^5.0.0",
"webpack": "^5.69.1", "webpack": "^5.75.0",
"webpack-cli": "^4.9.2" "webpack-cli": "^5.0.0"
} }
} }

View File

@ -1,8 +0,0 @@
#listing {
margin: 0 auto;
max-width: 28rem;
}
#listing ul {
list-style: none;
}

View File

@ -8,17 +8,20 @@
<meta name="description" content="Florine's tools" /> <meta name="description" content="Florine's tools" />
<meta name="theme-color" content="#0033cc" /> <meta name="theme-color" content="#0033cc" />
<meta name="fwd:nav:target" content="#nav" />
<meta name="fwd:nav:highlight-path" content="/Tools/" />
<meta name="fwd:footer:target" content="#footer" />
<meta name="fwd:footer:vcs-url" content="https://git.fwdekker.com/tools/tools/" />
<meta name="fwd:footer:version" content="v%%VERSION_NUMBER%%" />
<title>Tools | FWDekker</title> <title>Tools | FWDekker</title>
<link rel="stylesheet" href="https://static.fwdekker.com/fonts/roboto/roboto.css" /> <link rel="stylesheet" href="https://static.fwdekker.com/lib/template/3.x.x/template.css?v=%%VERSION_NUMBER%%" />
<link rel="stylesheet" href="https://static.fwdekker.com/lib/template/2.x.x/template.css" />
<!--suppress HtmlUnknownTarget -->
<link rel="stylesheet" href="main.css?v=%%VERSION_NUMBER%%" />
<script async src="https://stats.fwdekker.com/count.js" <script async src="https://stats.fwdekker.com/count.js"
data-goatcounter="https://stats.fwdekker.com/count"></script> data-goatcounter="https://stats.fwdekker.com/count"></script>
</head> </head>
<body> <body>
<noscript> <noscript class="fwd-js-notice">
<img src="https://stats.fwdekker.com/count?p=/tools/" alt="Counting pixel" /> <img src="https://stats.fwdekker.com/count?p=/tools/" alt="Counting pixel" />
<p> <p>
@ -30,24 +33,25 @@
Alternatively, check out the <a href="https://fwdekker.com/api/nav/">JSON site map</a>. Alternatively, check out the <a href="https://fwdekker.com/api/nav/">JSON site map</a>.
</p> </p>
</noscript> </noscript>
<main class="hidden"> <nav id="nav"></nav>
<div id="nav"></div> <main class="container hidden">
<div id="contents"> <div role="document">
<div id="header"></div> <section>
<header class="fwd-header">
<hgroup>
<h1><a href=".">Tools</a></h1>
<h2>An overview of tools I have created.</h2>
</hgroup>
</header>
<!-- Listing --> <!-- Listing -->
<section class="container"> <div id="listing"></div>
<div class="row">
<div class="column">
<div id="listing"></div>
</div>
</div>
</section> </section>
<footer id="footer"></footer>
</div> </div>
<div id="footer"></div>
</main> </main>
<script src="https://static.fwdekker.com/lib/template/2.x.x/template.js"></script> <script src="https://static.fwdekker.com/lib/template/3.x.x/template.js?v=%%VERSION_NUMBER%%"></script>
<!--suppress HtmlUnknownTarget --> <!--suppress HtmlUnknownTarget -->
<script src="bundle.js?v=%%VERSION_NUMBER%%"></script> <script src="bundle.js?v=%%VERSION_NUMBER%%"></script>
</body> </body>

View File

@ -1,44 +1,30 @@
// noinspection JSUnresolvedVariable // noinspection JSUnresolvedVariable
const {$, doAfterLoad, footer, header, nav, stringToHtml} = window.fwdekker; const {$, doAfterLoad, stringToHtml} = window.fwdekker;
/** /**
* Transforms the given (nested) entry into a list item to be displayed in HTML. * Transforms the given (nested) entry into a list item to be displayed in HTML.
* *
* @param entry the entry to transform * @param entry the entry to transform
* @param depth the current level of nesting
* @returns {string} the HTML form of the given entry * @returns {string} the HTML form of the given entry
*/ */
const unpackEntry = (entry, depth = 0) => { const unpackEntry = (entry) => {
const subEntries = entry.entries.length === 0 const subEntries = entry.entries.length === 0
? "" ? ""
: `<ul>` + entry.entries.map(it => unpackEntry(it, depth + 1)).join("") + `</ul>`; : `<ul>${entry.entries.map(unpackEntry).join("")}</ul>`;
return "" + return `<li><a href="${entry.link}">${entry.name}</a>${subEntries}</li>`;
`<h${depth + 4}>` +
`<a href="${entry.link}">${entry.name}</a>` +
subEntries +
`</h${depth + 4}>`;
};
/**
* Displays the given entries on the page.
*
* @param entries the entries to display
*/
const showEntries = entries => {
const toolEntries = entries.entries.find(it => it.name === "Tools").entries;
const entryHtml = stringToHtml(`<ul>${toolEntries.map(entry => unpackEntry(entry)).join("")}</ul>`, "ul");
$("#listing").append(entryHtml);
}; };
doAfterLoad(() => { doAfterLoad(() => {
$("#nav").appendChild(nav("/Tools/", showEntries)); fetch("https://fwdekker.com/api/nav/")
$("#header").appendChild(header({title: "Tools", description: "An overview of tools I have created"})); .then(it => it.json())
$("#footer").appendChild(footer({ .then(json => {
vcsURL: "https://git.fwdekker.com/tools/tools/", const toolEntries = json.entries.find(it => it.name === "Tools").entries;
version: "v%%VERSION_NUMBER%%" const entryHtml = stringToHtml(`<ul>${toolEntries.map(entry => unpackEntry(entry)).join("")}</ul>`, "ul");
})); $("#listing").append(entryHtml);
$("main").classList.remove("hidden");
$("main").classList.remove("hidden");
});
}); });