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

fix: add patches to compile and enable themes #5

Merged
merged 5 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,27 @@ To enable themes in your Tutor environment, follow these steps:
1. Add the necessary configuration in your Tutor environment's ``config.yml`` file:

.. code-block:: yaml
PICASSO_TUTOR_VERSION: <the version of the tutor your installation used. e.g., v18.1.1>
PICASSO_THEMES:
- name: <your_theme_name>
- name: <your_theme_repository>
repo: <your SSH URL for cloning the repo. e.g., [email protected]:yourorg/theme.git>
version: <your branch, tag o release for cloning. e.g., edunext/redwood.master>
- name: <another_theme_name>
- name: <another_theme_repository>
repo: <your SSH URL for cloning the repo. e.g., [email protected]:yourorg/another_theme.git>
version: <your branch, tag o release for cloning. e.g., edunext/redwood.blue>
PICASSO_THEMES_NAME:
- <your theme name. e.g., bragi>
- <another theme name. e.g., pearson-theme>
PICASSO_THEME_DIRS:
- <the directory where you store your themes. e.g., /openedx/themes/ednx-saas-themes/edx-platform>
- <another directory where you store your themes. e.g., /openedx/themes/openedx-themes/edx-platform>
**Note:** If your theme repository is public, you can also use the HTTPS URL in ``repo``.

**Note:** The ``PICASSO_THEMES``, ``PICASSO_THEME_DIRS`` and ``PICASSO_THEMES_NAME`` variables are lists and can have one or more elements.

2. Save the configuration with ``tutor config save``

3. Run the enable command
Expand All @@ -125,7 +134,15 @@ To enable themes in your Tutor environment, follow these steps:
# Enable themes
tutor picasso enable-themes
This command clones your theme repository into the folder that Tutor uses for themes. Documentation available at `Installing custom theme`_ tutorial.
This command will clone your theme repository into the folder that Tutor uses for themes. You can find the documentation in the `Installing custom theme`_ tutorial.

If ``PICASSO_THEMES`` is defined, the plugin will set ``ENABLE_COMPREHENSIVE_THEMING = True``.

If ``PICASSO_THEME_DIRS`` is defined, the plugin will extend the ``COMPREHENSIVE_THEME_DIRS`` by patches.

The ``PICASSO_TUTOR_VERSION``, ``PICASSO_THEME_DIRS`` and ``PICASSO_THEMES_NAME`` variables are used to compile the themes. For detailed information, see the patch `openedx-dockerfile-pre-assets <tutorpicasso/patches/openedx-dockerfile-pre-assets>`_.
MaferMazu marked this conversation as resolved.
Show resolved Hide resolved

You can set the ``PICASSO_DEFAULT_SITE_THEME`` (optional), which will be in ``DEFAULT_SITE_THEME``; if not, we will use the first element in ``PICASSO_THEMES_NAME``.
MaferMazu marked this conversation as resolved.
Show resolved Hide resolved

**Note:** Don't forget to add extra configurations in a Tutor plugin if your theme requires it.

Expand Down
3 changes: 3 additions & 0 deletions tutorpicasso/patches/cms-env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- if PICASSO_DEFAULT_SITE_THEME is defined or PICASSO_THEMES_NAME is defined %}
DEFAULT_SITE_THEME: "{{ PICASSO_DEFAULT_SITE_THEME | default(PICASSO_THEMES_NAME[0]) }}"
{% endif %}
3 changes: 3 additions & 0 deletions tutorpicasso/patches/lms-env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- if PICASSO_DEFAULT_SITE_THEME is defined or PICASSO_THEMES_NAME is defined %}
DEFAULT_SITE_THEME: "{{ PICASSO_DEFAULT_SITE_THEME | default(PICASSO_THEMES_NAME[0]) }}"
{% endif %}
6 changes: 6 additions & 0 deletions tutorpicasso/patches/openedx-cms-production-settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% if PICASSO_THEMES is defined -%}
ENABLE_COMPREHENSIVE_THEMING = True
{%- endif %}
{% if PICASSO_THEME_DIRS is defined -%}
COMPREHENSIVE_THEME_DIRS.extend({{ PICASSO_THEME_DIRS }})
{%- endif %}
3 changes: 3 additions & 0 deletions tutorpicasso/patches/openedx-common-assets-settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- if PICASSO_THEME_DIRS is defined %}
COMPREHENSIVE_THEME_DIRS.extend({{ PICASSO_THEME_DIRS }})
{%- endif %}
6 changes: 6 additions & 0 deletions tutorpicasso/patches/openedx-development-settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% if PICASSO_THEMES is defined -%}
ENABLE_COMPREHENSIVE_THEMING = True
{%- endif %}
{%- if PICASSO_THEME_DIRS is defined %}
COMPREHENSIVE_THEME_DIRS.extend({{ PICASSO_THEME_DIRS }})
{%- endif %}
40 changes: 40 additions & 0 deletions tutorpicasso/patches/openedx-dockerfile-pre-assets
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{% if PICASSO_TUTOR_VERSION is defined and PICASSO_THEME_DIRS is defined and PICASSO_THEMES_NAME is defined %}
{% set redwood_version = 'v18.0.0'.lstrip('v').split('.') %}
{% set current_version = PICASSO_TUTOR_VERSION.lstrip('v').split('.') %}
{% set redwood_version = redwood_version | map('int') | list %}
{% set current_version = current_version | map('int') | list %}

COPY --chown=app:app ./themes/ /openedx/themes
{% if (current_version[0] < redwood_version[0]) %}
# This compiles the Picasso themes assets in the releases < redwood.

# These commands are already in the Dockerfile Tutor template,
# but we needed them for the Picasso themes compilation.
ENV NO_PYTHON_UNINSTALL 1
ENV NO_PREREQ_INSTALL 1
RUN openedx-assets xmodule \
&& openedx-assets npm \
&& openedx-assets webpack --env=prod \
&& openedx-assets common
# Compiling the Picasso themes.
RUN openedx-assets themes \
--theme-dirs {{ PICASSO_THEME_DIRS | join(' ') }} \
--themes {{ PICASSO_THEMES_NAME | join(' ') }} \
&& openedx-assets collect --settings=tutor.assets \
&& rdfind -makesymlinks true -followsymlinks true /openedx/staticfiles/
{% else %}
# This compiles the Picasso themes assets from the redwood release.

# These commands are already in the Dockerfile Tutor template,
# but we needed them for the Picasso themes compilation.
RUN npm run postinstall
RUN npm run compile-sass -- --skip-themes
RUN npm run webpack
# Compiling the Picasso themes.
RUN npm run compile-sass -- \
--theme-dir {{ PICASSO_THEME_DIRS | join(' --theme-dir ') }} \
--theme {{ PICASSO_THEMES_NAME | join(' --theme ') }} \
&& ./manage.py lms collectstatic --noinput --settings=tutor.assets \
&& rdfind -makesymlinks true -followsymlinks true /openedx/staticfiles/
{% endif %}
{% endif %}
6 changes: 6 additions & 0 deletions tutorpicasso/patches/openedx-lms-production-settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% if PICASSO_THEMES is defined -%}
ENABLE_COMPREHENSIVE_THEMING = True
{%- endif %}
{% if PICASSO_THEME_DIRS is defined -%}
COMPREHENSIVE_THEME_DIRS.extend({{ PICASSO_THEME_DIRS }})
{%- endif %}
Loading