Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Radically simplify XModule SCSS #32283

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions pavelib/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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({
Expand All @@ -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,
],
Expand Down
26 changes: 8 additions & 18 deletions xmodule/annotatable_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
31 changes: 9 additions & 22 deletions xmodule/capa_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
20 changes: 7 additions & 13 deletions xmodule/conditional_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
25 changes: 9 additions & 16 deletions xmodule/html_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down
14 changes: 4 additions & 10 deletions xmodule/library_content_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 5 additions & 13 deletions xmodule/lti_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -374,27 +374,19 @@ 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'

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):
Expand Down
21 changes: 6 additions & 15 deletions xmodule/poll_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 4 additions & 14 deletions xmodule/seq_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
Loading