Use base templates
authorDavid Kerkeslager <kerkeslager@gmail.com>
Fri, 26 Feb 2021 18:12:38 +0000 (13:12 -0500)
committerDavid Kerkeslager <kerkeslager@gmail.com>
Fri, 26 Feb 2021 18:12:38 +0000 (13:12 -0500)
tickle/templates/tickle/area_breadcrumb.html
tickle/templates/tickle/area_detail.html
tickle/templates/tickle/area_list.html
tickle/templates/tickle/base.html [new file with mode: 0644]
tickle/templates/tickle/boulder_detail.html
tickle/templates/tickle/route_detail.html

index 6255c21..5f52d9e 100644 (file)
@@ -1,7 +1,11 @@
-{% if area.parent %}
-  {% include 'tickle/area_breadcrumb.html' with area=area.parent %} &gt;
+{% if area %}
+  {% include 'tickle/area_breadcrumb.html' with area=area.parent is_parent=True %}
+  &gt;
+  {% if is_parent %}
+    <a href='{% url "tickle:area-detail" pk=area.pk %}'>{{ area.name }}</a>
+  {% else %}
+    {{ area.name }}
+  {% endif %}
 {% else %}
-  <a href='{% url "tickle:area-list" %}'>All</a> &gt;
+  <a href='{% url "tickle:area-list" %}'>All</a>
 {% endif %}
-
-<a href='{% url "tickle:area-detail" pk=area.pk %}'>{{ area.name }}</a>
index 3e4d4a5..6880397 100644 (file)
@@ -1,40 +1,40 @@
-<html>
-  <head></head>
-  <body>
-    {% if area.parent %}
-      {% include 'tickle/area_breadcrumb.html' with area=area.parent %}
-    {% endif %}
+{% extends 'tickle/base.html' %}
 
-    <h1>{{ area.name }}</h1>
+{% block tickle_title_name %}{{ area.name }}{% endblock %}
+{% block tickle_header_name %}{{ area.name }}{% endblock %}
 
-    {% if area.children.count > 0 %}
-      <ul>
-        {% for child in area.children.all %}
-          {% include 'tickle/area_list_item.html' with area=child %}
-        {% endfor %}
-      </ul>
-    {% endif %}
+{% block tickle_nav %}
+  {% include 'tickle/area_breadcrumb.html' %}
+{% endblock %}
 
-    <div>
-      {{ area.notes }}
-    </div>
+{% block tickle_main %}
+  {% if area.children.count > 0 %}
+    <ul>
+      {% for child in area.children.all %}
+        {% include 'tickle/area_list_item.html' with area=child %}
+      {% endfor %}
+    </ul>
+  {% endif %}
 
-    {% if area.boulders.count > 0 %}
-      Boulders
-      <ul>
-        {% for boulder in area.boulders.all %}
-          <li>{% include 'tickle/boulder_list_item.html' %}</li>
-        {% endfor %}
-      </ul>
-    {% endif %}
+  <div>
+    {{ area.notes }}
+  </div>
 
