diff --git a/PluginBuilder/Views/Home/GetPluginDetails.cshtml b/PluginBuilder/Views/Home/GetPluginDetails.cshtml index 5f17f31..1048589 100644 --- a/PluginBuilder/Views/Home/GetPluginDetails.cshtml +++ b/PluginBuilder/Views/Home/GetPluginDetails.cshtml @@ -2,23 +2,17 @@ @using PluginBuilder.APIModels @using PluginBuilder.Controllers @using PluginBuilder.DataModels -@using PluginBuilder.Services -@using System.Text.RegularExpressions -@inject GitHostingProviderFactory GitHostingProviderFactory @model PluginDetailsViewModel @{ Layout = "_LayoutPublicModal"; var desc = string.IsNullOrWhiteSpace(Model.Plugin.Description) ? "Plugin for BTCPay Server" : Model.Plugin.Description; ViewData["Title"] = Model.Plugin.PluginTitle + " - " + desc; - var owner = Model.Plugin.GetOwnerName(GitHostingProviderFactory); - var ownerProfileUrl = Model.Plugin.GetOwnerProfileUrl(GitHostingProviderFactory); + var owner = Model.Plugin.GetGithubRepository()?.Owner; var dependencies = Model.Plugin.ManifestInfo?["Dependencies"] as JArray; - - var sourceUrl = Model.Plugin.GetSourceUrl(GitHostingProviderFactory); - var pluginUrl = Url.Action(nameof(HomeController.GetPluginDetails), "Home", new { pluginSlug = Model.Plugin.ProjectSlug }, - Context.Request.Scheme, Context.Request.Host.ToString()); - + var sourceUrl = Model.Plugin.GetGithubRepository()?.GetSourceUrl(Model.Plugin.BuildInfo?["gitCommit"]?.ToString(), Model.Plugin.BuildInfo?["pluginDir"]?.ToString()); + var pluginUrl = Url.Action(nameof(HomeController.GetPluginDetails), "Home", new { pluginSlug = Model.Plugin.ProjectSlug }, Context.Request.Scheme, Context.Request.Host.ToString()); var currentRating = Model.RatingFilter; + DateTimeOffset.TryParse(Model.Plugin.BuildInfo?["buildDate"]?.ToString(), out var buildDate); } @section Meta { @@ -35,7 +29,6 @@ - } @@ -51,7 +44,7 @@
-
+
@@ -61,698 +54,464 @@ @if (!string.IsNullOrWhiteSpace(owner)) { - by @if (!string.IsNullOrWhiteSpace(ownerProfileUrl)) {@owner} else {@owner} + by@owner @if (!string.IsNullOrWhiteSpace(Model.OwnerGithubUrl)) { - - - - + + } - @if (!string.IsNullOrWhiteSpace(Model.OwnerNostrUrl)) { - - - - + + } }
- Download
-
-
-
-
-
-
-

Description

-

@Model.Plugin.Description

-
-
+
+
+
+
+

Description

+

@Model.Plugin.Description

+
+
- @{ - var videoEmbedUrl = Model.Plugin.VideoUrl.GetVideoEmbedUrl(); - var videoThumbUrl = Model.Plugin.VideoUrl.GetVideoThumbnailUrl(); - var screenshots = Model.Plugin.Images?.Where(s => !string.IsNullOrWhiteSpace(s)).ToList() ?? new List(); - var mediaItems = new List<(bool IsVideo, string MediaUrl, string? ThumbUrl, string SlideAlt, string ThumbAriaLabel, string ThumbAlt)>(); + @{ + var videoEmbedUrl = Model.Plugin.VideoUrl.GetVideoEmbedUrl(); + var videoThumbUrl = Model.Plugin.VideoUrl.GetVideoThumbnailUrl(); + var screenshots = Model.Plugin.Images?.Where(s => !string.IsNullOrWhiteSpace(s)).ToList() ?? new List(); + var mediaItems = new List<(bool IsVideo, string MediaUrl, string? ThumbUrl, string Alt, string ThumbLabel)>(); - if (!string.IsNullOrWhiteSpace(videoEmbedUrl)) - { - mediaItems.Add(( - true, - videoEmbedUrl, - videoThumbUrl, - "Plugin video", - "Show video", - "Video thumbnail" - )); - } + if (!string.IsNullOrWhiteSpace(videoEmbedUrl)) + mediaItems.Add((true, videoEmbedUrl, videoThumbUrl, "Plugin video", "Show video")); - for (var i = 0; i < screenshots.Count; i++) - { - var screenshot = screenshots[i]; - mediaItems.Add(( - false, - screenshot, - screenshot, - $"{Model.Plugin.PluginTitle} screenshot {i + 1}", - $"Show screenshot {i + 1}", - $"Screenshot thumbnail {i + 1}" - )); - } - - var hasMedia = mediaItems.Count > 0; - } - @if (hasMedia) - { -
-
-

Media

- -
-
- } - -
-
-
-

Reviews

- - Write a review - -
- -
- @for (var star = 5; star >= 1; star--) + for (var i = 0; i < screenshots.Count; i++) + mediaItems.Add((false, screenshots[i], screenshots[i], $"{Model.Plugin.PluginTitle} screenshot {i + 1}", $"Show screenshot {i + 1}")); + } + @if (mediaItems.Any()) + { +
+
+

Media

+ +
+
+ } - var voted = review.UserVoteHelpful; - var upClass = $"{helpfulBaseBtn} vote-up {(voted == true ? "text-success" : "text-secondary")}"; - var downClass = $"{helpfulBaseBtn} vote-down {(voted == false ? "text-danger" : "text-secondary")}"; +
+
+
+

