Skip to content

Commit 4304efd

Browse files
Merge pull request #10 from maykinmedia/feature/5-port-api-styles-and-templates
Port API project styles and templates
2 parents 579eb2e + 842b8f9 commit 4304efd

File tree

22 files changed

+822
-16
lines changed

22 files changed

+822
-16
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ end_of_line = lf
77
insert_final_newline = true
88
trim_trailing_whitespace = true
99

10-
[*.{scss,sass}]
10+
[*.css]
1111
indent_size = 2
1212

1313
[*.{yml,yaml}]

.github/workflows/ci.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,30 @@ jobs:
4343
with:
4444
token: ${{ secrets.CODECOV_TOKEN }}
4545

46+
e2e_tests:
47+
runs-on: ubuntu-latest
48+
name: Run the end-to-end tests
49+
50+
steps:
51+
- uses: actions/checkout@v4
52+
- uses: actions/setup-python@v5
53+
with:
54+
python-version: '3.12'
55+
56+
- name: Install dependencies
57+
run: |
58+
pip install tox tox-gh-actions pytest-playwright
59+
playwright install --with-deps chromium
60+
61+
- name: Run tests
62+
run: tox -e e2e
63+
4664
publish:
4765
name: Publish package to PyPI
4866
runs-on: ubuntu-latest
49-
needs: tests
67+
needs:
68+
- tests
69+
- e2e_tests
5070
environment: release
5171
permissions:
5272
id-token: write

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ reports
5555
# Django stuff:
5656
*.log
5757
local_settings.py
58-
db.sqlite3
58+
testapp/*.db
5959

6060
# Flask stuff:
6161
instance/

README.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ Run the tests with:
6464
6565
tox
6666
67-
Note that if you run ``pytest`` directly, some tests are expected to fail when you have
68-
all optional dependency groups installed.
69-
7067
.. |build-status| image:: https://github.com/maykinmedia/django-common/workflows/Run%20CI/badge.svg
7168
:alt: Build status
7269
:target: https://github.com/maykinmedia/django-common/actions?query=workflow%3A%22Run+CI%22

docs/apis.rst

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
.. _apis:
2+
3+
============
4+
API projects
5+
============
6+
7+
Many of the Maykin projects are API-first projects with only a minimum of "public
8+
frontend" requirements. maykin-common facilitates these by providing some base
9+
templates, CSS and JS for the landing page.
10+
11+
Templates
12+
=========
13+
14+
Two templates are provided from the library that you should extend:
15+
16+
* ``maykin_common/api/index_base.html``, use it in ``index.html`` for your landing page
17+
* ``maykin_common/api/includes/footer.html``, use it to extend your
18+
``includes/footer.html`` from
19+
20+
You'll need to make some modifications to the root ``urls.py`` and ``master.html`` to
21+
wire up everything automatically.
22+
23+
.. tip:: With the default project setup, the necessary CSS and Javascript are
24+
automatically loaded. If you use another master template, make sure to define the
25+
``view_class``, ``extra_css`` and ``content`` blocks to override.
26+
27+
``maykin_common/api/index_base.html``
28+
-------------------------------------
29+
30+
Provides the general scaffolding of the language page with the tabbed layout for
31+
Dutch and English content and the general branding.
32+
33+
In your child template, make sure to override the blocks that are specific to your
34+
project:
35+
36+
* ``page_title``
37+
* ``page_subtitle``
38+
* ``content_nl``
39+
* ``content_en``
40+
* ``license_link``
41+
42+
``maykin_common/api/includes/footer.html``
43+
------------------------------------------
44+
45+
Provides the standard footer layout with sensible defaults. You can override (default)
46+
values by clever usage of the ``with`` tag:
47+
48+
.. code-block:: django
49+
50+
{% block footer %}
51+
{% capture as issues_link silent %}<a class="link link--muted" href="https://github.com/maykinmedia/awesome-project/issues">issues</a>{% endcapture %}
52+
53+
{% with issues_link=issues_link %}
54+
{{ block.super }}
55+
{% endwith %}
56+
57+
{% endblock %}
58+
59+
.. tip:: Consider installing django-capture-tag for cleaner templates, like the example
60+
above.
61+
62+
Blocks you'll typically want to override are:
63+
64+
* ``footer``
65+
* ``links`` - the middle column with project-specific links
66+
67+
Other blocks you can override are:
68+
69+
* ``other_links`` - the links in the rightmost column
70+
71+
Stylesheets
72+
===========
73+
74+
The base template automatically loads the ``maykin_common/css/api.css`` stylesheets
75+
which contains the majority of the styles for the landing page components.
76+
77+
.. note:: While the default template uses font-awesome class names, the font-awesome
78+
stylesheet is **not** included as we want to avoid any frontend toolchains as long
79+
as possible. You have to make sure your project includes the styles and font assets
80+
yourself.
81+
82+
.. tip:: No default values are provided, however the default-project template does
83+
provide a starter setup in the ``_os_api`` directory.
84+
85+
The CSS is written with theming in mind. At the time of writing, the following CSS
86+
variables are supported, grouped by component:
87+
88+
**Page title**
89+
90+
* ``--page-title-color``
91+
* ``--page-title-font-family``
92+
93+
**Footer**
94+
95+
* ``--footer-border-color``
96+
97+
**Tabs**
98+
99+
* ``--tabs-border-color``
100+
* ``--tabs-item-color``
101+
* ``--tabs-item-hover-color``
102+
* ``--tabs-item-hover-border-color``
103+
104+
**Button**
105+
106+
* ``--button-color``
107+
* ``--button-background-color``
108+
* ``--button-hover-background-color``
109+
* ``--button-alert-background-color``
110+
* ``--button-alert-hover-background-color``
111+
112+
**Link**
113+
114+
* ``--link-color``
115+
* ``--link-color-hover``
116+
* ``--link-color-muted``
117+
118+
Javascript
119+
==========
120+
121+
We ship a minimal amount of Javascript and it's automatically loaded from the base
122+
template.
123+
124+
``maykin_common/js/nav-tabs.js``
125+
--------------------------------
126+
127+
Controls the (active) tab state for the ``.tabs`` component.

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Features
4545
:caption: Contents:
4646

4747
quickstart
48+
apis
4849
maykin_common/settings
4950
maykin_common/checks
5051
maykin_common/context_processors

maykin_common/context_processors.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ def settings(request):
66
public_settings = (
77
"GOOGLE_ANALYTICS_ID",
88
"PROJECT_NAME",
9+
"RELEASE",
10+
"GIT_SHA",
911
)
1012

1113
context = {

0 commit comments

Comments
 (0)