diff options
Diffstat (limited to 'src/SMAPI.Web')
-rw-r--r-- | src/SMAPI.Web/ViewModels/ModListModel.cs | 2 | ||||
-rw-r--r-- | src/SMAPI.Web/ViewModels/ModModel.cs | 4 | ||||
-rw-r--r-- | src/SMAPI.Web/Views/Mods/Index.cshtml | 11 | ||||
-rw-r--r-- | src/SMAPI.Web/wwwroot/Content/css/mods.css | 4 |
4 files changed, 18 insertions, 3 deletions
diff --git a/src/SMAPI.Web/ViewModels/ModListModel.cs b/src/SMAPI.Web/ViewModels/ModListModel.cs index ff7513bc..6b8279c1 100644 --- a/src/SMAPI.Web/ViewModels/ModListModel.cs +++ b/src/SMAPI.Web/ViewModels/ModListModel.cs @@ -26,7 +26,7 @@ namespace StardewModdingAPI.Web.ViewModels public bool IsStale { get; set; } /// <summary>Whether the mod metadata is available.</summary> - public bool HasData => this.Mods != null; + public bool HasData => this.Mods?.Any() == true; /********* diff --git a/src/SMAPI.Web/ViewModels/ModModel.cs b/src/SMAPI.Web/ViewModels/ModModel.cs index 56316ab7..45b12397 100644 --- a/src/SMAPI.Web/ViewModels/ModModel.cs +++ b/src/SMAPI.Web/ViewModels/ModModel.cs @@ -22,6 +22,9 @@ namespace StardewModdingAPI.Web.ViewModels /// <summary>The mod author's alternative names, if any.</summary> public string AlternateAuthors { get; set; } + /// <summary>The GitHub repo, if any.</summary> + public string GitHubRepo { get; set; } + /// <summary>The URL to the mod's source code, if any.</summary> public string SourceUrl { get; set; } @@ -62,6 +65,7 @@ namespace StardewModdingAPI.Web.ViewModels this.AlternateNames = string.Join(", ", entry.Name.Skip(1).ToArray()); this.Author = entry.Author.FirstOrDefault(); this.AlternateAuthors = string.Join(", ", entry.Author.Skip(1).ToArray()); + this.GitHubRepo = entry.GitHubRepo; this.SourceUrl = this.GetSourceUrl(entry); this.Compatibility = new ModCompatibilityModel(entry.Compatibility); this.BetaCompatibility = entry.BetaCompatibility != null ? new ModCompatibilityModel(entry.BetaCompatibility) : null; diff --git a/src/SMAPI.Web/Views/Mods/Index.cshtml b/src/SMAPI.Web/Views/Mods/Index.cshtml index f9835d36..842a1e03 100644 --- a/src/SMAPI.Web/Views/Mods/Index.cshtml +++ b/src/SMAPI.Web/Views/Mods/Index.cshtml @@ -1,6 +1,7 @@ @using Humanizer @using Humanizer.Localisation @using StardewModdingAPI.Web.Framework +@using StardewModdingAPI.Web.ViewModels @model StardewModdingAPI.Web.ViewModels.ModListModel @{ ViewData["Title"] = "Mod compatibility"; @@ -15,7 +16,7 @@ <script src="~/Content/js/mods.js?r=20200218"></script> <script> $(function() { - var data = @this.ForJson(Model.Mods); + var data = @this.ForJson(Model.Mods ?? new ModModel[0]); var enableBeta = @this.ForJson(Model.BetaVersion != null); smapi.modList(data, enableBeta); }); @@ -103,7 +104,13 @@ else </td> <td class="mod-broke-in" v-html="mod.LatestCompatibility.BrokeIn" v-show="showAdvanced"></td> <td v-show="showAdvanced"> - <span v-if="mod.SourceUrl"><a v-bind:href="mod.SourceUrl">source</a></span> + <span v-if="mod.SourceUrl"> + <a v-bind:href="mod.SourceUrl">source</a> + <span v-if="mod.GitHubRepo"> + @* see https://shields.io/category/license *@ + (<img v-bind:src="'http://img.shields.io/github/license/' + mod.GitHubRepo + '?style=flat-square.png&label='" class="license-badge" alt="source" />) + </span> + </span> <span v-else class="mod-closed-source">no source</span> </td> <td> diff --git a/src/SMAPI.Web/wwwroot/Content/css/mods.css b/src/SMAPI.Web/wwwroot/Content/css/mods.css index 697ba514..4f6578cb 100644 --- a/src/SMAPI.Web/wwwroot/Content/css/mods.css +++ b/src/SMAPI.Web/wwwroot/Content/css/mods.css @@ -153,3 +153,7 @@ table.wikitable > caption { #mod-list td.smapi-3-col span { border-bottom: 1px dashed gray; } + +#mod-list .license-badge { + vertical-align: middle; +} |