Skip to content

Commit

Permalink
Updated project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed Nov 28, 2023
1 parent e87332b commit 0aaabf8
Show file tree
Hide file tree
Showing 56 changed files with 189 additions and 39 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Python Package

on:
release:
types: [published]

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Get fixtures
run: cd .. && git clone https://github.com/nationalarchives/tna-frontend.git
- name: Install Python requirements
run: poetry install
- name: Install Node dependencies
run: cd tasks && npm install
- name: Run server
run: poetry run flask --app tna-frontend-jinja run --debug --port 5000 &
- name: Run the tests
run: node ./tasks/test.mjs || exit 1

deploy:
name: Upload release to PyPI
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/nationalarchives/tna-frontend-jinja/compare/v0.1.1...HEAD)

### Added
### Changed
### Deprecated
### Removed
### Fixed
### Security

## [0.1.1](https://github.com/nationalarchives/tna-frontend-jinja/compare/v0.1.0...v0.1.1) - 2023-11-28

### Changed

- Package structure updated

## 0.1.0 - 2023-11-28

Initial release made to PyPi
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

[![Main build status](https://img.shields.io/github/actions/workflow/status/nationalarchives/tna-frontend-jinja/ci.yml?style=flat-square&event=push&branch=main)](https://github.com/nationalarchives/tna-frontend-jinja/actions/workflows/ci.yml?query=branch%3Amain)
[![Latest release](https://img.shields.io/github/v/release/nationalarchives/tna-frontend-jinja?style=flat-square&logo=github&logoColor=white&sort=semver)](https://github.com/nationalarchives/tna-frontend-jinja/releases)
[![PyPi version](https://img.shields.io/pypi/v/nationalarchives-frontend-jinja?style=flat-square&logo=pypi&logoColor=white)](https://pypi.org/project/nationalarchives-frontend-jinja/)
![Python version](https://img.shields.io/pypi/pyversions/nationalarchives-frontend-jinja?style=flat-square&logo=python&logoColor=white)
[![PyPi version](https://img.shields.io/pypi/v/tna-frontend-jinja?style=flat-square&logo=pypi&logoColor=white)](https://pypi.org/project/tna-frontend-jinja/)
![Python version](https://img.shields.io/pypi/pyversions/tna-frontend-jinja?style=flat-square&logo=python&logoColor=white)
[![Licence](https://img.shields.io/github/license/nationalarchives/tna-frontend-jinja?style=flat-square)](https://github.com/nationalarchives/tna-frontend-jinja/blob/main/LICENCE)

## Quickstart
Expand Down
2 changes: 1 addition & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


def create_app():
app = Flask(__name__)
app = Flask(__name__, template_folder="../templates")

from .components import bp as components_bp

Expand Down
4 changes: 3 additions & 1 deletion app/components/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from flask import Blueprint

bp = Blueprint("components", __name__)
bp = Blueprint(
"components", __name__, template_folder="test-templates"
)

from app.components import routes # noqa: E402,F401
2 changes: 2 additions & 0 deletions app/components/test-templates/breadcrumbs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{%- from "components/breadcrumbs/macro.html" import tnaBreadcrumbs -%}
{{ tnaBreadcrumbs(context) }}
2 changes: 2 additions & 0 deletions app/components/test-templates/button.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{%- from "components/button/macro.html" import tnaButton -%}
{{ tnaButton(context) }}
2 changes: 2 additions & 0 deletions app/components/test-templates/card.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{%- from "components/card/macro.html" import tnaCard -%}
{{ tnaCard(context) }}
2 changes: 2 additions & 0 deletions app/components/test-templates/cookie-banner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{%- from "components/cookie-banner/macro.html" import tnaCookieBanner -%}
{{ tnaCookieBanner(context) }}
2 changes: 2 additions & 0 deletions app/components/test-templates/filters.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{%- from "components/filters/macro.html" import tnaFilters -%}
{{ tnaFilters(context) }}
2 changes: 2 additions & 0 deletions app/components/test-templates/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{%- from "components/footer/macro.html" import tnaFooter -%}
{{ tnaFooter(context) }}
2 changes: 2 additions & 0 deletions app/components/test-templates/grid.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{%- from "components/grid/macro.html" import tnaGrid -%}
{{ tnaGrid(context) }}
2 changes: 2 additions & 0 deletions app/components/test-templates/header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{%- from "components/header/macro.html" import tnaHeader -%}
{{ tnaHeader(context) }}
2 changes: 2 additions & 0 deletions app/components/test-templates/hero.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{%- from "components/hero/macro.html" import tnaHero -%}
{{ tnaHero(context) }}
2 changes: 2 additions & 0 deletions app/components/test-templates/index-grid.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{%- from "components/index-grid/macro.html" import tnaIndexGrid -%}
{{ tnaIndexGrid(context) }}
2 changes: 2 additions & 0 deletions app/components/test-templates/message.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{%- from "components/message/macro.html" import tnaMessage -%}
{{ tnaMessage(context) }}
2 changes: 2 additions & 0 deletions app/components/test-templates/phase-banner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{%- from "components/phase-banner/macro.html" import tnaPhaseBanner -%}
{{ tnaPhaseBanner(context) }}
2 changes: 2 additions & 0 deletions app/components/test-templates/picture.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{%- from "components/picture/macro.html" import tnaPicture -%}
{{ tnaPicture(context) }}
2 changes: 2 additions & 0 deletions app/components/test-templates/sensitive-image.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{%- from "components/sensitive-image/macro.html" import tnaSensitiveImage -%}
{{ tnaSensitiveImage(context) }}
2 changes: 2 additions & 0 deletions app/components/test-templates/skip-link.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{%- from "components/skip-link/macro.html" import tnaSkipLink -%}
{{ tnaSkipLink(context) }}
2 changes: 2 additions & 0 deletions app/components/test-templates/tabs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{%- from "components/tabs/macro.html" import tnaTabs -%}
{{ tnaTabs(context) }}
2 changes: 0 additions & 2 deletions app/templates/breadcrumbs.html

This file was deleted.

2 changes: 0 additions & 2 deletions app/templates/button.html

This file was deleted.

2 changes: 0 additions & 2 deletions app/templates/card.html

This file was deleted.

2 changes: 0 additions & 2 deletions app/templates/cookie-banner.html

This file was deleted.

2 changes: 0 additions & 2 deletions app/templates/filters.html

This file was deleted.

2 changes: 0 additions & 2 deletions app/templates/footer.html

This file was deleted.

2 changes: 0 additions & 2 deletions app/templates/grid.html

This file was deleted.

2 changes: 0 additions & 2 deletions app/templates/header.html

This file was deleted.

2 changes: 0 additions & 2 deletions app/templates/hero.html

This file was deleted.

2 changes: 0 additions & 2 deletions app/templates/index-grid.html

This file was deleted.

2 changes: 0 additions & 2 deletions app/templates/message.html

This file was deleted.

2 changes: 0 additions & 2 deletions app/templates/phase-banner.html

This file was deleted.

2 changes: 0 additions & 2 deletions app/templates/picture.html

This file was deleted.

2 changes: 0 additions & 2 deletions app/templates/sensitive-image.html

This file was deleted.

2 changes: 0 additions & 2 deletions app/templates/skip-link.html

This file was deleted.

2 changes: 0 additions & 2 deletions app/templates/tabs.html

This file was deleted.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[tool.poetry]
name = "tna-frontend-jinja"
version = "0.1.0"
version = "0.1.1"
description = ""
authors = ["Andrew Hosgood <[email protected]>"]
readme = "README.md"
packages = [{include = "app"}]
packages = [{include = "templates"}]

[tool.poetry.dependencies]
python = "^3.11"
Expand Down
Empty file added templates/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% macro tnaCookieBanner(params) %}
{% from "components/button.html" import tnaButton %}
{% from "components/button/macro.html" import tnaButton %}

{%- set containerClasses = [params.classes] if params.classes else [] -%}
<div class="tna-cookie-banner {{ containerClasses | join(' ') }}" role="region" aria-label="Cookie usage" data-module="tna-cookie-banner" data-policies="{{ params.policies if params.policies }}" data-preferenceskey="{{ params.preferencesSetKey if params.preferencesSetKey else 'cookie_preferences_set' }}" data-policies-key="{{ params.policiesKey if params.policiesKey }}" data-domain="{{ params.cookiesDomain if params.cookiesDomain }}" data-path="{{ params.cookiesPath if params.cookiesPath }}" data-insecure="{{ 'true' if params.allowInsecure else 'false' }}" role="region" aria-label="Cookies on {{ params.serviceName }}" {%- if params.attributes %}{% for attribute, value in params.attributes.items() %} {{ attribute }}="{{ value }}"{% endfor %}{% endif %} hidden>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
73 changes: 73 additions & 0 deletions templates/layouts/generic.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{% from "components/cookie-banner/macro.html" import tnaCookieBanner -%}
{% from "components/footer/macro.html" import tnaFooter -%}
{% from "components/header/macro.html" import tnaHeader -%}
{% from "components/skip-link/macro.html" import tnaSkipLink -%}
<!DOCTYPE html>
<html lang="{{ htmlLang | default('en-GB') }}" class="tna-template tna-template--{{ theme | default('system') }}-theme tna-template--{{ themeAccent | default('black') }}-accent {{ htmlClasses }}">
<head>
<meta charset="utf-8">
<title>{% block pageTitle %}The National Archives{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="theme-color" content="{{ themeColor | default('#000000') }}">
<meta http-equiv="X-UA-Compatible" content="IE=edge">

{% block headIcons %}
<link rel="shortcut icon" sizes="16x16 32x32 48x48" href="{{ assetPath | default('/assets') }}/images/favicon.ico" type="image/x-icon">
<link rel="mask-icon" href="{{ assetPath | default('/assets') }}/images/mask-icon.svg" color="{{ themeColor | default('#000000') }}">
<link rel="apple-touch-icon" sizes="180x180" href="{{ assetPath | default('/assets') }}/images/apple-touch-icon-180x180.png">
<link rel="apple-touch-icon" sizes="167x167" href="{{ assetPath | default('/assets') }}/images/apple-touch-icon-167x167.png">
<link rel="apple-touch-icon" sizes="152x152" href="{{ assetPath | default('/assets') }}/images/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" href="{{ assetPath | default('/assets') }}/images/apple-touch-icon.png">
{% endblock %}

{% block head %}{% endblock %}

{% block stylesheets %}
<link rel="stylesheet" type="text/css" href="{{ tnaFrontendCssPath | default('/static/tna-frontend') }}/all.css">
<link rel="stylesheet" type="text/css" href="https://use.typekit.net/hkj3kuz.css">
{% endblock %}
</head>
<body class="tna-template__body {{ bodyClasses }}" {%- for attribute, value in bodyAttributes %} {{attribute}}="{{value}}"{% endfor %}>
{% block bodyStart %}
{% block cookies %}
{{ tnaCookieBanner({
url: '#'
}) }}
{% endblock %}

{% block skipLink %}
{{ tnaSkipLink({
href: 'main-content',
text: 'Skip to main content'
}) }}
{% endblock %}
{% endblock %}

{% block header %}
{{ tnaHeader({}) }}
{% endblock %}

{% block main %}
{% block beforeContent %}{% endblock %}
<main class="tna-main-wrapper {{ mainClasses }}" id="main-content" role="main">
{% block content %}{% endblock %}
</main>
{% block afterContent %}{% endblock %}
{% endblock %}

{% block footer %}
{{ tnaFooter({}) }}
{% endblock %}

{% block bodyEnd %}
<script src="{{ tnaFrontendJsPath | default('/static/tna-frontend') }}/all.js"></script>
<script>
if (window.TNAFrontend && window.TNAFrontend.initAll) {
document.addEventListener("DOMContentLoaded", function() {
window.TNAFrontend.initAll();
});
}
</script>
{% endblock %}
</body>
</html>

0 comments on commit 0aaabf8

Please sign in to comment.