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
|
else
|
||||||
title = I18n.t 'application.helper.video_title.unknown'
|
title = I18n.t 'application.helper.video_title.unknown'
|
||||||
end
|
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
|
end
|
||||||
return processed_message
|
return processed_message
|
||||||
end
|
end
|
||||||
|
|
@ -262,7 +262,7 @@ module ApplicationHelper
|
||||||
else
|
else
|
||||||
title = I18n.t 'application.helper.video_title.unknown'
|
title = I18n.t 'application.helper.video_title.unknown'
|
||||||
end
|
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
|
end
|
||||||
return processed_message
|
return processed_message
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
var service = $this.data("host"),
|
var service = $this.data("host"),
|
||||||
container = document.createElement("div"),
|
container = document.createElement("div"),
|
||||||
$container = $(container).attr("class", "video-container"),
|
$container = $(container).attr("class", "video-container"),
|
||||||
$videoContainer = $this.siblings(".video-container");
|
$videoContainer = $this.closest(".from").siblings(".video-container");
|
||||||
|
|
||||||
if($videoContainer.length) {
|
if($videoContainer.length) {
|
||||||
$videoContainer.slideUp("fast", function() { $(this).detach(); });
|
$videoContainer.slideUp("fast", function() { $(this).detach(); });
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
$container.hide()
|
$container.hide()
|
||||||
.insertBefore($this.siblings(".info"))
|
.insertBefore($this.closest(".from").siblings(".info"))
|
||||||
.slideDown('fast');
|
.slideDown('fast');
|
||||||
|
|
||||||
$this.click(function() {
|
$this.click(function() {
|
||||||
|
|
@ -53,6 +53,12 @@
|
||||||
Embedder.prototype.start = function() {
|
Embedder.prototype.start = function() {
|
||||||
$(".stream").delegate("a.video-link", "click", this.onVideoLinkClicked);
|
$(".stream").delegate("a.video-link", "click", this.onVideoLinkClicked);
|
||||||
this.registerServices();
|
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() {
|
Embedder.prototype.registerServices = function() {
|
||||||
|
|
@ -70,8 +76,10 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
Embedder.prototype.onVideoLinkClicked = function(evt) {
|
Embedder.prototype.onVideoLinkClicked = function(evt) {
|
||||||
|
if(this.canEmbed) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
Diaspora.widgets.embedder.embed($(this));
|
Diaspora.widgets.embedder.embed($(this));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Diaspora.widgets.add("embedder", Embedder);
|
Diaspora.widgets.add("embedder", Embedder);
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,16 @@ describe("Diaspora", function() {
|
||||||
expect($.fn.delegate).toHaveBeenCalledWith("a.video-link", "click", Diaspora.widgets.embedder.onVideoLinkClicked);
|
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