Merge pull request #13664 from edx/andya/common-refactoring
Move pipeline_js Django app into CMS
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
## This file is designed to load all the XModule Javascript files in one wad
|
||||
## using requirejs. It is passed through the Mako template system, which
|
||||
## populates the `urls` variable with a list of paths to XModule JS files.
|
||||
## These files assume that several libraries are available and bound to
|
||||
## variables in the global context, so we load those libraries with requirejs
|
||||
## and attach them to the global context manually.
|
||||
define(["jquery", "underscore", "codemirror", "tinymce",
|
||||
"jquery.tinymce", "jquery.qtip", "jquery.scrollTo", "jquery.flot",
|
||||
"jquery.cookie", "pretty-print", "utility"],
|
||||
function($, _, CodeMirror) {
|
||||
window.$ = $;
|
||||
window._ = _;
|
||||
require(['mathjax']);
|
||||
window.CodeMirror = CodeMirror;
|
||||
window.RequireJS = {
|
||||
'requirejs': requirejs,
|
||||
'require': require,
|
||||
'define': define
|
||||
};
|
||||
/**
|
||||
* Loads all modules one-by-one in exact order.
|
||||
* The module should be used until we'll use RequireJS for XModules.
|
||||
* @param {Array} modules A list of urls.
|
||||
* @return {jQuery Promise}
|
||||
**/
|
||||
var requireQueue = function(modules) {
|
||||
var deferred = $.Deferred();
|
||||
var loadScript = function (queue) {
|
||||
// Loads the next script if queue is not empty.
|
||||
if (queue.length) {
|
||||
require([queue.shift()], function() {
|
||||
loadScript(queue);
|
||||
});
|
||||
} else {
|
||||
deferred.resolve();
|
||||
}
|
||||
};
|
||||
|
||||
loadScript(modules.concat());
|
||||
return deferred.promise();
|
||||
};
|
||||
|
||||
return requireQueue(${urls});
|
||||
});
|
||||
@@ -1,11 +0,0 @@
|
||||
"""
|
||||
URL patterns for Javascript files used to load all of the XModule JS in one wad.
|
||||
"""
|
||||
from django.conf.urls import url, patterns
|
||||
|
||||
urlpatterns = patterns(
|
||||
'pipeline_js.views',
|
||||
|
||||
url(r'^files\.json$', 'xmodule_js_files', name='xmodule_js_files'),
|
||||
url(r'^xmodule\.js$', 'requirejs_xmodule', name='requirejs_xmodule'),
|
||||
)
|
||||
@@ -1,41 +0,0 @@
|
||||
"""
|
||||
Views for returning XModule JS (used by requirejs)
|
||||
"""
|
||||
import json
|
||||
from django.conf import settings
|
||||
from django.http import HttpResponse
|
||||
from django.contrib.staticfiles.storage import staticfiles_storage
|
||||
from edxmako.shortcuts import render_to_response
|
||||
|
||||
|
||||
def get_xmodule_urls():
|
||||
"""
|
||||
Returns a list of the URLs to hit to grab all the XModule JS
|
||||
"""
|
||||
if settings.DEBUG:
|
||||
paths = [path.replace(".coffee", ".js") for path in
|
||||
settings.PIPELINE_JS['module-js']['source_filenames']]
|
||||
else:
|
||||
paths = [settings.PIPELINE_JS['module-js']['output_filename']]
|
||||
return [staticfiles_storage.url(path) for path in paths]
|
||||
|
||||
|
||||
def xmodule_js_files(request):
|
||||
"""
|
||||
View function that returns XModule URLs as a JSON list; meant to be used
|
||||
as an API
|
||||
"""
|
||||
urls = get_xmodule_urls()
|
||||
return HttpResponse(json.dumps(urls), content_type="application/json")
|
||||
|
||||
|
||||
def requirejs_xmodule(request):
|
||||
"""
|
||||
View function that returns a requirejs-wrapped Javascript file that
|
||||
loads all the XModule URLs; meant to be loaded via requireJS
|
||||
"""
|
||||
return render_to_response(
|
||||
"xmodule.js",
|
||||
{"urls": get_xmodule_urls()},
|
||||
content_type="text/javascript",
|
||||
)
|
||||
Reference in New Issue
Block a user