Skip to content

Commit

Permalink
Merge pull request #67 from edx/farhan/default-edx-theme
Browse files Browse the repository at this point in the history
Set edx.org theme as default for edx-platform and MFEs
  • Loading branch information
huniafatima-arbi authored Jan 29, 2025
2 parents ec3bd77 + e2e7a62 commit cdfa616
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 1 deletion.
24 changes: 24 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,8 @@ services:
service: microfrontend
working_dir: '/edx/app/frontend-app-account'
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.frontend-app-account"
environment:
PARAGON_BRAND_PACKAGE: '@edx/[email protected]'
networks:
default:
aliases:
Expand All @@ -875,6 +877,8 @@ services:
service: microfrontend
working_dir: '/edx/app/frontend-app-profile'
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.frontend-app-profile"
environment:
PARAGON_BRAND_PACKAGE: '@edx/brand-edx.org@~2.0.0'
networks:
default:
aliases:
Expand All @@ -890,6 +894,8 @@ services:
service: microfrontend
working_dir: '/edx/app/frontend-app-authn'
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.frontend-app-authn"
environment:
PARAGON_BRAND_PACKAGE: '@edx/[email protected]'
networks:
default:
aliases:
Expand All @@ -905,6 +911,8 @@ services:
service: microfrontend
working_dir: '/edx/app/frontend-app-course-authoring'
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.frontend-app-course-authoring"
environment:
PARAGON_BRAND_PACKAGE: '@edx/[email protected]'
networks:
default:
aliases:
Expand Down Expand Up @@ -935,6 +943,8 @@ services:
service: microfrontend
working_dir: '/edx/app/frontend-app-ora-grading'
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.frontend-app-ora-grading"
environment:
PARAGON_BRAND_PACKAGE: '@edx/[email protected]'
networks:
default:
aliases:
Expand All @@ -950,6 +960,8 @@ services:
service: microfrontend
working_dir: '/edx/app/frontend-app-learner-dashboard'
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.frontend-app-learner-dashboard"
environment:
PARAGON_BRAND_PACKAGE: '@edx/[email protected]'
networks:
default:
aliases:
Expand All @@ -965,6 +977,8 @@ services:
service: microfrontend
working_dir: '/edx/app/frontend-app-learner-record'
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.frontend-app-learner-record"
environment:
PARAGON_BRAND_PACKAGE: '@edx/brand-edx.org@~2.0.0'
networks:
default:
aliases:
Expand All @@ -980,6 +994,8 @@ services:
service: microfrontend
working_dir: '/edx/app/frontend-app-learning'
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.frontend-app-learning"
environment:
PARAGON_BRAND_PACKAGE: '@edx/[email protected]'
networks:
default:
aliases:
Expand All @@ -995,6 +1011,8 @@ services:
service: microfrontend
working_dir: '/edx/app/frontend-app-library-authoring'
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.frontend-app-library-authoring"
environment:
PARAGON_BRAND_PACKAGE: '@edx/[email protected]'
networks:
default:
aliases:
Expand All @@ -1011,6 +1029,8 @@ services:
service: microfrontend
working_dir: '/edx/app/frontend-app-payment'
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.frontend-app-payment"
environment:
PARAGON_BRAND_PACKAGE: '@edx/brand-edx.org@^2.0.6'
networks:
default:
aliases:
Expand All @@ -1026,6 +1046,8 @@ services:
service: microfrontend
working_dir: '/edx/app/frontend-app-program-console'
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.frontend-app-program-console"
environment:
PARAGON_BRAND_PACKAGE: '@edx/[email protected]'
networks:
default:
aliases:
Expand All @@ -1042,6 +1064,8 @@ services:
service: microfrontend
working_dir: '/edx/app/frontend-app-publisher'
container_name: "edx.${COMPOSE_PROJECT_NAME:-devstack}.frontend-app-publisher"
environment:
PARAGON_BRAND_PACKAGE: '@edx/[email protected]'
networks:
default:
aliases:
Expand Down
13 changes: 12 additions & 1 deletion microfrontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,18 @@ services:
#
# Fail fast if package install fails to avoid mysterious
# errors later.
command: bash -c 'npm ci || exit 1; while true; do npm start; sleep 2; done'
command:
- bash
- -c
- |
npm ci || exit 1
if [ -n "$(printenv PARAGON_BRAND_PACKAGE)" ]; then
npx paragon install-theme "$(printenv PARAGON_BRAND_PACKAGE)" || exit 1
fi
while true; do
npm start
sleep 2
done
stdin_open: true
tty: true
image: node:18
Expand Down
3 changes: 3 additions & 0 deletions provision-lms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ done
# Fix missing vendor file by clearing the cache
# docker compose exec -T lms bash -e -c 'rm /edx/app/edxapp/edx-platform/.prereqs_cache/Node_prereqs.sha1'

