Skip to content

Commit

Permalink
Merge PR #3 fix/css-loading
Browse files Browse the repository at this point in the history
* Commits:
  Load CSS inline instead of externally
  • Loading branch information
stvstnfrd committed Apr 8, 2020
2 parents 1aea405 + 220b0d3 commit cc85ca0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions freetextresponse/mixins/fragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
split into its own library.
"""
from __future__ import absolute_import
import pkg_resources

from xblock.core import XBlock
from xblock.fragment import Fragment
Expand Down Expand Up @@ -78,10 +79,12 @@ def build_fragment(
for item in css:
if item.startswith('/'):
url = item
fragment.add_css_url(url)
else:
item = 'public/' + item
url = self.runtime.local_resource_url(self, item)
fragment.add_css_url(url)
item = '../public/' + item
data = pkg_resources.resource_string(__name__, item)
data = data.decode('utf8')
fragment.add_css(data)
for item in js:
item = 'public/' + item
url = self.runtime.local_resource_url(self, item)
Expand Down

0 comments on commit cc85ca0

Please sign in to comment.