From 16e4f8f2a9ead0f79b5b275dc547b517cc8891e9 Mon Sep 17 00:00:00 2001 From: Rosa Date: Wed, 27 May 2026 13:24:15 -0400 Subject: add 404.html, remove legacy code --- build.zig.zon | 4 +-- src/pages/errors/404.html | 8 +++++ src/pages/index.html | 6 ++-- src/pages/members/index.html | 7 ++-- src/pages/services/index.html | 28 ++++++++++++++++ src/templates/base.html | 43 ++++++++++++------------- src/templates/error.html | 15 +++++++++ src/templates/page.html | 19 +++++++++++ util/generate_html.zig | 74 ------------------------------------------- util/lighttpd.conf | 1 + util/pages.zig | 27 ---------------- 11 files changed, 101 insertions(+), 131 deletions(-) create mode 100644 src/pages/errors/404.html create mode 100644 src/pages/services/index.html create mode 100644 src/templates/error.html create mode 100644 src/templates/page.html delete mode 100644 util/generate_html.zig delete mode 100644 util/pages.zig diff --git a/build.zig.zon b/build.zig.zon index 56320c1..b92e6c9 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -3,8 +3,8 @@ .version = "0.16.0", .dependencies = .{ .webgen = .{ - .url = "git+https://git.eviltransgenders.club/~rosa/webgen.git?ref=main#e4857bef052bee6c31b2a7bf21893f175aed241c", - .hash = "webgen-0.1.0-XDIIqYUjAABUdAGaQ_tqcFCVRBefdGxd87n5fccnRg-v", + .url = "git+https://git.eviltransgenders.club/~rosa/webgen.git?ref=main#a71731ebe33cd2e26b52934253cb294a7aee1fe6", + .hash = "webgen-0.1.0-XDIIqTIlAAD42hVLDYUStcFKG1vMHAR4lJyHelYqbB7j", }, }, .paths = .{""}, diff --git a/src/pages/errors/404.html b/src/pages/errors/404.html new file mode 100644 index 0000000..1bae3fb --- /dev/null +++ b/src/pages/errors/404.html @@ -0,0 +1,8 @@ + + +not found + + + +The requested file was not found. + diff --git a/src/pages/index.html b/src/pages/index.html index 4009dac..231cc02 100644 --- a/src/pages/index.html +++ b/src/pages/index.html @@ -1,4 +1,4 @@ - + home @@ -15,8 +15,10 @@ home community primarily for queer people and allies, though anyone who is cool is welcome! :)

-

+ If you'd like to chat about tech or video games or being queer, or if you're + perhaps interested in accessing our services, you + can ask to join.

diff --git a/src/pages/members/index.html b/src/pages/members/index.html index fdf76fe..d3ab8f6 100644 --- a/src/pages/members/index.html +++ b/src/pages/members/index.html @@ -1,4 +1,4 @@ - + members @@ -14,6 +14,7 @@ members section.member-info header h2, section.member-info p { margin: 0.5rem 5px; + text-align: left; } section.member-info div#image-container { @@ -38,7 +39,7 @@ members Rosa's profile picture
-
+

Rosa

@@ -68,7 +69,7 @@ members {name}'s profile picture

-
+

Name

diff --git a/src/pages/services/index.html b/src/pages/services/index.html new file mode 100644 index 0000000..3714be1 --- /dev/null +++ b/src/pages/services/index.html @@ -0,0 +1,28 @@ + + + +services + + +

+
+

services

+

+ the evil transgenders club hosts some services for use by its members. the + following is a list of those services: +

+
+
    +
  • + cgit - web + frontend for our git repositories +
  • +
  • + members are allowed to host websites under the eviltransgenders.club + domain, whether on our infrastructure or their own. alternatively you can + be given a directory to host static files on this very website +
  • +
  • soon: matrix
  • +
+
+ diff --git a/src/templates/base.html b/src/templates/base.html index 11f6f57..c72c6cf 100644 --- a/src/templates/base.html +++ b/src/templates/base.html @@ -3,14 +3,12 @@ - {{title}} - the evil transgenders club {{extraHead}} @@ -109,17 +112,11 @@

the evil transgenders club

- + {{afterTitle}}
{{body}} diff --git a/src/templates/error.html b/src/templates/error.html new file mode 100644 index 0000000..7398774 --- /dev/null +++ b/src/templates/error.html @@ -0,0 +1,15 @@ + + + +

well, this is awkward...

+ + + +
+

{{message}}

+
+ + + +

</3 // go home

+ diff --git a/src/templates/page.html b/src/templates/page.html new file mode 100644 index 0000000..7854a72 --- /dev/null +++ b/src/templates/page.html @@ -0,0 +1,19 @@ + + + + + + + +

+ made with <3 by rosa + // view the source +

