From d49eb880115fefae406edfdf38fbff54acf8ba44 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 29 Mar 2018 00:43:31 -0400 Subject: show game path on log parser page instead of mods path --- src/SMAPI.Web/Framework/LogParsing/LogParser.cs | 1 + src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs | 3 +++ 2 files changed, 4 insertions(+) (limited to 'src/SMAPI.Web/Framework') diff --git a/src/SMAPI.Web/Framework/LogParsing/LogParser.cs b/src/SMAPI.Web/Framework/LogParsing/LogParser.cs index 9e44f163..f49fb05c 100644 --- a/src/SMAPI.Web/Framework/LogParsing/LogParser.cs +++ b/src/SMAPI.Web/Framework/LogParsing/LogParser.cs @@ -135,6 +135,7 @@ namespace StardewModdingAPI.Web.Framework.LogParsing { Match match = this.ModPathPattern.Match(message.Text); log.ModPath = match.Groups["path"].Value; + log.GamePath = new FileInfo(log.ModPath).Directory.FullName; } // log UTC timestamp line diff --git a/src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs b/src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs index a82b6a1b..87b20eb0 100644 --- a/src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs +++ b/src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs @@ -32,6 +32,9 @@ namespace StardewModdingAPI.Web.Framework.LogParsing.Models /// The player's operating system. public string OperatingSystem { get; set; } + /// The game install path. + public string GamePath { get; set; } + /// The mod folder path. public string ModPath { get; set; } -- cgit From 22965604bfa5858a089d842173cdebe6aaed0ed8 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 9 Apr 2018 19:30:17 -0400 Subject: add support for build message URLs (#471) --- src/SMAPI.ModBuildConfig/build/smapi.targets | 2 +- .../Framework/RewriteRules/RedirectToUrlRule.cs | 20 ++++++++------------ src/SMAPI.Web/Startup.cs | 1 + 3 files changed, 10 insertions(+), 13 deletions(-) (limited to 'src/SMAPI.Web/Framework') diff --git a/src/SMAPI.ModBuildConfig/build/smapi.targets b/src/SMAPI.ModBuildConfig/build/smapi.targets index d2e37101..a177840c 100644 --- a/src/SMAPI.ModBuildConfig/build/smapi.targets +++ b/src/SMAPI.ModBuildConfig/build/smapi.targets @@ -142,7 +142,7 @@ - + diff --git a/src/SMAPI.Web/Framework/RewriteRules/RedirectToUrlRule.cs b/src/SMAPI.Web/Framework/RewriteRules/RedirectToUrlRule.cs index 0719e311..4bae0b4c 100644 --- a/src/SMAPI.Web/Framework/RewriteRules/RedirectToUrlRule.cs +++ b/src/SMAPI.Web/Framework/RewriteRules/RedirectToUrlRule.cs @@ -12,11 +12,8 @@ namespace StardewModdingAPI.Web.Framework.RewriteRules /********* ** Properties *********/ - /// A predicate which indicates when the rule should be applied. - private readonly Func ShouldRewrite; - - /// The new URL to which to redirect. - private readonly string NewUrl; + /// Get the new URL to which to redirect (or null to skip). + private readonly Func NewUrl; /********* @@ -27,8 +24,7 @@ namespace StardewModdingAPI.Web.Framework.RewriteRules /// The new URL to which to redirect. public RedirectToUrlRule(Func shouldRewrite, string url) { - this.ShouldRewrite = shouldRewrite ?? (req => true); - this.NewUrl = url; + this.NewUrl = req => shouldRewrite(req) ? url : null; } /// Construct an instance. @@ -37,8 +33,7 @@ namespace StardewModdingAPI.Web.Framework.RewriteRules public RedirectToUrlRule(string pathRegex, string url) { Regex regex = new Regex(pathRegex, RegexOptions.IgnoreCase | RegexOptions.Compiled); - this.ShouldRewrite = req => req.Path.HasValue && regex.IsMatch(req.Path.Value); - this.NewUrl = url; + this.NewUrl = req => req.Path.HasValue ? regex.Replace(req.Path.Value, url) : null; } /// Applies the rule. Implementations of ApplyRule should set the value for (defaults to RuleResult.ContinueRules). @@ -47,14 +42,15 @@ namespace StardewModdingAPI.Web.Framework.RewriteRules { HttpRequest request = context.HttpContext.Request; - // check condition - if (!this.ShouldRewrite(request)) + // check rewrite + string newUrl = this.NewUrl(request); + if (newUrl == null || newUrl == request.Path.Value) return; // redirect request HttpResponse response = context.HttpContext.Response; response.StatusCode = (int)HttpStatusCode.Redirect; - response.Headers["Location"] = this.NewUrl; + response.Headers["Location"] = newUrl; context.Result = RuleResult.EndResponse; } } diff --git a/src/SMAPI.Web/Startup.cs b/src/SMAPI.Web/Startup.cs index 47102e5c..6c7ccecd 100644 --- a/src/SMAPI.Web/Startup.cs +++ b/src/SMAPI.Web/Startup.cs @@ -155,6 +155,7 @@ namespace StardewModdingAPI.Web // shortcut redirects redirects.Add(new RedirectToUrlRule(@"^/compat\.?$", "https://stardewvalleywiki.com/Modding:SMAPI_compatibility")); redirects.Add(new RedirectToUrlRule(@"^/docs\.?$", "https://stardewvalleywiki.com/Modding:Index")); + redirects.Add(new RedirectToUrlRule(@"^/buildmsg(?:/?(.*))$", "https://github.com/Pathoschild/SMAPI/blob/develop/docs/mod-build-config.md#$1")); // redirect legacy canimod.com URLs var wikiRedirects = new Dictionary -- cgit From 2d47e479a5e48a575db3ca9998653c0435419440 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 11 Apr 2018 19:55:01 -0400 Subject: fix draft releases being detected as update candidates --- docs/release-notes.md | 1 + src/SMAPI.Web/Framework/Clients/GitHub/GitHubClient.cs | 2 +- src/SMAPI.Web/Framework/Clients/GitHub/GitRelease.cs | 4 ++++ src/SMAPI.Web/appsettings.json | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src/SMAPI.Web/Framework') diff --git a/docs/release-notes.md b/docs/release-notes.md index a5bd205f..e68720da 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -22,6 +22,7 @@ * Fixed mod not loaded if it has an optional dependency that's loaded but skipped. * Fixed mod update alerts not shown if one mod has an invalid remote version. * Fixed SMAPI update alerts linking to the GitHub repository instead of [smapi.io](https://smapi.io). + * Fixed SMAPI update alerts for draft releases. * Fixed error when two content packs use different capitalisation for the same required mod ID. * Fixed rare crash if the game duplicates an item. diff --git a/src/SMAPI.Web/Framework/Clients/GitHub/GitHubClient.cs b/src/SMAPI.Web/Framework/Clients/GitHub/GitHubClient.cs index 4abe0737..2cfc6903 100644 --- a/src/SMAPI.Web/Framework/Clients/GitHub/GitHubClient.cs +++ b/src/SMAPI.Web/Framework/Clients/GitHub/GitHubClient.cs @@ -59,7 +59,7 @@ namespace StardewModdingAPI.Web.Framework.Clients.GitHub GitRelease[] results = await this.Client .GetAsync(string.Format(this.AnyReleaseUrlFormat, repo)) .AsArray(); - return results.FirstOrDefault(); + return results.FirstOrDefault(p => !p.IsDraft); } return await this.Client diff --git a/src/SMAPI.Web/Framework/Clients/GitHub/GitRelease.cs b/src/SMAPI.Web/Framework/Clients/GitHub/GitRelease.cs index 827374fb..d0db5297 100644 --- a/src/SMAPI.Web/Framework/Clients/GitHub/GitRelease.cs +++ b/src/SMAPI.Web/Framework/Clients/GitHub/GitRelease.cs @@ -19,6 +19,10 @@ namespace StardewModdingAPI.Web.Framework.Clients.GitHub /// The Markdown description for the release. public string Body { get; set; } + /// Whether this is a draft version. + [JsonProperty("draft")] + public bool IsDraft { get; set; } + /// Whether this is a prerelease version. [JsonProperty("prerelease")] public bool IsPrerelease { get; set; } diff --git a/src/SMAPI.Web/appsettings.json b/src/SMAPI.Web/appsettings.json index 03ca31ed..095707a8 100644 --- a/src/SMAPI.Web/appsettings.json +++ b/src/SMAPI.Web/appsettings.json @@ -25,7 +25,7 @@ "GitHubBaseUrl": "https://api.github.com", "GitHubStableReleaseUrlFormat": "repos/{0}/releases/latest", - "GitHubAnyReleaseUrlFormat": "repos/{0}/releases?per_page=1", + "GitHubAnyReleaseUrlFormat": "repos/{0}/releases?per_page=2", // allow for draft release (only visible if GitHub repo is owned by same account as the update check credentials) "GitHubAcceptHeader": "application/vnd.github.v3+json", "GitHubUsername": null, // see top note "GitHubPassword": null, // see top note -- cgit