diff --git a/pavelib/assets.py b/pavelib/assets.py index 991fb7f914b1..0ff1b9691ad8 100644 --- a/pavelib/assets.py +++ b/pavelib/assets.py @@ -170,8 +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_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(): @@ -201,8 +201,10 @@ 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 + [ + "css_destination_dir": path("xmodule") / "static" / "css", + "lookup_paths": [ + xmodule_lookup_dir, + *dependencies, sass_dir / "partials", system_sass_dir / "partials", system_sass_dir, @@ -235,8 +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_sass_dir = path("xmodule") / "static" / "sass" / system + xmodule_lookup_dir = path("xmodule") / "static" / "sass" / "include" dependencies = SASS_LOOKUP_DEPENDENCIES.get(system, []) dirs.append({ @@ -250,8 +252,10 @@ 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 + [ + "css_destination_dir": path("xmodule") / "static" / "css", + "lookup_paths": [ + xmodule_lookup_dir, + *dependencies, sass_dir / "partials", sass_dir, ], diff --git a/xmodule/annotatable_block.py b/xmodule/annotatable_block.py index 774ad900979b..e2c6a7a2c554 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,29 +75,19 @@ 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'), - ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), - } - preview_view_css = { - 'scss': [ - resource_string(__name__, 'css/annotatable/display.scss'), + 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_filename(__name__, 'js/src/xmodule.js'), } studio_view_js = { 'js': [ - resource_string(__name__, 'js/src/raw/edit/xml.js'), - ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), - } - studio_view_css = { - 'scss': [ - resource_string(__name__, 'css/codemirror/codemirror.scss'), + resource_filename(__name__, 'js/src/raw/edit/xml.js'), ], + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } studio_js_module_name = "XMLEditingDescriptor" mako_template = "widgets/raw-edit.html" diff --git a/xmodule/capa_block.py b/xmodule/capa_block.py index 3c02053c0eb0..c70e619f27c9 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,33 +168,20 @@ 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'), - ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js') - } - - preview_view_css = { - 'scss': [ - resource_string(__name__, 'css/capa/display.scss'), + 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_filename(__name__, 'js/src/xmodule.js') } 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'), - } - - studio_view_css = { - 'scss': [ - resource_string(__name__, 'css/editor/edit.scss'), - resource_string(__name__, 'css/problem/edit.scss'), - ] + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } display_name = String( diff --git a/xmodule/conditional_block.py b/xmodule/conditional_block.py index 91e7af2c156e..23ffbae43afa 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,24 +148,18 @@ 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'), - } - preview_view_css = { - 'scss': [], + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } 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'), - } - studio_view_css = { - 'scss': [], + 'js': [resource_filename(__name__, 'js/src/sequence/edit.js')], + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } # Map diff --git a/xmodule/html_block.py b/xmodule/html_block.py index ed5d84e395c0..c9f3ddbf4d69 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,14 @@ 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')]} uses_xmodule_styles_setup = True @@ -164,15 +163,9 @@ 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'), - } - studio_view_css = { - 'scss': [ - resource_string(__name__, 'css/editor/edit.scss'), - resource_string(__name__, 'css/html/edit.scss') - ] + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } # VS[compat] TODO (cpennington): Delete this method once all fall 2012 course diff --git a/xmodule/library_content_block.py b/xmodule/library_content_block.py index 04abe5de6eb3..2e405371d017 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,22 +97,16 @@ class LibraryContentBlock( preview_view_js = { 'js': [], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), - } - preview_view_css = { - 'scss': [], + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } mako_template = 'widgets/metadata-edit.html' 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'), - } - studio_view_css = { - 'scss': [], + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } show_in_read_only_mode = True diff --git a/xmodule/lti_block.py b/xmodule/lti_block.py index 8bf60f1c4486..66bb4e2049c7 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,14 +374,9 @@ class LTIBlock( preview_view_js = { 'js': [ - resource_string(__name__, 'js/src/lti/lti.js') - ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), - } - preview_view_css = { - 'scss': [ - resource_string(__name__, 'css/lti/lti.scss') + resource_filename(__name__, 'js/src/lti/lti.js') ], + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } mako_template = 'widgets/metadata-only-edit.html' @@ -389,12 +384,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'), - } - studio_view_css = { - 'scss': [], + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } def studio_view(self, _context): diff --git a/xmodule/poll_block.py b/xmodule/poll_block.py index b29ed710e922..3141c7b71984 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,27 +86,18 @@ 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') - ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), - } - preview_view_css = { - 'scss': [ - resource_string(__name__, 'css/poll/display.scss') + 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_filename(__name__, 'js/src/xmodule.js'), } # There is no studio_view() for this XBlock but this is needed to make the # the static_content command happy. studio_view_js = { 'js': [], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js') - } - - studio_view_css = { - 'scss': [] + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js') } def handle_ajax(self, dispatch, data): # lint-amnesty, pylint: disable=unused-argument diff --git a/xmodule/seq_block.py b/xmodule/seq_block.py index 0d8be411fd58..c46bb97e0fee 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,26 +273,16 @@ class SequenceBlock( preview_view_js = { 'js': [ - resource_string(__name__, 'js/src/sequence/display.js'), - ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js') - } - - preview_view_css = { - 'scss': [ - resource_string(__name__, 'css/sequence/display.scss'), + resource_filename(__name__, 'js/src/sequence/display.js'), ], + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js') } # There is no studio_view() for this XBlock but this is needed to make the # the static_content command happy. studio_view_js = { 'js': [], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js') - } - - studio_view_css = { - 'scss': [] + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js') } def __init__(self, *args, **kwargs): diff --git a/xmodule/split_test_block.py b/xmodule/split_test_block.py index c45848800fb3..b6d9f58549a7 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,20 +160,14 @@ class SplitTestBlock( # lint-amnesty, pylint: disable=abstract-method preview_view_js = { 'js': [], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), - } - preview_view_css = { - 'scss': [], + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } 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'), - } - studio_view_css = { - 'scss': [], + 'js': [resource_filename(__name__, 'js/src/sequence/edit.js')], + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } @cached_property 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/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 2447347da90f..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 """ @@ -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,28 +43,16 @@ class VideoBlock(HTMLSnippet): # lint-amnesty, pylint: disable=abstract-method preview_view_js = { 'js': [ - resource_string(__name__, 'js/src/video/10_main.js'), - ], - 'xmodule_js': resource_string(__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__, 'js/src/video/10_main.js'), ], + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js') } 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'), - } - - studio_view_css = { - 'scss': [ - resource_string(__name__, 'css/tabs/tabs.scss'), - ] + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } @@ -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,49 +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, hashed by the contents to remove - duplicates - """ - contents = {} - - css_fragments = defaultdict(set) - 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, [])): - 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 - - 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( - 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) - - _write_files(output_root, contents) - - def _write_js(output_root, classes, js_attribute): """ Write the javascript fragments from all XModules in `classes` @@ -177,10 +112,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()): @@ -306,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 70bafca7753e..abf1f2c725a9 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,11 @@ class CustomTagBlock(CustomTagTemplateBlock): # pylint: disable=abstract-method preview_view_js = { 'js': [], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), - } - preview_view_css = { - 'scss': [], + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } studio_view_js = { - 'js': [resource_string(__name__, 'js/src/raw/edit/xml.js')], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), - } - studio_view_css = { - 'scss': [resource_string(__name__, 'css/codemirror/codemirror.scss')], + 'js': [resource_filename(__name__, 'js/src/raw/edit/xml.js')], + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } def studio_view(self, _context): diff --git a/xmodule/util/xmodule_django.py b/xmodule/util/xmodule_django.py index 248e10bf981a..66fc87014d19 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': '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: diff --git a/xmodule/word_cloud_block.py b/xmodule/word_cloud_block.py index 2e7fadd0a2be..8fe741b881db 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,24 +114,16 @@ class WordCloudBlock( # pylint: disable=abstract-method preview_view_js = { 'js': [ - resource_string(__name__, 'assets/word_cloud/src/js/word_cloud.js'), - ], - 'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'), - } - preview_view_css = { - 'scss': [ - resource_string(__name__, 'css/word_cloud/display.scss'), + resource_filename(__name__, 'assets/word_cloud/src/js/word_cloud.js'), ], + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } 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'), - } - studio_view_css = { - 'scss': [], + 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } 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