set up favicon

This commit is contained in:
Sam Rijs 2018-02-04 01:41:29 +11:00
parent dff0f8d6e3
commit f34d87d60a
4 changed files with 11 additions and 1 deletions

BIN
assets/favicon.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -9,3 +9,5 @@ pub static BADGE_UNKNOWN_SVG: &'static [u8; 972] =
pub static STATIC_STYLE_CSS: &'static str = pub static STATIC_STYLE_CSS: &'static str =
include_str!(concat!(env!("OUT_DIR"), "/style.css")); include_str!(concat!(env!("OUT_DIR"), "/style.css"));
pub static STATIC_FAVICON_PNG: &'static [u8; 1338] =
include_bytes!("../../assets/favicon.png");

View file

@ -22,7 +22,8 @@ enum StatusFormat {
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
enum StaticFile { enum StaticFile {
StyleCss StyleCss,
FaviconPng
} }
enum Route { enum Route {
@ -44,6 +45,7 @@ impl Server {
router.add("/", Route::Index); router.add("/", Route::Index);
router.add("/static/style.css", Route::Static(StaticFile::StyleCss)); router.add("/static/style.css", Route::Static(StaticFile::StyleCss));
router.add("/static/favicon.png", Route::Static(StaticFile::FaviconPng));
router.add("/repo/:site/:qual/:name", Route::Status(StatusFormat::Html)); router.add("/repo/:site/:qual/:name", Route::Status(StatusFormat::Html));
router.add("/repo/:site/:qual/:name/status.json", Route::Status(StatusFormat::Json)); router.add("/repo/:site/:qual/:name/status.json", Route::Status(StatusFormat::Json));
@ -163,6 +165,11 @@ impl Server {
Response::new() Response::new()
.with_header(ContentType("text/css".parse().unwrap())) .with_header(ContentType("text/css".parse().unwrap()))
.with_body(assets::STATIC_STYLE_CSS) .with_body(assets::STATIC_STYLE_CSS)
},
StaticFile::FaviconPng => {
Response::new()
.with_header(ContentType("image/png".parse().unwrap()))
.with_body(assets::STATIC_FAVICON_PNG.to_vec())
} }
} }
} }

View file

@ -21,6 +21,7 @@ fn render_html<B: Render>(title: &str, body: B) -> Response {
meta charset="utf-8"; meta charset="utf-8";
meta name="viewport" content="width=device-width, initial-scale=1"; meta name="viewport" content="width=device-width, initial-scale=1";
title (title) title (title)
link rel="icon" type="image/png" href="/static/favicon.png";
link rel="stylesheet" type="text/css" href="/static/style.css"; link rel="stylesheet" type="text/css" href="/static/style.css";
link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Fira+Sans:400,500,600"; link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Fira+Sans:400,500,600";
link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Source+Code+Pro"; link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Source+Code+Pro";