Browse Source

templates: use a common base template (still to be done for list.html)

Baptiste Jonglez 8 years ago
parent
commit
fdc5fab1d1

+ 1 - 0
panorama/static/panorama/css/base.css

@@ -0,0 +1 @@
+/* CSS commun à toutes les pages */

+ 21 - 0
panorama/templates/panorama/base.html

@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+{% load staticfiles %}
+
+{# TODO: change lang? #}
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
+  <head>
+    <meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
+    <title>{% block title %}{% endblock title %}</title>
+    <link type="image/x-icon" rel="shortcut icon" href="{% static "panorama/img/tsf.png" %}"/>
+    <link rel="stylesheet" media="screen" href="{% static "panorama/css/base.css" %}" />
+    {% block css %}{% endblock css %}
+  </head>
+
+  <body>
+    {# Add base structure here, menu, etc... #}
+
+    {% block content %}{% endblock content %}
+
+    {% block js %}{% endblock js %}
+  </body>
+</html>

+ 4 - 0
panorama/templates/panorama/new.html

@@ -1,4 +1,8 @@
+{% extends "panorama/base.html" %}
+
+{% block content %}
 <form action="" enctype="multipart/form-data" method="post">{% csrf_token %}
   {{ form.as_p }}
   <input type="submit" value="Submit" />
 </form>
+{% endblock content %}

+ 13 - 12
panorama/templates/panorama/view.html

@@ -1,9 +1,9 @@
+{% extends "panorama/base.html" %}
 {% load staticfiles %}
-<!DOCTYPE html>
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
-  <head>
-    <meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
-    <title>{{ panorama.name }}</title>
+
+{% block title %}{{ panorama.name }}{% endblock title %}
+
+{% block js %}
     <script>
       var title = "{{ panorama.name|escapejs }}";
       var panorama_id = {{ panorama.pk }};
@@ -36,10 +36,7 @@
       ref_points["{{ ref.name|escapejs }}"] = {url: "/api/v1/references/{{ ref.id }}/", x: {{ ref.x }}, y: {{ ref.y }}, cap: {{ ref.cap }}, ele: {{ ref.elevation }}};
       {% endfor %}
     </script>
-    <link type="image/x-icon" rel="shortcut icon" href="{% static "panorama/img/tsf.png" %}"/>
-    <link rel="stylesheet" media="screen" href="{% static "panorama/css/map.css" %}" />
     <script src="{% static "panorama/js/hide_n_showForm.js" %}"></script>
-    <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
     <script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>
     <script src="https://code.jquery.com/jquery-3.0.0.min.js"></script>
     <script>
@@ -77,9 +74,14 @@
 
       });
     </script>
+{% endblock js %}
+
+{% block css %}
+    <link rel="stylesheet" media="screen" href="{% static "panorama/css/map.css" %}" />
+    <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
+{% endblock css %}
 
-  </head>
-  <body>
+{% block content %}
     <canvas id="mon-canvas">
       Ce message indique que ce navigateur est vétuste car il ne supporte pas <samp>canvas</samp> (IE6, IE7, IE8, ...)
     </canvas>
@@ -120,5 +122,4 @@
     <p id="res"></p>
 
     <div id="mapid"></div>
-  </body>
-</html>
+{% endblock content %}