# Set edX theme in LMS and CMS.
./provision-set-edx-theme.sh

# Create static assets for both LMS and CMS
for app in "${apps[@]}"; do
make "dev.static.$app"
Expand Down
47 changes: 47 additions & 0 deletions provision-set-edx-theme.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash

# This script sets up the edX theme in LMS and CMS.

REPO_URL="https://github.com/edx/edx-themes"
THEME_DIR="/edx/src/edx-themes/edx-platform"
DEVSTACK_FILE="../edx-platform/lms/envs/devstack.py"

# Clone the edx-themes repository into the src directory
cd ../src
if [ ! -d "edx-themes" ]; then
git clone "$REPO_URL"
else
echo "Directory 'edx-themes' already exists. Skipping clone."
fi
cd ../devstack

# Uncomment relevant lines in the devstack.py file
sed -i '' "s|^# from .common import _make_mako_template_dirs|from .common import _make_mako_template_dirs|" "$DEVSTACK_FILE"
sed -i '' "s|^# ENABLE_COMPREHENSIVE_THEMING = True|ENABLE_COMPREHENSIVE_THEMING = True|" "$DEVSTACK_FILE"
sed -i '' "s|^# COMPREHENSIVE_THEME_DIRS = \[|COMPREHENSIVE_THEME_DIRS = \[|" "$DEVSTACK_FILE"
sed -i '' "s|^# \"/edx/app/edxapp/edx-platform/themes/\"| \"/edx/app/edxapp/edx-platform/themes/\",|" "$DEVSTACK_FILE"
sed -i '' "/COMPREHENSIVE_THEME_DIRS = \[/a\\
\"$THEME_DIR\",
" "$DEVSTACK_FILE"
sed -i '' "s|^# \]|]|" "$DEVSTACK_FILE"
sed -i '' "s|^# TEMPLATES\[1\]\[\"DIRS\"\] = _make_mako_template_dirs|TEMPLATES[1][\"DIRS\"] = _make_mako_template_dirs|" "$DEVSTACK_FILE"
sed -i '' "s|^# derive_settings(__name__)|derive_settings(__name__)|" "$DEVSTACK_FILE"


# Add the theme directory to COMPREHENSIVE_THEME_DIRS if not already present
if ! grep -qF "$THEME_DIR" "$DEVSTACK_FILE"; then
sed -i '' "/COMPREHENSIVE_THEME_DIRS = \[/a\\
\"$THEME_DIR\",
" "$DEVSTACK_FILE"
fi

# Set the theme site-wide
SERVICE_NAME="mysql80"
DATABASE="edxapp"
THEME_NAME="edx.org-next"
SITE_ID=1

docker compose exec -T "$SERVICE_NAME" mysql -e "
USE $DATABASE;
INSERT INTO theming_sitetheme (theme_dir_name, site_id) VALUES ('$THEME_NAME', $SITE_ID);
"

0 comments on commit cdfa616

Please sign in to comment.