Skip to content

Commit 2d030f6

Browse files
Merge pull request #246 from digital-land/guidance-restructure
Guidance for publishers restructure - splitting intro page and making updates
2 parents b43307c + 4fcc34c commit 2d030f6

19 files changed

+221
-266
lines changed

application/routers/guidance_.py

+25
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import logging
33
from fastapi import APIRouter, Request
4+
from starlette.responses import RedirectResponse
45
from application.core.templates import templates
56

67
router = APIRouter()
@@ -66,10 +67,34 @@ def get_breadcrumbs(path):
6667
return crumb_dict
6768

6869

70+
def handleGuidanceRedirects(url_path, redirects):
71+
for redirect in redirects:
72+
url_path_copy = url_path
73+
if len(url_path_copy) > 0 and url_path_copy[-1] == "/":
74+
url_path_copy = url_path_copy[:-1]
75+
if redirect["from"] == url_path_copy:
76+
return RedirectResponse(url=redirect["to"], status_code=301)
77+
return False
78+
79+
6980
@router.get("/{url_path:path}")
7081
async def catch_all(request: Request, url_path: str):
7182
index_file = "index"
7283

84+
# Some redirects from old guidance
85+
86+
# introduction
87+
shouldRedirect = handleGuidanceRedirects(
88+
url_path,
89+
[
90+
{"from": "introduction", "to": "/guidance"},
91+
{"from": "how-to-provide-data", "to": "/guidance"},
92+
],
93+
)
94+
95+
if shouldRedirect:
96+
return shouldRedirect
97+
7398
# if URL path in this route is empty
7499
if url_path == "":
75100
url_path += index_file

application/templates/layouts/layout--guidance.html

+22-16
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ <h1 class="govuk-heading-xl">{{ pageData.pageTitle }}</h1>
2525
{% block content_secondary %}
2626

2727
{% set themes = [
28-
'Guidance for local planning authorities',
29-
'Data specification guidance',
28+
'Publish planning and housing data for England',
29+
'Prepare data to the specifications',
3030
'Other guidance'
3131
] %}
3232

@@ -46,19 +46,7 @@ <h1 class="govuk-heading-xl">{{ pageData.pageTitle }}</h1>
4646
'current': true if pageData.name == 'home' else false,
4747
},
4848
{
49-
'text': 'Introduction',
50-
'href': sectionPath + 'introduction',
51-
'theme': themes[0],
52-
'current': true if pageData.name == 'introduction' else false,
53-
},
54-
{
55-
'text': 'How to provide data',
56-
'theme': themes[0],
57-
'href': sectionPath + 'how-to-provide-data',
58-
'current': true if pageData.name == 'how-to-provide-data' else false,
59-
},
60-
{
61-
'text': 'Data specifications guidance',
49+
'text': 'Prepare data to the specifications',
6250
'theme': themes[0],
6351
'href': sectionPath + 'specifications/',
6452
'current': true if pageData.name == 'specifications' else false,
@@ -95,7 +83,25 @@ <h1 class="govuk-heading-xl">{{ pageData.pageTitle }}</h1>
9583
'current': true if pageData.name == 'tree-preservation-order' else false,
9684
}
9785
]
98-
}
86+
},
87+
{
88+
'text': 'Publish data on your website',
89+
'theme': themes[0],
90+
'href': sectionPath + 'publish-data-on-your-website',
91+
'current': true if pageData.name == 'publish-data-on-your-website' else false,
92+
},
93+
{
94+
'text': 'Keep your data up to date',
95+
'theme': themes[0],
96+
'href': sectionPath + 'keep-your-data-up-to-date',
97+
'current': true if pageData.name == 'keep-your-data-up-to-date' else false,
98+
},
99+
{
100+
'text': 'Try our new check and publish service',
101+
'theme': themes[0],
102+
'href': sectionPath + 'try-check-publish-service',
103+
'current': true if pageData.name == 'try-check-publish-service' else false,
104+
},
99105
]
100106
})
101107
}}

