Skip to content

Commit 897315e

Browse files
author
Ben Dickinson
committed
Add VS Code devcontainer config
1 parent 9f732d1 commit 897315e

File tree

11 files changed

+87
-33
lines changed

11 files changed

+87
-33
lines changed

.devcontainer/devcontainer.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/docker-existing-docker-compose
3+
{
4+
"name": "django-pattern-library devcontainer",
5+
"dockerComposeFile": [
6+
"../docker-compose.yml"
7+
],
8+
"service": "web",
9+
"workspaceFolder": "/app",
10+
"settings": {
11+
"terminal.integrated.profiles.linux": {
12+
"bash": {
13+
"path": "bash",
14+
"icon": "terminal-bash"
15+
},
16+
},
17+
"terminal.integrated.defaultProfile.linux": "bash"
18+
},
19+
"extensions": [
20+
"editorconfig.editorconfig",
21+
"github.vscode-pull-request-github",
22+
"ms-python.python",
23+
"ms-python.vscode-pylance",
24+
"syler.sass-indented"
25+
],
26+
"remoteUser": "dpl"
27+
}

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ jobs:
8181
# Docs website build.
8282
- run: poetry run mkdocs build --strict
8383
# Demo website build.
84-
- run: wget --mirror --page-requisites --no-parent --no-verbose http://localhost:8000/django-pattern-library/demo/pattern-library/
84+
- run: wget --mirror --page-requisites --no-parent --no-verbose http://localhost:8000/django-pattern-library/demo/
8585
- run: mv localhost:8000/django-pattern-library/demo site
8686
# Demo render_patterns.
8787
- run: poetry run django-admin render_patterns --settings=tests.settings.production --pythonpath=. --wrap-fragments --output=site/dpl-rendered-patterns
8888
# Package build, incl. publishing an experimental pre-release via GitHub Pages for builds on `main`.
89-
- run: cat pyproject.toml| awk '{sub(/^version = .+/,"version = \"0.0.0.dev\"")}1' > pyproject.toml.tmp && mv pyproject.toml.tmp pyproject.toml
89+
- run: cat pyproject.toml | awk '{sub(/^version = .+/,"version = \"0.0.0.dev\"")}1' > pyproject.toml.tmp && mv pyproject.toml.tmp pyproject.toml
9090
- run: poetry build
9191
- run: mv dist site
9292
- uses: actions/upload-artifact@v2

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
- Support for Django 4.0 ([#164](https://github.com/torchbox/django-pattern-library/pull/164)).
88
- Support for Python 3.10 ([#163](https://github.com/torchbox/django-pattern-library/pull/163)).
9+
- VS Code devcontainer for development [#178](https://github.com/torchbox/django-pattern-library/pull/178)
10+
11+
### Changed
12+
13+
- Change Poetry version to be `>=1.1.12,<2` in Docker development setup (prevents `JSONDecodeError` issue under Python 3.10) [#178](https://github.com/torchbox/django-pattern-library/pull/178)
14+
- Move demo/test app pattern-library from `/pattern-library/` to `/` [#178](https://github.com/torchbox/django-pattern-library/pull/178)
915

1016
### Removed
1117

@@ -29,7 +35,7 @@ This addresses the following limitations of the pattern library:
2935
- [#113 Django form fields not well supported](https://github.com/torchbox/django-pattern-library/issues/113)
3036
- [#135 Competing tag/context config for image provides inconsistent result](https://github.com/torchbox/django-pattern-library/issues/135)
3137

32-
View the [documentation](https://torchbox.github.io/django-pattern-library/guides/defining-template-context/#modifying-template-contexts-with-python), as well as demos leveraging the new capability: [forms](https://torchbox.github.io/django-pattern-library/demo/pattern-library/pattern/patterns/pages/forms/example_form.html) (see [forms and fields recipe](https://torchbox.github.io/django-pattern-library/recipes/forms-and-fields/)), and [pagination](https://torchbox.github.io/django-pattern-library/demo/pattern-library/pattern/patterns/pages/search/search.html) (see [pagination recipe](https://torchbox.github.io/django-pattern-library/recipes/pagination/)).
38+
View the [documentation](https://torchbox.github.io/django-pattern-library/guides/defining-template-context/#modifying-template-contexts-with-python), as well as demos leveraging the new capability: [forms](https://torchbox.github.io/django-pattern-library/demo/pattern/patterns/pages/forms/example_form.html) (see [forms and fields recipe](https://torchbox.github.io/django-pattern-library/recipes/forms-and-fields/)), and [pagination](https://torchbox.github.io/django-pattern-library/demo/pattern/patterns/pages/search/search.html) (see [pagination recipe](https://torchbox.github.io/django-pattern-library/recipes/pagination/)).
3339

3440
## [0.4.0](https://github.com/torchbox/django-pattern-library/releases/tag/v0.4.0) - 2021-05-20
3541

CONTRIBUTING.md

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,68 @@
22

33
This document contains information for anyone wishing to contribute to the project.
44

5-
## Install
5+
6+
7+
## Installation
68

79
The repo includes a simple test application that can be run locally to develop the pattern library itself.
10+
811
First, clone the repo:
912

1013
```sh
1114
git clone [email protected]:torchbox/django-pattern-library.git
1215
cd django-pattern-library
1316
```
1417

15-
### Run a local build with Poetry
18+
Once you have the code, there are several ways of running the project:
1619

17-
We use [Poetry](https://poetry.eustace.io/docs/) to manage Python dependencies, so make sure you've got it installed.
20+
- [In a VS Code devcontainer](#vs-code-devcontainer)
21+
- [In Docker, via docker-compose](#docker-compose)
22+
- [Locally, with Poetry](#run-locally-with-poetry)
1823

19-
Then you can install the dependencies and run the test app:
24+
### VS Code devcontainer
2025

21-
```sh
22-
poetry install
23-
# Start the server for testing:
24-
poetry run django-admin runserver --settings=tests.settings.dev --pythonpath=.
25-
# Or to try out the render_patterns command:
26-
poetry run django-admin render_patterns --settings=tests.settings.dev --pythonpath=. --dry-run --verbosity 2
27-
```
26+
For users of Docker and VS Code, there is a [devcontainer](https://code.visualstudio.com/docs/remote/containers) setup included in the repository
27+
that will automatically install the Python dependencies and start the frontend tooling.
28+
29+
Once the container is built, open a terminal with VS Code and run `django-admin runserver` and click the URL (normally http://127.0.0.1:8000/) to open the app in your browser. You'll see a 404 page, because there's nothing at `/`, add `pattern-libary/` to the end of the URL to view the demo app.
2830

29-
### Run a local build with docker
31+
### `docker-compose`
3032

31-
First [install Docker and docker-compose](https://docs.docker.com/compose/install/), and make sure Docker is started.
33+
First [install Docker and docker-compose](https://docs.docker.com/compose/install/), and make sure Docker is started. Then:
3234

3335
```sh
3436
# Install the front-end tooling in the docker container:
3537
docker-compose run frontend npm ci
36-
# Start the dev server and run the front-end tooling in watch mode:
38+
# Bring up the web container and run the front-end tooling in watch mode:
3739
docker-compose up
40+
# Run the development server:
41+
docker-compose exec web django-admin runserver 0.0.0.0:8000
3842
```
3943

40-
Once the server is started, the pattern library will be available at `http://localhost:8000/pattern-library/`.
44+
Once the server is started, the pattern library will be available at `http://localhost:8000/`.
45+
46+
### Run locally with Poetry
4147

42-
### Front-end tooling
48+
We use [Poetry](https://python-poetry.org/docs/) to manage Python dependencies, so make sure you've got it installed.
49+
50+
Then you can install the dependencies and run the test app:
51+
52+
```sh
53+
poetry install
54+
# Start the server for testing:
55+
poetry run django-admin runserver --settings=tests.settings.dev --pythonpath=.
56+
# Or to try out the render_patterns command:
57+
poetry run django-admin render_patterns --settings=tests.settings.dev --pythonpath=. --dry-run --verbosity 2
58+
```
59+
60+
## Front-end tooling
4361

4462
If you want to make changes to the front-end assets (located in the `pattern_library/static/pattern_library/src` folder), you'll need to ensure the tooling is set up in order to build the assets.
4563

46-
If you are using Docker you will already have the tooling set up and running in watch mode. Otherwise,
64+
If you are using Docker, you will already have the tooling set up and running in watch mode. You can view the logs with `docker-compose logs frontend` from your host machine.
65+
66+
Otherwise, we recommend using [`nvm`](https://github.com/nvm-sh/nvm):
4767

4868
```sh
4969
# Install the correct version of Node
@@ -56,7 +76,7 @@ npm run build
5676
npm run start
5777
```
5878

59-
### Documentation
79+
## Documentation
6080

6181
The project’s documentation website is built with [MkDocs](https://www.mkdocs.org/).
6282

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
FROM python:3.7
1+
FROM python:3.10
22

33
WORKDIR /app
44

5-
RUN useradd dpl && \
6-
pip install --pre poetry && \
5+
RUN useradd --create-home dpl && \
6+
pip install "poetry>=1.1.12,<2" && \
77
poetry config virtualenvs.create false
88

99
COPY pyproject.toml ./

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![PyPI](https://img.shields.io/pypi/v/django-pattern-library.svg)](https://pypi.org/project/django-pattern-library/) [![PyPI downloads](https://img.shields.io/pypi/dm/django-pattern-library.svg)](https://pypi.org/project/django-pattern-library/) [![Build status](https://github.com/torchbox/django-pattern-library/workflows/CI/badge.svg)](https://github.com/torchbox/django-pattern-library/actions) [![Total alerts](https://img.shields.io/lgtm/alerts/g/torchbox/django-pattern-library.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/torchbox/django-pattern-library/alerts/)
44

5-
> UI pattern libraries for Django templates. Try our [online demo](https://torchbox.github.io/django-pattern-library/demo/pattern-library/).
5+
> UI pattern libraries for Django templates. Try our [online demo](https://torchbox.github.io/django-pattern-library/demo/).
66
77
![Screenshot of the pattern library UI, with navigation, pattern rendering, and configuration](https://github.com/raw/torchbox/django-pattern-library/main/.github/pattern-library-screenshot.webp)
88

@@ -31,8 +31,8 @@ Learn more by watching our presentation – [Reusable UI components: A journey f
3131

3232
The pattern library is dependent on Django for rendering – but also supports exporting as a static site if needed. Try out our online demo:
3333

34-
- For a component, [accordion.html](https://torchbox.github.io/django-pattern-library/demo/pattern-library/pattern/patterns/molecules/accordion/accordion.html)
35-
- For a page-level template, [person_page.html](https://torchbox.github.io/django-pattern-library/demo/pattern-library/pattern/patterns/pages/people/person_page.html)
34+
- For a component, [accordion.html](https://torchbox.github.io/django-pattern-library/demo/pattern/patterns/molecules/accordion/accordion.html)
35+
- For a page-level template, [person_page.html](https://torchbox.github.io/django-pattern-library/demo/pattern/patterns/pages/people/person_page.html)
3636

3737
## Documentation
3838

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ services:
1212
source: .
1313
target: /app
1414
consistency: delegated
15+
command: tail -f /dev/null
1516

1617
frontend:
1718
command: npm start

docs/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Getting started
22

3-
> If you just want to see django-pattern-library up and running, have a look at our [online demo](https://torchbox.github.io/django-pattern-library/demo/pattern-library/pattern/patterns/molecules/accordion/accordion.html).
3+
> If you just want to see django-pattern-library up and running, have a look at our [online demo](https://torchbox.github.io/django-pattern-library/demo/pattern/patterns/molecules/accordion/accordion.html).
44
55
## Installation
66

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Pattern libraries will change your workflow for the better:
2929

3030
The pattern library is dependent on Django for rendering – but also supports exporting as a static site if needed. Try out our online demo:
3131

32-
- For a component, [accordion.html](https://torchbox.github.io/django-pattern-library/demo/pattern-library/pattern/patterns/molecules/accordion/accordion.html)
33-
- For a page-level template, [person_page.html](https://torchbox.github.io/django-pattern-library/demo/pattern-library/pattern/patterns/pages/people/person_page.html)
32+
- For a component, [accordion.html](https://torchbox.github.io/django-pattern-library/demo/pattern/patterns/molecules/accordion/accordion.html)
33+
- For a page-level template, [person_page.html](https://torchbox.github.io/django-pattern-library/demo/pattern/patterns/pages/people/person_page.html)
3434

3535
## Why this exists
3636

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ nav:
5858
- 'Related projects': 'community/related-projects.md'
5959
- 'Code of conduct': 'community/code-of-conduct.md'
6060
- 'Security policy': 'community/security-policy.md'
61-
- 'Online demo': '/django-pattern-library/demo/pattern-library/'
61+
- 'Online demo': '/django-pattern-library/demo/'

tests/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
if settings.GITHUB_PAGES_EXPORT:
77
urlpatterns = [
8-
path('django-pattern-library/demo/pattern-library/', include(pattern_library_urls)),
8+
path('django-pattern-library/demo/', include(pattern_library_urls)),
99
]
1010
else:
1111
urlpatterns = [
12-
path('pattern-library/', include(pattern_library_urls)),
12+
path('', include(pattern_library_urls)),
1313
]

0 commit comments

Comments
 (0)