From 4ec74d896758db5121b45cc35b18367375e193c4 Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Tue, 6 Jan 2026 17:12:38 -0800 Subject: [PATCH] better naming --- src/http/handler.zig | 22 ++++++++++----------- src/http/query.zig | 2 +- src/main.zig | 9 +++++---- src/render/{custom.zig => Custom.zig} | 0 src/render/{formatted.zig => Formatted.zig} | 2 +- src/render/{json.zig => Json.zig} | 0 src/render/{line.zig => Line.zig} | 0 src/render/{v2.zig => V2.zig} | 0 8 files changed, 18 insertions(+), 17 deletions(-) rename src/render/{custom.zig => Custom.zig} (100%) rename src/render/{formatted.zig => Formatted.zig} (99%) rename src/render/{json.zig => Json.zig} (100%) rename src/render/{line.zig => Line.zig} (100%) rename src/render/{v2.zig => V2.zig} (100%) diff --git a/src/http/handler.zig b/src/http/handler.zig index 932c690..c581635 100644 --- a/src/http/handler.zig +++ b/src/http/handler.zig @@ -3,11 +3,11 @@ const httpz = @import("httpz"); const WeatherProvider = @import("../weather/Provider.zig"); const Resolver = @import("../location/resolver.zig").Resolver; const QueryParams = @import("query.zig").QueryParams; -const formatted = @import("../render/formatted.zig"); -const line = @import("../render/line.zig"); -const json = @import("../render/json.zig"); -const v2 = @import("../render/v2.zig"); -const custom = @import("../render/custom.zig"); +const Formatted = @import("../render/Formatted.zig"); +const Line = @import("../render/Line.zig"); +const Json = @import("../render/Json.zig"); +const V2 = @import("../render/V2.zig"); +const Custom = @import("../render/Custom.zig"); const help = @import("help.zig"); const log = std.log.scoped(.handler); @@ -179,14 +179,14 @@ fn handleWeatherInternal( res.content_type = .TEXT; if (std.mem.eql(u8, fmt, "j1")) { res.content_type = .JSON; // reset to json - break :blk try json.render(req_alloc, weather); + break :blk try Json.render(req_alloc, weather); } if (std.mem.eql(u8, fmt, "v2")) - break :blk try v2.render(req_alloc, weather, render_options.use_imperial); + break :blk try V2.render(req_alloc, weather, render_options.use_imperial); if (std.mem.startsWith(u8, fmt, "%")) - break :blk try custom.render(req_alloc, weather, fmt, render_options.use_imperial); + break :blk try Custom.render(req_alloc, weather, fmt, render_options.use_imperial); // fall back to line if we don't understand the format parameter - break :blk try line.render(req_alloc, weather, fmt, render_options.use_imperial); + break :blk try Line.render(req_alloc, weather, fmt, render_options.use_imperial); } else { render_options.format = determineFormat(params, req.headers.get("user-agent")); log.debug( @@ -194,12 +194,12 @@ fn handleWeatherInternal( .{ render_options.format, params.ansi, params.text_only, req.headers.get("user-agent") }, ); if (render_options.format != .html) res.content_type = .TEXT else res.content_type = .HTML; - break :blk try formatted.render(req_alloc, weather, render_options); + break :blk try Formatted.render(req_alloc, weather, render_options); } }; } -fn determineFormat(params: QueryParams, user_agent: ?[]const u8) formatted.Format { +fn determineFormat(params: QueryParams, user_agent: ?[]const u8) Formatted.Format { if (params.ansi or params.text_only) { // user explicitly requested something. If both are set, text will win if (params.text_only) return .plain_text; diff --git a/src/http/query.zig b/src/http/query.zig index d853672..e7920aa 100644 --- a/src/http/query.zig +++ b/src/http/query.zig @@ -1,5 +1,5 @@ const std = @import("std"); -const RenderOptions = @import("../render/formatted.zig").RenderOptions; +const RenderOptions = @import("../render/Formatted.zig").RenderOptions; ///Units: /// diff --git a/src/main.zig b/src/main.zig index cedc265..05d93c8 100644 --- a/src/main.zig +++ b/src/main.zig @@ -92,10 +92,11 @@ test { _ = @import("http/RateLimiter.zig"); _ = @import("http/query.zig"); _ = @import("http/help.zig"); - _ = @import("render/line.zig"); - _ = @import("render/json.zig"); - _ = @import("render/v2.zig"); - _ = @import("render/custom.zig"); + _ = @import("render/Formatted.zig"); + _ = @import("render/Line.zig"); + _ = @import("render/Json.zig"); + _ = @import("render/V2.zig"); + _ = @import("render/Custom.zig"); _ = @import("location/GeoIp.zig"); _ = @import("location/GeoCache.zig"); _ = @import("location/Airports.zig"); diff --git a/src/render/custom.zig b/src/render/Custom.zig similarity index 100% rename from src/render/custom.zig rename to src/render/Custom.zig diff --git a/src/render/formatted.zig b/src/render/Formatted.zig similarity index 99% rename from src/render/formatted.zig rename to src/render/Formatted.zig index c5eca05..06c704c 100644 --- a/src/render/formatted.zig +++ b/src/render/Formatted.zig @@ -923,7 +923,7 @@ test "unknown weather code art" { } test "temperature matches between ansi and custom format" { - const custom = @import("custom.zig"); + const custom = @import("Custom.zig"); const data = types.WeatherData{ .location = "PDX", diff --git a/src/render/json.zig b/src/render/Json.zig similarity index 100% rename from src/render/json.zig rename to src/render/Json.zig diff --git a/src/render/line.zig b/src/render/Line.zig similarity index 100% rename from src/render/line.zig rename to src/render/Line.zig diff --git a/src/render/v2.zig b/src/render/V2.zig similarity index 100% rename from src/render/v2.zig rename to src/render/V2.zig