From 4b1b2dd5a331f1d1e1f1a792fa0a00176e4adf3b Mon Sep 17 00:00:00 2001 From: Kyle McCormick Date: Thu, 18 May 2023 14:46:12 -0400 Subject: [PATCH 1/6] refactor: define resource paths (not contents) on XModule classes For the XBlocks types that use legacy XModule-style assets, this is small refactor that brings them a bit closer to being like XBlocks. Given class attributes on those block types in the form: SomeXModuleLikeBlock.(studio|preview)_view_(js|css)['(js|scss|css|xmodule_js)'] we make it so their value is the *path to the resource* rather than *the actual content of the resource*. This will make future refactorings simpler. Part of: https://github.com/openedx/edx-platform/issues/31624 --- xmodule/annotatable_block.py | 20 ++++++++++---------- xmodule/capa_block.py | 24 ++++++++++++------------ xmodule/conditional_block.py | 14 +++++++------- xmodule/html_block.py | 24 ++++++++++++------------ xmodule/library_content_block.py | 8 ++++---- xmodule/lti_block.py | 12 ++++++------ xmodule/poll_block.py | 14 +++++++------- xmodule/seq_block.py | 10 +++++----- xmodule/split_test_block.py | 8 ++++---- xmodule/static_content.py | 28 +++++++++++++++++----------- xmodule/template_block.py | 10 +++++----- xmodule/word_cloud_block.py | 12 ++++++------ 12 files changed, 95 insertions(+), 89 deletions(-) diff --git a/xmodule/annotatable_block.py b/xmodule/annotatable_block.py index 774ad900979b..9ec6bf21dace 100644 --- a/xmodule/annotatable_block.py +++ b/xmodule/annotatable_block.py @@ -4,7 +4,7 @@ import textwrap from lxml import etree -from pkg_resources import resource_string +from pkg_resources import resource_filename from web_fragments.fragment import Fragment from xblock.core import XBlock from xblock.fields import Scope, String @@ -75,28 +75,28 @@ class AnnotatableBlock( preview_view_js = { 'js': [ - resource_string(__name__, 'js/src/html/display.js'), - resource_string(__name__, 'js/src/annotatable/display.js'), - resource_string(__name__, 'js/src/javascript_loader.js'), - resource_string(__name__, 'js/src/collapsible.js'), + resource_filename(__name__, 'js/src/html/display.js'), + resource_filename(__name__, 'js/src/annotatable/display.js'), + resource_filename(__name__, 'js/src/javascript_loader.js'), + resource_filename(__name__, 'js/src/collapsible.js'), ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } preview_view_css = { 'scss': [ - resource_string(__name__, 'css/annotatable/display.scss'), + resource_filename(__name__, 'css/annotatable/display.scss'), ], } studio_view_js = { 'js': [ - resource_string(__name__, 'js/src/raw/edit/xml.js'), + resource_filename(__name__, 'js/src/raw/edit/xml.js'), ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } studio_view_css = { 'scss': [ - resource_string(__name__, 'css/codemirror/codemirror.scss'), + resource_filename(__name__, 'css/codemirror/codemirror.scss'), ], } studio_js_module_name = "XMLEditingDescriptor" diff --git a/xmodule/capa_block.py b/xmodule/capa_block.py index 3c02053c0eb0..2b2ec8082534 100644 --- a/xmodule/capa_block.py +++ b/xmodule/capa_block.py @@ -19,7 +19,7 @@ from django.utils.encoding import smart_str from django.utils.functional import cached_property from lxml import etree -from pkg_resources import resource_string +from pkg_resources import resource_filename from pytz import utc from web_fragments.fragment import Fragment from xblock.core import XBlock @@ -168,32 +168,32 @@ class ProblemBlock( preview_view_js = { 'js': [ - resource_string(__name__, 'js/src/javascript_loader.js'), - resource_string(__name__, 'js/src/capa/display.js'), - resource_string(__name__, 'js/src/collapsible.js'), - resource_string(__name__, 'js/src/capa/imageinput.js'), - resource_string(__name__, 'js/src/capa/schematic.js'), + resource_filename(__name__, 'js/src/javascript_loader.js'), + resource_filename(__name__, 'js/src/capa/display.js'), + resource_filename(__name__, 'js/src/collapsible.js'), + resource_filename(__name__, 'js/src/capa/imageinput.js'), + resource_filename(__name__, 'js/src/capa/schematic.js'), ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js') + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js') } preview_view_css = { 'scss': [ - resource_string(__name__, 'css/capa/display.scss'), + resource_filename(__name__, 'css/capa/display.scss'), ], } studio_view_js = { 'js': [ - resource_string(__name__, 'js/src/problem/edit.js'), + resource_filename(__name__, 'js/src/problem/edit.js'), ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } studio_view_css = { 'scss': [ - resource_string(__name__, 'css/editor/edit.scss'), - resource_string(__name__, 'css/problem/edit.scss'), + resource_filename(__name__, 'css/editor/edit.scss'), + resource_filename(__name__, 'css/problem/edit.scss'), ] } diff --git a/xmodule/conditional_block.py b/xmodule/conditional_block.py index 91e7af2c156e..7fe545d1a307 100644 --- a/xmodule/conditional_block.py +++ b/xmodule/conditional_block.py @@ -9,7 +9,7 @@ from lazy import lazy from lxml import etree from opaque_keys.edx.locator import BlockUsageLocator -from pkg_resources import resource_string +from pkg_resources import resource_filename from web_fragments.fragment import Fragment from xblock.core import XBlock from xblock.fields import ReferenceList, Scope, String @@ -148,11 +148,11 @@ class ConditionalBlock( preview_view_js = { 'js': [ - resource_string(__name__, 'js/src/conditional/display.js'), - resource_string(__name__, 'js/src/javascript_loader.js'), - resource_string(__name__, 'js/src/collapsible.js'), + resource_filename(__name__, 'js/src/conditional/display.js'), + resource_filename(__name__, 'js/src/javascript_loader.js'), + resource_filename(__name__, 'js/src/collapsible.js'), ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } preview_view_css = { 'scss': [], @@ -161,8 +161,8 @@ class ConditionalBlock( mako_template = 'widgets/metadata-edit.html' studio_js_module_name = 'SequenceDescriptor' studio_view_js = { - 'js': [resource_string(__name__, 'js/src/sequence/edit.js')], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), + 'js': [resource_filename(__name__, 'js/src/sequence/edit.js')], + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } studio_view_css = { 'scss': [], diff --git a/xmodule/html_block.py b/xmodule/html_block.py index ed5d84e395c0..48786c2c5611 100644 --- a/xmodule/html_block.py +++ b/xmodule/html_block.py @@ -8,7 +8,7 @@ import textwrap from datetime import datetime -from pkg_resources import resource_string +from pkg_resources import resource_filename from django.conf import settings from fs.errors import ResourceNotFound @@ -144,15 +144,15 @@ def studio_view(self, _context): preview_view_js = { 'js': [ - resource_string(__name__, 'js/src/html/display.js'), - resource_string(__name__, 'js/src/javascript_loader.js'), - resource_string(__name__, 'js/src/collapsible.js'), - resource_string(__name__, 'js/src/html/imageModal.js'), - resource_string(__name__, 'js/common_static/js/vendor/draggabilly.js'), + resource_filename(__name__, 'js/src/html/display.js'), + resource_filename(__name__, 'js/src/javascript_loader.js'), + resource_filename(__name__, 'js/src/collapsible.js'), + resource_filename(__name__, 'js/src/html/imageModal.js'), + resource_filename(__name__, 'js/common_static/js/vendor/draggabilly.js'), ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } - preview_view_css = {'scss': [resource_string(__name__, 'css/html/display.scss')]} + preview_view_css = {'scss': [resource_filename(__name__, 'css/html/display.scss')]} uses_xmodule_styles_setup = True @@ -164,14 +164,14 @@ def studio_view(self, _context): studio_view_js = { 'js': [ - resource_string(__name__, 'js/src/html/edit.js') + resource_filename(__name__, 'js/src/html/edit.js') ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } studio_view_css = { 'scss': [ - resource_string(__name__, 'css/editor/edit.scss'), - resource_string(__name__, 'css/html/edit.scss') + resource_filename(__name__, 'css/editor/edit.scss'), + resource_filename(__name__, 'css/html/edit.scss') ] } diff --git a/xmodule/library_content_block.py b/xmodule/library_content_block.py index 04abe5de6eb3..7193247f58d5 100644 --- a/xmodule/library_content_block.py +++ b/xmodule/library_content_block.py @@ -17,7 +17,7 @@ from lxml import etree from lxml.etree import XMLSyntaxError from opaque_keys.edx.locator import LibraryLocator -from pkg_resources import resource_string +from pkg_resources import resource_filename from web_fragments.fragment import Fragment from webob import Response from xblock.completable import XBlockCompletionMode @@ -97,7 +97,7 @@ class LibraryContentBlock( preview_view_js = { 'js': [], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } preview_view_css = { 'scss': [], @@ -107,9 +107,9 @@ class LibraryContentBlock( studio_js_module_name = "VerticalDescriptor" studio_view_js = { 'js': [ - resource_string(__name__, 'js/src/vertical/edit.js'), + resource_filename(__name__, 'js/src/vertical/edit.js'), ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } studio_view_css = { 'scss': [], diff --git a/xmodule/lti_block.py b/xmodule/lti_block.py index 8bf60f1c4486..76c03d73a671 100644 --- a/xmodule/lti_block.py +++ b/xmodule/lti_block.py @@ -68,7 +68,7 @@ from django.conf import settings from lxml import etree from oauthlib.oauth1.rfc5849 import signature -from pkg_resources import resource_string +from pkg_resources import resource_filename from pytz import UTC from webob import Response from web_fragments.fragment import Fragment @@ -374,13 +374,13 @@ class LTIBlock( preview_view_js = { 'js': [ - resource_string(__name__, 'js/src/lti/lti.js') + resource_filename(__name__, 'js/src/lti/lti.js') ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } preview_view_css = { 'scss': [ - resource_string(__name__, 'css/lti/lti.scss') + resource_filename(__name__, 'css/lti/lti.scss') ], } @@ -389,9 +389,9 @@ class LTIBlock( studio_js_module_name = 'MetadataOnlyEditingDescriptor' studio_view_js = { 'js': [ - resource_string(__name__, 'js/src/raw/edit/metadata-only.js') + resource_filename(__name__, 'js/src/raw/edit/metadata-only.js') ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } studio_view_css = { 'scss': [], diff --git a/xmodule/poll_block.py b/xmodule/poll_block.py index b29ed710e922..0ce6d38e1e51 100644 --- a/xmodule/poll_block.py +++ b/xmodule/poll_block.py @@ -13,7 +13,7 @@ from collections import OrderedDict from copy import deepcopy -from pkg_resources import resource_string +from pkg_resources import resource_filename from web_fragments.fragment import Fragment from lxml import etree @@ -86,15 +86,15 @@ class PollBlock( preview_view_js = { 'js': [ - resource_string(__name__, 'js/src/javascript_loader.js'), - resource_string(__name__, 'js/src/poll/poll.js'), - resource_string(__name__, 'js/src/poll/poll_main.js') + resource_filename(__name__, 'js/src/javascript_loader.js'), + resource_filename(__name__, 'js/src/poll/poll.js'), + resource_filename(__name__, 'js/src/poll/poll_main.js') ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } preview_view_css = { 'scss': [ - resource_string(__name__, 'css/poll/display.scss') + resource_filename(__name__, 'css/poll/display.scss') ], } @@ -102,7 +102,7 @@ class PollBlock( # the static_content command happy. studio_view_js = { 'js': [], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js') + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js') } studio_view_css = { diff --git a/xmodule/seq_block.py b/xmodule/seq_block.py index 0d8be411fd58..250a69d83b6a 100644 --- a/xmodule/seq_block.py +++ b/xmodule/seq_block.py @@ -14,7 +14,7 @@ from lxml import etree from opaque_keys.edx.keys import UsageKey -from pkg_resources import resource_string +from pkg_resources import resource_filename from pytz import UTC from web_fragments.fragment import Fragment from xblock.completable import XBlockCompletionMode @@ -273,14 +273,14 @@ class SequenceBlock( preview_view_js = { 'js': [ - resource_string(__name__, 'js/src/sequence/display.js'), + resource_filename(__name__, 'js/src/sequence/display.js'), ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js') + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js') } preview_view_css = { 'scss': [ - resource_string(__name__, 'css/sequence/display.scss'), + resource_filename(__name__, 'css/sequence/display.scss'), ], } @@ -288,7 +288,7 @@ class SequenceBlock( # the static_content command happy. studio_view_js = { 'js': [], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js') + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js') } studio_view_css = { diff --git a/xmodule/split_test_block.py b/xmodule/split_test_block.py index c45848800fb3..f9f8eea812f1 100644 --- a/xmodule/split_test_block.py +++ b/xmodule/split_test_block.py @@ -12,7 +12,7 @@ from django.utils.functional import cached_property from lxml import etree -from pkg_resources import resource_string +from pkg_resources import resource_filename from web_fragments.fragment import Fragment from webob import Response from xblock.core import XBlock @@ -160,7 +160,7 @@ class SplitTestBlock( # lint-amnesty, pylint: disable=abstract-method preview_view_js = { 'js': [], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } preview_view_css = { 'scss': [], @@ -169,8 +169,8 @@ class SplitTestBlock( # lint-amnesty, pylint: disable=abstract-method mako_template = "widgets/metadata-only-edit.html" studio_js_module_name = 'SequenceDescriptor' studio_view_js = { - 'js': [resource_string(__name__, 'js/src/sequence/edit.js')], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), + 'js': [resource_filename(__name__, 'js/src/sequence/edit.js')], + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } studio_view_css = { 'scss': [], diff --git a/xmodule/static_content.py b/xmodule/static_content.py index 2447347da90f..58ffcb2de12b 100755 --- a/xmodule/static_content.py +++ b/xmodule/static_content.py @@ -13,7 +13,7 @@ import sys import textwrap from collections import defaultdict -from pkg_resources import resource_string +from pkg_resources import resource_filename import django from docopt import docopt @@ -43,27 +43,27 @@ class VideoBlock(HTMLSnippet): # lint-amnesty, pylint: disable=abstract-method preview_view_js = { 'js': [ - resource_string(__name__, 'js/src/video/10_main.js'), + resource_filename(__name__, 'js/src/video/10_main.js'), ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js') + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js') } preview_view_css = { 'scss': [ - resource_string(__name__, 'css/video/display.scss'), - resource_string(__name__, 'css/video/accessible_menu.scss'), + resource_filename(__name__, 'css/video/display.scss'), + resource_filename(__name__, 'css/video/accessible_menu.scss'), ], } studio_view_js = { 'js': [ - resource_string(__name__, 'js/src/tabs/tabs-aggregator.js'), + resource_filename(__name__, 'js/src/tabs/tabs-aggregator.js'), ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } studio_view_css = { 'scss': [ - resource_string(__name__, 'css/tabs/tabs.scss'), + resource_filename(__name__, 'css/tabs/tabs.scss'), ] } @@ -132,7 +132,9 @@ def _write_styles(selector, output_root, classes, css_attribute, suffix): for class_ in classes: class_css = getattr(class_, css_attribute)() for filetype in ('sass', 'scss', 'css'): - for idx, fragment in enumerate(class_css.get(filetype, [])): + for idx, fragment_path in enumerate(class_css.get(filetype, [])): + with open(fragment_path, 'rb') as fragment_file: + fragment = fragment_file.read() css_fragments[idx, filetype, fragment].add(class_.__name__) css_imports = defaultdict(set) for (idx, filetype, fragment), classes in sorted(css_fragments.items()): # lint-amnesty, pylint: disable=redefined-argument-from-local @@ -177,10 +179,14 @@ def _write_js(output_root, classes, js_attribute): fragment_owners = defaultdict(list) for class_ in classes: module_js = getattr(class_, js_attribute)() + with open(module_js.get('xmodule_js'), 'rb') as xmodule_js_file: + xmodule_js_fragment = xmodule_js_file.read() # It will enforce 000 prefix for xmodule.js. - fragment_owners[(0, 'js', module_js.get('xmodule_js'))].append(getattr(class_, js_attribute + '_bundle_name')()) + fragment_owners[(0, 'js', xmodule_js_fragment)].append(getattr(class_, js_attribute + '_bundle_name')()) for filetype in ('coffee', 'js'): - for idx, fragment in enumerate(module_js.get(filetype, [])): + for idx, fragment_path in enumerate(module_js.get(filetype, [])): + with open(fragment_path, 'rb') as fragment_file: + fragment = fragment_file.read() fragment_owners[(idx + 1, filetype, fragment)].append(getattr(class_, js_attribute + '_bundle_name')()) for (idx, filetype, fragment), owners in sorted(fragment_owners.items()): diff --git a/xmodule/template_block.py b/xmodule/template_block.py index 70bafca7753e..71b2c21f1441 100644 --- a/xmodule/template_block.py +++ b/xmodule/template_block.py @@ -6,7 +6,7 @@ from xblock.core import XBlock from lxml import etree -from pkg_resources import resource_string +from pkg_resources import resource_filename from web_fragments.fragment import Fragment from xmodule.editing_block import EditingMixin from xmodule.raw_block import RawMixin @@ -67,17 +67,17 @@ class CustomTagBlock(CustomTagTemplateBlock): # pylint: disable=abstract-method preview_view_js = { 'js': [], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } preview_view_css = { 'scss': [], } studio_view_js = { - 'js': [resource_string(__name__, 'js/src/raw/edit/xml.js')], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), + 'js': [resource_filename(__name__, 'js/src/raw/edit/xml.js')], + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } studio_view_css = { - 'scss': [resource_string(__name__, 'css/codemirror/codemirror.scss')], + 'scss': [resource_filename(__name__, 'css/codemirror/codemirror.scss')], } def studio_view(self, _context): diff --git a/xmodule/word_cloud_block.py b/xmodule/word_cloud_block.py index 2e7fadd0a2be..d7d35dedc5f3 100644 --- a/xmodule/word_cloud_block.py +++ b/xmodule/word_cloud_block.py @@ -10,7 +10,7 @@ import json import logging -from pkg_resources import resource_string +from pkg_resources import resource_filename from web_fragments.fragment import Fragment from xblock.core import XBlock @@ -114,21 +114,21 @@ class WordCloudBlock( # pylint: disable=abstract-method preview_view_js = { 'js': [ - resource_string(__name__, 'assets/word_cloud/src/js/word_cloud.js'), + resource_filename(__name__, 'assets/word_cloud/src/js/word_cloud.js'), ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } preview_view_css = { 'scss': [ - resource_string(__name__, 'css/word_cloud/display.scss'), + resource_filename(__name__, 'css/word_cloud/display.scss'), ], } studio_view_js = { 'js': [ - resource_string(__name__, 'js/src/raw/edit/metadata-only.js'), + resource_filename(__name__, 'js/src/raw/edit/metadata-only.js'), ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } studio_view_css = { 'scss': [], From 04d503ef6aa18c698fc50bf765fb5ae368ea8f4b Mon Sep 17 00:00:00 2001 From: Kyle McCormick Date: Thu, 18 May 2023 16:47:55 -0400 Subject: [PATCH 2/6] build: stop prefixing copied XModule SCSS with indexes The `xmodule_assets` command copies SCSS files from xmodule/css to common/static/xmodule/{modules|descriptors}/scss. It renames the files to the format: _{INDEX}-{HASH}.scss where an XModule's first SCSS resource will have INDEX==0, the next will have INDEX==1, ...and that's it because no XModule has more than two SCSS resources. The output looks like this: common/static/xmodule/descriptors/scss: _000-808fcbb4c5109c5156ae3c0c9729c8be.scss _000-9bdcda00f046f78be79aca7791e1d4fb.scss _000-d41921b4c5d45188759ef3d04fd9a78a.scss _001-901b985e5ea2dea2a89cce747cf4307d.scss _001-a10fc3e0fd6aca63426a89e75fe69c31.scss common/static/xmodule/modules/scss: _000-1ad2f05db822d3176affd203d70319c0.scss _000-1dc4276d3849a14ea538286e97740c14.scss _000-29baf1ef1af89b1051362f51124abd01.scss _000-6bf8c2340b013d835b25df13e03b8d33.scss _000-8b6bb50b058d34efefa40107307a32c6.scss _000-958d6ef6baa09be94bccaf488861c8e5.scss _000-a3c2cdf2141d24a76be9afa56f237c29.scss _000-b80300e1a5f290f6a850e35874068427.scss _001-482ebc752ab6e41946651ceb0f3e7f55.scss These indexes serve no purpose. Reading the comments and git-blame in xmodule/static_content.py, one can glean that they indexes might have been intended to enforce dependency relationships between the assets, but this is unnecessary, because the ordering of the copied SCSS is *already preserved* by the order which they're included into the {BLOCK_NAME}{Studio|Preivew}.{HASH}.scss SCSS entrypoint files. I have to assume that this is an unnecessary relic from the timebefore the XModule system was reduced to a legacy corner of the XBlock framework. So, we remove the indexes, which lets us simplify the logic of xmodule/static_content.py. This is a minor refactoring, but it'll make it easier for the next steps on our way to deleting xmodule/static_content.py entirely. The new output looks like this: common/static/xmodule/descriptors/scss: _808fcbb4c5109c5156ae3c0c9729c8be.scss _901b985e5ea2dea2a89cce747cf4307d.scss _9bdcda00f046f78be79aca7791e1d4fb.scss _a10fc3e0fd6aca63426a89e75fe69c31.scss _d41921b4c5d45188759ef3d04fd9a78a.scss common/static/xmodule/modules/scss: _1ad2f05db822d3176affd203d70319c0.scss _1dc4276d3849a14ea538286e97740c14.scss _29baf1ef1af89b1051362f51124abd01.scss _482ebc752ab6e41946651ceb0f3e7f55.scss _6bf8c2340b013d835b25df13e03b8d33.scss _8b6bb50b058d34efefa40107307a32c6.scss _958d6ef6baa09be94bccaf488861c8e5.scss _a3c2cdf2141d24a76be9afa56f237c29.scss _b80300e1a5f290f6a850e35874068427.scss Part of: https://github.com/openedx/edx-platform/issues/31624 --- xmodule/static_content.py | 39 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/xmodule/static_content.py b/xmodule/static_content.py index 58ffcb2de12b..585f79cd206c 100755 --- a/xmodule/static_content.py +++ b/xmodule/static_content.py @@ -123,44 +123,33 @@ def _ensure_dir(directory): def _write_styles(selector, output_root, classes, css_attribute, suffix): """ Write the css fragments from all XModules in `classes` - into `output_root` as individual files, hashed by the contents to remove - duplicates + into `output_root` as individual files """ contents = {} - css_fragments = defaultdict(set) for class_ in classes: class_css = getattr(class_, css_attribute)() - for filetype in ('sass', 'scss', 'css'): - for idx, fragment_path in enumerate(class_css.get(filetype, [])): - with open(fragment_path, 'rb') as fragment_file: - fragment = fragment_file.read() - css_fragments[idx, filetype, fragment].add(class_.__name__) - css_imports = defaultdict(set) - for (idx, filetype, fragment), classes in sorted(css_fragments.items()): # lint-amnesty, pylint: disable=redefined-argument-from-local - fragment_name = "{idx:0=3d}-{hash}.{type}".format( - idx=idx, - hash=hashlib.md5(fragment).hexdigest(), - type=filetype) - # Prepend _ so that sass just includes the files into a single file - filename = '_' + fragment_name - contents[filename] = fragment + fragment_names = [] + for fragment_path in class_css.get('scss', []): + with open(fragment_path, 'rb') as fragment_file: + fragment = fragment_file.read() + fragment_name = "{hash}.{type}".format( + hash=hashlib.md5(fragment).hexdigest(), + type='scss') + # Prepend _ so that sass just includes the files into a single file + filename = '_' + fragment_name + contents[filename] = fragment + fragment_names.append(fragment_name) - for class_ in classes: - css_imports[class_].add(fragment_name) - - for class_, fragment_names in sorted(css_imports.items()): module_styles_lines = [] - - fragment_names = sorted(fragment_names) - module_styles_lines.append("""{selector}.xmodule_{class_} {{""".format( + module_styles_lines.append("""{selector}.xmodule_{class_.__name__} {{""".format( class_=class_, selector=selector )) module_styles_lines.extend(f' @import "{name}";' for name in fragment_names) module_styles_lines.append('}') file_hash = hashlib.md5("".join(fragment_names).encode('ascii')).hexdigest() - contents[f"{class_}{suffix}.{file_hash}.scss"] = '\n'.join(module_styles_lines) + contents[f"{class_.__name__}{suffix}.{file_hash}.scss"] = '\n'.join(module_styles_lines) _write_files(output_root, contents) From 97465e338b225c6590ad94474c57896023b8c44b Mon Sep 17 00:00:00 2001 From: Kyle McCormick Date: Thu, 18 May 2023 16:56:52 -0400 Subject: [PATCH 3/6] build: stop suffixing XModule SCSS with hashes Similar to https://github.com/openedx/edx-platform/pull/32287, this change removes another unnecessary step from the `xmodule_assets` script. The script, which generates XModule SCSS "entrypoint" files (synthesizing one or more "source" SCSS resources), was appending MD5 hashes to each SCSS entrypoint filename: common/static/xmodule/descriptors/scss: AboutBlockStudio.768623f4d8d73dfb637fc94583adb990.scss AnnotatableBlockStudio.be69909d83985d31e206fad272906958.scss ConditionalBlockStudio.d41d8cd98f00b204e9800998ecf8427e.scss CourseInfoBlockStudio.768623f4d8d73dfb637fc94583adb990.scss CustomTagBlockStudio.be69909d83985d31e206fad272906958.scss HtmlBlockStudio.768623f4d8d73dfb637fc94583adb990.scss LibraryContentBlockStudio.d41d8cd98f00b204e9800998ecf8427e.scss LTIBlockStudio.d41d8cd98f00b204e9800998ecf8427e.scss PollBlockStudio.d41d8cd98f00b204e9800998ecf8427e.scss ProblemBlockStudio.5893b30426f88e14712556c6c4342f23.scss SequenceBlockStudio.d41d8cd98f00b204e9800998ecf8427e.scss SplitTestBlockStudio.d41d8cd98f00b204e9800998ecf8427e.scss StaticTabBlockStudio.768623f4d8d73dfb637fc94583adb990.scss VideoBlockStudio.e4a6920a875dfb91eb65ee7e6dad7e2e.scss WordCloudBlockStudio.d41d8cd98f00b204e9800998ecf8427e.scss common/static/xmodule/modules/scss: AboutBlockPreview.05a6cbd5c10100a245fa2cbf151b9770.scss AnnotatableBlockPreview.7e95b106aa0a61824f4290da1374960d.scss ConditionalBlockPreview.d41d8cd98f00b204e9800998ecf8427e.scss CourseInfoBlockPreview.05a6cbd5c10100a245fa2cbf151b9770.scss CustomTagBlockPreview.d41d8cd98f00b204e9800998ecf8427e.scss HtmlBlockPreview.05a6cbd5c10100a245fa2cbf151b9770.scss LibraryContentBlockPreview.d41d8cd98f00b204e9800998ecf8427e.scss LTIBlockPreview.a763928b2c415251720f8634b8daee59.scss PollBlockPreview.39730e54c1eebbafd18a82fbb09c1e37.scss ProblemBlockPreview.70b905ac161108a0a03c639232450aaa.scss SequenceBlockPreview.e2336fa64ba495fa7c0f4f838d20ad8c.scss SplitTestBlockPreview.d41d8cd98f00b204e9800998ecf8427e.scss StaticTabBlockPreview.05a6cbd5c10100a245fa2cbf151b9770.scss VideoBlockPreview.b2de5e1c4da8cba16ce1c4bdeab50f9e.scss WordCloudBlockPreview.7b899a56a70d29c58cf14b7e1888a0ec.scss It's unclear why these MD5 hashes needed to be appended. A comment in xmodule/static_content.py hints that it might have something to do with de-duplication, but that doesn't make any sense, because each XModule has exactly two SCSS entrypoint files (one for studio_view and one for other student/author_views) and none of those entrypoint files can possibly be shared between XModules. Soon, as part of deleting the `xmodule_assets` script, we would like to just check these SCSS files into version control rather than generating them. In order to do that, we will need to drop the hashes. So, in the interest of isolating changes in hard-to-test subsystems, this change simply drops the MD5 hashes from the generated SCSS filenames. The new output looks like this: common/static/xmodule/descriptors: AboutBlockStudio.scss AnnotatableBlockStudio.scss ConditionalBlockStudio.scss CourseInfoBlockStudio.scss CustomTagBlockStudio.scss HtmlBlockStudio.scss LibraryContentBlockStudio.scss LTIBlockStudio.scss PollBlockStudio.scss ProblemBlockStudio.scss SequenceBlockStudio.scss SplitTestBlockStudio.scss StaticTabBlockStudio.scss VideoBlockStudio.scss WordCloudBlockStudio.scss common/static/xmodule/modules: AboutBlockPreview.scss AnnotatableBlockPreview.scss ConditionalBlockPreview.scss CourseInfoBlockPreview.scss CustomTagBlockPreview.scss HtmlBlockPreview.scss LibraryContentBlockPreview.scss LTIBlockPreview.scss PollBlockPreview.scss ProblemBlockPreview.scss SequenceBlockPreview.scss SplitTestBlockPreview.scss StaticTabBlockPreview.scss VideoBlockPreview.scss WordCloudBlockPreview.scss Part of: https://github.com/openedx/edx-platform/issues/31624 --- xmodule/static_content.py | 3 +-- xmodule/util/xmodule_django.py | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/xmodule/static_content.py b/xmodule/static_content.py index 585f79cd206c..e93499b702e1 100755 --- a/xmodule/static_content.py +++ b/xmodule/static_content.py @@ -147,9 +147,8 @@ def _write_styles(selector, output_root, classes, css_attribute, suffix): )) module_styles_lines.extend(f' @import "{name}";' for name in fragment_names) module_styles_lines.append('}') - file_hash = hashlib.md5("".join(fragment_names).encode('ascii')).hexdigest() - contents[f"{class_.__name__}{suffix}.{file_hash}.scss"] = '\n'.join(module_styles_lines) + contents[f"{class_.__name__}{suffix}.scss"] = '\n'.join(module_styles_lines) _write_files(output_root, contents) diff --git a/xmodule/util/xmodule_django.py b/xmodule/util/xmodule_django.py index 248e10bf981a..1d9a858ea495 100644 --- a/xmodule/util/xmodule_django.py +++ b/xmodule/util/xmodule_django.py @@ -61,9 +61,9 @@ def load_assets(self): 'path': '/openedx/edx-platform/common/static/bundles/AnnotatableBlockPreview.js.map' }, { - 'name': 'AnnotatableBlockPreview.85745121.css', - 'path': 'common/static/css/xmodule/AnnotatableBlockPreview.85745121.css', - 'publicPath': '/static/css/xmodule/AnnotatableBlockPreview.85745121.css' + 'name': 'AnnotatableBlockPreview.css', + 'path': 'common/static/css/xmodule/AnnotatableBlockPreview.css', + 'publicPath': '/static/css/xmodule/AnnotatableBlockPreview.css' } ], ... From 66e6f4e776bfbc5f09c6b0e03fa6621372a882c1 Mon Sep 17 00:00:00 2001 From: Kyle McCormick Date: Thu, 18 May 2023 17:06:42 -0400 Subject: [PATCH 4/6] build: import XModule source SCSS directly rather than copying The `xmodule_assets` command copies SCSS source files from xmodule/css to common/static/xmodule/scss, renaming them to `{MD5_HASH}.scss` in order to "remove duplicates". The copied files are then included into the generated SCSS entrypoint files (eg AnnotatableBlockStudio.scss). The "de-deplication" is completely unnecessary: there are only a couple dozen SCSS files, and none of them are duplicates. This copying process is confusing, it complicates our build process, and it makes our SCSS harder to understand. So, in the generated SCSS entrypoint files, we stop importing the *copied* SCSS sources, and just import the *original* SCSS sources instead. For example, common/static/xmodule/descriptors/scss/AboutBlockStudio.scss is changed from: .xmodule_edit.xmodule_AboutBlock { @import "9bdcda00f046f78be79aca7791e1d4fb.scss"; @import "a10fc3e0fd6aca63426a89e75fe69c31.scss"; } to: .xmodule_edit.xmodule_AboutBlock { @import "editor/edit.scss"; @import "html/edit.scss"; } In order to make the `@import` lines work, we add xmodule/css to the list of lookup dirs for XModule SCSS compilation. We also remove the copying logic from `xmodule_assets`, as it is no longer needed. Part of: https://github.com/openedx/edx-platform/issues/31624 --- pavelib/assets.py | 10 ++++++++-- xmodule/static_content.py | 16 +++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pavelib/assets.py b/pavelib/assets.py index 991fb7f914b1..19bb98ea071e 100644 --- a/pavelib/assets.py +++ b/pavelib/assets.py @@ -172,6 +172,7 @@ def get_theme_sass_dirs(system, theme_dir): certs_css_dir = theme_dir / system / "static" / "certificates" / "css" xmodule_sass_folder = "modules" if system == 'lms' else "descriptors" xmodule_sass_dir = path("common") / "static" / "xmodule" / xmodule_sass_folder / "scss" + xmodule_lookup_dir = path("xmodule") / "css" dependencies = SASS_LOOKUP_DEPENDENCIES.get(system, []) if sass_dir.isdir(): @@ -202,7 +203,9 @@ def get_theme_sass_dirs(system, theme_dir): dirs.append({ "sass_source_dir": xmodule_sass_dir, "css_destination_dir": path("common") / "static" / "css" / "xmodule", - "lookup_paths": dependencies + [ + "lookup_paths": [ + xmodule_lookup_dir, + *dependencies, sass_dir / "partials", system_sass_dir / "partials", system_sass_dir, @@ -237,6 +240,7 @@ def get_system_sass_dirs(system): css_dir = path(system) / "static" / "css" xmodule_sass_folder = "modules" if system == 'lms' else "descriptors" xmodule_sass_dir = path("common") / "static" / "xmodule" / xmodule_sass_folder / "scss" + xmodule_lookup_dir = path("xmodule") / "css" dependencies = SASS_LOOKUP_DEPENDENCIES.get(system, []) dirs.append({ @@ -251,7 +255,9 @@ def get_system_sass_dirs(system): dirs.append({ "sass_source_dir": xmodule_sass_dir, "css_destination_dir": path("common") / "static" / "css" / "xmodule", - "lookup_paths": dependencies + [ + "lookup_paths": [ + xmodule_lookup_dir, + *dependencies, sass_dir / "partials", sass_dir, ], diff --git a/xmodule/static_content.py b/xmodule/static_content.py index e93499b702e1..6730dcb7a0ea 100755 --- a/xmodule/static_content.py +++ b/xmodule/static_content.py @@ -126,26 +126,20 @@ def _write_styles(selector, output_root, classes, css_attribute, suffix): into `output_root` as individual files """ contents = {} + xmodule_scss_path = resource_filename(__name__, "") + "/css/" for class_ in classes: class_css = getattr(class_, css_attribute)() - fragment_names = [] + rel_fragment_paths = [] for fragment_path in class_css.get('scss', []): - with open(fragment_path, 'rb') as fragment_file: - fragment = fragment_file.read() - fragment_name = "{hash}.{type}".format( - hash=hashlib.md5(fragment).hexdigest(), - type='scss') - # Prepend _ so that sass just includes the files into a single file - filename = '_' + fragment_name - contents[filename] = fragment - fragment_names.append(fragment_name) + rel_fragment_path = fragment_path.split(xmodule_scss_path)[1] + rel_fragment_paths.append(rel_fragment_path) module_styles_lines = [] module_styles_lines.append("""{selector}.xmodule_{class_.__name__} {{""".format( class_=class_, selector=selector )) - module_styles_lines.extend(f' @import "{name}";' for name in fragment_names) + module_styles_lines.extend(f' @import "{path}";' for path in rel_fragment_paths) module_styles_lines.append('}') contents[f"{class_.__name__}{suffix}.scss"] = '\n'.join(module_styles_lines) From fa043aa3ba3527501ebbba6bcfbaa544bc1df4d0 Mon Sep 17 00:00:00 2001 From: Kyle McCormick Date: Sat, 20 May 2023 08:38:11 -0400 Subject: [PATCH 5/6] build: check in XModule SCSS entry files instead of generating them xmodule_assets formerly generated a series of SCSS entry files, which imported from SCSS sources in xmodule/static/sass. This adds an unnecessary and confusing step to the SCSS build. Instead, we move the generated files to xmodule/sass, and TODO Part of: https://github.com/openedx/edx-platform/issues/31624 --- pavelib/assets.py | 10 ++-- xmodule/annotatable_block.py | 10 ---- xmodule/capa_block.py | 13 ----- xmodule/conditional_block.py | 6 -- xmodule/html_block.py | 7 --- xmodule/library_content_block.py | 6 -- xmodule/lti_block.py | 8 --- xmodule/poll_block.py | 9 --- xmodule/seq_block.py | 10 ---- xmodule/split_test_block.py | 6 -- xmodule/static/sass/cms/AboutBlockStudio.scss | 4 ++ .../sass/cms/AnnotatableBlockStudio.scss | 3 + .../sass/cms/ConditionalBlockStudio.scss | 2 + .../sass/cms/CourseInfoBlockStudio.scss | 4 ++ .../static/sass/cms/CustomTagBlockStudio.scss | 3 + xmodule/static/sass/cms/HtmlBlockStudio.scss | 4 ++ xmodule/static/sass/cms/LTIBlockStudio.scss | 2 + .../sass/cms/LibraryContentBlockStudio.scss | 2 + xmodule/static/sass/cms/PollBlockStudio.scss | 2 + .../static/sass/cms/ProblemBlockStudio.scss | 4 ++ .../static/sass/cms/SequenceBlockStudio.scss | 2 + .../static/sass/cms/SplitTestBlockStudio.scss | 2 + .../static/sass/cms/StaticTabBlockStudio.scss | 4 ++ xmodule/static/sass/cms/VideoBlockStudio.scss | 3 + .../static/sass/cms/WordCloudBlockStudio.scss | 2 + .../sass/include}/annotatable/display.scss | 0 .../sass/include}/capa/display.scss | 0 .../sass/include}/codemirror/codemirror.scss | 0 .../sass/include}/editor/edit.scss | 0 .../sass/include}/html/display.scss | 0 .../sass/include}/html/edit.scss | 0 .../{css => static/sass/include}/lti/lti.scss | 0 .../sass/include}/poll/display.scss | 0 .../sass/include}/problem/edit.scss | 0 .../sass/include}/sequence/display.scss | 0 .../sass/include}/tabs/codemirror.scss | 0 .../sass/include}/tabs/tabs.scss | 0 .../sass/include}/video/accessible_menu.scss | 0 .../sass/include}/video/display.scss | 0 .../sass/include}/word_cloud/display.scss | 0 .../static/sass/lms/AboutBlockPreview.scss | 3 + .../sass/lms/AnnotatableBlockPreview.scss | 3 + .../sass/lms/ConditionalBlockPreview.scss | 2 + .../sass/lms/CourseInfoBlockPreview.scss | 3 + .../sass/lms/CustomTagBlockPreview.scss | 2 + xmodule/static/sass/lms/HtmlBlockPreview.scss | 3 + xmodule/static/sass/lms/LTIBlockPreview.scss | 3 + .../sass/lms/LibraryContentBlockPreview.scss | 2 + xmodule/static/sass/lms/PollBlockPreview.scss | 3 + .../static/sass/lms/ProblemBlockPreview.scss | 3 + .../static/sass/lms/SequenceBlockPreview.scss | 3 + .../sass/lms/SplitTestBlockPreview.scss | 2 + .../sass/lms/StaticTabBlockPreview.scss | 3 + .../static/sass/lms/VideoBlockPreview.scss | 4 ++ .../sass/lms/WordCloudBlockPreview.scss | 3 + xmodule/static_content.py | 55 +------------------ xmodule/template_block.py | 6 -- xmodule/word_cloud_block.py | 8 --- xmodule/x_module.py | 11 ---- 59 files changed, 91 insertions(+), 159 deletions(-) create mode 100644 xmodule/static/sass/cms/AboutBlockStudio.scss create mode 100644 xmodule/static/sass/cms/AnnotatableBlockStudio.scss create mode 100644 xmodule/static/sass/cms/ConditionalBlockStudio.scss create mode 100644 xmodule/static/sass/cms/CourseInfoBlockStudio.scss create mode 100644 xmodule/static/sass/cms/CustomTagBlockStudio.scss create mode 100644 xmodule/static/sass/cms/HtmlBlockStudio.scss create mode 100644 xmodule/static/sass/cms/LTIBlockStudio.scss create mode 100644 xmodule/static/sass/cms/LibraryContentBlockStudio.scss create mode 100644 xmodule/static/sass/cms/PollBlockStudio.scss create mode 100644 xmodule/static/sass/cms/ProblemBlockStudio.scss create mode 100644 xmodule/static/sass/cms/SequenceBlockStudio.scss create mode 100644 xmodule/static/sass/cms/SplitTestBlockStudio.scss create mode 100644 xmodule/static/sass/cms/StaticTabBlockStudio.scss create mode 100644 xmodule/static/sass/cms/VideoBlockStudio.scss create mode 100644 xmodule/static/sass/cms/WordCloudBlockStudio.scss rename xmodule/{css => static/sass/include}/annotatable/display.scss (100%) rename xmodule/{css => static/sass/include}/capa/display.scss (100%) rename xmodule/{css => static/sass/include}/codemirror/codemirror.scss (100%) rename xmodule/{css => static/sass/include}/editor/edit.scss (100%) rename xmodule/{css => static/sass/include}/html/display.scss (100%) rename xmodule/{css => static/sass/include}/html/edit.scss (100%) rename xmodule/{css => static/sass/include}/lti/lti.scss (100%) rename xmodule/{css => static/sass/include}/poll/display.scss (100%) rename xmodule/{css => static/sass/include}/problem/edit.scss (100%) rename xmodule/{css => static/sass/include}/sequence/display.scss (100%) rename xmodule/{css => static/sass/include}/tabs/codemirror.scss (100%) rename xmodule/{css => static/sass/include}/tabs/tabs.scss (100%) rename xmodule/{css => static/sass/include}/video/accessible_menu.scss (100%) rename xmodule/{css => static/sass/include}/video/display.scss (100%) rename xmodule/{css => static/sass/include}/word_cloud/display.scss (100%) create mode 100644 xmodule/static/sass/lms/AboutBlockPreview.scss create mode 100644 xmodule/static/sass/lms/AnnotatableBlockPreview.scss create mode 100644 xmodule/static/sass/lms/ConditionalBlockPreview.scss create mode 100644 xmodule/static/sass/lms/CourseInfoBlockPreview.scss create mode 100644 xmodule/static/sass/lms/CustomTagBlockPreview.scss create mode 100644 xmodule/static/sass/lms/HtmlBlockPreview.scss create mode 100644 xmodule/static/sass/lms/LTIBlockPreview.scss create mode 100644 xmodule/static/sass/lms/LibraryContentBlockPreview.scss create mode 100644 xmodule/static/sass/lms/PollBlockPreview.scss create mode 100644 xmodule/static/sass/lms/ProblemBlockPreview.scss create mode 100644 xmodule/static/sass/lms/SequenceBlockPreview.scss create mode 100644 xmodule/static/sass/lms/SplitTestBlockPreview.scss create mode 100644 xmodule/static/sass/lms/StaticTabBlockPreview.scss create mode 100644 xmodule/static/sass/lms/VideoBlockPreview.scss create mode 100644 xmodule/static/sass/lms/WordCloudBlockPreview.scss diff --git a/pavelib/assets.py b/pavelib/assets.py index 19bb98ea071e..65dfa9e25941 100644 --- a/pavelib/assets.py +++ b/pavelib/assets.py @@ -170,9 +170,8 @@ def get_theme_sass_dirs(system, theme_dir): css_dir = theme_dir / system / "static" / "css" certs_sass_dir = theme_dir / system / "static" / "certificates" / "sass" certs_css_dir = theme_dir / system / "static" / "certificates" / "css" - xmodule_sass_folder = "modules" if system == 'lms' else "descriptors" - xmodule_sass_dir = path("common") / "static" / "xmodule" / xmodule_sass_folder / "scss" - xmodule_lookup_dir = path("xmodule") / "css" + xmodule_sass_dir = path("xmodule") / "static" / "sass" / system + xmodule_lookup_dir = path("xmodule") / "static" / "sass" / "include" dependencies = SASS_LOOKUP_DEPENDENCIES.get(system, []) if sass_dir.isdir(): @@ -238,9 +237,8 @@ def get_system_sass_dirs(system): dirs = [] sass_dir = path(system) / "static" / "sass" css_dir = path(system) / "static" / "css" - xmodule_sass_folder = "modules" if system == 'lms' else "descriptors" - xmodule_sass_dir = path("common") / "static" / "xmodule" / xmodule_sass_folder / "scss" - xmodule_lookup_dir = path("xmodule") / "css" + xmodule_sass_dir = path("xmodule") / "sass" / system + xmodule_lookup_dir = path("xmodule") / "sass" / "include" dependencies = SASS_LOOKUP_DEPENDENCIES.get(system, []) dirs.append({ diff --git a/xmodule/annotatable_block.py b/xmodule/annotatable_block.py index 9ec6bf21dace..e2c6a7a2c554 100644 --- a/xmodule/annotatable_block.py +++ b/xmodule/annotatable_block.py @@ -82,11 +82,6 @@ class AnnotatableBlock( ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } - preview_view_css = { - 'scss': [ - resource_filename(__name__, 'css/annotatable/display.scss'), - ], - } studio_view_js = { 'js': [ @@ -94,11 +89,6 @@ class AnnotatableBlock( ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } - studio_view_css = { - 'scss': [ - resource_filename(__name__, 'css/codemirror/codemirror.scss'), - ], - } studio_js_module_name = "XMLEditingDescriptor" mako_template = "widgets/raw-edit.html" diff --git a/xmodule/capa_block.py b/xmodule/capa_block.py index 2b2ec8082534..c70e619f27c9 100644 --- a/xmodule/capa_block.py +++ b/xmodule/capa_block.py @@ -177,12 +177,6 @@ class ProblemBlock( 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js') } - preview_view_css = { - 'scss': [ - resource_filename(__name__, 'css/capa/display.scss'), - ], - } - studio_view_js = { 'js': [ resource_filename(__name__, 'js/src/problem/edit.js'), @@ -190,13 +184,6 @@ class ProblemBlock( 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } - studio_view_css = { - 'scss': [ - resource_filename(__name__, 'css/editor/edit.scss'), - resource_filename(__name__, 'css/problem/edit.scss'), - ] - } - display_name = String( display_name=_("Display Name"), help=_("The display name for this component."), diff --git a/xmodule/conditional_block.py b/xmodule/conditional_block.py index 7fe545d1a307..23ffbae43afa 100644 --- a/xmodule/conditional_block.py +++ b/xmodule/conditional_block.py @@ -154,9 +154,6 @@ class ConditionalBlock( ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } - preview_view_css = { - 'scss': [], - } mako_template = 'widgets/metadata-edit.html' studio_js_module_name = 'SequenceDescriptor' @@ -164,9 +161,6 @@ class ConditionalBlock( 'js': [resource_filename(__name__, 'js/src/sequence/edit.js')], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } - studio_view_css = { - 'scss': [], - } # Map # key: diff --git a/xmodule/html_block.py b/xmodule/html_block.py index 48786c2c5611..c9f3ddbf4d69 100644 --- a/xmodule/html_block.py +++ b/xmodule/html_block.py @@ -152,7 +152,6 @@ def studio_view(self, _context): ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } - preview_view_css = {'scss': [resource_filename(__name__, 'css/html/display.scss')]} uses_xmodule_styles_setup = True @@ -168,12 +167,6 @@ def studio_view(self, _context): ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } - studio_view_css = { - 'scss': [ - resource_filename(__name__, 'css/editor/edit.scss'), - resource_filename(__name__, 'css/html/edit.scss') - ] - } # VS[compat] TODO (cpennington): Delete this method once all fall 2012 course # are being edited in the cms diff --git a/xmodule/library_content_block.py b/xmodule/library_content_block.py index 7193247f58d5..2e405371d017 100644 --- a/xmodule/library_content_block.py +++ b/xmodule/library_content_block.py @@ -99,9 +99,6 @@ class LibraryContentBlock( 'js': [], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } - preview_view_css = { - 'scss': [], - } mako_template = 'widgets/metadata-edit.html' studio_js_module_name = "VerticalDescriptor" @@ -111,9 +108,6 @@ class LibraryContentBlock( ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } - studio_view_css = { - 'scss': [], - } show_in_read_only_mode = True diff --git a/xmodule/lti_block.py b/xmodule/lti_block.py index 76c03d73a671..66bb4e2049c7 100644 --- a/xmodule/lti_block.py +++ b/xmodule/lti_block.py @@ -378,11 +378,6 @@ class LTIBlock( ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } - preview_view_css = { - 'scss': [ - resource_filename(__name__, 'css/lti/lti.scss') - ], - } mako_template = 'widgets/metadata-only-edit.html' @@ -393,9 +388,6 @@ class LTIBlock( ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } - studio_view_css = { - 'scss': [], - } def studio_view(self, _context): """ diff --git a/xmodule/poll_block.py b/xmodule/poll_block.py index 0ce6d38e1e51..3141c7b71984 100644 --- a/xmodule/poll_block.py +++ b/xmodule/poll_block.py @@ -92,11 +92,6 @@ class PollBlock( ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } - preview_view_css = { - 'scss': [ - resource_filename(__name__, 'css/poll/display.scss') - ], - } # There is no studio_view() for this XBlock but this is needed to make the # the static_content command happy. @@ -105,10 +100,6 @@ class PollBlock( 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js') } - studio_view_css = { - 'scss': [] - } - def handle_ajax(self, dispatch, data): # lint-amnesty, pylint: disable=unused-argument """Ajax handler. diff --git a/xmodule/seq_block.py b/xmodule/seq_block.py index 250a69d83b6a..c46bb97e0fee 100644 --- a/xmodule/seq_block.py +++ b/xmodule/seq_block.py @@ -278,12 +278,6 @@ class SequenceBlock( 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js') } - preview_view_css = { - 'scss': [ - resource_filename(__name__, 'css/sequence/display.scss'), - ], - } - # There is no studio_view() for this XBlock but this is needed to make the # the static_content command happy. studio_view_js = { @@ -291,10 +285,6 @@ class SequenceBlock( 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js') } - studio_view_css = { - 'scss': [] - } - def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) diff --git a/xmodule/split_test_block.py b/xmodule/split_test_block.py index f9f8eea812f1..b6d9f58549a7 100644 --- a/xmodule/split_test_block.py +++ b/xmodule/split_test_block.py @@ -162,9 +162,6 @@ class SplitTestBlock( # lint-amnesty, pylint: disable=abstract-method 'js': [], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } - preview_view_css = { - 'scss': [], - } mako_template = "widgets/metadata-only-edit.html" studio_js_module_name = 'SequenceDescriptor' @@ -172,9 +169,6 @@ class SplitTestBlock( # lint-amnesty, pylint: disable=abstract-method 'js': [resource_filename(__name__, 'js/src/sequence/edit.js')], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } - studio_view_css = { - 'scss': [], - } @cached_property def child_block(self): diff --git a/xmodule/static/sass/cms/AboutBlockStudio.scss b/xmodule/static/sass/cms/AboutBlockStudio.scss new file mode 100644 index 000000000000..0af42e47ff02 --- /dev/null +++ b/xmodule/static/sass/cms/AboutBlockStudio.scss @@ -0,0 +1,4 @@ +.xmodule_edit.xmodule_AboutBlock { + @import "editor/edit.scss"; + @import "html/edit.scss"; +} diff --git a/xmodule/static/sass/cms/AnnotatableBlockStudio.scss b/xmodule/static/sass/cms/AnnotatableBlockStudio.scss new file mode 100644 index 000000000000..8f2852422d7d --- /dev/null +++ b/xmodule/static/sass/cms/AnnotatableBlockStudio.scss @@ -0,0 +1,3 @@ +.xmodule_edit.xmodule_AnnotatableBlock { + @import "codemirror/codemirror.scss"; +} diff --git a/xmodule/static/sass/cms/ConditionalBlockStudio.scss b/xmodule/static/sass/cms/ConditionalBlockStudio.scss new file mode 100644 index 000000000000..c3db589e532c --- /dev/null +++ b/xmodule/static/sass/cms/ConditionalBlockStudio.scss @@ -0,0 +1,2 @@ +.xmodule_edit.xmodule_ConditionalBlock { +} diff --git a/xmodule/static/sass/cms/CourseInfoBlockStudio.scss b/xmodule/static/sass/cms/CourseInfoBlockStudio.scss new file mode 100644 index 000000000000..df1af8311546 --- /dev/null +++ b/xmodule/static/sass/cms/CourseInfoBlockStudio.scss @@ -0,0 +1,4 @@ +.xmodule_edit.xmodule_CourseInfoBlock { + @import "editor/edit.scss"; + @import "html/edit.scss"; +} diff --git a/xmodule/static/sass/cms/CustomTagBlockStudio.scss b/xmodule/static/sass/cms/CustomTagBlockStudio.scss new file mode 100644 index 000000000000..3abd162c808d --- /dev/null +++ b/xmodule/static/sass/cms/CustomTagBlockStudio.scss @@ -0,0 +1,3 @@ +.xmodule_edit.xmodule_CustomTagBlock { + @import "codemirror/codemirror.scss"; +} diff --git a/xmodule/static/sass/cms/HtmlBlockStudio.scss b/xmodule/static/sass/cms/HtmlBlockStudio.scss new file mode 100644 index 000000000000..350a80cc5d84 --- /dev/null +++ b/xmodule/static/sass/cms/HtmlBlockStudio.scss @@ -0,0 +1,4 @@ +.xmodule_edit.xmodule_HtmlBlock { + @import "editor/edit.scss"; + @import "html/edit.scss"; +} diff --git a/xmodule/static/sass/cms/LTIBlockStudio.scss b/xmodule/static/sass/cms/LTIBlockStudio.scss new file mode 100644 index 000000000000..c30e40363794 --- /dev/null +++ b/xmodule/static/sass/cms/LTIBlockStudio.scss @@ -0,0 +1,2 @@ +.xmodule_edit.xmodule_LTIBlock { +} diff --git a/xmodule/static/sass/cms/LibraryContentBlockStudio.scss b/xmodule/static/sass/cms/LibraryContentBlockStudio.scss new file mode 100644 index 000000000000..2d93e694e95a --- /dev/null +++ b/xmodule/static/sass/cms/LibraryContentBlockStudio.scss @@ -0,0 +1,2 @@ +.xmodule_edit.xmodule_LibraryContentBlock { +} diff --git a/xmodule/static/sass/cms/PollBlockStudio.scss b/xmodule/static/sass/cms/PollBlockStudio.scss new file mode 100644 index 000000000000..bb9d59fe9425 --- /dev/null +++ b/xmodule/static/sass/cms/PollBlockStudio.scss @@ -0,0 +1,2 @@ +.xmodule_edit.xmodule_PollBlock { +} diff --git a/xmodule/static/sass/cms/ProblemBlockStudio.scss b/xmodule/static/sass/cms/ProblemBlockStudio.scss new file mode 100644 index 000000000000..03d3cf1e2a98 --- /dev/null +++ b/xmodule/static/sass/cms/ProblemBlockStudio.scss @@ -0,0 +1,4 @@ +.xmodule_edit.xmodule_ProblemBlock { + @import "editor/edit.scss"; + @import "problem/edit.scss"; +} diff --git a/xmodule/static/sass/cms/SequenceBlockStudio.scss b/xmodule/static/sass/cms/SequenceBlockStudio.scss new file mode 100644 index 000000000000..7a5de5a62061 --- /dev/null +++ b/xmodule/static/sass/cms/SequenceBlockStudio.scss @@ -0,0 +1,2 @@ +.xmodule_edit.xmodule_SequenceBlock { +} diff --git a/xmodule/static/sass/cms/SplitTestBlockStudio.scss b/xmodule/static/sass/cms/SplitTestBlockStudio.scss new file mode 100644 index 000000000000..96aea0c65a82 --- /dev/null +++ b/xmodule/static/sass/cms/SplitTestBlockStudio.scss @@ -0,0 +1,2 @@ +.xmodule_edit.xmodule_SplitTestBlock { +} diff --git a/xmodule/static/sass/cms/StaticTabBlockStudio.scss b/xmodule/static/sass/cms/StaticTabBlockStudio.scss new file mode 100644 index 000000000000..37fa9ca36030 --- /dev/null +++ b/xmodule/static/sass/cms/StaticTabBlockStudio.scss @@ -0,0 +1,4 @@ +.xmodule_edit.xmodule_StaticTabBlock { + @import "editor/edit.scss"; + @import "html/edit.scss"; +} diff --git a/xmodule/static/sass/cms/VideoBlockStudio.scss b/xmodule/static/sass/cms/VideoBlockStudio.scss new file mode 100644 index 000000000000..eb966091ce46 --- /dev/null +++ b/xmodule/static/sass/cms/VideoBlockStudio.scss @@ -0,0 +1,3 @@ +.xmodule_edit.xmodule_VideoBlock { + @import "tabs/tabs.scss"; +} diff --git a/xmodule/static/sass/cms/WordCloudBlockStudio.scss b/xmodule/static/sass/cms/WordCloudBlockStudio.scss new file mode 100644 index 000000000000..6fe38e9fb45c --- /dev/null +++ b/xmodule/static/sass/cms/WordCloudBlockStudio.scss @@ -0,0 +1,2 @@ +.xmodule_edit.xmodule_WordCloudBlock { +} diff --git a/xmodule/css/annotatable/display.scss b/xmodule/static/sass/include/annotatable/display.scss similarity index 100% rename from xmodule/css/annotatable/display.scss rename to xmodule/static/sass/include/annotatable/display.scss diff --git a/xmodule/css/capa/display.scss b/xmodule/static/sass/include/capa/display.scss similarity index 100% rename from xmodule/css/capa/display.scss rename to xmodule/static/sass/include/capa/display.scss diff --git a/xmodule/css/codemirror/codemirror.scss b/xmodule/static/sass/include/codemirror/codemirror.scss similarity index 100% rename from xmodule/css/codemirror/codemirror.scss rename to xmodule/static/sass/include/codemirror/codemirror.scss diff --git a/xmodule/css/editor/edit.scss b/xmodule/static/sass/include/editor/edit.scss similarity index 100% rename from xmodule/css/editor/edit.scss rename to xmodule/static/sass/include/editor/edit.scss diff --git a/xmodule/css/html/display.scss b/xmodule/static/sass/include/html/display.scss similarity index 100% rename from xmodule/css/html/display.scss rename to xmodule/static/sass/include/html/display.scss diff --git a/xmodule/css/html/edit.scss b/xmodule/static/sass/include/html/edit.scss similarity index 100% rename from xmodule/css/html/edit.scss rename to xmodule/static/sass/include/html/edit.scss diff --git a/xmodule/css/lti/lti.scss b/xmodule/static/sass/include/lti/lti.scss similarity index 100% rename from xmodule/css/lti/lti.scss rename to xmodule/static/sass/include/lti/lti.scss diff --git a/xmodule/css/poll/display.scss b/xmodule/static/sass/include/poll/display.scss similarity index 100% rename from xmodule/css/poll/display.scss rename to xmodule/static/sass/include/poll/display.scss diff --git a/xmodule/css/problem/edit.scss b/xmodule/static/sass/include/problem/edit.scss similarity index 100% rename from xmodule/css/problem/edit.scss rename to xmodule/static/sass/include/problem/edit.scss diff --git a/xmodule/css/sequence/display.scss b/xmodule/static/sass/include/sequence/display.scss similarity index 100% rename from xmodule/css/sequence/display.scss rename to xmodule/static/sass/include/sequence/display.scss diff --git a/xmodule/css/tabs/codemirror.scss b/xmodule/static/sass/include/tabs/codemirror.scss similarity index 100% rename from xmodule/css/tabs/codemirror.scss rename to xmodule/static/sass/include/tabs/codemirror.scss diff --git a/xmodule/css/tabs/tabs.scss b/xmodule/static/sass/include/tabs/tabs.scss similarity index 100% rename from xmodule/css/tabs/tabs.scss rename to xmodule/static/sass/include/tabs/tabs.scss diff --git a/xmodule/css/video/accessible_menu.scss b/xmodule/static/sass/include/video/accessible_menu.scss similarity index 100% rename from xmodule/css/video/accessible_menu.scss rename to xmodule/static/sass/include/video/accessible_menu.scss diff --git a/xmodule/css/video/display.scss b/xmodule/static/sass/include/video/display.scss similarity index 100% rename from xmodule/css/video/display.scss rename to xmodule/static/sass/include/video/display.scss diff --git a/xmodule/css/word_cloud/display.scss b/xmodule/static/sass/include/word_cloud/display.scss similarity index 100% rename from xmodule/css/word_cloud/display.scss rename to xmodule/static/sass/include/word_cloud/display.scss diff --git a/xmodule/static/sass/lms/AboutBlockPreview.scss b/xmodule/static/sass/lms/AboutBlockPreview.scss new file mode 100644 index 000000000000..1df920bc232b --- /dev/null +++ b/xmodule/static/sass/lms/AboutBlockPreview.scss @@ -0,0 +1,3 @@ +.xmodule_display.xmodule_AboutBlock { + @import "html/display.scss"; +} diff --git a/xmodule/static/sass/lms/AnnotatableBlockPreview.scss b/xmodule/static/sass/lms/AnnotatableBlockPreview.scss new file mode 100644 index 000000000000..66e1e756f3da --- /dev/null +++ b/xmodule/static/sass/lms/AnnotatableBlockPreview.scss @@ -0,0 +1,3 @@ +.xmodule_display.xmodule_AnnotatableBlock { + @import "annotatable/display.scss"; +} diff --git a/xmodule/static/sass/lms/ConditionalBlockPreview.scss b/xmodule/static/sass/lms/ConditionalBlockPreview.scss new file mode 100644 index 000000000000..56fbe85f7d9a --- /dev/null +++ b/xmodule/static/sass/lms/ConditionalBlockPreview.scss @@ -0,0 +1,2 @@ +.xmodule_display.xmodule_ConditionalBlock { +} diff --git a/xmodule/static/sass/lms/CourseInfoBlockPreview.scss b/xmodule/static/sass/lms/CourseInfoBlockPreview.scss new file mode 100644 index 000000000000..ff6353df74e2 --- /dev/null +++ b/xmodule/static/sass/lms/CourseInfoBlockPreview.scss @@ -0,0 +1,3 @@ +.xmodule_display.xmodule_CourseInfoBlock { + @import "html/display.scss"; +} diff --git a/xmodule/static/sass/lms/CustomTagBlockPreview.scss b/xmodule/static/sass/lms/CustomTagBlockPreview.scss new file mode 100644 index 000000000000..a4871cdd9baa --- /dev/null +++ b/xmodule/static/sass/lms/CustomTagBlockPreview.scss @@ -0,0 +1,2 @@ +.xmodule_display.xmodule_CustomTagBlock { +} diff --git a/xmodule/static/sass/lms/HtmlBlockPreview.scss b/xmodule/static/sass/lms/HtmlBlockPreview.scss new file mode 100644 index 000000000000..09610448fed5 --- /dev/null +++ b/xmodule/static/sass/lms/HtmlBlockPreview.scss @@ -0,0 +1,3 @@ +.xmodule_display.xmodule_HtmlBlock { + @import "html/display.scss"; +} diff --git a/xmodule/static/sass/lms/LTIBlockPreview.scss b/xmodule/static/sass/lms/LTIBlockPreview.scss new file mode 100644 index 000000000000..ea92202df2ad --- /dev/null +++ b/xmodule/static/sass/lms/LTIBlockPreview.scss @@ -0,0 +1,3 @@ +.xmodule_display.xmodule_LTIBlock { + @import "lti/lti.scss"; +} diff --git a/xmodule/static/sass/lms/LibraryContentBlockPreview.scss b/xmodule/static/sass/lms/LibraryContentBlockPreview.scss new file mode 100644 index 000000000000..7269554b634a --- /dev/null +++ b/xmodule/static/sass/lms/LibraryContentBlockPreview.scss @@ -0,0 +1,2 @@ +.xmodule_display.xmodule_LibraryContentBlock { +} diff --git a/xmodule/static/sass/lms/PollBlockPreview.scss b/xmodule/static/sass/lms/PollBlockPreview.scss new file mode 100644 index 000000000000..85110778c742 --- /dev/null +++ b/xmodule/static/sass/lms/PollBlockPreview.scss @@ -0,0 +1,3 @@ +.xmodule_display.xmodule_PollBlock { + @import "poll/display.scss"; +} diff --git a/xmodule/static/sass/lms/ProblemBlockPreview.scss b/xmodule/static/sass/lms/ProblemBlockPreview.scss new file mode 100644 index 000000000000..5175529246b0 --- /dev/null +++ b/xmodule/static/sass/lms/ProblemBlockPreview.scss @@ -0,0 +1,3 @@ +.xmodule_display.xmodule_ProblemBlock { + @import "capa/display.scss"; +} diff --git a/xmodule/static/sass/lms/SequenceBlockPreview.scss b/xmodule/static/sass/lms/SequenceBlockPreview.scss new file mode 100644 index 000000000000..0c5aa3c82c49 --- /dev/null +++ b/xmodule/static/sass/lms/SequenceBlockPreview.scss @@ -0,0 +1,3 @@ +.xmodule_display.xmodule_SequenceBlock { + @import "sequence/display.scss"; +} diff --git a/xmodule/static/sass/lms/SplitTestBlockPreview.scss b/xmodule/static/sass/lms/SplitTestBlockPreview.scss new file mode 100644 index 000000000000..1ca469c5df78 --- /dev/null +++ b/xmodule/static/sass/lms/SplitTestBlockPreview.scss @@ -0,0 +1,2 @@ +.xmodule_display.xmodule_SplitTestBlock { +} diff --git a/xmodule/static/sass/lms/StaticTabBlockPreview.scss b/xmodule/static/sass/lms/StaticTabBlockPreview.scss new file mode 100644 index 000000000000..5c044e659b28 --- /dev/null +++ b/xmodule/static/sass/lms/StaticTabBlockPreview.scss @@ -0,0 +1,3 @@ +.xmodule_display.xmodule_StaticTabBlock { + @import "html/display.scss"; +} diff --git a/xmodule/static/sass/lms/VideoBlockPreview.scss b/xmodule/static/sass/lms/VideoBlockPreview.scss new file mode 100644 index 000000000000..ccd9a3ed1326 --- /dev/null +++ b/xmodule/static/sass/lms/VideoBlockPreview.scss @@ -0,0 +1,4 @@ +.xmodule_display.xmodule_VideoBlock { + @import "video/display.scss"; + @import "video/accessible_menu.scss"; +} diff --git a/xmodule/static/sass/lms/WordCloudBlockPreview.scss b/xmodule/static/sass/lms/WordCloudBlockPreview.scss new file mode 100644 index 000000000000..884112a4804c --- /dev/null +++ b/xmodule/static/sass/lms/WordCloudBlockPreview.scss @@ -0,0 +1,3 @@ +.xmodule_display.xmodule_WordCloudBlock { + @import "word_cloud/display.scss"; +} diff --git a/xmodule/static_content.py b/xmodule/static_content.py index 6730dcb7a0ea..80b0b1d14b97 100755 --- a/xmodule/static_content.py +++ b/xmodule/static_content.py @@ -1,7 +1,7 @@ # /usr/bin/env python """ -This module has utility functions for gathering up the static content -that is defined by XModules and XModuleDescriptors (javascript and css) +This module has utility functions for gathering up the javascript +that is defined by XModules and XModuleDescriptors """ @@ -47,12 +47,6 @@ class VideoBlock(HTMLSnippet): # lint-amnesty, pylint: disable=abstract-method ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js') } - preview_view_css = { - 'scss': [ - resource_filename(__name__, 'css/video/display.scss'), - resource_filename(__name__, 'css/video/accessible_menu.scss'), - ], - } studio_view_js = { 'js': [ @@ -61,12 +55,6 @@ class VideoBlock(HTMLSnippet): # lint-amnesty, pylint: disable=abstract-method 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } - studio_view_css = { - 'scss': [ - resource_filename(__name__, 'css/tabs/tabs.scss'), - ] - } - # List of XBlocks which use this static content setup. # Should only be used for XModules being converted to XBlocks. @@ -89,21 +77,11 @@ class VideoBlock(HTMLSnippet): # lint-amnesty, pylint: disable=abstract-method ] -def write_module_styles(output_root): - """Write all registered XModule css, sass, and scss files to output root.""" - return _write_styles('.xmodule_display', output_root, XBLOCK_CLASSES, 'get_preview_view_css', 'Preview') - - def write_module_js(output_root): """Write all registered XModule js and coffee files to output root.""" return _write_js(output_root, XBLOCK_CLASSES, 'get_preview_view_js') -def write_descriptor_styles(output_root): - """Write all registered XModuleDescriptor css, sass, and scss files to output root.""" - return _write_styles('.xmodule_edit', output_root, XBLOCK_CLASSES, 'get_studio_view_css', 'Studio') - - def write_descriptor_js(output_root): """Write all registered XModuleDescriptor js and coffee files to output root.""" return _write_js(output_root, XBLOCK_CLASSES, 'get_studio_view_js') @@ -120,33 +98,6 @@ def _ensure_dir(directory): raise -def _write_styles(selector, output_root, classes, css_attribute, suffix): - """ - Write the css fragments from all XModules in `classes` - into `output_root` as individual files - """ - contents = {} - xmodule_scss_path = resource_filename(__name__, "") + "/css/" - - for class_ in classes: - class_css = getattr(class_, css_attribute)() - rel_fragment_paths = [] - for fragment_path in class_css.get('scss', []): - rel_fragment_path = fragment_path.split(xmodule_scss_path)[1] - rel_fragment_paths.append(rel_fragment_path) - - module_styles_lines = [] - module_styles_lines.append("""{selector}.xmodule_{class_.__name__} {{""".format( - class_=class_, selector=selector - )) - module_styles_lines.extend(f' @import "{path}";' for path in rel_fragment_paths) - module_styles_lines.append('}') - - contents[f"{class_.__name__}{suffix}.scss"] = '\n'.join(module_styles_lines) - - _write_files(output_root, contents) - - def _write_js(output_root, classes, js_attribute): """ Write the javascript fragments from all XModules in `classes` @@ -294,9 +245,7 @@ def main(): root = path(args['']) descriptor_files = write_descriptor_js(root / 'descriptors/js') - write_descriptor_styles(root / 'descriptors/scss') module_files = write_module_js(root / 'modules/js') - write_module_styles(root / 'modules/scss') write_webpack(root / 'webpack.xmodule.config.js', module_files, descriptor_files) diff --git a/xmodule/template_block.py b/xmodule/template_block.py index 71b2c21f1441..abf1f2c725a9 100644 --- a/xmodule/template_block.py +++ b/xmodule/template_block.py @@ -69,16 +69,10 @@ class CustomTagBlock(CustomTagTemplateBlock): # pylint: disable=abstract-method 'js': [], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } - preview_view_css = { - 'scss': [], - } studio_view_js = { 'js': [resource_filename(__name__, 'js/src/raw/edit/xml.js')], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } - studio_view_css = { - 'scss': [resource_filename(__name__, 'css/codemirror/codemirror.scss')], - } def studio_view(self, _context): """ diff --git a/xmodule/word_cloud_block.py b/xmodule/word_cloud_block.py index d7d35dedc5f3..8fe741b881db 100644 --- a/xmodule/word_cloud_block.py +++ b/xmodule/word_cloud_block.py @@ -118,11 +118,6 @@ class WordCloudBlock( # pylint: disable=abstract-method ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } - preview_view_css = { - 'scss': [ - resource_filename(__name__, 'css/word_cloud/display.scss'), - ], - } studio_view_js = { 'js': [ @@ -130,9 +125,6 @@ class WordCloudBlock( # pylint: disable=abstract-method ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } - studio_view_css = { - 'scss': [], - } studio_js_module_name = "MetadataOnlyEditingDescriptor" mako_template = "widgets/metadata-only-edit.html" diff --git a/xmodule/x_module.py b/xmodule/x_module.py index 5478ccc45def..4d14f16b083d 100644 --- a/xmodule/x_module.py +++ b/xmodule/x_module.py @@ -214,9 +214,6 @@ class HTMLSnippet: preview_view_js = {} studio_view_js = {} - preview_view_css = {} - studio_view_css = {} - @classmethod def get_preview_view_js(cls): return cls.preview_view_js @@ -233,14 +230,6 @@ def get_studio_view_js(cls): def get_studio_view_js_bundle_name(cls): return cls.__name__ + 'Studio' - @classmethod - def get_preview_view_css(cls): - return cls.preview_view_css - - @classmethod - def get_studio_view_css(cls): - return cls.studio_view_css - def get_html(self): """ Return the html used to display this snippet From 6a1038a21a1ae5c9cd79dcb4b16cbd32fd73ef7e Mon Sep 17 00:00:00 2001 From: Kyle McCormick Date: Sat, 20 May 2023 09:50:16 -0400 Subject: [PATCH 6/6] build: common/static/css/xmodule -> xmodule/static/css Part of: https://github.com/openedx/edx-platform/issues/31624 --- pavelib/assets.py | 8 ++++---- xmodule/static/.gitignore | 1 + xmodule/util/xmodule_django.py | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 xmodule/static/.gitignore diff --git a/pavelib/assets.py b/pavelib/assets.py index 65dfa9e25941..0ff1b9691ad8 100644 --- a/pavelib/assets.py +++ b/pavelib/assets.py @@ -201,7 +201,7 @@ def get_theme_sass_dirs(system, theme_dir): dirs.append({ "sass_source_dir": xmodule_sass_dir, - "css_destination_dir": path("common") / "static" / "css" / "xmodule", + "css_destination_dir": path("xmodule") / "static" / "css", "lookup_paths": [ xmodule_lookup_dir, *dependencies, @@ -237,8 +237,8 @@ def get_system_sass_dirs(system): dirs = [] sass_dir = path(system) / "static" / "sass" css_dir = path(system) / "static" / "css" - xmodule_sass_dir = path("xmodule") / "sass" / system - xmodule_lookup_dir = path("xmodule") / "sass" / "include" + xmodule_sass_dir = path("xmodule") / "static" / "sass" / system + xmodule_lookup_dir = path("xmodule") / "static" / "sass" / "include" dependencies = SASS_LOOKUP_DEPENDENCIES.get(system, []) dirs.append({ @@ -252,7 +252,7 @@ def get_system_sass_dirs(system): dirs.append({ "sass_source_dir": xmodule_sass_dir, - "css_destination_dir": path("common") / "static" / "css" / "xmodule", + "css_destination_dir": path("xmodule") / "static" / "css", "lookup_paths": [ xmodule_lookup_dir, *dependencies, diff --git a/xmodule/static/.gitignore b/xmodule/static/.gitignore new file mode 100644 index 000000000000..b83e8995b9a9 --- /dev/null +++ b/xmodule/static/.gitignore @@ -0,0 +1 @@ +/css diff --git a/xmodule/util/xmodule_django.py b/xmodule/util/xmodule_django.py index 1d9a858ea495..66fc87014d19 100644 --- a/xmodule/util/xmodule_django.py +++ b/xmodule/util/xmodule_django.py @@ -62,7 +62,7 @@ def load_assets(self): }, { 'name': 'AnnotatableBlockPreview.css', - 'path': 'common/static/css/xmodule/AnnotatableBlockPreview.css', + 'path': 'xmodule/static/css/AnnotatableBlockPreview.css', 'publicPath': '/static/css/xmodule/AnnotatableBlockPreview.css' } ], @@ -75,7 +75,7 @@ def load_assets(self): """ assets = super().load_assets() - css_path = "common/static/css/xmodule" + css_path = "xmodule/static/css" css_files = listdir(css_path) for css_file in css_files: