From 8175df9f9af2393964f053af5a98851c376e1675 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 11 Jun 2022 02:06:51 +0200 Subject: Use game boxes instead of tables. --- views/games_active.pug | 10 ++-- views/games_finished.pug | 2 +- views/games_public.pug | 14 ++++-- views/head.pug | 117 +++++++++++++++++++---------------------------- views/info.pug | 15 +++--- 5 files changed, 73 insertions(+), 85 deletions(-) (limited to 'views') diff --git a/views/games_active.pug b/views/games_active.pug index 49d20d8..16d8ceb 100644 --- a/views/games_active.pug +++ b/views/games_active.pug @@ -13,24 +13,24 @@ html if ready_games.length > 0 h2 Ready to start - +gametable(0,ready_games) + +gamelist(ready_games, "ready") if open_games.length > 0 h2 Open - +gametable(0,open_games) + +gamelist(open_games, "open") if replacement_games.length > 0 h2 Need replacement - +gametable(0, replacement_games) + +gamelist(replacement_games, "replacement") if active_games.length > 0 h2 Active - +gametable(1,active_games) + +gamelist(active_games, "active") if finished_games.length > 0 h2 Recently finished - +gametable(2,finished_games) + +gamelist(finished_games, "finished") p All your finished games diff --git a/views/games_finished.pug b/views/games_finished.pug index 59c0491..c6fa66d 100644 --- a/views/games_finished.pug +++ b/views/games_finished.pug @@ -10,6 +10,6 @@ html h1 Your finished games if finished_games.length > 0 - +gametable(2,finished_games) + +gamelist(finished_games, "finished") else p Nothing here. diff --git a/views/games_public.pug b/views/games_public.pug index 4af36bd..a681419 100644 --- a/views/games_public.pug +++ b/views/games_public.pug @@ -12,15 +12,21 @@ html h1 All Public Games h2 Open - +gametable(0, open_games) + if open_games.length > 0 + +gamelist(open_games, "open") + else + p No open games. if replacement_games.length > 0 h2 Need replacement - +gametable(0, replacement_games) + +gamelist(replacement_games, "replacement") if ready_games.length > 0 h2 Ready to start - +gametable(0, ready_games) + +gamelist(ready_games, "ready") h2 Active - +gametable(1, active_games) + if active_games.length > 0 + +gamelist(active_games, "active") + else + p No open games. diff --git a/views/head.pug b/views/head.pug index 0a1052a..911def4 100644 --- a/views/head.pug +++ b/views/head.pug @@ -34,75 +34,54 @@ mixin forumpost(row,show_buttons) | | #[a(href="/forum/reply/"+row.post_id) Reply] -mixin gametable(status,table,hide_title=0) - table - thead - tr - th ID - unless hide_title - th Title - th Scenario - th Players - th Description - case status - when 0 - th Date - when 1 - th Changed - th Turn - when 2 - th Finished - th Result - th - tbody - each row in table - tr - td: a(href="/join/"+row.game_id)= row.game_id - unless hide_title - td.w: a(href="/"+row.title_id)= row.title_name - td= row.scenario - if row.player_names - td!= row.player_names - else - td.error Nobody - td= row.description - if row.status === 0 - td.w= row.ctime - else - td.w= row.mtime - case status - when 1 - if (row.is_active) - td.is_active!= row.active - else - td!= row.active - when 2 - td!= row.result - td.command - if status === 0 - a(href="/join/"+row.game_id) Join - else if status === 1 - if row.is_yours - if row.is_shared - a(href="/join/"+row.game_id) Play +mixin gamelist(list,status,hide_title=0) + div.game_list(class=status) + each item in list + div + div.game_item(class=item.your_turn ? "your_turn" : "") + div.game_head + if item.scenario.length <= 2 + div + | #{item.game_id} – + | #{item.title_name} + | (#{item.scenario}) + else + div + | #{item.game_id} – + | #{item.title_name} + + if item.status === 0 || !item.is_ready + a(class="command" href=`/join/${item.game_id}`) Join + else + if item.is_yours + - let verb = (item.status > 1) ? "Review" : "Play" + if item.your_role + a(class="command" href=`/${item.title_id}/play:${item.game_id}:${item.your_role}`)= verb else - a(href=`/${row.title_id}/play:${row.game_id}:${row.your_role}`) Play + a(class="command" href="/join/"+item.game_id)= verb else - a(href=`/${row.title_id}/play:${row.game_id}`) View - else if status >= 2 - if row.is_yours - if row.is_shared - a(href="/join/"+row.game_id) View - else - a(href=`/${row.title_id}/play:${row.game_id}:${row.your_role}`) View + - let verb = (item.status > 1) ? "Review" : "View" + a(class="command" href=`/${item.title_id}/play:${item.game_id}`)= verb + + div.game_main + div.game_info + if item.description + i= item.description + if item.scenario !== "Standard" && item.scenario !== "Historical" && item.scenario.length > 2 + div Scenario: #{item.scenario} + unless item.human_options === "None" + div Options: #{item.human_options} + if item.player_names + div Players: !{item.player_names} else - a(href=`/${row.title_id}/replay:${row.game_id}`) View - else - tr - case status - when 0 - td(colspan=7-hide_title) No open games. - when 1 - td(colspan=8-hide_title) No active games. - when 2 - td(colspan=8-hide_title) No finished games. + div Players: Nobody + case item.status + when 0 + div Created: #{item.ctime} + when 1 + div Changed: #{item.mtime} + when 2 + div Finished: #{item.mtime} + div Result: !{item.result} + unless hide_title + img(src=`/${item.title_id}/thumbnail.jpg`) diff --git a/views/info.pug b/views/info.pug index 785ee91..c7083ef 100644 --- a/views/info.pug +++ b/views/info.pug @@ -20,23 +20,26 @@ html p Read more about the game on #[a(href="https://boardgamegeek.com/boardgame/"+title.bgg) boardgamegeek.com]. h2 Open - +gametable(0,open_games,1) + if open_games.length > 0 + +gamelist(open_games, "open", true) + else + p No open games. if replacement_games.length > 0 h2 Need replacement - +gametable(0, replacement_games) + +gamelist(replacement_games, "replacement", true) p a(href="/create/"+title.title_id) Create a new game if ready_games.length > 0 h2 Ready to start - +gametable(0,ready_games,1) + +gamelist(ready_games, "ready", true) if active_games.length > 0 h2 Active - +gametable(1,active_games,1) + +gamelist(active_games, "active", true) if finished_games.length > 0 - h2 Finished - +gametable(2,finished_games,1) + h2 Recently finished + +gamelist(finished_games, "finished", true) -- cgit v1.2.3