Add Favicon

This commit is contained in:
spikecodes 2021-01-12 20:18:20 -08:00
parent eb9a0dcb4a
commit 96607256fc
4 changed files with 7 additions and 5 deletions

View file

@ -1,5 +1,5 @@
// Import Crates
use actix_web::{get, middleware, web, App, HttpResponse, HttpServer}; // dev::Service
use actix_web::{middleware, web, App, HttpResponse, HttpServer}; // dev::Service
// Reference local files
mod post;
@ -21,9 +21,10 @@ async fn robots() -> HttpResponse {
.body(include_str!("../static/robots.txt"))
}
#[get("/favicon.ico")]
async fn favicon() -> HttpResponse {
HttpResponse::Ok().body("")
HttpResponse::Ok()
.header("Cache-Control", "public, max-age=1209600, s-maxage=86400")
.body(include_bytes!("../static/favicon.ico").as_ref())
}
#[actix_web::main]
@ -64,7 +65,7 @@ async fn main() -> std::io::Result<()> {
.default_service(web::get().to(|| utils::error("Nothing here".to_string())))
// GENERAL SERVICES
.route("/style.css/", web::get().to(style))
.route("/favicon.ico/", web::get().to(HttpResponse::Ok))
.route("/favicon.ico/", web::get().to(favicon))
.route("/robots.txt/", web::get().to(robots))
// SETTINGS SERVICE
.route("/settings/", web::get().to(settings::get))

BIN
static/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 789 B

View file

@ -8,6 +8,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="View on Libreddit, an alternative private front-end to Reddit.">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
<link rel="stylesheet" href="/style.css">
{% endblock %}
</head>

View file

@ -27,7 +27,7 @@
{% endif %}
<span class="datetime">{{ item.time }}</span>
</summary>
<p class="comment_body">{{ item.body }}</p>
<div class="comment_body">{{ item.body }}</div>
{%- endmacro %}
<!-- CLOSE COMMENT MACRO -->