From ece708b32624d11ce74afc5af3a264415feed30b Mon Sep 17 00:00:00 2001 From: Chiruzzi Marco Date: Thu, 22 Feb 2024 17:29:23 +0100 Subject: [PATCH 1/2] Add themed brand and learning MFE submodules; Add tutor plugin for MFE theming local testing --- .gitmodules | 36 +++++++----- mfe/brand-openedx-themed | 1 + mfe/frontend-app-learning-themed | 1 + plugins/community-mfe.py | 10 +++- plugins/theming-mfe-local.py | 97 ++++++++++++++++++++++++++++++++ 5 files changed, 128 insertions(+), 17 deletions(-) create mode 160000 mfe/brand-openedx-themed create mode 160000 mfe/frontend-app-learning-themed create mode 100644 plugins/theming-mfe-local.py diff --git a/.gitmodules b/.gitmodules index a0cd2a11..0d384bcd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,35 +1,35 @@ [submodule "mfe/frontend-app-profile"] path = mfe/frontend-app-profile url = git@github.com:Abstract-Tech/community-theme-profile.git - branch = community-theme.palm + branch = community-theme.quince [submodule "mfe/frontend-app-learning"] path = mfe/frontend-app-learning url = git@github.com:Abstract-Tech/community-theme-learning.git - branch = community-theme.master + branch = community-theme.quince [submodule "mfe/frontend-app-course_about"] path = mfe/frontend-app-course_about url = git@github.com:Abstract-Tech/community-theme-course-about.git - branch = community-theme.palm + branch = community-theme.quince [submodule "mfe/frontend-app-gradebook"] path = mfe/frontend-app-gradebook url = git@github.com:Abstract-Tech/community-theme-gradebook.git - branch = community-theme.palm + branch = community-theme.quince [submodule "mfe/frontend-app-account"] path = mfe/frontend-app-account url = git@github.com:Abstract-Tech/community-theme-account.git - branch = community-theme.palm + branch = community-theme.quince [submodule "mfe/frontend-app-home"] path = mfe/frontend-app-home url = git@github.com:Abstract-Tech/community-theme-home.git - branch = community-theme.palm + branch = community-theme.quince [submodule "mfe/frontend-component-footer"] path = mfe/frontend-component-footer url = git@github.com:Abstract-Tech/community-theme-footer.git - branch = community-theme.palm + branch = community-theme.quince [submodule "mfe/frontend-component-header"] path = mfe/frontend-component-header url = git@github.com:Abstract-Tech/community-theme-header.git - branch = community-theme.palm + branch = community-theme.quince [submodule "mfe/brand-openedx"] path = mfe/brand-openedx url = git@github.com:Abstract-Tech/community-theme-brand.git @@ -37,22 +37,28 @@ [submodule "mfe/frontend-app-discussions"] path = mfe/frontend-app-discussions url = git@github.com:Abstract-Tech/community-theme-discussions.git - branch = community-theme.palm + branch = community-theme.quince [submodule "mfe/frontend-app-authn"] path = mfe/frontend-app-authn url = git@github.com:Abstract-Tech/community-theme-authn.git - branch = community-theme.palm + branch = community-theme.quince [submodule "mfe/frontend-app-course-authoring"] path = mfe/frontend-app-course-authoring url = git@github.com:Abstract-Tech/community-theme-course-authoring.git - branch = community-theme.palm + branch = community-theme.quince [submodule "mfe/frontend-app-communications"] path = mfe/frontend-app-communications url = git@github.com:Abstract-Tech/community-theme-communications.git - branch = community-theme.palm + branch = community-theme.quince [submodule "mfe/frontend-app-ora-grading"] path = mfe/frontend-app-ora-grading url = git@github.com:Abstract-Tech/community-theme-ora-grading.git - branch = community-theme.palm - - + branch = community-theme.quince +[submodule "mfe/frontend-app-learning-themed"] + path = mfe/frontend-app-learning-themed + url = git@github.com:Abstract-Tech/community-theme-learning-themed.git + branch = community-theme.quince +[submodule "mfe/brand-openedx-themed"] + path = mfe/brand-openedx-themed + url = git@github.com:Abstract-Tech/community-theme-brand-themed.git + branch = community-theme diff --git a/mfe/brand-openedx-themed b/mfe/brand-openedx-themed new file mode 160000 index 00000000..7b068c13 --- /dev/null +++ b/mfe/brand-openedx-themed @@ -0,0 +1 @@ +Subproject commit 7b068c1397f54bc5ad19334d899645795afb1bf0 diff --git a/mfe/frontend-app-learning-themed b/mfe/frontend-app-learning-themed new file mode 160000 index 00000000..c6d4bb3b --- /dev/null +++ b/mfe/frontend-app-learning-themed @@ -0,0 +1 @@ +Subproject commit c6d4bb3b455f0106111d1527df8736681890ca7a diff --git a/plugins/community-mfe.py b/plugins/community-mfe.py index 84c24034..782225d9 100644 --- a/plugins/community-mfe.py +++ b/plugins/community-mfe.py @@ -82,7 +82,7 @@ def mfe_forks(mfes): "name": "course_about", } # Note: The changes of the following might not take effect due to tutor order of loading plugins - # This to change it you might need to edit the upstream pplugin at: + # This to change it you might need to edit the upstream plugin at: # https://github.com/Abstract-Tech/openedx-tutor-plugins/blob/5556c1d5c55e1a0e95f36a9f0b89dbf21382f581/plugins/tutor-contrib-learner-dashboard-mfe/tutor_learner_dashboard_mfe/plugin.py#L20-L25 mfes["learner-dashboard"] = { "repository": "https://github.com/Abstract-Tech/community-theme-learner-dashboard.git", @@ -90,7 +90,13 @@ def mfe_forks(mfes): "refs": "https://api.github.com/repos/abstract-tech/community-theme-learner-dashboard/git/refs/heads", "port":1996, } - + mfes["learning-themed"] = { + "repository": "https://github.com/Abstract-Tech/community-theme-learning-themed", + "version": "community-theme.quince", + "refs": "https://api.github.com/repos/abstract-tech/community-theme-learning-themed/git/refs/heads", + "port": 2003, + "name": "learning-themed", + } return mfes diff --git a/plugins/theming-mfe-local.py b/plugins/theming-mfe-local.py new file mode 100644 index 00000000..9508cbda --- /dev/null +++ b/plugins/theming-mfe-local.py @@ -0,0 +1,97 @@ +from tutor import hooks + + +hooks.Filters.ENV_PATCHES.add_items( + [ + ( + "caddyfile", + """ +microsite.local.edly.io{$default_site_port} preview.microsite.local.edly.io{$default_site_port} { + @favicon_matcher { + path_regexp ^/favicon.ico$ + } + rewrite @favicon_matcher /theming/asset/images/favicon.ico + + # Limit profile image upload size + handle_path /api/profile_images/*/*/upload { + request_body { + max_size 1MB + } + } + + import proxy "lms:8000" + + route /courses/*/about { + reverse_proxy "mfe:8002" { + rewrite /course_about/{uri} + header_up X-Forwarded-Port 80 + } + } + + route /course_about/* { + reverse_proxy "mfe:8002" { + header_up X-Forwarded-Port 80 + } + } + route / { + reverse_proxy "mfe:8002" { + rewrite /home/{uri} + header_up X-Forwarded-Port 80 + } + } + + route /home/* { + reverse_proxy "mfe:8002" { + header_up X-Forwarded-Port 80 + } + } + header * { + Content-Security-Policy "frame-ancestors microsite.local.edly.io *.microsite.local.edly.io;" + } + + handle_path /* { + request_body { + max_size 4MB + } + } +} + +apps.microsite.local.edly.io{$default_site_port} { + respond / 204 + request_body { + max_size 2MB + } + import proxy "mfe:8002" +} + """, + ), + ( + "openedx-lms-production-settings", + """ +LOGIN_REDIRECT_WHITELIST.append("apps.microsite.local.edly.io") +CORS_ORIGIN_WHITELIST.append("http://apps.microsite.local.edly.io") +CSRF_TRUSTED_ORIGINS.append("apps.microsite.local.edly.io") + +LOGIN_REDIRECT_WHITELIST.append("microsite.local.edly.io") +CORS_ORIGIN_WHITELIST.append("http://microsite.local.edly.io") +CSRF_TRUSTED_ORIGINS.append("microsite.local.edly.io") + +SESSION_COOKIE_DOMAIN = "edly.io" +ALLOWED_HOSTS.append("microsite.local.edly.io") + """, + ), + ( + "mfe-dockerfile-post-npm-install-learning-themed", + """ +ADD https://api.github.com/repos/abstract-tech/community-theme-brand-themed/git/refs/heads/community-theme /tmp/gitref-brand +RUN npm install '@edx/brand@git+https://git@github.com/abstract-tech/community-theme-brand-themed.git#community-theme' --registry=$NPM_REGISTRY + """, + ), + ( + "local-docker-compose-caddy-aliases", + """ +- microsite.local.edly.io + """, + ), + ] +) From 6ccd39900849ff5758815b7f69b00e77c84db727 Mon Sep 17 00:00:00 2001 From: Chiruzzi Marco Date: Thu, 22 Feb 2024 17:48:32 +0100 Subject: [PATCH 2/2] Run with a custom edx-platform fork --- config.yml | 2 ++ plugins/theming-mfe-local.py | 23 +++++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/config.yml b/config.yml index 4b3ca9ae..772f342b 100644 --- a/config.yml +++ b/config.yml @@ -7,6 +7,8 @@ CMS_OAUTH2_SECRET: 2icx54cdu9SJ77KMlZgHTWcm CONTACT_EMAIL: noreply@community.abzt.de DOCKER_IMAGE_CADDY: docker.io/library/caddy:2.7.5 DOCKER_IMAGE_OPENEDX: docker.io/abstract2tech/community-theme-openedx:17.0.0 +EDX_PLATFORM_REPOSITORY: https://github.com/Abstract-Tech/edx-platform.git +EDX_PLATFORM_VERSION: community-theme ENABLE_HTTPS: false ENABLE_WEB_PROXY: true ID: jxBish2U54zbLTe82GMVvnyO diff --git a/plugins/theming-mfe-local.py b/plugins/theming-mfe-local.py index 9508cbda..1e637fe4 100644 --- a/plugins/theming-mfe-local.py +++ b/plugins/theming-mfe-local.py @@ -6,7 +6,7 @@ ( "caddyfile", """ -microsite.local.edly.io{$default_site_port} preview.microsite.local.edly.io{$default_site_port} { +microsite.{{ MFE_HOST }}{$default_site_port} preview.microsite.{{ MFE_HOST }}{$default_site_port} { @favicon_matcher { path_regexp ^/favicon.ico$ } @@ -46,7 +46,7 @@ } } header * { - Content-Security-Policy "frame-ancestors microsite.local.edly.io *.microsite.local.edly.io;" + Content-Security-Policy "frame-ancestors microsite.{{ MFE_HOST }} *.microsite.{{ MFE_HOST }};" } handle_path /* { @@ -56,7 +56,7 @@ } } -apps.microsite.local.edly.io{$default_site_port} { +apps.microsite.{{ MFE_HOST }}{$default_site_port} { respond / 204 request_body { max_size 2MB @@ -68,16 +68,15 @@ ( "openedx-lms-production-settings", """ -LOGIN_REDIRECT_WHITELIST.append("apps.microsite.local.edly.io") -CORS_ORIGIN_WHITELIST.append("http://apps.microsite.local.edly.io") -CSRF_TRUSTED_ORIGINS.append("apps.microsite.local.edly.io") +LOGIN_REDIRECT_WHITELIST.append("apps.microsite.{{ LMS_HOST }}") +CORS_ORIGIN_WHITELIST.append("http://apps.microsite.{{ LMS_HOST }}") +CSRF_TRUSTED_ORIGINS.append("apps.microsite.{{ LMS_HOST }}") -LOGIN_REDIRECT_WHITELIST.append("microsite.local.edly.io") -CORS_ORIGIN_WHITELIST.append("http://microsite.local.edly.io") -CSRF_TRUSTED_ORIGINS.append("microsite.local.edly.io") +LOGIN_REDIRECT_WHITELIST.append("microsite.{{ LMS_HOST }}") +CORS_ORIGIN_WHITELIST.append("http://microsite.{{ LMS_HOST }}") +CSRF_TRUSTED_ORIGINS.append("microsite.{{ LMS_HOST }}") -SESSION_COOKIE_DOMAIN = "edly.io" -ALLOWED_HOSTS.append("microsite.local.edly.io") +ALLOWED_HOSTS.append("microsite.{{ LMS_HOST }}") """, ), ( @@ -90,7 +89,7 @@ ( "local-docker-compose-caddy-aliases", """ -- microsite.local.edly.io +- microsite.{{ LMS_HOST }} """, ), ]