application/templates/pages/guidance/how-to-provide-data.md

-101
This file was deleted.

application/templates/pages/guidance/index.html

+4-19
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{%- from "components/back-button/macro.jinja" import dlBackButton %}
33
{% set templateName = 'dl-info/guidance/index.html' %}
44
{%- do pageData.update({
5-
'pageTitle': 'Guidance for local planning authorities'
5+
'pageTitle': 'Publish planning and housing data for England'
66
}) %}
77
{% block breadcrumbs%}
88
{{ dlBackButton({
@@ -11,24 +11,9 @@
1111
{% endblock %}
1212
{% block content_primary %}
1313

14-
<h2 class="govuk-heading-s govuk-!-margin-bottom-1">
15-
<a href="introduction">Introduction</a>
16-
</h2>
17-
<p>A brief overview of the process of providing data and the services this will contribute to.</p>
14+
<p>
15+
Guidance for planning authorities adding data to the platform.
16+
</p>
1817

19-
<h2 class="govuk-heading-s govuk-!-margin-bottom-1">
20-
<a href="how-to-provide-data">How to provide data</a>
21-
</h2>
22-
<p>Step-by-step instructions on how to publish your data.</p>
23-
24-
<h2 class="govuk-heading-s govuk-!-margin-bottom-1">
25-
<a href="specifications/">Data specifications guidance</a>
26-
</h2>
27-
<p>What to include in each dataset.</p>
28-
29-
<h2 class="govuk-heading-s govuk-!-margin-bottom-1">
30-
<a href="https://digital-land.github.io/specification/specification/">Technical specifications</a>
31-
</h2>
32-
<p>Technical guidance on what to include in each dataset.</p>
3318
{# <hr class="govuk-section-break govuk-section-break--visible govuk-section-break--l"> #}
3419
{% endblock %}

application/templates/pages/guidance/introduction.html

-24
This file was deleted.

application/templates/pages/guidance/introduction.md

-53
This file was deleted.

application/templates/pages/guidance/how-to-provide-data.html application/templates/pages/guidance/keep-your-data-up-to-date.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{%- do pageData.update({
2-
'pageTitle': 'How to provide data'
2+
'pageTitle': 'Keep your data up to date'
33
}) %}
4-
{% set templateName = 'dl-info/guidance/how-to-provide-data.html' %}
4+
{% set templateName = 'dl-info/guidance/keep-your-data-up-to-date.html' %}
55
{% extends "layouts/layout--guidance.html" %}
66
{%- from "components/back-button/macro.jinja" import dlBackButton %}
77

@@ -14,7 +14,7 @@
1414
{% block content_primary %}
1515

1616
{% set markdown_content %}
17-
{%- include pageData.root_url + "how-to-provide-data.md" with context -%}
17+
{%- include pageData.root_url + "keep-your-data-up-to-date.md" with context -%}
1818
{% endset %}
1919

2020
{{ markdown_content | render_markdown(govAttributes=True) }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Whenever the data changes, update it in the data URL.
2+
3+
Every day we collect the data from the URL you have shared.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{%- do pageData.update({
2+
'pageTitle': 'Publish data on your website'
3+
}) %}
4+
{% set templateName = 'dl-info/guidance/publish-data-on-your-website.html' %}
5+
{% extends "layouts/layout--guidance.html" %}
6+
{%- from "components/back-button/macro.jinja" import dlBackButton %}
7+
8+
{% block breadcrumbs%}
9+
{{ dlBackButton({
10+
"parentHref": '/guidance/'
11+
})}}
12+
{% endblock %}
13+
14+
{% block content_primary %}
15+
16+
{% set markdown_content %}
17+
{%- include pageData.root_url + "publish-data-on-your-website.md" with context -%}
18+
{% endset %}
19+
20+
{{ markdown_content | render_markdown(govAttributes=True) }}
21+
22+
{% endblock %}

0 commit comments

Comments
 (0)