From 189479074094707440d4d0a240b75fb0ffb7bb7f Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Sun, 15 Nov 2020 19:15:55 +0100
Subject: [PATCH] More refactor, and include previously forgotten decks.tpl.

---
 views/_card.css       |  5 +++++
 views/_card.tpl       | 17 +++++++++++++++++
 views/_meta_foot.tpl  |  1 +
 views/_meta_head.tpl  |  2 ++
 views/card.tpl        | 29 ++++-------------------------
 views/card_form.tpl   |  5 ++---
 views/cards.tpl       |  5 ++---
 views/cards_print.tpl | 31 ++++++-------------------------
 views/decks.tpl       | 12 ++++++++++++
 views/delete_card.tpl |  5 ++---
 10 files changed, 53 insertions(+), 59 deletions(-)
 create mode 100644 views/_card.css
 create mode 100644 views/_card.tpl
 create mode 100644 views/_meta_foot.tpl
 create mode 100644 views/_meta_head.tpl
 create mode 100644 views/decks.tpl

diff --git a/views/_card.css b/views/_card.css
new file mode 100644
index 0000000..9e71295
--- /dev/null
+++ b/views/_card.css
@@ -0,0 +1,5 @@
+.card {
+    box-sizing: border-box;
+    border: 30px solid #aaaaaa;
+    width: 200px;
+    height: 400px; }
diff --git a/views/_card.tpl b/views/_card.tpl
new file mode 100644
index 0000000..d5a541a
--- /dev/null
+++ b/views/_card.tpl
@@ -0,0 +1,17 @@
+<div class="card">
+  % if card["type"] == 'guilt':
+  <h1 id="title">GUILT CARD</h1>
+  <p id="prompt">Choose at least one of these guilts as your own:</p>
+  <ul id="answers">
+  % for answer in card["answers"]:
+    <li>{{ answer }}</li>
+  % end
+  <ul/>
+  % end
+  % if card["type"] == 'action':
+  <h1 id="title">ACTION CARD<br />{{ card["title"] }}</h1>
+  % for paragraph in card["paragraphs"]:
+  <p>{{ paragraph }}</p>
+  % end
+  % end
+</div>
diff --git a/views/_meta_foot.tpl b/views/_meta_foot.tpl
new file mode 100644
index 0000000..5f85cab
--- /dev/null
+++ b/views/_meta_foot.tpl
@@ -0,0 +1 @@
+</html>
diff --git a/views/_meta_head.tpl b/views/_meta_head.tpl
new file mode 100644
index 0000000..2fe56b9
--- /dev/null
+++ b/views/_meta_head.tpl
@@ -0,0 +1,2 @@
+<!DOCTYPE HTML>
+<html>
diff --git a/views/card.tpl b/views/card.tpl
index 31749f4..f946b21 100644
--- a/views/card.tpl
+++ b/views/card.tpl
@@ -1,30 +1,9 @@
-<!DOCTYPE HTML>
-<html>
+% include('_meta_head.tpl')
 <style>
-  .card {
-      box-sizing: border-box;
-      border: 30px solid #aaaaaa;
-      width: 200px;
-      height: 400px; }
+% include('_card.css')
 </style>
 <body>
-  <div class="card">
-    % if card["type"] == 'guilt':
-    <h1 id="title">GUILT CARD</h1>
-    <p id="prompt">Choose at least one of these guilts as your own:</p>
-    <ul id="answers">
-    % for answer in card["answers"]:
-      <li>{{ answer }}</li>
-    % end
-    <ul/>
-    % end
-    % if card["type"] == 'action':
-    <h1 id="title">ACTION CARD<br />{{ card["title"] }}</h1>
-    % for paragraph in card["paragraphs"]:
-    <p>{{ paragraph }}</p>
-    % end
-    % end
-  </div>
+% include('_card.tpl')
 <a href="{{ web_path }}/decks/{{deck_id}}/cards">back to overview</a>
 </body>
