~mika/kethel2

197aa6eecd7d04d752824a643f4e4db545dcd716 — mika a month ago
generate colophon and default page
A  => .gitignore +7 -0
@@ 1,7 @@
/mkpage
/mkpage.o
/out
/darkhttpd*

/kethel.db
/stage.sql

A  => COPYME.html +15 -0
@@ 1,15 @@
<!DOCTYPE html>
<html lang="en">
    <head>
<!--LOAD include/stdhead.html -->
        <title>PAGETITLE - m1kadev.nl</title>
    </head>

    <body>
<!--LOAD include/stdnav.html -->
        <main>
            <h1>your content here</h1>
        </main>
<!--LOAD include/stdfooter.html -->
    </body>
</html>

A  => Makefile +38 -0
@@ 1,38 @@
CC=clang
CFLAGS=-Wall -Wextra -Werror -pedantic -O2 -std=c99

DEVSERVER='https://raw.githubusercontent.com/emikulic/darkhttpd/refs/heads/master/darkhttpd.c'

.PHONY: all serve initdb commitdb

all: mkpage out/index.html out/colophon.html

initdb:
	@echo "In the sql prompt, use '.read schemata.sql'"
	sqlite3 kethel.db

commitdb:
		@echo "In the sql prompt, use '.read stage.sql'"
		sqlite3 kethel.db
		rm stage.sql

serve: all darkhttpd
	./darkhttpd out

darkhttpd:
	curl $(DEVSERVER) > darkhttpd.c
	$(CC) -O2 darkhttpd.c -o darkhttpd

mkpage: mkpage.c
	$(CC) $(CFLAGS) -c mkpage.c -o mkpage.o
	$(CC) $(CFLAGS) mkpage.o -o mkpage

# list of all pages

out/index.html: index.html
	./mkpage index.html out/index.html

out/colophon.html: colophon.html
	./mkpage colophon.html out/colophon.html

out/thoughts/index.html: kethel.db

A  => colophon.html +31 -0
@@ 1,31 @@
<!DOCTYPE html>
<html lang="en">
    <head>
<!--LOAD include/stdhead.html -->
        <title>colophon - m1kadev.nl</title>
    </head>

    <body>
<!--LOAD include/stdnav.html -->
        <main>
            <h1>colophon</h1>
            <blockquote cite="https://brutalist-web.design/">
                [...] start with left-aligned black text on a white background, and to apply styling only to solve a specific problem.
                    <br> <em> - <a href="https://brutalist-web.design/">Brutalist Web Design</a></em>
            </blockquote>
            <p>
                The current iteration of m1kadev.nl was an experiment, to see how far one could get by using
                as little javascript and css possible, with as little build steps as possible. Which I think
                I've succeeded in rather well. This entire site uses only one (!) CSS rule at the moment.
            </p>
            <p>Used technologies:</p>
            <ul>
                <li><code>make</code> (BSD)  - as to not rebuild half the site for 1 change</li>
                <li>C99 - the build system is (as of 13/09/2026) only 70 lines of 100% POSIX C</li>
                <li><code>darkhttpd</code> - the development http server</li>
                <li><code>sqlite3</code> - the sql database engine, mostly there for rss feeds</li>
            </ul>
        </main>
<!--LOAD include/stdfooter.html -->
    </body>
</html>

A  => contrib/mkthought +8 -0
@@ 1,8 @@
#!/usr/bin/env bash

echo -n "Title: "
TITLE=$(cat)
echo -n "Body: "
BODY=$(cat)

echo "INSERT INTO thoughts VALUES('$TITLE', '$BODY', '$(date "+%Y-%m-%d %H:%M:%S")');" >> ./stage.sql

A  => include/stdfooter.html +4 -0
@@ 1,4 @@
<hr>
<footer>
<p>Built with BSD make and C99. <a href="/colophon.html">colophon</a></p>
</footer>

