feat: add logo and minify CSS
This commit is contained in:
parent
bb371d6ab8
commit
939fe6be81
8 changed files with 182 additions and 4 deletions
|
@ -1,3 +1,6 @@
|
|||
/// Generated by build script
|
||||
/// JS Generated by build script
|
||||
pub const @"index.js" = @embedFile("zig-cache/index.js");
|
||||
|
||||
pub const @"index.css" = @embedFile("assets/index.css");
|
||||
pub const @"vidzig.png" = @embedFile("assets/vidzig.png");
|
||||
pub const @"vidzig.svg" = @embedFile("assets/vidzig.svg");
|
||||
|
|
|
@ -72,3 +72,11 @@ ul {
|
|||
.description_txt {
|
||||
color: #8be9fd;
|
||||
}
|
||||
|
||||
#head_div {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
#head_div * {
|
||||
padding: 5px;
|
||||
}
|
||||
|
|
80
assets/vidzig.inkscape.svg
Normal file
80
assets/vidzig.inkscape.svg
Normal file
|
@ -0,0 +1,80 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="132.29167mm"
|
||||
height="82.141884mm"
|
||||
viewBox="0 0 132.29167 82.141883"
|
||||
version="1.1"
|
||||
id="svg5"
|
||||
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
|
||||
sodipodi:docname="vidzig.inkscape.svg"
|
||||
xml:space="preserve"
|
||||
inkscape:export-filename="vidzig.svg"
|
||||
inkscape:export-xdpi="60.476189"
|
||||
inkscape:export-ydpi="60.476189"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
|
||||
id="namedview7"
|
||||
pagecolor="#505050"
|
||||
bordercolor="#ffffff"
|
||||
borderopacity="1"
|
||||
inkscape:showpageshadow="0"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pagecheckerboard="1"
|
||||
inkscape:deskcolor="#505050"
|
||||
inkscape:document-units="mm"
|
||||
showgrid="false"
|
||||
inkscape:zoom="0.70710678"
|
||||
inkscape:cx="-157.68481"
|
||||
inkscape:cy="92.630988"
|
||||
inkscape:window-width="1876"
|
||||
inkscape:window-height="1018"
|
||||
inkscape:window-x="1940"
|
||||
inkscape:window-y="40"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="layer1" /><defs
|
||||
id="defs2" /><g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(132.29167,102.02887)"><g
|
||||
id="g174"
|
||||
transform="matrix(0.86465142,0,0,0.86465142,-132.29167,-121.0512)"
|
||||
style="fill:#f7a41d"><polygon
|
||||
points="28,44 19,30 46,22 "
|
||||
id="polygon168" /><polygon
|
||||
points="20,100 12,117 0,117 0,22 46,22 33,33 28,44 22,44 22,95 31,95 "
|
||||
shape-rendering="crispEdges"
|
||||
id="polygon170" /><polygon
|
||||
points="12,117 4,106 31,95 "
|
||||
id="polygon172" /></g><g
|
||||
id="g194"
|
||||
transform="matrix(0.86465142,0,0,0.86465142,-132.29167,-121.0512)"
|
||||
style="fill:#f7a41d"><polygon
|
||||
points="140,40 122,45 141,22 "
|
||||
id="polygon188" /><polygon
|
||||
points="131,45 122,45 132,36 141,22 153,22 153,117 106,117 120,105 125,95 131,95 "
|
||||
shape-rendering="crispEdges"
|
||||
id="polygon190" /><polygon
|
||||
points="130,110 106,117 125,95 "
|
||||
id="polygon192" /></g><path
|
||||
sodipodi:type="star"
|
||||
style="fill:#f7a41d;fill-opacity:1;stroke:none;stroke-width:1;stroke-linejoin:round;stroke-miterlimit:2"
|
||||
id="path503"
|
||||
inkscape:flatsided="true"
|
||||
sodipodi:sides="3"
|
||||
sodipodi:cx="248.28915"
|
||||
sodipodi:cy="227.47044"
|
||||
sodipodi:r1="158.18137"
|
||||
sodipodi:r2="79.090683"
|
||||
sodipodi:arg1="0"
|
||||
sodipodi:arg2="1.0471976"
|
||||
inkscape:rounded="0"
|
||||
inkscape:randomized="0"
|
||||
d="m 406.47052,227.47044 -237.27205,136.98909 0,-273.978168 z"
|
||||
transform="matrix(0.27310818,0,0,0.27310818,-137.03714,-123.08197)"
|
||||
inkscape:transform-center-x="-10.800156"
|
||||
inkscape:transform-center-y="2.4103578e-06" /></g></svg>
|
After Width: | Height: | Size: 3 KiB |
BIN
assets/vidzig.png
Normal file
BIN
assets/vidzig.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
39
assets/vidzig.svg
Normal file
39
assets/vidzig.svg
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="132.29167mm"
|
||||
height="82.141884mm"
|
||||
viewBox="0 0 132.29167 82.141883"
|
||||
version="1.1"
|
||||
id="svg5"
|
||||
xml:space="preserve"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"><defs
|
||||
id="defs2" /><g
|
||||
id="layer1"
|
||||
transform="translate(132.29167,102.02887)"><g
|
||||
id="g174"
|
||||
transform="matrix(0.86465142,0,0,0.86465142,-132.29167,-121.0512)"
|
||||
style="fill:#f7a41d"><polygon
|
||||
points="19,30 46,22 28,44 "
|
||||
id="polygon168" /><polygon
|
||||
points="46,22 33,33 28,44 22,44 22,95 31,95 20,100 12,117 0,117 0,22 "
|
||||
shape-rendering="crispEdges"
|
||||
id="polygon170" /><polygon
|
||||
points="4,106 31,95 12,117 "
|
||||
id="polygon172" /></g><g
|
||||
id="g194"
|
||||
transform="matrix(0.86465142,0,0,0.86465142,-132.29167,-121.0512)"
|
||||
style="fill:#f7a41d"><polygon
|
||||
points="122,45 141,22 140,40 "
|
||||
id="polygon188" /><polygon
|
||||
points="153,22 153,117 106,117 120,105 125,95 131,95 131,45 122,45 132,36 141,22 "
|
||||
shape-rendering="crispEdges"
|
||||
id="polygon190" /><polygon
|
||||
points="106,117 125,95 130,110 "
|
||||
id="polygon192" /></g><path
|
||||
style="fill:#f7a41d;fill-opacity:1;stroke:none;stroke-width:1;stroke-linejoin:round;stroke-miterlimit:2"
|
||||
id="path503"
|
||||
d="m 406.47052,227.47044 -237.27205,136.98909 0,-273.978168 z"
|
||||
transform="matrix(0.27310818,0,0,0.27310818,-137.03714,-123.08197)" /></g></svg>
|
After Width: | Height: | Size: 1.6 KiB |
13
src/main.zig
13
src/main.zig
|
@ -3,6 +3,7 @@ const assets = @import("assets");
|
|||
|
||||
const routes = @import("routes.zig");
|
||||
|
||||
const minify = @import("minify.zig");
|
||||
const sendPlainResponseText = @import("status_response.zig").sendPlainResponseText;
|
||||
const DownloadQueue = @import("DownloadQueue.zig");
|
||||
const Config = @import("Config.zig");
|
||||
|
@ -127,7 +128,17 @@ fn tryHandleRequest(state: *State, res: *std.http.Server.Response) !void {
|
|||
} else if (std.mem.eql(u8, path, "/static/index.js")) {
|
||||
try routes.static(res, assets.@"index.js", "application/javascript");
|
||||
} else if (std.mem.eql(u8, path, "/static/index.css")) {
|
||||
try routes.static(res, assets.@"index.css", "text/css");
|
||||
try routes.static(res, comptime minify.minifyCSS(assets.@"index.css"), "text/css");
|
||||
} else if (std.mem.eql(u8, path, "/static/vidzig.png") or
|
||||
std.mem.eql(u8, path, "/favicon.ico"))
|
||||
{
|
||||
try routes.static(res, assets.@"vidzig.png", "image/png");
|
||||
} else if (std.mem.eql(u8, path, "/static/vidzig.svg")) {
|
||||
try routes.static(
|
||||
res,
|
||||
comptime minify.minifyHTML(assets.@"vidzig.svg"),
|
||||
"image/svg+xml",
|
||||
);
|
||||
} else if (std.mem.startsWith(u8, path, "/vids/")) {
|
||||
try routes.vidsRoute(state, res);
|
||||
} else {
|
||||
|
|
|
@ -2,17 +2,29 @@ const std = @import("std");
|
|||
|
||||
/// Very basic comptime HTML minification
|
||||
pub fn minifyHTML(comptime html: []const u8) []const u8 {
|
||||
var out: []const u8 = &[_]u8{};
|
||||
@setEvalBranchQuota(10000);
|
||||
|
||||
var out: []const u8 = "";
|
||||
var i = 0;
|
||||
while (i < html.len) {
|
||||
if (html[i] == '\n' or i == 0) {
|
||||
if (i != 0) {
|
||||
i += 1;
|
||||
}
|
||||
while (html[i] == ' ') {
|
||||
while (i < html.len and html[i] == ' ') {
|
||||
i += 1;
|
||||
}
|
||||
|
||||
if (i < html.len and html[i] != '<') {
|
||||
out = out ++ " ";
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= html.len)
|
||||
break;
|
||||
|
||||
if (html[i] == '\n')
|
||||
continue;
|
||||
|
||||
out = out ++ [_]u8{html[i]};
|
||||
|
||||
|
@ -21,3 +33,24 @@ pub fn minifyHTML(comptime html: []const u8) []const u8 {
|
|||
|
||||
return out;
|
||||
}
|
||||
|
||||
/// Minify CSS. Guaranteed to break the majority of CSS files.
|
||||
pub fn minifyCSS(comptime css: []const u8) []const u8 {
|
||||
@setEvalBranchQuota(10000);
|
||||
|
||||
var out: []const u8 = "";
|
||||
var i = 0;
|
||||
while (i < css.len) {
|
||||
const c = css[i];
|
||||
|
||||
const is_whitespace = std.ascii.isWhitespace(c);
|
||||
|
||||
if (!is_whitespace or (i + 1 < css.len and css[i + 1] == '*')) {
|
||||
out = out ++ [_]u8{c};
|
||||
}
|
||||
|
||||
i += 1;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,10 @@ pub fn indexRoute(
|
|||
\\ <link rel="stylesheet" href="static/index.css">
|
||||
\\</head>
|
||||
\\<body>
|
||||
\\<div id="head_div">
|
||||
\\ <img src="static/vidzig.svg" alt="logo" width="100px" />
|
||||
\\ <h1>Vidzig</h1>
|
||||
\\</div>
|
||||
));
|
||||
|
||||
var paused = false;
|
||||
|
|
Loading…
Reference in a new issue