Added better custom template
This commit is contained in:
parent
9b082fdc64
commit
27c8c8f10b
6 changed files with 19 additions and 29 deletions
|
@ -1,13 +1,12 @@
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
|
|
||||||
|
|
||||||
class CustomHeaderBG():
|
class CustomTemplate(TemplateView):
|
||||||
"""Allow custom header background"""
|
html_title = ""
|
||||||
|
body_class = ""
|
||||||
class Template(TemplateView):
|
|
||||||
header_BG = ""
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['header_BG'] = self.header_BG
|
context['html_title'] = self.html_title
|
||||||
|
context['body_class'] = self.body_class
|
||||||
return context
|
return context
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
from django.views.generic import TemplateView
|
from project.common.views import CustomTemplate
|
||||||
from project.common.views import CustomHeaderBG
|
|
||||||
from django.contrib.staticfiles.templatetags.staticfiles import static
|
from django.contrib.staticfiles.templatetags.staticfiles import static
|
||||||
|
|
||||||
|
|
||||||
class IndexView(TemplateView):
|
class IndexView(CustomTemplate):
|
||||||
template_name = 'index.html'
|
template_name = 'index.html'
|
||||||
|
html_title = "Homepage"
|
||||||
|
body_class = "index"
|
||||||
|
|
||||||
|
|
||||||
class NoJavascriptView(TemplateView):
|
class NoJavascriptView(CustomTemplate):
|
||||||
template_name = 'core/no-js.html'
|
template_name = 'core/no-js.html'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
|
@ -16,7 +17,7 @@ class NoJavascriptView(TemplateView):
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class Custom404View(CustomHeaderBG.Template):
|
class Custom404View(CustomTemplate):
|
||||||
template_name = 'core/404.html'
|
template_name = 'core/404.html'
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
|
@ -24,9 +25,9 @@ class Custom404View(CustomHeaderBG.Template):
|
||||||
return self.render_to_response(context, status=404)
|
return self.render_to_response(context, status=404)
|
||||||
|
|
||||||
|
|
||||||
class AboutWebsiteView(CustomHeaderBG.Template):
|
class AboutWebsiteView(CustomTemplate):
|
||||||
template_name = 'about/website.html'
|
template_name = 'about/website.html'
|
||||||
|
|
||||||
|
|
||||||
class AboutIndexView(TemplateView):
|
class AboutIndexView(CustomTemplate):
|
||||||
template_name = 'about/index.html'
|
template_name = 'about/index.html'
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
{% extends 'content_base.html' %}
|
{% extends 'content_base.html' %}
|
||||||
|
|
||||||
{% block htmlTitle %}About the website{% endblock %}
|
|
||||||
|
|
||||||
{% block bodyClass %}{% endblock %}
|
|
||||||
|
|
||||||
{% block pageTitle %}About my website{% endblock %}
|
{% block pageTitle %}About my website{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>{% block baseHtmlTitle %}{% endblock %} | TheOrangeOne</title>
|
<title>{{ html_title }} | TheOrangeOne</title>
|
||||||
<meta chatset='utf-8' />
|
<meta chatset='utf-8' />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
|
||||||
<script type="text/javascript" src="{% static 'js/jquery.js' %}"></script>
|
<script type="text/javascript" src="{% static 'js/jquery.js' %}"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}"/>
|
<link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}"/>
|
||||||
<link rel="shortcut icon" href=""/>
|
<link rel="shortcut icon" href=""/>
|
||||||
</head>
|
</head>
|
||||||
<body class="{% block baseBodyClass%}{% endblock %}">
|
<body class="{{ body_class }}">
|
||||||
{% block baseContent%}{% endblock %}
|
{% block baseContent%}{% endblock %}
|
||||||
<footer>
|
<footer>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
{% block baseHtmlTitle%}
|
|
||||||
{% block htmlTitle %}{% endblock %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block baseBodyClass %}
|
{% block baseBodyClass %}
|
||||||
{% block bodyClass %}{% endblock %}
|
{% block bodyClass %}{% endblock %}
|
||||||
{% endblock%}
|
{% endblock%}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
{% block baseHtmlTitle %}Homepage{% endblock %}
|
|
||||||
{% block baseBodyClass %}index{% endblock %}
|
|
||||||
{% block baseContent%}
|
{% block baseContent%}
|
||||||
<div class="container-fluid" id="header">
|
<div class="container-fluid" id="header">
|
||||||
<div class="jumbotron container animated zoomInDown">
|
<div class="jumbotron container animated zoomInDown">
|
||||||
|
|
Reference in a new issue