fallback gracefully, break build if videos can't embed
This commit is contained in:
parent
93bdf1e91e
commit
d7c7775b6c
3 changed files with 24 additions and 6 deletions
|
|
@ -215,7 +215,7 @@ module ApplicationHelper
|
|||
else
|
||||
title = I18n.t 'application.helper.video_title.unknown'
|
||||
end
|
||||
' <a class="video-link" data-host="youtube.com" data-video-id="' + video_id + '" href="'+ match_data[0].strip + '">Youtube: ' + title + '</a>'
|
||||
' <a class="video-link" data-host="youtube.com" data-video-id="' + video_id + '" href="http://'+ match_data[0].strip + '" target="_blank">Youtube: ' + title + '</a>'
|
||||
end
|
||||
return processed_message
|
||||
end
|
||||
|
|
@ -262,7 +262,7 @@ module ApplicationHelper
|
|||
else
|
||||
title = I18n.t 'application.helper.video_title.unknown'
|
||||
end
|
||||
' <a class="video-link" data-host="vimeo.com" data-video-id="' + video_id + '" href="' + match_data[0] + '">Vimeo: ' + title + '</a>'
|
||||
' <a class="video-link" data-host="vimeo.com" data-video-id="' + video_id + '" href="http://' + match_data[0] + '" target="_blank">Vimeo: ' + title + '</a>'
|
||||
end
|
||||
return processed_message
|
||||
end
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
var service = $this.data("host"),
|
||||
container = document.createElement("div"),
|
||||
$container = $(container).attr("class", "video-container"),
|
||||
$videoContainer = $this.siblings(".video-container");
|
||||
$videoContainer = $this.closest(".from").siblings(".video-container");
|
||||
|
||||
if($videoContainer.length) {
|
||||
$videoContainer.slideUp("fast", function() { $(this).detach(); });
|
||||
|
|
@ -40,7 +40,7 @@
|
|||
);
|
||||
|
||||
$container.hide()
|
||||
.insertBefore($this.siblings(".info"))
|
||||
.insertBefore($this.closest(".from").siblings(".info"))
|
||||
.slideDown('fast');
|
||||
|
||||
$this.click(function() {
|
||||
|
|
@ -53,6 +53,12 @@
|
|||
Embedder.prototype.start = function() {
|
||||
$(".stream").delegate("a.video-link", "click", this.onVideoLinkClicked);
|
||||
this.registerServices();
|
||||
|
||||
var $post = $("#main_stream").children(".stream_element:first"),
|
||||
$contentParagraph = $post.children(".content").children(".from").children("p"),
|
||||
$infoDiv = $contentParagraph.closest(".from").siblings(".info");
|
||||
|
||||
this.canEmbed = $infoDiv.length;
|
||||
};
|
||||
|
||||
Embedder.prototype.registerServices = function() {
|
||||
|
|
@ -70,8 +76,10 @@
|
|||
};
|
||||
|
||||
Embedder.prototype.onVideoLinkClicked = function(evt) {
|
||||
evt.preventDefault();
|
||||
Diaspora.widgets.embedder.embed($(this));
|
||||
if(this.canEmbed) {
|
||||
evt.preventDefault();
|
||||
Diaspora.widgets.embedder.embed($(this));
|
||||
}
|
||||
};
|
||||
|
||||
Diaspora.widgets.add("embedder", Embedder);
|
||||
|
|
|
|||
|
|
@ -45,6 +45,16 @@ describe("Diaspora", function() {
|
|||
expect($.fn.delegate).toHaveBeenCalledWith("a.video-link", "click", Diaspora.widgets.embedder.onVideoLinkClicked);
|
||||
});
|
||||
});
|
||||
|
||||
it("has to have a certain DOM structure", function() {
|
||||
spec.loadFixture("aspects_index");
|
||||
|
||||
var $post = $("#main_stream").children(".stream_element:first"),
|
||||
$contentParagraph = $post.children(".content").children(".from").children("p"),
|
||||
$infoDiv = $contentParagraph.closest(".from").siblings(".info");
|
||||
|
||||
expect($infoDiv.length).toEqual(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue