From b84ca6d84fc7635b42e518dec66fc00cc205633f Mon Sep 17 00:00:00 2001 From: Alek Ratzloff Date: Fri, 29 Jul 2022 19:59:10 -0700 Subject: [PATCH] Add Youtube embeds This will embed a youtube video inline on the page. Hopefully it works! Signed-off-by: Alek Ratzloff --- board/static/board/post.js | 21 +++++++++++++++++++++ board/static/board/style.css | 3 +++ board/templatetags/post_body.py | 23 ++++++++++++++++++++--- tests/test_replybuilder.py | 12 ++++++++++++ 4 files changed, 56 insertions(+), 3 deletions(-) diff --git a/board/static/board/post.js b/board/static/board/post.js index 53228cb..4fea7bd 100644 --- a/board/static/board/post.js +++ b/board/static/board/post.js @@ -345,6 +345,27 @@ $(window).on("load", () => { $(e.target).attr("src", thumbUrl); } }); + + $(".youtube_embed_link").on("click", (e) => { + e.preventDefault(); + let fullEnt = $(e.target).parents(".youtube_embed"); + let frame = fullEnt.find(".youtube_embed_frame"); + if (frame.length) { + frame.remove(); + } else { + let hash = $(e.target).attr("data-yt-hash"); + let embed = $("") + .attr("class", "youtube_embed_frame") + .append("
") + .append( + $("