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