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

Hotfix/release multiple video bug #850

Closed
wants to merge 6 commits into from
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
2 changes: 1 addition & 1 deletion cms/templates/import.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ <h2>${_("Course to import:")}</h2>
add: function(e, data) {
submitBtn.unbind('click');
var file = data.files[0];
if (file.type == "application/x-gzip") {
if (file.name.match(/tar\.gz$/)) {
submitBtn.click(function(e){
e.preventDefault();
submitBtn.hide();
Expand Down
7 changes: 7 additions & 0 deletions common/lib/capa/capa/capa_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,13 @@ def _extract_html(self, problemtree): # private

Used by get_html.
'''
if not isinstance(problemtree.tag, basestring):
# Comment and ProcessingInstruction nodes are not Elements,
# and we're ok leaving those behind.
# BTW: etree gives us no good way to distinguish these things
# other than to examine .tag to see if it's a string. :(
return

if (problemtree.tag == 'script' and problemtree.get('type')
and 'javascript' in problemtree.get('type')):
# leave javascript intact.
Expand Down
20 changes: 20 additions & 0 deletions common/lib/capa/capa/tests/test_html_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,26 @@ def test_substitute_python_vars(self):
span_element = rendered_html.find('span')
self.assertEqual(span_element.get('attr'), "TEST")

def test_xml_comments_and_other_odd_things(self):
# Comments and processing instructions should be skipped.
xml_str = textwrap.dedent("""\
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html [
<!ENTITY % wacky "lxml.etree is wacky!">
]>
<problem>
<!-- A commment. -->
<?ignore this processing instruction. ?>
</problem>
""")

# Create the problem
problem = new_loncapa_problem(xml_str)

# Render the HTML
the_html = problem.get_html()
self.assertRegexpMatches(the_html, r"<div>\s+</div>")

def _create_test_file(self, path, content_str):
test_fp = self.system.filestore.open(path, "w")
test_fp.write(content_str)
Expand Down
27 changes: 27 additions & 0 deletions common/lib/xmodule/xmodule/css/video/display.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ div.video {
padding-bottom: 56.25%;
position: relative;

div {
&.hidden {
display: none;
}
}

object, iframe {
border: none;
height: 100%;
Expand All @@ -48,6 +54,15 @@ div.video {
top: 0;
width: 100%;
}

h3 {
text-align: center;
color: white;

&.hidden {
display: none;
}
}
}

section.video-controls {
Expand Down Expand Up @@ -516,6 +531,12 @@ div.video {
height: 0px;
}

article.video-wrapper section.video-player {
h3 {
color: black;
}
}

ol.subtitles {
width: 0;
height: 0;
Expand Down Expand Up @@ -563,6 +584,12 @@ div.video {
position: static;
}

article.video-wrapper section.video-player {
h3 {
color: white;
}
}

div.tc-wrapper {
@include clearfix;
display: table;
Expand Down
2 changes: 2 additions & 0 deletions common/lib/xmodule/xmodule/js/fixtures/video.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
data-end=""
data-caption-asset-path="/static/subs/"
data-autoplay="False"
data-yt-test-timeout="1500"
data-yt-test-url="https://gdata.youtube.com/feeds/api/videos/"
>
<div class="tc-wrapper">
<article class="video-wrapper">
Expand Down
4 changes: 3 additions & 1 deletion common/lib/xmodule/xmodule/js/fixtures/video_all.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
data-webm-source="test_files/test.webm"
data-ogg-source="test_files/test.ogv"
data-autoplay="False"
data-yt-test-timeout="1500"
data-yt-test-url="https://gdata.youtube.com/feeds/api/videos/"
>
<div class="tc-wrapper">
<article class="video-wrapper">
Expand Down Expand Up @@ -55,4 +57,4 @@ <h3>Speed</h3>
</div>
</div>
</div>
</div>
</div>
4 changes: 3 additions & 1 deletion common/lib/xmodule/xmodule/js/fixtures/video_html5.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
data-webm-source="test_files/test.webm"
data-ogg-source="test_files/test.ogv"
data-autoplay="False"
data-yt-test-timeout="1500"
data-yt-test-url="https://gdata.youtube.com/feeds/api/videos/"
>
<div class="tc-wrapper">
<article class="video-wrapper">
Expand All @@ -27,4 +29,4 @@
</div>
</div>
</div>
</div>
</div>
2 changes: 2 additions & 0 deletions common/lib/xmodule/xmodule/js/fixtures/video_no_captions.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
data-end=""
data-caption-asset-path="/static/subs/"
data-autoplay="False"
data-yt-test-timeout="1500"
data-yt-test-url="https://gdata.youtube.com/feeds/api/videos/"
>
<div class="tc-wrapper">
<article class="video-wrapper">
Expand Down
16 changes: 14 additions & 2 deletions common/lib/xmodule/xmodule/js/spec/helper.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,24 @@ jasmine.stubbedHtml5Speeds = ['0.75', '1.0', '1.25', '1.50']
jasmine.stubRequests = ->
spyOn($, 'ajax').andCallFake (settings) ->
if match = settings.url.match /youtube\.com\/.+\/videos\/(.+)\?v=2&alt=jsonc/
if settings.success
status = match[1].split('_')
if status and status[0] is 'status'
{
always: (callback) ->
callback.call(window, {}, status[1])
error: (callback) ->
callback.call(window, {}, status[1])
done: (callback) ->
callback.call(window, {}, status[1])
}
else if settings.success
# match[1] - it's video ID
settings.success data: jasmine.stubbedMetadata[match[1]]
else {
always: (callback) ->
callback.call(window, {}, 'success');
callback.call(window, {}, 'success')
done: (callback) ->
callback.call(window, {}, 'success')
}
else if match = settings.url.match /static(\/.*)?\/subs\/(.+)\.srt\.sjson/
settings.success jasmine.stubbedCaption
Expand Down
60 changes: 16 additions & 44 deletions common/lib/xmodule/xmodule/js/spec/video/general_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,46 +55,6 @@
expect(this.state.speed).toEqual('0.75');
});
});

describe('Check Youtube link existence', function () {
var statusList = {
error: 'html5',
timeout: 'html5',
abort: 'html5',
parsererror: 'html5',
success: 'youtube',
notmodified: 'youtube'
};

function stubDeffered(data, status) {
return {
always: function(callback) {
callback.call(window, data, status);
}
}
}

function checkPlayer(videoType, data, status) {
this.state = new window.Video('#example');
spyOn(this.state , 'getVideoMetadata')
.andReturn(stubDeffered(data, status));
this.state.initialize('#example');

expect(this.state.videoType).toEqual(videoType);
}

it('if video id is incorrect', function () {
checkPlayer('html5', { error: {} }, 'success');
});

$.each(statusList, function(status, mode){
it('Status:' + status + ', mode:' + mode, function () {
checkPlayer(mode, {}, status);
});
});

});

});

describe('HTML5', function () {
Expand Down Expand Up @@ -154,10 +114,22 @@

it('parse Html5 sources', function () {
var html5Sources = {
mp4: 'test_files/test.mp4',
webm: 'test_files/test.webm',
ogg: 'test_files/test.ogv'
};
mp4: null,
webm: null,
ogg: null
}, v = document.createElement('video');

if (!!(v.canPlayType && v.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/no/, ''))) {
html5Sources['webm'] = 'xmodule/include/fixtures/test.webm';
}

if (!!(v.canPlayType && v.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"').replace(/no/, ''))) {
html5Sources['mp4'] = 'xmodule/include/fixtures/test.mp4';
}

if (!!(v.canPlayType && v.canPlayType('video/ogg; codecs="theora"').replace(/no/, ''))) {
html5Sources['ogg'] = 'xmodule/include/fixtures/test.ogv';
}

expect(state.html5Sources).toEqual(html5Sources);
});
Expand Down
Loading