fmt
This commit is contained in:
36
src/game.rs
36
src/game.rs
@@ -1,14 +1,14 @@
|
||||
use crate::{language::language, page::Page, Backend, NameUpdateError};
|
||||
use crate::{Backend, NameUpdateError, language::language, page::Page};
|
||||
use axum::{
|
||||
Form, Router,
|
||||
extract::{Path, State},
|
||||
http::HeaderMap,
|
||||
response::{IntoResponse, Redirect, Response},
|
||||
routing::{get, post},
|
||||
Form, Router,
|
||||
};
|
||||
use axum_extra::extract::CookieJar;
|
||||
use axum_messages::Messages;
|
||||
use maud::{html, Markup, PreEscaped};
|
||||
use maud::{Markup, PreEscaped, html};
|
||||
use serde::Deserialize;
|
||||
use std::sync::Arc;
|
||||
use uuid::Uuid;
|
||||
@@ -110,7 +110,12 @@ async fn game(
|
||||
if let Ok(number) = backend.client_found_camera(&client, &camera).await {
|
||||
messages.info(format!("found-cam|{}|{number}", camera.name));
|
||||
} else {
|
||||
messages.info(&format!("err|{}|{}|{}", t!("error_already_found_title"), t!("error_already_found_body"), t!("error_already_found_footer")));
|
||||
messages.info(&format!(
|
||||
"err|{}|{}|{}",
|
||||
t!("error_already_found_title"),
|
||||
t!("error_already_found_body"),
|
||||
t!("error_already_found_footer")
|
||||
));
|
||||
}
|
||||
|
||||
Ok(Redirect::to("/game"))
|
||||
@@ -138,9 +143,26 @@ async fn set_name(
|
||||
|
||||
match backend.set_client_name(&client, &form.name).await {
|
||||
Ok(()) => messages.info("set-name-succ"),
|
||||
Err(NameUpdateError::TooShort(expected, actual)) => messages.info(format!("err|{}|{}|{}: {}", t!("error_name_too_short_title"), t!("error_name_too_short_body", expected = expected), t!("received_characters"), actual)),
|
||||
Err(NameUpdateError::TooLong(expected, actual)) => messages.info(format!("err|{}|{}|{}: {}", t!("error_name_too_long_title"), t!("error_name_too_long_body", expected = expected), t!("received_characters"), actual)),
|
||||
Err(NameUpdateError::ContainsBadWord) => messages.info(format!("err|{}|{}|{}", t!("error_bad_word_title"), t!("error_bad_word_body"), t!("error_bad_word_footer"))),
|
||||
Err(NameUpdateError::TooShort(expected, actual)) => messages.info(format!(
|
||||
"err|{}|{}|{}: {}",
|
||||
t!("error_name_too_short_title"),
|
||||
t!("error_name_too_short_body", expected = expected),
|
||||
t!("received_characters"),
|
||||
actual
|
||||
)),
|
||||
Err(NameUpdateError::TooLong(expected, actual)) => messages.info(format!(
|
||||
"err|{}|{}|{}: {}",
|
||||
t!("error_name_too_long_title"),
|
||||
t!("error_name_too_long_body", expected = expected),
|
||||
t!("received_characters"),
|
||||
actual
|
||||
)),
|
||||
Err(NameUpdateError::ContainsBadWord) => messages.info(format!(
|
||||
"err|{}|{}|{}",
|
||||
t!("error_bad_word_title"),
|
||||
t!("error_bad_word_body"),
|
||||
t!("error_bad_word_footer")
|
||||
)),
|
||||
};
|
||||
|
||||
// Redirect back to the game page
|
||||
|
@@ -1,7 +1,7 @@
|
||||
use crate::{language::language, page::Page};
|
||||
use axum::http::HeaderMap;
|
||||
use axum_extra::extract::CookieJar;
|
||||
use maud::{html, Markup, PreEscaped};
|
||||
use maud::{Markup, PreEscaped, html};
|
||||
|
||||
pub(super) async fn index(cookies: CookieJar, headers: HeaderMap) -> Markup {
|
||||
let lang = language(&cookies, &headers);
|
||||
|
@@ -1,8 +1,8 @@
|
||||
use crate::model::client::Client;
|
||||
use axum::{http::HeaderMap, routing::get, Router};
|
||||
use axum_extra::extract::{cookie::Cookie, CookieJar};
|
||||
use axum::{Router, http::HeaderMap, routing::get};
|
||||
use axum_extra::extract::{CookieJar, cookie::Cookie};
|
||||
use axum_messages::MessagesManagerLayer;
|
||||
use sqlx::{pool::PoolOptions, sqlite::SqliteConnectOptions, SqlitePool};
|
||||
use sqlx::{SqlitePool, pool::PoolOptions, sqlite::SqliteConnectOptions};
|
||||
use std::{
|
||||
collections::HashSet,
|
||||
fmt::Display,
|
||||
|
@@ -1,4 +1,4 @@
|
||||
use crate::{random_names::get_name_by_uuid, Backend};
|
||||
use crate::{Backend, random_names::get_name_by_uuid};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::FromRow;
|
||||
use uuid::Uuid;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
use crate::{model::client::Client, Backend};
|
||||
use crate::{Backend, model::client::Client};
|
||||
|
||||
pub(crate) struct Rank {
|
||||
pub(crate) rank: i64,
|
||||
|
@@ -1,9 +1,9 @@
|
||||
use crate::{
|
||||
model::{camera::Camera, client::Client},
|
||||
Backend,
|
||||
model::{camera::Camera, client::Client},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{types::chrono::NaiveDateTime, FromRow};
|
||||
use sqlx::{FromRow, types::chrono::NaiveDateTime};
|
||||
|
||||
#[derive(FromRow, Debug, Serialize, Deserialize)]
|
||||
pub struct SightingDb {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
use crate::Language;
|
||||
use axum_messages::Messages;
|
||||
use maud::{html, Markup, DOCTYPE};
|
||||
use maud::{DOCTYPE, Markup, html};
|
||||
|
||||
pub(crate) struct Page {
|
||||
lang: Language,
|
||||
|
Reference in New Issue
Block a user