+ diff --git a/util/generate_html.zig b/util/generate_html.zig deleted file mode 100644 index 0933d18..0000000 --- a/util/generate_html.zig +++ /dev/null @@ -1,74 +0,0 @@ -const std = @import("std"); -const pages = @import("pages.zig").pages; - -pub fn main(init: std.process.Init) !void { - const sources_dir = try std.Io.Dir.cwd().createDirPathOpen(init.io, "src", .{}); - defer sources_dir.close(init.io); - const out_dir = try std.Io.Dir.cwd().createDirPathOpen(init.io, "html-out", .{}); - defer out_dir.close(init.io); - - const templates_dir = try sources_dir.createDirPathOpen(init.io, "templates", .{ .open_options = .{ .iterate = true } }); - defer templates_dir.close(init.io); - const pages_dir = try sources_dir.createDirPathOpen(init.io, "pages", .{ .open_options = .{ .iterate = true } }); - defer pages_dir.close(init.io); - try generateHtmlPages(init.io, init.arena.allocator(), templates_dir, pages_dir, out_dir); - - const static_dir = try sources_dir.createDirPathOpen(init.io, "static", .{ .open_options = .{ .iterate = true } }); - defer static_dir.close(init.io); - try copyStaticFiles(init.io, init.arena.allocator(), static_dir, out_dir); -} - -fn generateHtmlPages(io: std.Io, ally: std.mem.Allocator, templates_dir: std.Io.Dir, pages_dir: std.Io.Dir, out_dir: std.Io.Dir) !void { - for (pages) |page_def| { - const template = try templates_dir.openFile(io, page_def.template_path, .{}); - defer template.close(io); - const template_buf = try ally.alloc(u8, (try template.stat(io)).size); - _ = try template.readPositionalAll(io, template_buf, 0); - - const page = try pages_dir.openFile(io, page_def.source_path, .{}); - defer page.close(io); - const page_buf = try ally.alloc(u8, (try page.stat(io)).size); - _ = try page.readPositionalAll(io, page_buf, 0); - - var out_buf: []u8 = template_buf; - for (page_def.replacements) |replacement| { - switch (replacement.replacement) { - .file_content => { - out_buf = try std.mem.replaceOwned(u8, ally, out_buf, replacement.placeholder, page_buf); - }, - .literal => |value| { - out_buf = try std.mem.replaceOwned(u8, ally, out_buf, replacement.placeholder, value); - }, - } - } - - const maybeDirname = std.mem.cutLast(u8, page_def.source_path, "/"); - if (maybeDirname) |dirname| { - try out_dir.createDirPath(io, dirname[0]); - } - const out = try out_dir.createFile(io, page_def.source_path, .{}); - defer out.close(io); - std.debug.print("Writing page {s}...\n", .{page_def.source_path}); - try out.writeStreamingAll(io, out_buf); - } -} - -fn copyStaticFiles(io: std.Io, ally: std.mem.Allocator, sources_dir: std.Io.Dir, out_dir: std.Io.Dir) !void { - var walker = try sources_dir.walk(ally); - defer walker.deinit(); - while (try walker.next(io)) |entry| { - switch (entry.kind) { - .file, .sym_link => { - std.debug.print("Copying static file {s}...\n", .{entry.path}); - try entry.dir.copyFile(entry.basename, out_dir, entry.basename, io, .{}); - }, - .directory => { - const new_out = try out_dir.createDirPathOpen(io, entry.basename, .{ .open_options = .{ .iterate = true } }); - defer new_out.close(io); - try copyStaticFiles(io, ally, sources_dir, out_dir); - }, - - else => {}, - } - } -} diff --git a/util/lighttpd.conf b/util/lighttpd.conf index b4f012f..ba34f3f 100644 --- a/util/lighttpd.conf +++ b/util/lighttpd.conf @@ -2,3 +2,4 @@ index-file.names = ( "index.html" ) server.bind = "127.0.0.1" server.document-root = var.CWD + "/html-out" server.port = 8888 +server.errorfile-prefix = server.document-root + "/errors/" diff --git a/util/pages.zig b/util/pages.zig deleted file mode 100644 index 1881aff..0000000 --- a/util/pages.zig +++ /dev/null @@ -1,27 +0,0 @@ -const std = @import("std"); - -pub const pages = [_]Page{Page{ - .source_path = "index.html", - .template_path = "base.html", - .replacements = &[_]Replacement{ Replacement{ - .placeholder = "{{title}}", - .replacement = .{ .literal = "home" }, - }, Replacement{ - .placeholder = "{{body}}", - .replacement = .{ .file_content = {} }, - } }, -}}; - -const Page = struct { - source_path: []const u8, - template_path: []const u8, - replacements: []const Replacement, -}; - -const Replacement = struct { - placeholder: []const u8, - replacement: union(enum) { - file_content, - literal: []const u8, - }, -}; -- cgit v1.3.1