Add form to join game
Dependencies
- [2]
BVCWJKEXGet auth info for slow game page - [3]
LOFH5LIAMake bold player name - [4]
XKG2L3QBShow label if player could join the game - [5]
A2LJT7TTShow duration in turns - [6]
GUAEZDLEAdd turns info to slow game's page - [7]
AEWYJHUDStart to show player list - [8]
6NYILMKIAdd page for slow game - [9]
6BDGQ4VMShow player names for registered players - [10]
C6F7SJZIAdd players count to slow game's page - [*]
EVP2FSBHSplit index page - [*]
FUCFD4UVAdd log in and log out support - [*]
3HT5CE6SManage TTL duration in config - [*]
4MZ4VIR7Initial commit
Change contents
- replacement in src/templates/slow-game.html at line 68
{{#if can_join}}<p>Can join</p>{{#if join_data}}<form id="join-game" action="join-game.do" method="post"><fieldset><input name="csrf" type="hidden" value="{{ join_data.csrf }}"><input name="submit" type="submit" value="Join Game"></fieldset></form> - edit in src/pages/slow_game.rs at line 2
use uuid::Uuid; - edit in src/pages/slow_game.rs at line 16
struct JoinData {csrf: Uuid,}#[derive(serde_derive::Serialize)] - replacement in src/pages/slow_game.rs at line 32
player_list: Option<&'a Vec<PlayerInfo>>,can_join: bool,player_list: Option<Vec<PlayerInfo>>,join_data: Option<JoinData>, - replacement in src/pages/slow_game.rs at line 121
let player_list = if let Some(ref user) = user {let status = row.get::<_, Option<&str>>(0);let (player_list, join_data) = if let Some(ref user) = user { - replacement in src/pages/slow_game.rs at line 148
Some((users, has_itself))let join_data = if !has_itself && status.is_none() {let csrf = Uuid::new_v4();let mut cache = data.cache_join_game.lock().await;cache.insert(csrf,(gameuid.clone(), user.to_string()),std::time::Duration::from_secs(data.cache_duration_sec),);Some(JoinData { csrf })} else {None};(Some(users), join_data) - replacement in src/pages/slow_game.rs at line 164
None(None, None) - edit in src/pages/slow_game.rs at line 167[4.145]→[4.145:193](∅→∅),[4.193]→[5.1122:1123](∅→∅),[5.1092]→[5.1122:1123](∅→∅),[5.1122]→[5.1122:1123](∅→∅)
let status = row.get::<_, Option<&str>>(0); - replacement in src/pages/slow_game.rs at line 181
player_list: player_list.as_ref().map(|x| &x.0),can_join: player_list.as_ref().map_or(false, |x| !x.1 && status.is_none()),player_list,join_data, - edit in src/pages/mod.rs at line 47
pub cache_join_game: Mutex<TtlCache<Uuid, (String, String)>>, - edit in src/main.rs at line 218
cache_join_game: tokio::sync::Mutex::new(ttl_cache::TtlCache::new(cache_capacity)),