Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Customizable theming fix background images issue #2006

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

amitupreti
Copy link
Contributor

Closes #1996

Background: On PR #1986, we started to allow specific deployments of Physionet customize the theme of platform. This involved making the css styles, and static images configurable by using the .env file.

This #1986, introduced few bad designs and issues as pointed out by #1989 (tracked css files are being edited), and #1995 (downloading of files during installation).
This PR uses the suggestion provided by @alistairewj on #1996

Context:
This PR allows us to modify/customize the static files without messing with tracked file. As suggested by @alistairewj , we added a new directory static-overrides(where the updated static files are saved during compilestatic command)

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static-overrides'),
    os.path.join(BASE_DIR, 'static'),
]

So when the collectstatic command is ran it will first look inside the static-overrides directory, and copy the files to the STATIC_ROOT. As mentioned in https://docs.djangoproject.com/en/dev/howto/static-files/#serving-static-files-during-development, the files in static-overrides will be used in case we have files with same name in static-overrides and static.

During deployment, It is expected that compilestatic command will be ran first(which will generate the css, image files and store them to the static-override folder), and then collectstatic command will be ran which will collect static files
from static and static-override directories

Note: Regarding the part of code which lets us customize background image, i also added the option to allow someone to provide a link to background image because i am not sure if we can provide a local image path where the deployment happens in a container.

WIP: Currently, when the static files are generated in static-overrides by compilestatic and copied to STATIC_ROOT by collectstatic command. The static files are still loaded directly from static instead of STATIC_ROOT directory.(Happens when i run the dev environment through docker).
I tried to play around with DEBUG, STATIC_ROOT, and STATIC_URL in local dev settings.

As discussed on MIT-LCP#1996,
we are making the theme customizable for deployment
by .env configuration. This lead us modifying existing css files
adding configurable image files.
This folder should be used to store deployment specific
static files.

It is expected that compilestatic will be ran first(which will
generate the css, image files and store them to the static-override folder),
and then collectstatic will be ran which will collect static files
from static and static-override directories

Note that, the `static-overrides` comes before the `static` on base.py
This is intentional to make sure `static-overrides` is given
first priority if there are same file in these two directories.
@amitupreti amitupreti marked this pull request as draft May 17, 2023 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Overwriting default repository static assets on deployment
1 participant