A  => include/stdhead.html +3 -0
@@ 1,3 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style> p { width: max(50vw, 60rem); } </style>

A  => include/stdnav.html +10 -0
@@ 1,10 @@
<header>
    <span><em>www.</em><br />m1kadev.nl</span>
            /
    <nav style="display: inline">
        <a href="/">root</a> |
        <a href="/blog/index.html">macroblog</a> |
        <a href="/thoughts/index.html">microblog</a> |
        <a href="/review/index.html">media</a> |
    </nav>
</header>

A  => index.html +30 -0
@@ 1,30 @@
<!DOCTYPE html>
<html lang="en">
    <head>
<!--LOAD include/stdhead.html -->
        <title>root - m1kadev.nl</title>
    </head>

    <body>
<!--LOAD include/stdnav.html -->
        <main>
            <h2>
                Welcome, sit down and
                <a href="https://www.rfc-editor.org/info/rfc7168/#section-2.1" >grab a <code>BREW</code></a>!
            </h2>

            <p>
                I'm currently in my exam year of highschool
                (<abbr title="(Dutch) Pre-university Physics/Biology">VWO-NT/NG</abbr>).
                However, this hasn't stopped me from <a href="/thought/index.html">shitposting on main</a>, <a href="/blog/index.html">vagueposting on main</a>,
                and <a href="/review/index.html">livetweeting about the latest game/series/<span title="in american that's movie">film</span></a> i've watched.
            </p>

            <p>
                Welcome, and enjoy your stay!
                    <br><em>-mika</em>
            </p>
        </main>
<!--LOAD include/stdfooter.html -->
    </body>
</html>

A  => mkpage.c +66 -0
@@ 1,66 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char* argv[]) {
    if (argc <= 2) {
        fprintf(stderr, "Usage: ./mkpage <input> <output>\n");
    }
    FILE* input  = fopen(argv[1], "r");
    if (input == NULL) {
        fprintf(stderr, "mkpage: fopen: %s does not exist!\n", argv[1]);
        return -1;
    }
    FILE* output = fopen(argv[2], "w");
    if (output == NULL) {
        fprintf(stderr, "mkpage: fopen: could not open %s for writing\n", argv[1]);
        fclose(input);
        return -1;
    }
    uintptr_t lineno = 0;
    char buf[256]; // ! NOTE: lines longer than 255 chars do not process correctly

    while (fgets(buf, sizeof(buf), input) != NULL) {
        lineno++;

        if (strncmp("<!--", buf, 4) == 0) {
            const char* commandPtr = (buf + 4);
            if (strncmp(commandPtr, "LOAD", 4) == 0) {
                char path[256];
                if (sscanf((commandPtr + 4), "%s", path) == 0) {
                    fputs("ERROR: LOAD directive was improperly terminated!\n", stderr);
                    fprintf(stderr, "%s %lu | %s ", argv[1], lineno, buf);
                    fclose(input);
                    fclose(output);
                    return -1;
                }
                FILE* load = fopen(path, "r");
                if (load == NULL) {
                    fputs("ERROR: LOAD directive did not point to readable file!\n", stderr);
                    fprintf(stderr, "%s %lu | %s ", argv[1], lineno, buf);
                    fprintf(stderr, "From parsed path: %s", path);

                    fclose(input);
                    fclose(output);
                    return -1;
                }
                fseek(load, 0, SEEK_END);
                long file_size = ftell(load);
                fseek(load, 0, SEEK_SET);
                char* readBuf = malloc(file_size);
                fread(readBuf, file_size, 1, load);
                fputs(readBuf, output);
                free(readBuf);
                fclose(load);
            }
        } else {
            fputs(buf, output);
        }
    }

    fclose(input);
    fclose(output);

    return 0;
}

A  => schemata.sql +5 -0
@@ 1,5 @@
CREATE TABLE Thoughts (
    title VARCHAR(64),
    body TEXT,
    date TEXT
);