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 // 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 // Reference local files
mod post; mod post;
@ -21,9 +21,10 @@ async fn robots() -> HttpResponse {
.body(include_str!("../static/robots.txt")) .body(include_str!("../static/robots.txt"))
} }
#[get("/favicon.ico")]
async fn favicon() -> HttpResponse { 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] #[actix_web::main]
@ -64,7 +65,7 @@ async fn main() -> std::io::Result<()> {
.default_service(web::get().to(|| utils::error("Nothing here".to_string()))) .default_service(web::get().to(|| utils::error("Nothing here".to_string())))
// GENERAL SERVICES // GENERAL SERVICES
.route("/style.css/", web::get().to(style)) .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)) .route("/robots.txt/", web::get().to(robots))
// SETTINGS SERVICE // SETTINGS SERVICE
.route("/settings/", web::get().to(settings::get)) .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 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="description" content="View on Libreddit, an alternative private front-end to Reddit.">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <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"> <link rel="stylesheet" href="/style.css">
{% endblock %} {% endblock %}
</head> </head>

View File

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