From 9437eb5a547c3e528c9d5406f847ecfd8b85a38c Mon Sep 17 00:00:00 2001 From: PlexSheep Date: Sun, 8 Sep 2024 14:19:58 +0200 Subject: [PATCH] refactor: split templates further for reusability --- data/www/admin/base.html | 13 +++ data/www/admin/details.html | 56 ++-------- data/www/admin/index.html | 14 +-- data/www/base.html | 106 ++++++++++++++++--- data/www/components/contestants_winners.html | 41 +++++++ data/www/user/base.html | 12 +++ data/www/{ => user}/details.html | 10 +- data/www/{ => user}/index.html | 16 +-- src/meta/admin.rs | 23 ++-- src/meta/mod.rs | 28 ++++- src/meta/user.rs | 27 +++-- 11 files changed, 224 insertions(+), 122 deletions(-) create mode 100644 data/www/admin/base.html create mode 100644 data/www/components/contestants_winners.html create mode 100644 data/www/user/base.html rename data/www/{ => user}/details.html (89%) rename data/www/{ => user}/index.html (55%) diff --git a/data/www/admin/base.html b/data/www/admin/base.html new file mode 100644 index 0000000..d28debb --- /dev/null +++ b/data/www/admin/base.html @@ -0,0 +1,13 @@ +{% extends "base" %} +{% block title %}{{ title }}{% endblock %} +{% block main %} +

{{title}}

+

+ You have reached the {{title}}. This site can be used by + the host of the challenge to see the challenge progress, solution, and + hints for that challenge. This site is NOT part of the + challenge. +

+
+{% block content %}{% endblock content %} +{% endblock %} diff --git a/data/www/admin/details.html b/data/www/admin/details.html index bc3df0a..ce598a9 100644 --- a/data/www/admin/details.html +++ b/data/www/admin/details.html @@ -1,5 +1,5 @@ -{% extends "base" %} -{% block main %} +{% extends "admin:base" %} +{% block content %}

{{title}}

You have reached the {{title}}. This site can be used by @@ -11,8 +11,8 @@


-

Challenge {{ challenge_idx}} — {{ challenge_title }}

-

{{ challenge_description }}

+

Challenge {{ challenge.id }} — {{ challenge.title }}

+

{{ challenge.description }}

Hints

-
- -
-
-

Contestants

-

- There are cuttently {{ contestants_amount }} contestants. - These contestants currently have had at least one connection to - the challenge: -

- -
- -
-

Winners

-

- There are cuttently {{ winners_amount }} winners. These contestants currently have been sent the secret: -

- -
-
+{% include "comp:contestants_winners" %} {% endblock %} diff --git a/data/www/admin/index.html b/data/www/admin/index.html index bdb0f33..6abd128 100644 --- a/data/www/admin/index.html +++ b/data/www/admin/index.html @@ -1,14 +1,5 @@ -{% extends "base" %} -{% block main %} -

{{title}}

-

- You have reached the {{title}}. This site can be used by - the host of the challenge to see the challenge progress, solution, and - hints for that challenge. This site is NOT part of the - challenge. -

- -
+{% extends "admin:base" %} +{% block content %}
@@ -25,6 +16,7 @@ {{ challenge.id }} — {{ challenge.title }} + ⇒ {{ challenge.addr }} {% endfor %} diff --git a/data/www/base.html b/data/www/base.html index 8bc2755..602cf6d 100644 --- a/data/www/base.html +++ b/data/www/base.html @@ -44,11 +44,21 @@ d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0zM4.5 7.5a.5.5 0 0 0 0 1h5.793l-2.147 2.146a.5.5 0 0 0 .708.708l3-3a.5.5 0 0 0 0-.708l-3-3a.5.5 0 1 0-.708.708L10.293 7.5H4.5z" /> - Bootstrap + {{app_name}} + + + + + + + + @@ -100,24 +110,86 @@
- -
-
- - - - - {{title}} - -
+
+
+ + -
- {% block main %}{% endblock %} -
-
- Created by {{ author }} © {{year}} -
+ +
+
+ + + + + {{app_name}} + +
+ +
+ {% block main %}{% endblock %} +
+
+ Created by {{ author }} © {{year}} +
+
+ +
+ diff --git a/data/www/components/contestants_winners.html b/data/www/components/contestants_winners.html new file mode 100644 index 0000000..4a45b11 --- /dev/null +++ b/data/www/components/contestants_winners.html @@ -0,0 +1,41 @@ +
+
+

Contestants

+

+ There are cuttently {{ contestants_amount }} contestants. + These contestants currently have had at least one connection to + the challenge: +

+ +
+ +
+

Winners

+

+ There are cuttently {{ winners_amount }} winners. These contestants currently have been sent the secret: +

+ +
+
diff --git a/data/www/user/base.html b/data/www/user/base.html new file mode 100644 index 0000000..2ec39e6 --- /dev/null +++ b/data/www/user/base.html @@ -0,0 +1,12 @@ +{% extends "base" %} +{% block title %}{{ title }}{% endblock %} +{% block main %} +

{{title}}

+

+ You have reached the {{title}}. This site can be used by the + contestants see the challenges and their progress and hints for that + challenge. This site is NOT part of the challenge. +

+
+{% block content %}{% endblock content %} +{% endblock %} diff --git a/data/www/details.html b/data/www/user/details.html similarity index 89% rename from data/www/details.html rename to data/www/user/details.html index 9ae5f60..65185b4 100644 --- a/data/www/details.html +++ b/data/www/user/details.html @@ -1,6 +1,6 @@ -{% extends "base" %} +{% extends "user:base" %} {% block title %}{{ title }}{% endblock %} -{% block main %} +{% block content %}

{{title}} User Interface

You have reached the {{title}} User @@ -13,8 +13,8 @@


-

Challenge {{ challenge_idx}} — {{ challenge_title }}

-

{{ challenge_description }}

+

Challenge {{ challenge.idx}} — {{ challenge.title }}

+

{{ challenge.description }}

Hints