Add page title in html

This commit is contained in:
2022-12-28 23:36:46 +01:00
parent 8bd2635c28
commit 538dc0bd80
10 changed files with 29 additions and 23 deletions

View File

@@ -12,7 +12,7 @@
<meta name="description" content="{{ site_conf.about}}"> <meta name="description" content="{{ site_conf.about}}">
<meta name="author" content="{{ site_conf.site_author }}"> <meta name="author" content="{{ site_conf.site_author }}">
<meta name="generator" content="Django Framework"> <meta name="generator" content="Django Framework">
<title>{{ site_conf.site_name }}</title> <title>{% block title %}{{ title }}{% endblock %} - {{ site_conf.site_name }}</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap-dark-5@1.1.3/dist/css/bootstrap-nightshade.min.css" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/bootstrap-dark-5@1.1.3/dist/css/bootstrap-nightshade.min.css" rel="stylesheet">
<link href="{% static "css/main.css" %}" rel="stylesheet"> <link href="{% static "css/main.css" %}" rel="stylesheet">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"> <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
@@ -81,7 +81,9 @@
<section class="py-4 text-center container"> <section class="py-4 text-center container">
<div class="row"> <div class="row">
<div class="mx-auto"> <div class="mx-auto">
{% block header %}{% endblock %} <h1 class="fw-light">{{ title }}</h1>
{% block header %}
{% endblock %}
</div> </div>
</div> </div>
</section> </section>

View File

@@ -1,8 +1,5 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block header %}
<h1 class="fw-light">Companies</h1>
{% endblock %}
{% block cards %} {% block cards %}
{% for c in company %} {% for c in company %}
<div class="col"> <div class="col">

View File

@@ -1,7 +1,6 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block header %} {% block header %}
<h1 class="fw-light">{{ consist }}</h1>
{% if consist.tags.all %} {% if consist.tags.all %}
<p><small>Tags:</small> <p><small>Tags:</small>
{% for t in consist.tags.all %}<a href="{% url 'filtered' _filter="tag" search=t.slug %}" class="badge rounded-pill bg-primary"> {% for t in consist.tags.all %}<a href="{% url 'filtered' _filter="tag" search=t.slug %}" class="badge rounded-pill bg-primary">

View File

@@ -1,8 +1,5 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block header %}
<h1 class="fw-light">Consists</h1>
{% endblock %}
{% block cards %} {% block cards %}
{% for c in consist %} {% for c in consist %}
<div class="col"> <div class="col">

View File

@@ -1,7 +1,6 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% block header %} {% block header %}
<h1 class="fw-light">{{ flatpage.name }}</h1>
<small class="text-muted">Updated {{ flatpage.updated_time | date:"M d, Y H:i" }}</small> <small class="text-muted">Updated {{ flatpage.updated_time | date:"M d, Y H:i" }}</small>
{% endblock %} {% endblock %}
{% block extra_content %} {% block extra_content %}

View File

@@ -1,7 +1,6 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block header %} {% block header %}
{% if site_conf.about %}<h1 class="fw-light">About</h1>{% endif %}
<p class="lead text-muted">{{ site_conf.about | safe }}</p> <p class="lead text-muted">{{ site_conf.about | safe }}</p>
{% endblock %} {% endblock %}

View File

@@ -1,7 +1,6 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% block header %} {% block header %}
<h1 class="fw-light">{{ rolling_stock }}</h1>
{% if rolling_stock.tags.all %} {% if rolling_stock.tags.all %}
<p><small>Tags:</small> <p><small>Tags:</small>
{% for t in rolling_stock.tags.all %}<a href="{% url 'filtered' _filter="tag" search=t.slug %}" class="badge rounded-pill bg-primary"> {% for t in rolling_stock.tags.all %}<a href="{% url 'filtered' _filter="tag" search=t.slug %}" class="badge rounded-pill bg-primary">

View File

@@ -1,8 +1,5 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block header %}
<h1 class="fw-light">Scales</h1>
{% endblock %}
{% block cards %} {% block cards %}
{% for s in scale %} {% for s in scale %}
<div class="col"> <div class="col">

View File

@@ -1,7 +1,6 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block header %} {% block header %}
<h1 class="fw-light">{{ filter | default_if_none:"Search" | title }}: {{ search }}</h1>
<p class="lead text-muted">Results found: {{ matches }}</p> <p class="lead text-muted">Results found: {{ matches }}</p>
{% endblock %} {% endblock %}
{% block pagination %} {% block pagination %}

View File

@@ -46,7 +46,11 @@ class GetHome(View):
return render( return render(
request, request,
"home.html", "home.html",
{"rolling_stock": rolling_stock, "page_range": page_range}, {
"title": "Home",
"rolling_stock": rolling_stock,
"page_range": page_range,
},
) )
@@ -83,8 +87,10 @@ class GetHomeFiltered(View):
query = Q(tags__slug__iexact=search) query = Q(tags__slug__iexact=search)
else: else:
raise Http404 raise Http404
rolling_stock = RollingStock.objects.filter(query).distinct().order_by( rolling_stock = (
*order_by_fields() RollingStock.objects.filter(query)
.distinct()
.order_by(*order_by_fields())
) )
matches = len(rolling_stock) matches = len(rolling_stock)
@@ -105,6 +111,7 @@ class GetHomeFiltered(View):
request, request,
"search.html", "search.html",
{ {
"title": "{0}: {1}".format(_filter.capitalize(), search),
"search": search, "search": search,
"filter": _filter, "filter": _filter,
"matches": matches, "matches": matches,
@@ -125,6 +132,7 @@ class GetHomeFiltered(View):
request, request,
"search.html", "search.html",
{ {
"title": "{0}: {1}".format(_filter.capitalize(), search),
"search": search, "search": search,
"filter": _filter, "filter": _filter,
"matches": matches, "matches": matches,
@@ -164,6 +172,7 @@ class GetRollingStock(View):
request, request,
"page.html", "page.html",
{ {
"title": rolling_stock,
"rolling_stock": rolling_stock, "rolling_stock": rolling_stock,
"class_properties": class_properties, "class_properties": class_properties,
"rolling_stock_properties": rolling_stock_properties, "rolling_stock_properties": rolling_stock_properties,
@@ -186,7 +195,11 @@ class Consists(View):
return render( return render(
request, request,
"consists.html", "consists.html",
{"consist": consist, "page_range": page_range}, {
"title": "Consists",
"consist": consist,
"page_range": page_range,
},
) )
@@ -209,6 +222,7 @@ class GetConsist(View):
request, request,
"consist.html", "consist.html",
{ {
"title": consist,
"consist": consist, "consist": consist,
"rolling_stock": rolling_stock, "rolling_stock": rolling_stock,
"page_range": page_range, "page_range": page_range,
@@ -230,7 +244,11 @@ class Companies(View):
return render( return render(
request, request,
"companies.html", "companies.html",
{"company": company, "page_range": page_range}, {
"title": "Companies",
"company": company,
"page_range": page_range,
},
) )
@@ -248,7 +266,7 @@ class Scales(View):
return render( return render(
request, request,
"scales.html", "scales.html",
{"scale": scale, "page_range": page_range}, {"title": "Scales", "scale": scale, "page_range": page_range},
) )
@@ -264,5 +282,5 @@ class GetFlatpage(View):
return render( return render(
request, request,
"flatpage.html", "flatpage.html",
{"flatpage": flatpage}, {"title": flatpage.name, "flatpage": flatpage},
) )