Skip to content

Commit 6f7acd4

Browse files
committed
Refactor site settings to set up static export of demo site
1 parent 9259345 commit 6f7acd4

File tree

10 files changed

+20
-9
lines changed

10 files changed

+20
-9
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ coverage.xml
6262
*.pot
6363
# Django stuff:
6464
*.log
65-
local_settings.py
6665
# Flask instance folder
6766
instance/
6867
# Scrapy stuff:

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ Then you can install the dependencies and run the test app:
2121
```sh
2222
poetry install
2323
# Start the server for testing:
24-
poetry run django-admin runserver --settings=tests.settings --pythonpath=.
24+
poetry run django-admin runserver --settings=tests.settings.dev --pythonpath=.
2525
# Or to try out the render_patterns command:
26-
poetry run django-admin render_patterns --settings=tests.settings --pythonpath=. --dry-run --verbosity 2
26+
poetry run django-admin render_patterns --settings=tests.settings.dev --pythonpath=. --dry-run --verbosity 2
2727
```
2828

2929
### Run a local build with docker

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN useradd dpl && \
99
COPY pyproject.toml ./
1010
RUN poetry install --no-root
1111

12-
ENV DJANGO_SETTINGS_MODULE=tests.settings \
12+
ENV DJANGO_SETTINGS_MODULE=tests.settings.dev \
1313
PYTHONPATH=.
1414

1515
USER dpl

runtests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
cov.start()
2323

2424
# Django setup
25-
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
25+
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings.dev'
2626
django.setup()
2727

2828
# Test runner setup

tests/settings/__init__.py

Whitespace-only changes.
File renamed without changes.

tests/settings/dev.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .base import * # noqa

tests/settings/production.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from .base import * # noqa
2+
3+
# Serve the site as if it was hosted at the `/django-pattern-library/` sub-path
4+
STATIC_URL = '/django-pattern-library/demo/static/'
5+
GITHUB_PAGES_EXPORT = True

tests/urls.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
from django.conf import settings
12
from django.conf.urls import include, url
23

34
from pattern_library import urls as pattern_library_urls
45

5-
urlpatterns = [
6-
url(r'^pattern-library/', include(pattern_library_urls)),
7-
]
6+
if settings.GITHUB_PAGES_EXPORT:
7+
urlpatterns = [
8+
url(r'^django-pattern-library/demo/pattern-library/', include(pattern_library_urls)),
9+
]
10+
else:
11+
urlpatterns = [
12+
url(r'^pattern-library/', include(pattern_library_urls)),
13+
]

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ install_command =
99
./tox_install.sh {packages}
1010
commands =
1111
poetry run ./runtests.py
12-
poetry run django-admin render_patterns --settings=tests.settings --pythonpath=. --dry-run
12+
poetry run django-admin render_patterns --settings=tests.settings.dev --pythonpath=. --dry-run
1313
deps =
1414
dj22: Django>=2.2,<2.3
1515
dj30: Django>=3.0,<3.1

0 commit comments

Comments
 (0)