Skip to content

Commit

Permalink
support nico video for the submission encode embed link field
Browse files Browse the repository at this point in the history
  • Loading branch information
adelikat committed Oct 15, 2023
1 parent e77463f commit 8e1c91b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
11 changes: 11 additions & 0 deletions TASVideos/Pages/Shared/_NicoEmbed.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@model string
@{
var code = Model.Split('/').Last();
var embedLink = $"//embed.nicovideo.jp/watch/{code}";
var fullLink = $"//www.nicovideo.jp/watch/{code}";
}
<div>
<iframe src="@embedLink" style="width: 728px; height: 410px;" allowfullscreen="true" type="text/html" class="mw-100"></iframe>
<br />
<a href="@fullLink" rel="nofollow" target="_blank">(Link to video)</a>
</div>
5 changes: 4 additions & 1 deletion TASVideos/Pages/Submissions/View.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
? "https://i.ytimg.com/vi/" + Model.Submission.EncodeEmbedLink.Split('/').Last() + "/hqdefault.jpg"
: null;

var isNicoEmbed = hasEncode && Model.Submission.EncodeEmbedLink!.Contains("nicovideo");

ViewData.SetMetaTags(new MetaTagModel
{
Title = Model.Submission.Title,
Expand Down Expand Up @@ -60,7 +62,8 @@

<row class="mt-2">
<div class="col-lg-6" condition="hasEncode">
<partial name="_YoutubeEmbed" model="Model.Submission.EncodeEmbedLink" />
<partial condition="!isNicoEmbed" name="_YoutubeEmbed" model="Model.Submission.EncodeEmbedLink" />
<partial condition="isNicoEmbed" name="_NicoEmbed" model="Model.Submission.EncodeEmbedLink" />
</div>
<div class="@(hasEncode ? "col-lg-6" : "col-lg-12")">
<div class="alert alert-@(statusColor)" role="alert">
Expand Down
3 changes: 3 additions & 0 deletions TASVideos/TASVideos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@
<Content Update="Pages\Shared\Components\FirstEditionTas\Default.cshtml">
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Pages\Shared\_NicoEmbed.cshtml">
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
<Content Update="Pages\Shared\_YoutubeEmbed.cshtml">
<Pack>$(IncludeRazorContentInPack)</Pack>
</Content>
Expand Down

0 comments on commit 8e1c91b

Please sign in to comment.