Skip to content

Commit

Permalink
Merge pull request #246 from digital-land/guidance-restructure
Browse files Browse the repository at this point in the history
Guidance for publishers restructure - splitting intro page and making updates
  • Loading branch information
GeorgeGoodall authored Mar 6, 2024
2 parents b43307c + 4fcc34c commit 2d030f6
Show file tree
Hide file tree
Showing 19 changed files with 221 additions and 266 deletions.
25 changes: 25 additions & 0 deletions application/routers/guidance_.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import logging
from fastapi import APIRouter, Request
from starlette.responses import RedirectResponse
from application.core.templates import templates

router = APIRouter()
Expand Down Expand Up @@ -66,10 +67,34 @@ def get_breadcrumbs(path):
return crumb_dict


def handleGuidanceRedirects(url_path, redirects):
for redirect in redirects:
url_path_copy = url_path
if len(url_path_copy) > 0 and url_path_copy[-1] == "/":
url_path_copy = url_path_copy[:-1]
if redirect["from"] == url_path_copy:
return RedirectResponse(url=redirect["to"], status_code=301)
return False


@router.get("/{url_path:path}")
async def catch_all(request: Request, url_path: str):
index_file = "index"

# Some redirects from old guidance

# introduction
shouldRedirect = handleGuidanceRedirects(
url_path,
[
{"from": "introduction", "to": "/guidance"},
{"from": "how-to-provide-data", "to": "/guidance"},
],
)

if shouldRedirect:
return shouldRedirect

# if URL path in this route is empty
if url_path == "":
url_path += index_file
Expand Down
38 changes: 22 additions & 16 deletions application/templates/layouts/layout--guidance.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ <h1 class="govuk-heading-xl">{{ pageData.pageTitle }}</h1>
{% block content_secondary %}

{% set themes = [
'Guidance for local planning authorities',
'Data specification guidance',
'Publish planning and housing data for England',
'Prepare data to the specifications',
'Other guidance'
] %}

Expand All @@ -46,19 +46,7 @@ <h1 class="govuk-heading-xl">{{ pageData.pageTitle }}</h1>
'current': true if pageData.name == 'home' else false,
},
{
'text': 'Introduction',
'href': sectionPath + 'introduction',
'theme': themes[0],
'current': true if pageData.name == 'introduction' else false,
},
{
'text': 'How to provide data',
'theme': themes[0],
'href': sectionPath + 'how-to-provide-data',
'current': true if pageData.name == 'how-to-provide-data' else false,
},
{
'text': 'Data specifications guidance',
'text': 'Prepare data to the specifications',
'theme': themes[0],
'href': sectionPath + 'specifications/',
'current': true if pageData.name == 'specifications' else false,
Expand Down Expand Up @@ -95,7 +83,25 @@ <h1 class="govuk-heading-xl">{{ pageData.pageTitle }}</h1>
'current': true if pageData.name == 'tree-preservation-order' else false,
}
]
}
},
{
'text': 'Publish data on your website',
'theme': themes[0],
'href': sectionPath + 'publish-data-on-your-website',
'current': true if pageData.name == 'publish-data-on-your-website' else false,
},
{
'text': 'Keep your data up to date',
'theme': themes[0],
'href': sectionPath + 'keep-your-data-up-to-date',
'current': true if pageData.name == 'keep-your-data-up-to-date' else false,
},
{
'text': 'Try our new check and publish service',
'theme': themes[0],
'href': sectionPath + 'try-check-publish-service',
'current': true if pageData.name == 'try-check-publish-service' else false,
},
]
})
}}
Expand Down
101 changes: 0 additions & 101 deletions application/templates/pages/guidance/how-to-provide-data.md

This file was deleted.

23 changes: 4 additions & 19 deletions application/templates/pages/guidance/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{%- from "components/back-button/macro.jinja" import dlBackButton %}
{% set templateName = 'dl-info/guidance/index.html' %}
{%- do pageData.update({
'pageTitle': 'Guidance for local planning authorities'
'pageTitle': 'Publish planning and housing data for England'
}) %}
{% block breadcrumbs%}
{{ dlBackButton({
Expand All @@ -11,24 +11,9 @@
{% endblock %}
{% block content_primary %}

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

<h2 class="govuk-heading-s govuk-!-margin-bottom-1">
<a href="how-to-provide-data">How to provide data</a>
</h2>
<p>Step-by-step instructions on how to publish your data.</p>

<h2 class="govuk-heading-s govuk-!-margin-bottom-1">
<a href="specifications/">Data specifications guidance</a>
</h2>
<p>What to include in each dataset.</p>

<h2 class="govuk-heading-s govuk-!-margin-bottom-1">
<a href="https://digital-land.github.io/specification/specification/">Technical specifications</a>
</h2>
<p>Technical guidance on what to include in each dataset.</p>
{# <hr class="govuk-section-break govuk-section-break--visible govuk-section-break--l"> #}
{% endblock %}
24 changes: 0 additions & 24 deletions application/templates/pages/guidance/introduction.html

This file was deleted.

53 changes: 0 additions & 53 deletions application/templates/pages/guidance/introduction.md

This file was deleted.

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

Expand All @@ -14,7 +14,7 @@
{% block content_primary %}

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

{{ markdown_content | render_markdown(govAttributes=True) }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Whenever the data changes, update it in the data URL.

Every day we collect the data from the URL you have shared.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{%- do pageData.update({
'pageTitle': 'Publish data on your website'
}) %}
{% set templateName = 'dl-info/guidance/publish-data-on-your-website.html' %}
{% extends "layouts/layout--guidance.html" %}
{%- from "components/back-button/macro.jinja" import dlBackButton %}

{% block breadcrumbs%}
{{ dlBackButton({
"parentHref": '/guidance/'
})}}
{% endblock %}

{% block content_primary %}

{% set markdown_content %}
{%- include pageData.root_url + "publish-data-on-your-website.md" with context -%}
{% endset %}

{{ markdown_content | render_markdown(govAttributes=True) }}

{% endblock %}
Loading

0 comments on commit 2d030f6

Please sign in to comment.