Reviews

+ Write a review +
-
-
-
+
+ @for (var star = 5; star >= 1; star--) + { + var count = Model.Plugin.RatingSummary?.StarCounts?.GetValueOrDefault(star) ?? 0; + var pct = Model.Plugin.RatingSummary?.StarPct?.GetValueOrDefault(star) ?? 0; + var isActive = currentRating == star; + +
+ @star★ +
+
+
+ @count +
+
+ } +
-
- @if (!string.IsNullOrEmpty(review.AuthorAvatarUrl)) - { - @review.AuthorDisplay avatar - } - @if (!string.IsNullOrEmpty(review.AuthorUrl)) - { - @review.AuthorDisplay - } - else - { - @review.AuthorDisplay - } + @if (currentRating is not null) + { +
+ Filtering by @currentRating★ +
+ } - @review.CreatedAt.ToString("MMM dd, yyyy") +
+ +
- @if (!string.IsNullOrEmpty(review.PluginVersion)) - { - @review.PluginVersion - } -
- -
- @for (var i = 1; i <= 5; i++) - { - + @if (!Model.Reviews.Any()) + { +
+ No reviews yet. Be the first to write one. +
+ } + else + { + @foreach (var review in Model.Reviews) + { + const string voteBtn = "btn btn-link btn-sm p-0 align-middle d-inline-flex align-items-center"; +
+
+
+
+ @if (!string.IsNullOrEmpty(review.AuthorAvatarUrl)) + { + @review.AuthorDisplay avatar + } + @if (!string.IsNullOrEmpty(review.AuthorUrl)) + { + @review.AuthorDisplay + } + else + { + @review.AuthorDisplay + } + @review.CreatedAt.ToString("MMM dd, yyyy") + @if (!string.IsNullOrEmpty(review.PluginVersion)) + { + @review.PluginVersion + } +
+
+ @for (var i = 1; i <= 5; i++) + { + - } -
-
- -
- @if (review.IsReviewOwner) - { - - - @review.UpCount - - - - @review.DownCount - - } - else - { - -
- @Html.AntiForgeryToken() - -
- - -
- @Html.AntiForgeryToken() - -
- } -
-
- -
-
- @if (!string.IsNullOrWhiteSpace(review.Body)) - { - - } -
- - @if (review.IsReviewOwner || Model.IsAdmin) - { - }
- } - } - - -
- - - @if (User.Identity?.IsAuthenticated == true) - { - if (Model.IsOwner == true) - { -
- Owners can’t review their own plugin. +
+ @if (review.IsReviewOwner) + { + + @review.UpCount + + + @review.DownCount + + } + else + { +
+ @Html.AntiForgeryToken() + +
+
+ @Html.AntiForgeryToken() + +
+ }
- } - else - { -
- @Html.AntiForgeryToken() - -
-
-
- @for (var i = 1; i <= 5; i++) - { - - } - -
-
- -
-
- -
- -
-
-
-
- - - - } - } - else - { -
- Please sign in to - write a review.
- } + +
+
+ @if (!string.IsNullOrWhiteSpace(review.Body)) + { + + } +
+ @if (review.IsReviewOwner || Model.IsAdmin) + { + + } +
+
+ } + } + + +
+ + + @if (User.Identity?.IsAuthenticated == true) + { + @if (Model.IsOwner == true) + { +
Owners can't review their own plugin.
+ } + else + { +
+ @Html.AntiForgeryToken() +
+ @for (var i = 1; i <= 5; i++) + { + + } + +
+ + + + } + } + else + { +
+ Please sign in to write a review.
-
-
- -
- - - @if (Model.Contributors is List contributors && contributors.Any()) - { -
-
-

Contributors

-
- @foreach (var user in contributors) - { -
-
- @if (!string.IsNullOrEmpty(user.AvatarUrl)) - { - @user.Login avatar - } - else - { -
- @user.Login?.FirstOrDefault() -
- } -
-
- @if (!string.IsNullOrEmpty(user.HtmlUrl)) - { - @user.Login - } - else - { - @user.Login - } -
-
- } -
-
-
- } + }
-
+
+ + + @if (Model.Contributors?.Any() == true) + { +
+
+

Contributors

+
+ @foreach (var user in Model.Contributors) + { +
+
+ @user.Login avatar +
+ +
+ } +
+
+
+ } +
+
+ - -