-    {% if area.routes.count > 0 %}
-      Routes
-      <ul>
-        {% for route in area.routes.all %}
-          <li>{% include 'tickle/route_list_item.html' %}</li>
-        {% endfor %}
-      </ul>
-    {% endif %}
-  </body>
-</html>
+  {% if area.boulders.count > 0 %}
+    Boulders
+    <ul>
+      {% for boulder in area.boulders.all %}
+        <li>{% include 'tickle/boulder_list_item.html' %}</li>
+      {% endfor %}
+    </ul>
+  {% endif %}
+
+  {% if area.routes.count > 0 %}
+    Routes
+    <ul>
+      {% for route in area.routes.all %}
+        <li>{% include 'tickle/route_list_item.html' %}</li>
+      {% endfor %}
+    </ul>
+  {% endif %}
+{% endblock %}
index 3cdadae..9b1fa73 100644 (file)
@@ -1,11 +1,12 @@
-<html>
-  <head></head>
-  <body>
-    <h1>All Areas</h1>
-    <ul>
-      {% for area in area_list %}
-        {% include 'tickle/area_list_item.html' %}
-      {% endfor %}
-    </ul>
-  </body>
-</html>
+{% extends 'tickle/base.html' %}
+
+{% block tickle_title_name %}All Areas{% endblock %}
+{% block tickle_header_name %}All Areas{% endblock %}
+
+{% block tickle_main %}
+  <ul>
+    {% for area in area_list %}
+      {% include 'tickle/area_list_item.html' %}
+    {% endfor %}
+  </ul>
+{% endblock %}
diff --git a/tickle/templates/tickle/base.html b/tickle/templates/tickle/base.html
new file mode 100644 (file)
index 0000000..1359846
--- /dev/null
@@ -0,0 +1,28 @@
+<!doctype html>
+
+<html lang='en'>
+  <head>
+    <meta charset='utf-8'>
+    <meta name='viewport' content='width=device-width, initial-scale=1'>
+
+    <title>{% block tickle_title_name %}{% endblock %}</title>
+  </head>
+
+  <body>
+    <nav>
+      {% block tickle_nav %}{% endblock %}
+    </nav>
+
+    <header>
+      <h1>{% block tickle_header_name %}{% endblock %}</h1>
+      {% block tickle_extra_header %}{% endblock %}
+    </header>
+
+    <main>
+      {% block tickle_main %}{% endblock %}
+    </main>
+
+    <footer>
+    </footer>
+  </body>
+</html>
index b3e2e0d..51e8977 100644 (file)
@@ -1,12 +1,16 @@
-<html>
-  <head></head>
-
-  <body>
-    {% include 'tickle/area_breadcrumb.html' with area=boulder.area %}
-    <header>
-      <h1>{{ boulder.name }}</h1>
-      <div>{{ boulder.difficulty }}</div>
-      <div>{{ boulder.notes }}</div>
-    </header>
-  </body>
-</html>
+{% extends 'tickle/base.html' %}
+
+{% block tickle_title_name %}{{ boulder.name }}{% endblock %}
+{% block tickle_header_name %}{{ boulder.name }}{% endblock %}
+
+{% block tickle_nav %}
+  {% include 'tickle/area_breadcrumb.html' with area=boulder.area is_parent=True %}
+{% endblock %}
+
+{% block tickle_extra_header %}
+  <h2>{{ boulder.difficulty }}</h2>
+{% endblock %}
+
+{% block tickle_main %}
+  <div>{{ boulder.notes }}</div>
+{% endblock %}
index 114504b..6b6ad52 100644 (file)
@@ -1,22 +1,26 @@
-<html>
-  <head></head>
+{% extends 'tickle/base.html' %}
 
-  <body>
-    {% include 'tickle/area_breadcrumb.html' with area=route.area %}
-    <header>
-      <h1>{{ route.name }}</h1>
-      <div>{{ route.difficulty }}</div>
-      <div>{{ route.notes }}</div>
+{% block tickle_title_name %}{{ route.name }}{% endblock %}
+{% block tickle_header_name %}{{ route.name }}{% endblock %}
 
-      {% if route.pitches.count == 1 %}
-        {% include 'tickle/pitch_list_item.html' with pitch=route.pitches.first %}
-      {% else %}
-        <ul>
-          {% for pitch in route.pitches.all %}
-            <li>{% include 'tickle/pitch_list_item.html' %}</li>
-          {% endfor %}
-        </ul>
-      {% endif %}
-    </header>
-  </body>
-</html>
+{% block tickle_nav %}
+  {% include 'tickle/area_breadcrumb.html' with area=route.area is_parent=True %}
+{% endblock %}
+
+{% block tickle_extra_header %}
+  <h2>{{ route.difficulty }}</h2>
+{% endblock %}
+
+{% block tickle_main %}
+  <div>{{ route.notes }}</div>
+
+  {% if route.pitches.count == 1 %}
+    {% include 'tickle/pitch_list_item.html' with pitch=route.pitches.first %}
+  {% else %}
+    <ul>
+      {% for pitch in route.pitches.all %}
+        <li>{% include 'tickle/pitch_list_item.html' %}</li>
+      {% endfor %}
+    </ul>
+  {% endif %}
+{% endblock %}