diff --git a/.gitignore b/.gitignore index 40e0fb4..26eae60 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ *.tmp *.egg-info static/ +!pems/static __pycache__/ .coverage .DS_Store diff --git a/pems/core/context_processors.py b/pems/core/context_processors.py new file mode 100644 index 0000000..496473a --- /dev/null +++ b/pems/core/context_processors.py @@ -0,0 +1,11 @@ +""" +The core application: context processors for enriching request context data. +""" + +from pems import __version__ + + +def pems_version(request): + """Context processor adds information about the PeMS application's version.""" + + return {"pems_version": __version__} diff --git a/pems/core/templates/core/base.html b/pems/core/templates/core/base.html new file mode 100644 index 0000000..0e7e398 --- /dev/null +++ b/pems/core/templates/core/base.html @@ -0,0 +1,168 @@ +{% load static %} + + +
+ +This is the home page
+{% endblock inner-content %} diff --git a/pems/core/urls.py b/pems/core/urls.py new file mode 100644 index 0000000..db292c8 --- /dev/null +++ b/pems/core/urls.py @@ -0,0 +1,9 @@ +from django.urls import path +from django.views.generic import TemplateView + +app_name = "core" + +# / +urlpatterns = [ + path("", TemplateView.as_view(template_name="core/index.html"), name="index"), +] diff --git a/pems/districts/templates/districts/district.html b/pems/districts/templates/districts/district.html index 0b2b8f8..9c77165 100644 --- a/pems/districts/templates/districts/district.html +++ b/pems/districts/templates/districts/district.html @@ -1,2 +1,2 @@URL of route: {% url "districts:district" district%}
+URL of route: {% url "districts:district" district %}
diff --git a/pems/districts/templates/districts/index.html b/pems/districts/templates/districts/index.html index 09a3b8a..b199e5a 100644 --- a/pems/districts/templates/districts/index.html +++ b/pems/districts/templates/districts/index.html @@ -1 +1,7 @@ -Districts
+{% endblock inner-content %} diff --git a/pems/settings.py b/pems/settings.py index 2848e41..329d965 100644 --- a/pems/settings.py +++ b/pems/settings.py @@ -31,6 +31,7 @@ def _filter_empty(ls): "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", + "pems.core", "pems.districts", "pems.streamlit_sample", ] @@ -59,6 +60,7 @@ def _filter_empty(ls): "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", + "pems.core.context_processors.pems_version", ], }, }, @@ -113,10 +115,25 @@ def _filter_empty(ls): # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/5.1/howto/static-files/ -STATIC_URL = "static/" +STATIC_URL = "/static/" + +STATICFILES_DIRS = [os.path.join(BASE_DIR, "pems", "static")] + +# use Manifest Static Files Storage by default +STORAGES = { + "default": { + "BACKEND": "django.core.files.storage.FileSystemStorage", + }, + "staticfiles": { + "BACKEND": os.environ.get( + "DJANGO_STATICFILES_STORAGE", "django.contrib.staticfiles.storage.ManifestStaticFilesStorage" + ) + }, +} STATIC_ROOT = os.path.join(BASE_DIR, "static") + # Default primary key field type # https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field diff --git a/pems/static/css/styles.css b/pems/static/css/styles.css new file mode 100644 index 0000000..c95d545 --- /dev/null +++ b/pems/static/css/styles.css @@ -0,0 +1,12 @@ +header { + > div.navigation-search { + > div.search-container > div.d-block > a.drawer-logo-link { + outline-offset: -3px; + > img.drawer-logo { + width: 232px; + filter: brightness(0) invert(1); + aspect-ratio: 18/5; + } + } + } +} diff --git a/pems/static/img/caltranslogo.png b/pems/static/img/caltranslogo.png new file mode 100644 index 0000000..09e87da Binary files /dev/null and b/pems/static/img/caltranslogo.png differ diff --git a/pems/urls.py b/pems/urls.py index 2820ad6..aa7a2ba 100644 --- a/pems/urls.py +++ b/pems/urls.py @@ -2,6 +2,7 @@ from django.urls import include, path urlpatterns = [ + path("", include("pems.core.urls")), path("admin/", admin.site.urls), path("districts/", include("pems.districts.urls")), path("streamlit/", include("pems.streamlit_sample.urls")), diff --git a/pyproject.toml b/pyproject.toml index ce18a5b..f466c3a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ maintainers = [{ name = "Compiler LLC", email = "dev@compiler.la" }] dependencies = ["Django==5.1.6", "gunicorn==23.0.0"] [project.optional-dependencies] -dev = ["black", "flake8", "pre-commit", "setuptools_scm>=8"] +dev = ["black", "djlint", "flake8", "pre-commit", "setuptools_scm>=8"] test = ["coverage", "pytest", "pytest-django", "pytest-mock", "pytest-socket"] @@ -34,6 +34,15 @@ relative_files = true source = ["pems", "streamlit_app"] omit = ["streamlit_app/apps/*"] +[tool.djlint] +ignore = "H006,H017,H031" +indent = 2 +max_attribute_length = 127 +max_line_length = 127 +profile = "django" +preserve_blank_lines = true +use_gitignore = true + [tool.pytest.ini_options] DJANGO_SETTINGS_MODULE = "pems.settings"