From 7fd6155807c7129f26afbcc9a26c92d98e2ba4ae Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Tue, 10 Oct 2017 16:05:21 +0100 Subject: [PATCH] Bit too aggressive with the C# cleanup - adds back in HelpController but just with the method that is needed to load the videos in the help section --- .../Editors/BackOfficeServerVariables.cs | 4 ++ src/Umbraco.Web/Editors/HelpController.cs | 43 +++++++++++++++++++ src/Umbraco.Web/Umbraco.Web.csproj | 1 + 3 files changed, 48 insertions(+) create mode 100644 src/Umbraco.Web/Editors/HelpController.cs diff --git a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs index 3b185ef4b1..6d69310434 100644 --- a/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs +++ b/src/Umbraco.Web/Editors/BackOfficeServerVariables.cs @@ -260,6 +260,10 @@ namespace Umbraco.Web.Editors { "codeFileApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( controller => controller.GetByPath("", "")) + }, + { + "helpApiBaseUrl", _urlHelper.GetUmbracoApiServiceBaseUrl( + controller => controller.GetContextHelpForPage("","","")) } } }, diff --git a/src/Umbraco.Web/Editors/HelpController.cs b/src/Umbraco.Web/Editors/HelpController.cs new file mode 100644 index 0000000000..7cb393aed6 --- /dev/null +++ b/src/Umbraco.Web/Editors/HelpController.cs @@ -0,0 +1,43 @@ +using Newtonsoft.Json; +using System.Collections.Generic; +using System.Net.Http; +using System.Runtime.Serialization; +using System.Threading.Tasks; + +namespace Umbraco.Web.Editors +{ + public class HelpController : UmbracoAuthorizedJsonController + { + public async Task> GetContextHelpForPage(string section, string tree, string baseUrl = "https://our.umbraco.org") + { + var url = string.Format(baseUrl + "/Umbraco/Documentation/Lessons/GetContextHelpDocs?sectionAlias={0}&treeAlias={1}", section, tree); + using (var web = new HttpClient()) + { + //fetch dashboard json and parse to JObject + var json = await web.GetStringAsync(url); + var result = JsonConvert.DeserializeObject>(json); + if (result != null) + return result; + + return new List(); + } + } + } + + [DataContract(Name = "HelpPage")] + public class HelpPage + { + [DataMember(Name = "name")] + public string Name { get; set; } + + [DataMember(Name = "description")] + public string Description { get; set; } + + [DataMember(Name = "url")] + public string Url { get; set; } + + [DataMember(Name = "type")] + public string Type { get; set; } + + } +} diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index c86b86db30..417b6ac184 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -323,6 +323,7 @@ +