/* Copyright: (C) 2022-2023 Daniele 'dzonerzy' Linguaglossa - http://libdzonerzy.so This file is part of libdzonerzy.so. GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. */ #define _POSIX_C_SOURCE 200809L #include "libdzonerzy.so.h" #include "res.h" // this is a shared object library #define MAIN_CSS \ CSS_COMMENT("main.css") \ CSS_NEWLINE() \ CSS_SELECTOR(":root") \ CSS_PROPERTY("--main-link-color", "#215fc2") \ CSS_END_SELECTOR() \ CSS_SELECTOR("html") \ CSS_PROPERTY("margin", "0") \ CSS_PROPERTY("padding", "0") \ CSS_PROPERTY("width", "100%") \ CSS_PROPERTY("height", "100vh") \ CSS_END_SELECTOR() \ CSS_SELECTOR("body") \ CSS_PROPERTY("margin", "auto") \ CSS_PROPERTY("max-width", "60em") \ CSS_PROPERTY("min-height", "100vh") \ CSS_PROPERTY("font-family", "monospace") \ CSS_PROPERTY("font-size", "1.23em") \ CSS_PROPERTY("background-color", "#ddd") \ CSS_PROPERTY("display", "flex") \ CSS_PROPERTY("flex-direction", "column") \ CSS_END_SELECTOR() \ CSS_SELECTOR("nav#TOC > ul") \ CSS_PROPERTY("list-style-type", "decimal") \ CSS_END_SELECTOR() \ CSS_SELECTOR("nav#TOC ul li") \ CSS_PROPERTY("margin-bottom", "1em") \ CSS_END_SELECTOR() \ CSS_SELECTOR("#title-block-header, #TOC") \ CSS_PROPERTY("border", "1px solid #222") \ CSS_PROPERTY("border-radius", "15px") \ CSS_PROPERTY("background-color", "#ccc") \ CSS_PROPERTY("color", "#000") \ CSS_PROPERTY("margin", "1em") \ CSS_PROPERTY("padding", "1em") \ CSS_END_SELECTOR() \ CSS_SELECTOR("footer") \ CSS_PROPERTY("border", "1px solid #222") \ CSS_PROPERTY("border-radius", "15px") \ CSS_PROPERTY("background-color", "#ccc") \ CSS_PROPERTY("color", "#000") \ CSS_PROPERTY("flex-shrink", "0") \ CSS_PROPERTY("display", "flex") \ CSS_PROPERTY("flex-direction", "column") \ CSS_PROPERTY("justify-content", "center") \ CSS_PROPERTY("align-items", "center") \ CSS_PROPERTY("font-size", "0.9em") \ CSS_END_SELECTOR() \ CSS_SELECTOR("div.hearth") \ CSS_PROPERTY("display", "flex") \ CSS_PROPERTY("justify-content", "center") \ CSS_PROPERTY("align-items", "center") \ CSS_PROPERTY("margin-left", "0.2em") \ CSS_PROPERTY("margin-right", "0.2em") \ CSS_PROPERTY("font-size", "1.5em") \ CSS_PROPERTY("padding", "0px") \ CSS_PROPERTY("animation", "bounce 1s infinite") \ CSS_PROPERTY("color", "#d00000") \ CSS_END_SELECTOR() \ CSS_SELECTOR("b.author") \ CSS_PROPERTY("color", "#000") \ CSS_PROPERTY("text-transform", "uppercase") \ CSS_END_SELECTOR() \ CSS_SELECTOR("p.author::before") \ CSS_PROPERTY("text-transform", "lowercase") \ CSS_PROPERTY("font-weight", "normal") \ CSS_PROPERTY("content", "\"by \"") \ CSS_END_SELECTOR() \ CSS_SELECTOR("p.date::before") \ CSS_PROPERTY("text-transform", "lowercase") \ CSS_PROPERTY("font-weight", "normal") \ CSS_PROPERTY("content", "\"updated on \"") \ CSS_END_SELECTOR() \ CSS_SELECTOR("p.date") \ CSS_PROPERTY("text-transform", "capitalize") \ CSS_PROPERTY("font-weight", "bold") \ CSS_END_SELECTOR() \ CSS_SELECTOR("p.author") \ CSS_PROPERTY("text-transform", "uppercase") \ CSS_PROPERTY("font-weight", "bold") \ CSS_END_SELECTOR() \ CSS_SELECTOR("h1.title") \ CSS_PROPERTY("text-align", "center") \ CSS_END_SELECTOR() \ CSS_SELECTOR("section") \ CSS_PROPERTY("margin", "1em") \ CSS_PROPERTY("flex", "1 0 auto") \ CSS_END_SELECTOR() \ CSS_SELECTOR("h1, h2, h3, h4, h5, h6") \ CSS_PROPERTY("font-family", "monospace") \ CSS_PROPERTY("clear", "both") \ CSS_END_SELECTOR() \ CSS_SELECTOR("img") \ CSS_PROPERTY("padding", "2px") \ CSS_PROPERTY("border", "2px dashed #333") \ CSS_PROPERTY("background-color", "#fff") \ CSS_PROPERTY("color", "#000") \ CSS_PROPERTY("height", "15em") \ CSS_PROPERTY("float", "right") \ CSS_PROPERTY("clear", "right") \ CSS_PROPERTY("margin-left", "1em") \ CSS_PROPERTY("margin-bottom", "1em") \ CSS_END_SELECTOR() \ CSS_SELECTOR("figcaption") \ CSS_PROPERTY("display", "none") \ CSS_END_SELECTOR() \ CSS_SELECTOR("@keyframes bounce") \ CSS_END_SELECTOR() \ CSS_SELECTOR("from, to") \ CSS_PROPERTY("transform", "scale(1, 1)") \ CSS_END_SELECTOR() \ CSS_SELECTOR("25%") \ CSS_PROPERTY("transform", "scale(0.9, 1.1)") \ CSS_END_SELECTOR() \ CSS_SELECTOR("50%") \ CSS_PROPERTY("transform", "scale(1.1, 0.9)") \ CSS_END_SELECTOR() \ CSS_SELECTOR("75%") \ CSS_PROPERTY("transform", "scale(0.95, 1.05)") \ CSS_END_SELECTOR() \ CSS_SELECTOR("header ~ *") \ CSS_PROPERTY("margin", "1em") \ CSS_PROPERTY("padding", "1em") \ CSS_END_SELECTOR() \ CSS_SELECTOR("footer > span") \ CSS_PROPERTY("display", "flex") \ CSS_PROPERTY("text-align", "center") \ CSS_PROPERTY("justify-content", "center") \ CSS_PROPERTY("align-items", "center") \ CSS_END_SELECTOR() \ CSS_SELECTOR("strong") \ CSS_PROPERTY("font-weight", "bold") \ CSS_PROPERTY("color", "rgb(130, 12, 12)") \ CSS_END_SELECTOR() \ CSS_SELECTOR("a > strong") \ CSS_PROPERTY("text-decoration", "none") \ CSS_END_SELECTOR() \ CSS_SELECTOR("a:hover > strong") \ CSS_PROPERTY("text-decoration", "underline") \ CSS_END_SELECTOR() \ CSS_SELECTOR("pre") \ CSS_PROPERTY("padding", "1rem") \ CSS_END_SELECTOR() \ CSS_SELECTOR("div.sourceCode") \ CSS_PROPERTY("background-color", "#ffd") \ CSS_END_SELECTOR() \ CSS_SELECTOR("pre, code") \ CSS_PROPERTY("font-family", "\"Fira Code\", monospace") \ CSS_PROPERTY("background-color", "#ffd") \ CSS_PROPERTY("color", "#1e1e1e") \ CSS_PROPERTY("overflow", "auto") \ CSS_PROPERTY("max-height", "500px") \ CSS_PROPERTY("line-height", "1.6") \ CSS_END_SELECTOR() \ CSS_SELECTOR("pre") \ CSS_PROPERTY("margin", "1em 0") \ CSS_PROPERTY("line-height", "1.5") \ CSS_PROPERTY("font-size", "0.9em") \ CSS_END_SELECTOR() \ CSS_SELECTOR("pre::-webkit-scrollbar, code::-webkit-scrollbar, div.sourceCode::-webkit-scrollbar") \ CSS_PROPERTY("width", "15px") \ CSS_PROPERTY("height", "15px") \ CSS_PROPERTY("background-color", "#ffd") \ CSS_END_SELECTOR() \ CSS_SELECTOR("pre::-webkit-scrollbar-thumb, code::-webkit-scrollbar-thumb, div.sourceCode::-webkit-scrollbar-thumb") \ CSS_PROPERTY("background-color", "#dcdcba") \ CSS_PROPERTY("border-radius", "6px") \ CSS_PROPERTY("border", "1px solid #fff") \ CSS_END_SELECTOR() \ CSS_SELECTOR("pre::-webkit-scrollbar-track, code::-webkit-scrollbar-track, div.sourceCode::-webkit-scrollbar-track") \ CSS_PROPERTY("background-color", "#ffd") \ CSS_END_SELECTOR() \ CSS_SELECTOR("pre.numberSource") \ CSS_PROPERTY("padding-left", "3.5em") \ CSS_PROPERTY("counter-reset", "line-number") \ CSS_END_SELECTOR() \ CSS_SELECTOR("pre.numberSource code > span::before") \ CSS_PROPERTY("counter-increment", "line-number") \ CSS_PROPERTY("content", "counter(line-number)") \ CSS_PROPERTY("display", "inline-block") \ CSS_PROPERTY("width", "2.5em") \ CSS_PROPERTY("margin-right", "1em") \ CSS_PROPERTY("color", "#666") \ CSS_PROPERTY("text-align", "right") \ CSS_END_SELECTOR() \ CSS_SELECTOR("blockquote img") \ CSS_PROPERTY("clear", "none") \ CSS_PROPERTY("height", "auto") \ CSS_PROPERTY("max-height", "32em") \ CSS_PROPERTY("max-width", "100%") \ CSS_PROPERTY("float", "none") \ CSS_END_SELECTOR() \ CSS_SELECTOR("blockquote") \ CSS_PROPERTY("padding", "1em") \ CSS_PROPERTY("color", "#111") \ CSS_PROPERTY("clear", "both") \ CSS_PROPERTY("padding-top", "0.25em") \ CSS_PROPERTY("padding-bottom", "0.25em") \ CSS_PROPERTY("width", "auto") \ CSS_PROPERTY("margin", "0 auto") \ CSS_PROPERTY("display", "table") \ CSS_END_SELECTOR() \ CSS_SELECTOR("a") \ CSS_PROPERTY("text-decoration", "none") \ CSS_PROPERTY("color", "var(--main-link-color)") \ CSS_END_SELECTOR() \ CSS_SELECTOR("a:visited") \ CSS_PROPERTY("color", "var(--main-link-color)") \ CSS_END_SELECTOR() \ CSS_SELECTOR(".modal") \ CSS_PROPERTY("position", "fixed") \ CSS_PROPERTY("top", "0") \ CSS_PROPERTY("left", "0") \ CSS_PROPERTY("width", "100%") \ CSS_PROPERTY("height", "100%") \ CSS_PROPERTY("background-color", "rgba(0, 0, 0, 0.7)") \ CSS_PROPERTY("z-index", "9999") \ CSS_PROPERTY("cursor", "zoom-out") \ CSS_END_SELECTOR() \ CSS_SELECTOR(".modal img") \ CSS_PROPERTY("min-height", "80vh") \ CSS_PROPERTY("max-height", "80vh") \ CSS_PROPERTY("width", "auto") \ CSS_PROPERTY("max-width", "95vw") \ CSS_PROPERTY("position", "absolute") \ CSS_PROPERTY("top", "50%") \ CSS_PROPERTY("left", "50%") \ CSS_PROPERTY("transform", "translate(-50%, -50%)") \ CSS_PROPERTY("margin", "0") \ CSS_END_SELECTOR() \ CSS_SELECTOR(".zoomable") \ CSS_PROPERTY("max-width", "60vw") \ CSS_PROPERTY("max-height", "45vh") \ CSS_END_SELECTOR() #define FOOTER_HTML \ MD_RAWTAG("footer", "" \ "" \ "Powered by libdzonerzy.so" \ "" \ "
" \ "made with
by dzonerzy
") \ MD_NEWLINE() #define SCRIPTS_HTML \ HTML_TAG_OPEN_CONTENT("script", "src=\"/main.js\"", "") \ HTML_TAG_OPEN_CONTENT("script", "async src=\"https://www.googletagmanager.com/gtag/js?id=G-C4VP1TE4JZ\"", "") \ HTML_TAG_OPEN("script", "type=\"text/javascript\"") \ HTML_RAWTEXT("window.dataLayer = window.dataLayer || [];") \ HTML_NEWLINE() \ HTML_RAWTEXT("function gtag(){dataLayer.push(arguments);}") \ HTML_NEWLINE() \ HTML_RAWTEXT("gtag('js', new Date());") \ HTML_NEWLINE() \ HTML_RAWTEXT("gtag('config', 'G-C4VP1TE4JZ');") \ HTML_NEWLINE() \ HTML_TAG_CLOSE("script") \ HTML_NEWLINE() // wait for page ready and then execute the code don't use jQuery // because it's a static website and I don't want to use external // libraries // use a div with class modal to show the image // the image must maintain the aspect ratio // the image must be centered #define MAIN_JS \ HTML_RAWTEXT("function zoomImages() {") \ HTML_NEWLINE() \ HTML_RAWTEXT("var imgs = document.getElementsByClassName('zoomable');") \ HTML_NEWLINE() \ HTML_RAWTEXT("for (var i = 0; i < imgs.length; i++) {") \ HTML_NEWLINE() \ HTML_RAWTEXT("imgs[i].style.cursor = 'zoom-in';") \ HTML_NEWLINE() \ HTML_RAWTEXT("imgs[i].addEventListener('click', function() {") \ HTML_NEWLINE() \ HTML_RAWTEXT("var modal = document.createElement('div');") \ HTML_NEWLINE() \ HTML_RAWTEXT("modal.className = 'modal';") \ HTML_NEWLINE() \ HTML_RAWTEXT("modal.addEventListener('click', function() {") \ HTML_NEWLINE() \ HTML_RAWTEXT("modal.parentNode.removeChild(modal);") \ HTML_NEWLINE() \ HTML_RAWTEXT("});") \ HTML_NEWLINE() \ HTML_RAWTEXT("var img = document.createElement('img');") \ HTML_NEWLINE() \ HTML_RAWTEXT("img.src = this.src;") \ HTML_NEWLINE() \ HTML_RAWTEXT("modal.appendChild(img);") \ HTML_NEWLINE() \ HTML_RAWTEXT("document.body.appendChild(modal);") \ HTML_NEWLINE() \ HTML_RAWTEXT("});") \ HTML_NEWLINE() \ HTML_RAWTEXT("}") \ HTML_NEWLINE() \ HTML_RAWTEXT("}") \ HTML_NEWLINE() \ HTML_RAWTEXT("document.addEventListener('DOMContentLoaded', function() {") \ HTML_NEWLINE() \ HTML_RAWTEXT("zoomImages();") \ HTML_NEWLINE() \ HTML_RAWTEXT("});") \ HTML_NEWLINE() #define SITEMAP_XML \ XML_URLSET() \ XML_URL("https://libdzonerzy.so/index.html") \ XML_URL("https://libdzonerzy.so/sitemap.xml") \ XML_END_URLSET() int main(int argc, char **argv) { fprintf(stdout, "https://libdzonerzy.so\n"); return EXIT_SUCCESS; } // resources SECTION("main.css") static const char maincss[] = MAIN_CSS; SECTION("footer.html") static const char footerhtml[] = FOOTER_HTML; SECTION("scripts.html") static const char scriptshtml[] = SCRIPTS_HTML; SECTION("main.js") static const char mainjs[] = MAIN_JS; SECTION("sitemap.xml") static const char sitemapxml[] = SITEMAP_XML;