use source code pro - fixes mobile browser rendering
This commit is contained in:
parent
ea88a88e31
commit
148bd862b5
2 changed files with 32 additions and 4 deletions
|
|
@ -242,14 +242,25 @@ test "handleWeather: default endpoint uses IP address" {
|
|||
|
||||
try ht.expectStatus(200);
|
||||
try ht.expectBody(
|
||||
\\<pre>Weather report: Union City, California, United States
|
||||
\\<!DOCTYPE html>
|
||||
\\<html>
|
||||
\\<head>
|
||||
\\<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
\\<link rel="stylesheet" href="https://adobe-fonts.github.io/source-code-pro/source-code-pro.css">
|
||||
\\<style>
|
||||
\\body{background:#000;color:#bbb}
|
||||
\\pre{font-family:"Source Code Pro","DejaVu Sans Mono",Menlo,"Lucida Sans Typewriter","Lucida Console",monaco,"Bitstream Vera Sans Mono",monospace;font-size:75%}
|
||||
\\</style>
|
||||
\\</head>
|
||||
\\<body><pre>
|
||||
\\Weather report: Union City, California, United States
|
||||
\\
|
||||
\\<span style="color:#ffff00"> \ / </span> Clear
|
||||
\\<span style="color:#ffff00"> .-. </span> <span style="color:#d7ff00">+68(+68)</span> °F
|
||||
\\<span style="color:#ffff00"> ― ( ) ― </span> ↓ <span style="color:#6c6c6c">3</span> mph
|
||||
\\<span style="color:#ffff00"> `-' </span> 6 mi
|
||||
\\<span style="color:#ffff00"> / \ </span> 0.0 in
|
||||
\\</pre>
|
||||
\\</pre></body></html>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -100,9 +100,26 @@ pub const RenderOptions = struct {
|
|||
format: Format = .ansi,
|
||||
};
|
||||
|
||||
fn writeHtmlHeader(w: *std.Io.Writer) !void {
|
||||
try w.writeAll(
|
||||
\\<!DOCTYPE html>
|
||||
\\<html>
|
||||
\\<head>
|
||||
\\<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
\\<link rel="stylesheet" href="https://adobe-fonts.github.io/source-code-pro/source-code-pro.css">
|
||||
\\<style>
|
||||
\\body{background:#000;color:#bbb}
|
||||
\\pre{font-family:"Source Code Pro","DejaVu Sans Mono",Menlo,"Lucida Sans Typewriter","Lucida Console",monaco,"Bitstream Vera Sans Mono",monospace;font-size:75%}
|
||||
\\</style>
|
||||
\\</head>
|
||||
\\<body><pre>
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
pub fn render(writer: *std.Io.Writer, data: types.WeatherData, options: RenderOptions) !void {
|
||||
const w = writer;
|
||||
if (options.format == .html) try w.writeAll("<pre>");
|
||||
if (options.format == .html) try writeHtmlHeader(w);
|
||||
if (!options.super_quiet)
|
||||
try w.print(
|
||||
"{s}{s}\n\n",
|
||||
|
|
@ -118,7 +135,7 @@ pub fn render(writer: *std.Io.Writer, data: types.WeatherData, options: RenderOp
|
|||
try renderForecastDay(w, day, options);
|
||||
}
|
||||
}
|
||||
if (options.format == .html) try w.writeAll("</pre>");
|
||||
if (options.format == .html) try w.writeAll("</pre></body></html>");
|
||||
}
|
||||
|
||||
fn renderCurrent(w: *std.Io.Writer, current: types.CurrentCondition, options: RenderOptions) !void {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue