Skip to content
Merged
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
1,521 changes: 512 additions & 1,009 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,11 @@ def is_requirement(line):
# so edx-platform natively discovers the templates/ directory.
"lms.djangoapp": [
"xblocks_contrib_problem_capa = xblocks_contrib.problem.capa.apps:CapaAppConfig",
"xblocks_contrib_discussion = xblocks_contrib.discussion.apps:DiscussionAppConfig",
],
"cms.djangoapp": [
"xblocks_contrib_problem_capa = xblocks_contrib.problem.capa.apps:CapaAppConfig",
"xblocks_contrib_discussion = xblocks_contrib.discussion.apps:DiscussionAppConfig",
],
},
)
53 changes: 53 additions & 0 deletions xblocks_contrib/discussion/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""
Django App configuration for the xblocks-contrib Discussion XBlock.
"""

from django.apps import AppConfig


class DiscussionAppConfig(AppConfig):
"""
Configuration for the Discussion XBlock Django application.

Why are we registering this as a Django App?
--------------------------------------------
By default, Django's template engine (specifically the `app_directories` loader)
only discovers `templates/` folders that belong to an app listed in `INSTALLED_APPS`.

Since XBlocks are inherently isolated components, they are not typically added
to the LMS/CMS global `INSTALLED_APPS`. As a result, any standard Django templates
(.html files) inside this block would be invisible to the core Open edX platform
when it attempts to route or render them natively.

Instead of forcing repository consumers to manually modify `lms/envs/common.py`
or use deployment-specific Tutor plugins to append to `TEMPLATES['DIRS']`, we
leverage the Open edX Django App Plugin Framework (`plugin_app`). This hook
dynamically injects this module into `INSTALLED_APPS` at runtime.

This automatically exposes our `templates/` directory to the platform natively
without manual intervention.

References:

- Open edX Plugin App Framework:
https://docs.openedx.org/projects/edx-django-utils/en/latest/plugins/how_tos/how_to_create_a_plugin_app.html

- Django App Directories Loader:
https://docs.djangoproject.com/en/stable/ref/templates/api/#django.template.loaders.app_directories.Loader