-</html>
+% include('_meta_foot.tpl')
diff --git a/views/card_form.tpl b/views/card_form.tpl
index 9e1e687..2454df5 100644
--- a/views/card_form.tpl
+++ b/views/card_form.tpl
@@ -1,5 +1,4 @@
-<!DOCTYPE HTML>
-<html>
+% include('_meta_head.tpl')
 <body>
 <h1>Edit {{ card["type"] }} card</h1>
 <form action="{{ web_path }}/decks/{{deck_id}}/cards/{{ card_id }}" method="POST">
@@ -35,4 +34,4 @@ Or would you rather <a href="{{ web_path }}/decks/{{deck_id}}/cards/{{ card_id }
 % end
 </form>
 </body>
-</html>
+% include('_meta_foot.tpl')
diff --git a/views/cards.tpl b/views/cards.tpl
index d63aab1..49d7617 100644
--- a/views/cards.tpl
+++ b/views/cards.tpl
@@ -1,5 +1,4 @@
-<!DOCTYPE HTML>
-<html>
+% include('_meta_head.tpl')
 <body>
 <h1>deck: {{deck_name}}</h1>
 <ul>
@@ -17,4 +16,4 @@ add another guilt card? name: <input type="text" name="card_name" /> type: <sele
 <a href="{{ web_path }}/decks">back to decks overview</a>
 </p>
 </body>
-</html>
+% include('_meta_foot.tpl')
diff --git a/views/cards_print.tpl b/views/cards_print.tpl
index 99f88b0..b7b63a1 100644
--- a/views/cards_print.tpl
+++ b/views/cards_print.tpl
@@ -1,32 +1,13 @@
-<!DOCTYPE HTML>
-<html>
+% include('_meta_head.tpl')
 <style>
+% include('_card.css')
   .card {
       page-break-before: always;
-      box-sizing: border-box;
-      border: 30px solid #aaaaaa;
-      width: 200px;
-      height: 400px; }
+  }
 </style>
 <body>
 % for card in cards:
-  <div class="card">
-    % if card["type"] == 'guilt':
-    <h1 id="title">GUILT CARD</h1>
-    <p id="prompt">Choose at least one of these guilts as your own:</p>
-    <ul id="answers">
-    % for answer in card["answers"]:
-      <li>{{ answer }}</li>
-    % end
-    <ul/>
-    % end
-    % if card["type"] == 'action':
-    <h1 id="title">ACTION CARD<br />{{ card["title"] }}</h1>
-    % for paragraph in card["paragraphs"]:
-    <p>{{ paragraph }}</p>
-    % end
-    % end
-  </div>
+% include('_card.tpl')
 % end
-</body>
-</html>
+<body>
+% include('_meta_foot.tpl')
diff --git a/views/decks.tpl b/views/decks.tpl
new file mode 100644
index 0000000..9cbae2c
--- /dev/null
+++ b/views/decks.tpl
@@ -0,0 +1,12 @@
+% include('_meta_head.tpl')
+<body>
+<ul>
+% for deck_id in decks:
+<li><a href="{{ web_path }}/decks/{{deck_id}}">{{decks[deck_id]}}</a></li>
+% end
+</ul>
+<form action="{{ web_path }}/decks/" method="GET">
+add another deck? name: <input type="text" name="deck_name" />
+</form>
+</body>
+% include('_meta_foot.tpl')
diff --git a/views/delete_card.tpl b/views/delete_card.tpl
index c9c0677..2d75375 100644
--- a/views/delete_card.tpl
+++ b/views/delete_card.tpl
@@ -1,9 +1,8 @@
-<!DOCTYPE HTML>
-<html>
+% include('_meta_head.tpl')
 <body>
 <form action="{{ web_path }}/decks/{{ deck_id }}/cards/{{ card_id }}/delete" method="POST">
 <input type="submit" value="delete {{card_name}}?" />
 </form>
 <a href="{{ web_path }}/decks/{{ deck_id }}/cards">Nah, better not …</a>
 </body>
-</html>
+% include('_meta_foot.tpl')
-- 
2.30.2