Переглянути джерело

Adding navbar to all templates

David Leonard 10 роки тому
батько
коміт
065d37937b

+ 48 - 16
hackathon_starter/hackathon/templates/hackathon/base.html

@@ -1,20 +1,52 @@
 <!DOCTYPE html>
-
-{% load staticfiles %} <!-- New line -->
-
-<html>
-
+  <html lang="en">
     <head>
-        <title>Base</title>
-        <link rel="stylesheet" href="{% static "css/base.css" %}" /> <!-- CSS -->
-        <script src="{% static "js/jquery.js" %}"></script> <!-- JavaScript -->
+      <title> Django Hackathon Starter </title>
+      <script src="/static/bower_components/jquery/dist/jquery.js"></script>
+      <script type="text/javascript" src="/static/bower_components/bootstrap/dist/bootstrap.min.js"></script>
+      
+      
+      <link rel="stylesheet" href="/static/bower_components/bootstrap/dist/css/bootstrap.min.css">
+      <link rel="stylesheet" href="/static/bower_components/bootstrap/dist/css/bootstrap-theme.min.css">
     </head>
+    
+  <body>
+    <nav class="navbar navbar-default" role="navigation">
+      <div class="container-fluid">
+        <!-- Brand and toggle get grouped for better mobile display -->
+        <div class="navbar-header">
+          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+            <span class="sr-only">Toggle navigation</span>
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+          </button>
+          <a class="navbar-brand" href="#">Django Hackathon Starter</a>
+      </div>
 
-    <body>
-        <h1>Api Example</h1>
-        <strong>{{ boldmessage }}</strong><br />
-
-        <!-- New line -->
-    </body>
-
-</html>
+      <!-- Collect the nav links, forms, and other content for toggling -->
+      <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+        <ul class="nav navbar-nav navbar-right">
+          {% if not user.is_authenticated %}
+            <li class="active"><a href="/hackathon/register">Register <span class="sr-only">(current)</span></a></li>
+            
+            <li><a href="/hackathon/login">Login</a></li>
+          {% endif %}
+            
+        </ul>
+        
+        <ul  class="nav navbar-nav navbar-right">
+          {% if user.is_authenticated %}
+    
+            <li><a>Hello {{user}}</a></li>
+            <li><a href="/hackathon/logout/">Logout</a></li>
+          {% endif %}
+        </ul>
+          
+          
+          </li>
+         </ul>
+        </div><!-- /.navbar-collapse -->
+      </div><!-- /.container-fluid -->
+    </nav>
+  </body>

+ 1 - 15
hackathon_starter/hackathon/templates/hackathon/index.html

@@ -1,24 +1,10 @@
 <!DOCTYPE html>
 
 <html>
-
-    <head>
-        <title>Base</title>
-        <script src="/static/bower_components/jquery/dist/jquery.js"></script> <!-- JavaScript -->
-    </head>
+    {% include 'hackathon/base.html' %}
 
     <body>
         <h1>Api Example</h1>
         <strong>{{ boldmessage }}</strong><br />
     </body>
-
-{% if user.is_authenticated %}
-<a href="/hackathon/logout/">Logout</a><br />
-{% else %}
-<a href="/hackathon/register/">Register Here</a><br />
-<a href="/hackathon/login/">Login</a><br />
-{% endif %}
-
-
-
 </html>

+ 1 - 3
hackathon_starter/hackathon/templates/hackathon/login.html

@@ -1,8 +1,6 @@
 <!DOCTYPE html>
 <html>
-    <head>
-        <title>Django Hackathon Starter</title>
-    </head>
+    {% include 'hackathon/base.html' %}
 
     <body>
         <h1>Login to Django Hackathon Starter</h1>

+ 1 - 4
hackathon_starter/hackathon/templates/hackathon/register.html

@@ -1,9 +1,6 @@
 <!DOCTYPE html>
 <html>
-    <head>
-        <title>Django Hackathon Starter</title>
-    </head>
-
+    {% include 'hackathon/base.html' %}
     <body>
         <h1>Register with Django Hackathon Starter</h1>