Create a super-simple homepage

This commit is contained in:
Danielle McLean 2017-10-23 09:37:24 +11:00
parent 8bd2faa8a9
commit 55abf1780e
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
9 changed files with 75 additions and 1 deletions

0
home/__init__.py Normal file
View file

View file

@ -0,0 +1,10 @@
{% extends 'lemoncurry/layout.html' %}
{% block main %}
<aside class="author">
<article class="h-card card p-author">
<h4 class="card-title p-name">
<span class="p-given-name">{{ user.first_name }}</span> <span class="p-family-name">{{ user.last_name }}</span>
</h4>
</article>
</aside>
{% endblock %}

8
home/urls.py Normal file
View file

@ -0,0 +1,8 @@
from django.conf.urls import url
from . import views
app_name = 'home'
urlpatterns = [
url(r'^$', views.index, name='index'),
]

7
home/views.py Normal file
View file

@ -0,0 +1,7 @@
from django.shortcuts import get_object_or_404, render
from users.models import User
def index(request):
user = get_object_or_404(User, pk=1)
return render(request, 'home/index.html', {'user': user})

View file

@ -38,6 +38,8 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'lemoncurry',
'home',
'users',
]

View file

@ -0,0 +1,38 @@
{% load lemoncurry_tags static %}<!doctype html>
<html lang="en" class="{% block html_class %}{% endblock %}">
<head>
<title class="p-name">{{ site_name }}</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css"
integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-md navbar-dark">
<a class="navbar-brand" href="{% url 'home:index' %}">Site</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar"
aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbar">
</div>
</nav>
</header>
<main>
{% block main %}{% endblock %}
</main>
<footer></footer>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" crossorigin="anonymous"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" crossorigin="anonymous"
integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" crossorigin="anonymous"
integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ"></script>
</body>
</html>

View file

View file

@ -0,0 +1,8 @@
from django import template
from django.conf import settings
register = template.Library()
@register.simple_tag
def site_name():
return settings.SITE_NAME

View file

@ -13,9 +13,10 @@ Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^', include('home.urls')),
url(r'^admin/', admin.site.urls),
]