Ver código fonte

Splitting base into includes. Increase number of blocks to help with presentation flexibility

Edd Baldry 8 anos atrás
pai
commit
2767d65de3

+ 22 - 121
bakerydemo/templates/base.html

@@ -1,144 +1,45 @@
 {% load navigation_tags static wagtailuserbar %}
 
-<!DOCTYPE html>
-<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
-<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
-<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
-<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
-    <head>
-        <meta charset="utf-8">
-        <meta http-equiv="X-UA-Compatible" content="IE=edge">
-        <title>
-            {% block title %}
-                {% block title_prefix %}
-                    Wagtail demo bakery
-                {% endblock %}
-                {% if self.seo_title %}
-                    {{ self.seo_title }}
-                {% else %}
-                    {{ self.title }}
-                {% endif %}
-            {% endblock %}
-        </title>
-        <meta name="description" content="{% if self.search_description %}{{ self.search_description }}{% endif %}">
-        <meta name="viewport" content="width=device-width, initial-scale=1">
-
-        <!-- Bootstrap Core CSS -->
-        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
-
-        <!-- Custom Fonts -->
-        <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
-
-        <!-- Theme CSS -->
-        {# <link href="css/clean-blog.min.css" rel="stylesheet">#}
-        <link rel="stylesheet" type="text/css" href="{% static 'css/main.css' %}">
-        <link rel="stylesheet" type="text/css" href="{% static 'css/main2.css' %}">
-
-
-        <link href='https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
-        <link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
-
-        <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
-        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
-        <!--[if lt IE 9]>
-            <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
-            <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
-        <![endif]-->
-
-</head>
+{% block head %}
+    {% include "includes/head.html" %}
+{% endblock head %}
 
 <body>
+{% wagtailuserbar %}
 
-    {% wagtailuserbar %}
+{% block header %}
+    {% include "includes/header.html" with parent=site_root calling_page=self %}
+    {# Header contains the main_navigation block #}
+{% endblock header %}
 
-    <div class="header clearfix">
-      <div class="container">
-        <div class="row">
-          <div class="col-lg-12">
-            <a href="#" class="logo">The Wagtail Bakery 🍞</a>
-            <form action="/search" method="get" class="search" _lpchecked="1">
-              <input name="q" type="text" placeholder="Search the site" id="" aria-label="Search the site" autocomplete="off">
-              <a href="#" class="search-icon">
-                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 451 451"><path d="M447.05 428l-109.6-109.6c29.4-33.8 47.2-77.9 47.2-126.1C384.65 86.2 298.35 0 192.35 0 86.25 0 .05 86.3.05 192.3s86.3 192.3 192.3 192.3c48.2 0 92.3-17.8 126.1-47.2L428.05 447c2.6 2.6 6.1 4 9.5 4s6.9-1.3 9.5-4c5.2-5.2 5.2-13.8 0-19zM26.95 192.3c0-91.2 74.2-165.3 165.3-165.3 91.2 0 165.3 74.2 165.3 165.3s-74.1 165.4-165.3 165.4c-91.1 0-165.3-74.2-165.3-165.4z"></path></svg>
-              </a>
-            </form>
-            {% block main_navigation %}
-            <nav>
-              <ul class="nav nav-pills">
-                {% get_site_root as site_root %}
-                {% top_menu parent=site_root calling_page=self %}
-                {# main_menu is defined in base/templatetags/navigation_tags.py #}
-              </ul>
-            </nav>
-          </div>
-        </div>
-      </div>
-      {% endblock %}
-    </div>
+{% block messages %}
+    {% include "includes/messages.html" %}
+{% endblock messages %}
 
-    {% if messages %}
-    <div>
-        <ul class="messages">
-            {% for message in messages %}
-            <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
-            {% endfor %}
-        </ul>
-    </div>
-    {% endif %}
+    <content> 
+        {% block content-header %}
+        {% endblock content-header %}
 
-    {% block breadcrumbs %}
-        {% breadcrumbs %}
-    {# breadcrumbs is defined in base/templatetags/navigation_tags.py #}
-    {% endblock %}
+        {% block breadcrumbs %}
+            {% breadcrumbs %}
+            {# breadcrumbs is defined in base/templatetags/navigation_tags.py #}
+        {% endblock breadcrumbs %}
 
-    <content> 
-        {% block content %}
-        {% endblock %}
+        {% block content-body %}
+        {% endblock content-body %}
     </content>
 
     <hr>
 
     <!-- Footer -->
     <footer>
-        <div class="container">
-            <div class="row">
-                <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
-                    <ul class="list-inline text-center">
-                        <li>
-                            <a href="#">
-                                <span class="fa-stack fa-lg">
-                                    <i class="fa fa-circle fa-stack-2x"></i>
-                                    <i class="fa fa-twitter fa-stack-1x fa-inverse"></i>
-                                </span>
-                            </a>
-                        </li>
-                        <li>
-                            <a href="#">
-                                <span class="fa-stack fa-lg">
-                                    <i class="fa fa-circle fa-stack-2x"></i>
-                                    <i class="fa fa-facebook fa-stack-1x fa-inverse"></i>
-                                </span>
-                            </a>
-                        </li>
-                        <li>
-                            <a href="#">
-                                <span class="fa-stack fa-lg">
-                                    <i class="fa fa-circle fa-stack-2x"></i>
-                                    <i class="fa fa-github fa-stack-1x fa-inverse"></i>
-                                </span>
-                            </a>
-                        </li>
-                    </ul>
-                    <p class="copyright text-center text-muted">{% get_footer_text %}</p>
-                </div>
-            </div>
-        </div>
+        {% include "includes/footer.html" %}
     </footer>
 
     <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
-
+    <script src="{% static 'js/bakery.js' %}"></script>
 
     <!-- Theme JavaScript -->
     <script src="{% static 'js/clean-blog.min.js' %}"></script>

+ 4 - 2
bakerydemo/templates/base/about_page.html

@@ -1,13 +1,15 @@
 {% extends "base.html" %}
 {% load wagtailimages_tags %}
 
-{% block content %}
+{% block content-header %}
     {{ page.title }}
 
     <div class="image">
         {% image page.image width-500 as photo %}
               <img src="{{ photo.url }}" width="{{ photo.width }}" height="{{ photo.height }}" alt="{{ photo.alt }}" />
     </div>
+{% endblock content-header %}
 
+{% block content-body %}
     {{ page.body }}
-{% endblock content %}
+{% endblock content-body %}

+ 5 - 2
bakerydemo/templates/base/form_page.html

@@ -1,12 +1,15 @@
 {% extends "base.html" %}
 {% load wagtailcore_tags %}
 
-{% block content %}
+{% block content-header %}
+    {{ page.title }}
     {{ page.intro|richtext }}
+{% endblock content-header %}
 
+{% endblock content-body %}
     <form action="{% pageurl page %}" method="POST">
         {% csrf_token %}
         {{ form.as_p }}
         <input type="submit">
     </form>
-{% endblock content %}
+{% endblock content-body %}

+ 8 - 2
bakerydemo/templates/base/form_page_landing.html

@@ -1,7 +1,13 @@
 {% extends "base.html" %}
 {% load wagtailcore_tags %}
 
-{% block content %}
+{% block content-header %}
     <h1>{{ page.title }}</h1>
+{% endblock content-header %}
+
+{% block breadcrumbs %}
+{% endblock breadcrumbs %}
+
+{% block content-body %}
     {{ page.thank_you_text|richtext }}
-{% endblock content %}
+{% endblock content-body %}

+ 3 - 1
bakerydemo/templates/base/gallery_page.html

@@ -1,13 +1,15 @@
 {% extends "base.html" %}
 {% load wagtailimages_tags gallery_tags %}
 
-{% block content %}
+{% block content-header %}
     {{ page.title }}
 
     <div class="image">
         {% image page.image width-500 as photo %}
               <img src="{{ photo.url }}" width="{{ photo.width }}" height="{{ photo.height }}" alt="{{ photo.alt }}" />
     </div>
+{% endblock content-header %}
 
+{% block content-body %}
     {% gallery page.choices %}
 {% endblock content %}

+ 4 - 2
bakerydemo/templates/base/home_page.html

@@ -1,13 +1,15 @@
 {% extends "base.html" %}
 {% load wagtailimages_tags %}
 
-{% block content %}
+{% block content-header %}
     {{ page.title }}
 
     <div class="image">
         {% image page.image width-500 as photo %}
               <img src="{{ photo.url }}" width="{{ photo.width }}" height="{{ photo.height }}" alt="{{ photo.alt }}" />
     </div>
+{% endblock content-header %}
 
+{% endblock content-body %}
     {{ page.body }}
-{% endblock content %}
+{% endblock content-body %}

+ 25 - 10
bakerydemo/templates/blog/blog_index_page.html

@@ -1,16 +1,31 @@
 {% extends "base.html" %}
 {% load wagtailimages_tags %}
 
-{% block content %}
-    {{ page.title }}
-    {% for blog in blogs %}
-        <div>
-            <h2><a href="{{ blog.url }}">{{ blog.title }}</a></h2>
-            {{ blog.body|truncatewords_html:10 }}
+{% block content-header %}
+<div class="container">
+    <div class="row">
+        <div class="col-md-7 col-md-offset-2">
+            {{ page.title }}
+        </div>
+    </div>
+</div>
+{% endblock content-header %}
+
+{% block content-body %}
+<div class="container">
+    <div class="row">
+        <div class="col-md-7 col-md-offset-2">
+            {% for blog in blogs %}
+                <div>
+                    <h2><a href="{{ blog.url }}">{{ blog.title }}</a></h2>
+                    {{ blog.body|truncatewords_html:10 }}
 
-            {% for tag in blog.get_tags  %}
-                <a href="{{ tag.url }}">{{ tag }}</a>
+                    {% for tag in blog.get_tags  %}
+                        <a href="{{ tag.url }}">{{ tag }}</a>
+                    {% endfor %}
+                </div>
             {% endfor %}
         </div>
-    {% endfor %}
-{% endblock content %}
+    </div>
+</div>
+{% endblock content-body %}

+ 17 - 5
bakerydemo/templates/blog/blog_page.html

@@ -1,19 +1,31 @@
 {% extends "base.html" %}
-{% load wagtailimages_tags %}
+{% load navigation_tags wagtailimages_tags %}
 
-{% block content %}
+{% block content-header %}
 {% image self.image fill-1920x600 as hero_img %}
 <div class="container-fluid hero" style="background-image:url('{{ hero_img.url }}')">
+<div class="hero-gradient-mask"></div>
     <div class="container">
-        <h1>{{ page.title }}</h1>
-        <h2>{{ page.subtitle }}</h2>
+        <div class="row">
+            <div class="col-md-7 col-md-offset-2">
+                <h1>{{ page.title }}</h1>
+                <p class="stand-first">{{ page.subtitle }}</p>
+            </div>
+        </div>
     </div>
 </div>
+{% endblock content-header %}
+
+{% block content-body %}
 <div class="container">
     <div class="row">
         <div class="col-md-7 col-md-offset-2">
+            {% if page.introduction %}
+                <p class="intro">{{ page.introduction }}</p>
+            {% endif %}
+            
             {{ page.body }}
         </div>
     </div>
 </div>
-{% endblock content %}
+{% endblock content-body %}

+ 4 - 1
bakerydemo/templates/breads/bread_page.html

@@ -1,11 +1,14 @@
 {% extends "base.html" %}
 {% load wagtailimages_tags %}
 
-{% block content %}
+{% block content-header %}
     <h1>{{ page.title }}</h1>
     <figure>
       {% image self.image fill-600x600 %}
     </figure>
+{% endblock content-header %}
+
+{% endblock content %}
     <p>{{ page.origin }}</p>
     <p>{{ page.bread_type }}</p>
     {{ page.description }}

+ 4 - 3
bakerydemo/templates/breads/breads_index_page.html

@@ -1,7 +1,7 @@
 {% extends "base.html" %}
 {% load wagtailimages_tags %}
 
-{% block content %}
+{% block content-header %}
     {{ page.title }}
     {% for bread in resources %}
 		<div>
@@ -10,7 +10,9 @@
 			</div>
 		</div>
 	{% endfor %}
+{% block content-header %}
 
+{% block content-body %}
 	{% if resources.has_other_pages %}
 	<div class="clearfix">
 	  <div class="pagination-wrapper">
@@ -36,5 +38,4 @@
 	  </div>
 	</div>
 	{% endif %}
-
-{% endblock content %}
+{% endblock content-body %}

+ 35 - 0
bakerydemo/templates/includes/footer.html

@@ -0,0 +1,35 @@
+{% load navigation_tags static %}
+
+<div class="container">
+    <div class="row">
+        <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
+            <ul class="list-inline text-center">
+                <li>
+                    <a href="#">
+                        <span class="fa-stack fa-lg">
+                            <i class="fa fa-circle fa-stack-2x"></i>
+                            <i class="fa fa-twitter fa-stack-1x fa-inverse"></i>
+                        </span>
+                    </a>
+                </li>
+                <li>
+                    <a href="#">
+                        <span class="fa-stack fa-lg">
+                            <i class="fa fa-circle fa-stack-2x"></i>
+                            <i class="fa fa-facebook fa-stack-1x fa-inverse"></i>
+                        </span>
+                    </a>
+                </li>
+                <li>
+                    <a href="#">
+                        <span class="fa-stack fa-lg">
+                            <i class="fa fa-circle fa-stack-2x"></i>
+                            <i class="fa fa-github fa-stack-1x fa-inverse"></i>
+                        </span>
+                    </a>
+                </li>
+            </ul>
+            <p class="copyright text-center text-muted">{% get_footer_text %}</p>
+        </div>
+    </div>
+</div>

+ 51 - 0
bakerydemo/templates/includes/head.html

@@ -0,0 +1,51 @@
+{% load static %}
+
+<!DOCTYPE html>
+<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
+<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
+<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
+<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
+<head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <title>
+        {% block title %}
+            {% block title_prefix %}
+                Wagtail demo bakery
+            {% endblock %}
+            {% if self.seo_title %}
+                {{ self.seo_title }}
+            {% else %}
+                {{ self.title }}
+            {% endif %}
+        {% endblock %}
+    </title>
+    <meta name="description" content="{% if self.search_description %}{{ self.search_description }}{% endif %}">
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+
+    <!-- Bootstrap Core CSS -->
+    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
+
+    <!-- Custom Fonts -->
+    <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
+    <link href="https://fonts.googleapis.com/css?family=Alegreya:400,700|Lato:300,400,700,900" rel="stylesheet">
+
+    <!-- Theme CSS -->
+    {# <link href="css/clean-blog.min.css" rel="stylesheet">#}
+    <link rel="stylesheet" type="text/css" href="{% static 'css/main.css' %}">
+    <link rel="stylesheet" type="text/css" href="{% static 'css/main2.css' %}">
+
+
+    <link href='https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
+    <link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
+
+    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
+    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
+    <!--[if lt IE 9]>
+        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
+        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
+    <![endif]-->
+    
+    {% block head-extra %}
+    {% endblock head-extra %}
+</head>

+ 26 - 0
bakerydemo/templates/includes/header.html

@@ -0,0 +1,26 @@
+{% load navigation_tags %}
+<div class="header clearfix">
+  <div class="container">
+    <div class="row">
+      <div class="col-lg-12">
+        <a href="#" class="logo">The Wagtail Bakery</a>
+        <form action="/search" method="get" class="search" _lpchecked="1">
+          <input name="q" type="text" placeholder="Search the site" id="" aria-label="Search the site" autocomplete="off">
+          <a href="#" class="search-icon">
+            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 451 451"><path d="M447.05 428l-109.6-109.6c29.4-33.8 47.2-77.9 47.2-126.1C384.65 86.2 298.35 0 192.35 0 86.25 0 .05 86.3.05 192.3s86.3 192.3 192.3 192.3c48.2 0 92.3-17.8 126.1-47.2L428.05 447c2.6 2.6 6.1 4 9.5 4s6.9-1.3 9.5-4c5.2-5.2 5.2-13.8 0-19zM26.95 192.3c0-91.2 74.2-165.3 165.3-165.3 91.2 0 165.3 74.2 165.3 165.3s-74.1 165.4-165.3 165.4c-91.1 0-165.3-74.2-165.3-165.4z"></path></svg>
+          </a>
+        </form>
+        
+        {% block main_navigation %}
+          <nav>
+            <ul class="nav nav-pills">
+              {% get_site_root as site_root %}
+              {% top_menu parent=site_root calling_page=self %}
+              {# main_menu is defined in base/templatetags/navigation_tags.py #}
+            </ul>
+          </nav>
+        {% endblock %}
+      </div>
+    </div>
+  </div> 
+</div>

+ 9 - 0
bakerydemo/templates/includes/messages.html

@@ -0,0 +1,9 @@
+{% if messages %}
+    <div>
+        <ul class="messages">
+            {% for message in messages %}
+            <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
+            {% endfor %}
+        </ul>
+    </div>
+{% endif %}

+ 13 - 6
bakerydemo/templates/locations/location_page.html

@@ -1,28 +1,35 @@
 {% extends "base.html" %}
 {% load wagtailimages_tags %}
 
-{% block content %}
-
-    <style>
+{% block head-extra %}
+  <style>
       /* Needed for Google map embed */
       #map {
         height: 100%;
       }
+      .maps.embed-container {
+         pointer-events: none;
+      }
       html, body {
         height: 100%;
         margin: 0;
         padding: 0;
       }
-    </style>
+  </style>
+{% endblock head-extra %}
 
+{% block content-header %}
     <h1>{{ page.title }}</h1>
     <figure>
       {% image self.image fill-600x600 %}
     </figure>
+{% endblock content-header %}
+
+{% block content-body %}
     <p>{{ page.address }}</p>
     <p>{{ page.lat_long }}</p>
 
-    <div id="map"></div>
+    <div id="map" class="maps embed-container"></div>
     <script>
       var map;
       function initMap() {
@@ -48,4 +55,4 @@
     {% for hours in page.opening_hours %}
         <li>{{ hours }}</li>
     {% endfor %}
-{% endblock content %}
+{% endblock content-body %}

+ 4 - 2
bakerydemo/templates/locations/locations_index_page.html

@@ -1,10 +1,12 @@
 {% extends "base.html" %}
 {% load wagtailimages_tags %}
 
-{% block content %}
+{% block content-header %}
     {{ page.title }}
+{% endblock content-header %}
 
+{% block content-body %}
     {% for location in locations %}
         <div><a href="{{ location.slug }}">{{ location.title }}</a></div>
     {% endfor %}
-{% endblock content %}
+{% endblock content-body %}

+ 7 - 3
bakerydemo/templates/search/search_results.html

@@ -3,11 +3,15 @@
 
 {% block title %}Search{% if search_results %} results{% endif %}{% endblock %}
 
-{% block content %}
+{% block content-header %}
     <h1>
-        Search results{% if request.GET.query %} for “{{ request.GET.query }}”{% endif %}
+        Search results
     </h1>
+{% endblock content-header %}
+
+{% block content-body %}
     {% if search_results %}
+    You searched <p>{% if request.GET.query %} for “{{ request.GET.query }}”{% endif %}</p>
         <ul>
             {% for result in search_results %}
                 <li>
@@ -30,4 +34,4 @@
     {% else %}
         You didn’t search for anything!
     {% endif %}
-{% endblock %}
+{% endblock content-body %}