Commit 943e08e2 by Xavier Antoviaque

Use `local_resource_url()` to load js and css

parent 335ee78e
......@@ -31,7 +31,7 @@ from xblock.fragment import Fragment
from .light_children import LightChild, Boolean, Scope, String
from .models import Answer
from .utils import load_resource, render_template
from .utils import render_template
# Globals ###########################################################
......@@ -81,8 +81,9 @@ class AnswerBlock(LightChild):
})
fragment = Fragment(html)
fragment.add_css(load_resource('static/css/answer.css'))
fragment.add_javascript(load_resource('static/js/answer.js'))
fragment.add_css_url(self.runtime.local_resource_url(self.xblock_container, 'public/css/answer.css'))
fragment.add_javascript_url(self.runtime.local_resource_url(self.xblock_container,
'public/js/answer.js'))
fragment.initialize_js('AnswerBlock')
return fragment
......@@ -91,7 +92,7 @@ class AnswerBlock(LightChild):
'self': self,
})
fragment = Fragment(html)
fragment.add_css(load_resource('static/css/answer_table.css'))
fragment.add_css_url(self.runtime.local_resource_url(self.xblock_container, 'public/css/answer_table.css'))
return fragment
def submit(self, submission):
......
......@@ -31,7 +31,7 @@ from xblock.core import XBlock
from xblock.fragment import Fragment
from .models import Answer
from .utils import load_resource, list2csv, render_template
from .utils import list2csv, render_template
# Globals ###########################################################
......@@ -52,8 +52,8 @@ class MentoringDataExportBlock(XBlock):
})
fragment = Fragment(html)
fragment.add_javascript(load_resource('static/js/dataexport.js'))
fragment.add_css(load_resource('static/css/dataexport.css'))
fragment.add_javascript_url(self.runtime.local_resource_url(self, 'public/js/dataexport.js'))
fragment.add_css_url(self.runtime.local_resource_url(self, 'public/css/dataexport.css'))
fragment.initialize_js('MentoringDataExportBlock')
......
......@@ -70,17 +70,17 @@ class MentoringBlock(XBlockWithLightChildren):
fragment, named_children = self.get_children_fragment(context, view_name='mentoring_view',
not_instance_of=MentoringMessageBlock)
correct_icon_url = self.runtime.local_resource_url(self.xblock_container,
'public/img/correct-icon.png')
correct_icon_url = self.runtime.local_resource_url(self, 'public/img/correct-icon.png')
fragment.add_content(render_template('templates/html/mentoring.html', {
'self': self,
'named_children': named_children,
'missing_dependency_url': self.has_missing_dependency and self.next_step_url,
}))
fragment.add_css(load_resource('static/css/mentoring.css'))
fragment.add_javascript(load_resource('static/js/vendor/underscore-min.js'))
fragment.add_javascript(load_resource('static/js/mentoring.js'))
fragment.add_css_url(self.runtime.local_resource_url(self, 'public/css/mentoring.css'))
fragment.add_javascript_url(
self.runtime.local_resource_url(self, 'public/js/vendor/underscore-min.js'))
fragment.add_javascript_url(self.runtime.local_resource_url(self, 'public/js/mentoring.js'))
fragment.add_resource(load_resource('templates/html/mentoring_progress.html').format(
completed=correct_icon_url),
"text/html")
......
......@@ -28,7 +28,7 @@ import logging
from xblock.fragment import Fragment
from .light_children import LightChild, Scope, String
from .utils import load_resource, render_template
from .utils import render_template
# Globals ###########################################################
......@@ -91,8 +91,10 @@ class QuizzBlock(LightChild):
})
fragment = Fragment(html)
fragment.add_css(load_resource('static/css/quizz.css'))
fragment.add_javascript(load_resource('static/js/quizz.js'))
fragment.add_css_url(self.runtime.local_resource_url(self.xblock_container,
'public/css/quizz.css'))
fragment.add_javascript_url(self.runtime.local_resource_url(self.xblock_container,
'public/js/quizz.js'))
fragment.initialize_js('QuizzBlock')
return fragment
......
......@@ -73,9 +73,12 @@ class MentoringTableBlock(LightChild):
'bg_image_url': bg_image_url,
'bg_image_description': bg_image_description,
}))
fragment.add_css(load_resource('static/css/mentoring-table.css'))
fragment.add_javascript(load_resource('static/js/vendor/jquery.shorten.js'))
fragment.add_javascript(load_resource('static/js/mentoring-table.js'))
fragment.add_css_url(self.runtime.local_resource_url(self.xblock_container,
'public/css/mentoring-table.css'))
fragment.add_javascript_url(self.runtime.local_resource_url(self.xblock_container,
'public/js/vendor/jquery.shorten.js'))
fragment.add_javascript_url(self.runtime.local_resource_url(self.xblock_container,
'public/js/mentoring-table.js'))
fragment.initialize_js('MentoringTableBlock')
return fragment
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment