Support links to video hosts other than YouTube

This commit is contained in:
rubenwardy 2022-01-25 22:13:48 +00:00
parent 8f2a87e5ed
commit e20863a7e1
8 changed files with 22 additions and 10 deletions

@ -89,7 +89,7 @@ Tokens can be attained by visiting [Settings > API Tokens](/user/tokens/).
* `website`: Website URL.
* `issue_tracker`: Issue tracker URL.
* `forums`: forum topic ID.
* `video_url`: URL to a video, YouTube only for now.
* `video_url`: URL to a video.
* GET `/api/packages/<username>/<name>/dependencies/`
* Returns dependencies, with suggested candidates
* If query argument `only_hard` is present, only hard deps will be returned.

@ -61,7 +61,7 @@ It should be a JSON dictionary with one or more of the following optional keys:
* `website`: Website URL.
* `issue_tracker`: Issue tracker URL.
* `forums`: forum topic ID.
* `video_url`: URL to a video, YouTube only for now.
* `video_url`: URL to a video.
Use `null` to unset fields where relevant.

@ -131,9 +131,7 @@ def do_edit_package(user: User, package: Package, was_new: bool, was_web: bool,
data["media_license"] = get_license(data["media_license"])
if "video_url" in data:
data["video_url"] = clean_youtube_url(data["video_url"])
if data["video_url"] is None:
raise LogicError(400, lazy_gettext("Video URL is not a YouTube video URL"))
data["video_url"] = clean_youtube_url(data["video_url"]) or data["video_url"]
for key in ["name", "title", "short_desc", "desc", "type", "dev_state", "license", "media_license",
"repo", "website", "issueTracker", "forums", "video_url"]:

@ -24,6 +24,8 @@ document.querySelectorAll(".video-embed").forEach(ele => {
ele.setAttribute("data-src", href);
ele.removeAttribute("href");
ele.querySelector(".label").innerText = "YouTube";
}
} catch (e) {
console.error(url);

@ -47,11 +47,12 @@
background: #111;
position: relative;
display: flex !important;
flex-direction: column !important;
align-items: center !important;
justify-content: center !important;
cursor: pointer;
.fas {
.fa-play {
display: block;
font-size: 200%;
color: #f44;
@ -60,10 +61,18 @@
&:hover {
background: #191919;
.fas {
.fa-play {
color: red;
}
}
.label {
position: absolute;
top: 0.25rem;
right: 0.5rem;
color: #555;
font-size: 80%;
}
}
.screenshot-add {

@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}title{% endblock %} - {{ config.USER_APP_NAME }}</title>
<link rel="stylesheet" type="text/css" href="/static/libs/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/static/custom.css?v=33">
<link rel="stylesheet" type="text/css" href="/static/custom.css?v=34">
<link rel="search" type="application/opensearchdescription+xml" href="/static/opensearch.xml" title="ContentDB" />
<link rel="shortcut icon" href="/favicon-16.png" sizes="16x16">
<link rel="icon" href="/favicon-128.png" sizes="128x128">

@ -117,7 +117,7 @@
pattern="[0-9]+",
prefix="forum.minetest.net/viewtopic.php?t=",
placeholder=_("Tip: paste in a forum topic URL")) }}
{{ render_field(form.video_url, class_="pkg_meta", hint=_("Only supports YouTube, for now")) }}
{{ render_field(form.video_url, class_="pkg_meta", hint=_("YouTube videos will be shown in an embed.")) }}
</fieldset>
<div class="pkg_meta mt-5">{{ render_submit_field(form.submit) }}</div>

@ -252,8 +252,11 @@
<ul class="gallery">
{% if package.video_url %}
<li>
<a href="{{ package.video_url }}" class="video-embed" title="{{ _('YouTube video embed') }}">
<a href="{{ package.video_url }}" class="video-embed">
<i class="fas fa-play"></i>
<div class="label">
<i class="fas fa-external-link-square-alt"></i>
</div>
</a>
</li>
{% endif %}