"""

name = "xblocks_contrib.discussion"
label = "xblocks_contrib_discussion"
verbose_name = "XBlocks Contrib - Discussion Templates"

plugin_app = {
"settings_config": {
"lms.djangoapp": {
"default": "",
},
"cms.djangoapp": {
"default": "",
},
},
}
12 changes: 12 additions & 0 deletions xblocks_contrib/discussion/assets/jasmine.common.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* eslint-env node */

'use strict';

// By default, fixtures are loaded from spec/javascripts/fixtures but in karma everything gets served from /base
jasmine.getFixtures().fixturesPath = '/base/static/spec/fixtures/';

// https://github.com/edx/js-test-tool/blob/master/js_test_tool/templates/jasmine_test_runner.html#L10
// Stub out modal dialog alerts, which will prevent
// us from accessing the test results in the DOM
window.confirm = function() { return true; };
window.alert = function() { };
112 changes: 112 additions & 0 deletions xblocks_contrib/discussion/assets/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/* eslint-env node */
'use strict';

const path = require('path');

const discussionRoot = __dirname;
const uiToolkitRoot = path.dirname(require.resolve('edx-ui-toolkit/package.json'));

module.exports = function (config) {
config.set({
basePath: discussionRoot,

frameworks: ['jasmine'],

files: [
{ pattern: require.resolve('jquery/dist/jquery.js'), included: true },
{ pattern: require.resolve('jasmine-jquery/lib/jasmine-jquery.js'), included: true },
{ pattern: require.resolve('underscore/underscore.js'), included: true },
{ pattern: require.resolve('backbone/backbone.js'), included: true },
{ pattern: path.join(uiToolkitRoot, 'src/js/utils/global-loader.js'), included: true },
{ pattern: path.join(uiToolkitRoot, 'src/js/utils/string-utils.js'), included: true },
{ pattern: path.join(uiToolkitRoot, 'src/js/utils/html-utils.js'), included: true },
{ pattern: 'static/spec/spec_helpers/i18n.js', included: true },
{ pattern: 'jasmine.common.conf.js', included: true },
{ pattern: require.resolve('draggabilly/dist/draggabilly.pkgd.js'), included: true },
{ pattern: 'static/js/vendor/URI.min.js', included: true },
{ pattern: 'static/js/vendor/jquery.leanModal.js', included: true },
{ pattern: 'static/js/vendor/Markdown.Converter.js', included: true },
{ pattern: 'static/js/vendor/Markdown.Sanitizer.js', included: true },
{ pattern: 'static/js/vendor/Markdown.Editor.js', included: true },
{ pattern: 'static/js/vendor/jquery.ajaxfileupload.js', included: true },
{ pattern: 'static/js/vendor/jquery.timeago.js', included: true },
{ pattern: 'static/js/vendor/jquery.truncate.js', included: true },
{ pattern: 'static/js/vendor/split.js', included: true },
{ pattern: 'static/js/mathjax_accessible.js', included: true },
{ pattern: 'static/js/mathjax_delay_renderer.js', included: true },
{ pattern: 'static/js/common/utils.js', included: true },
{ pattern: 'static/js/common/models/*.js', included: true },
{ pattern: 'static/js/common/content.js', included: true },
{ pattern: 'static/js/common/discussion.js', included: true },
{ pattern: 'static/js/common/mathjax_include.js', included: true },
{ pattern: 'static/js/customwmd.js', included: true },
{ pattern: 'static/js/common/views/*.js', included: true },
{ pattern: 'static/spec/spec_helpers/discussion_spec_helper.js', included: true },
{ pattern: 'static/spec/view/discussion_view_spec_helper.js', included: true },
{ pattern: 'static/spec/fixtures/**/*', included: false, served: true },
{ pattern: 'static/spec/**/*_spec.js', included: true }
],

exclude: [
'**/public/**'
],

preprocessors: {
'static/js/**/*.js': ['sourcemap'],
'static/spec/view/discussion_thread_view_spec.js': ['regex', 'sourcemap'],
'static/spec/**/*.js': ['sourcemap']
},

regexPreprocessor: {
rules: [
{
fileName: 'discussion_thread_view_spec.js',
replacement: [
{ replace: /return function\(\) \{\s*/g, with: '' },
{ replace: / \};\s*\n \}\);\s*\n describe\('thread responses'/g, with: ' });\n describe(\'thread responses\'' }
]
}
]
},

plugins: [
'karma-regex-preprocessor',
'karma-jasmine',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-sourcemap-loader',
'karma-coverage',
require('karma-spec-reporter')
],

reporters: ['spec', 'coverage'],

coverageReporter: {
dir: 'coverage/',
reporters: [
{ type: 'html', subdir: 'report-html' },
{ type: 'lcov', subdir: 'report-lcov' }
]
},

port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ['FirefoxNoUpdates'],

customLaunchers: {
FirefoxNoUpdates: {
base: 'Firefox',
prefs: {
'app.update.auto': false,
'app.update.enabled': false
}
}
},

singleRun: true,
concurrency: Infinity,
client: { captureConsole: true }
});
};
33 changes: 33 additions & 0 deletions xblocks_contrib/discussion/assets/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"private": true,
"scripts": {
"build": "webpack --config webpack.prod.config.js",
"build-dev": "webpack --config webpack.dev.config.js",
"test": "karma start karma.conf.js",
"test-ci": "xvfb-run --auto-servernum karma start karma.conf.js"
},
"devDependencies": {
"backbone": "^1",
"backbone-associations": "^0.6",
"backbone.paginator": "^2",
"append-prepend-loader": "^1.0.0",
"copy-webpack-plugin": "13.0.1",
"imports-loader": "^0.8",
"webpack": "^5",
"webpack-cli": "^5",
"draggabilly": "^3.0.0",
"edx-ui-toolkit": "^1",
"jasmine-core": "2.6.4",
"jasmine-jquery": "git+https://git@github.com/velesin/jasmine-jquery.git#ebad463d592d3fea00c69f26ea18a930e09c7b58",
"jquery": "^2",
"karma": "^0.13",
"karma-chrome-launcher": "^3",
"karma-coverage": "^2",
"karma-firefox-launcher": "^2",
"karma-jasmine": "^0.3",
"karma-regex-preprocessor": "^1.0.1",
"karma-sourcemap-loader": "^0.4.0",
"karma-spec-reporter": "0.0.20",
"underscore": "^1"
}
}
Loading
Loading