diff --git a/src/Umbraco.Web/Editors/HelpController.cs b/src/Umbraco.Web/Editors/HelpController.cs deleted file mode 100644 index e21238cb20..0000000000 --- a/src/Umbraco.Web/Editors/HelpController.cs +++ /dev/null @@ -1,163 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; -using System.Web.Http; -using Umbraco.Core; -using Umbraco.Core.Configuration; -using Umbraco.Web.WebApi.Filters; -using Umbraco.Core.Cache; -using Umbraco.Core.Logging; - -namespace Umbraco.Web.Editors -{ - public class HelpController : UmbracoAuthorizedJsonController - { - - /// - /// Fetches available lessons for a given section from our.umbaco.org - /// - /// Name of the documentation section to fetch from, ex: "getting-started", "getting-started/backoffice" - /// The url to retrieve from, by default https://our.umbraco.org - /// - [ValidateAngularAntiForgeryToken] - public async Task> GetLessons(string path, string baseUrl = "https://our.umbraco.org") - { - //We need the umbraco context to fetch the currrent user and version - var context = UmbracoContext; - - //this only works in the context of a umbraco backoffice request - if (context == null) - throw new HttpResponseException(HttpStatusCode.InternalServerError); - - //information for the request, so we could in the future filter by user, allowed sections, langugae and user-type - var user = Security.CurrentUser; - var userType = user.UserType.Alias; - var allowedSections = string.Join(",", user.AllowedSections); - var language = user.Language; - var version = UmbracoVersion.GetSemanticVersion().ToSemanticString(); - - //construct the url and cache key - var url = string.Format(baseUrl + "/Umbraco/Documentation/Lessons/GetDocsForPath?path={0}&userType={1}&allowedSections={2}&lang={3}&version={4}", path, userType, allowedSections, language, version); - var key = "umbraco-lessons-" + userType + language + allowedSections.Replace(",", "-") + path; - - //try and find an already cached version of this request - var content = ApplicationContext.ApplicationCache.RuntimeCache.GetCacheItem>(key); - - - var result = new List(); - if (content != null) - { - result = content; - } - else - { - //content is null, go get it - try - { - using (var web = new HttpClient()) - { - //fetch dashboard json and parse to JObject - var json = await web.GetStringAsync(url); - result = JsonConvert.DeserializeObject>(json).ToList(); - } - - ApplicationContext.ApplicationCache.RuntimeCache.InsertCacheItem>(key, () => result, new TimeSpan(0, 30, 0)); - } - catch (HttpRequestException ex) - { - LogHelper.Debug(string.Format("Error getting lesson content from '{0}': {1}\n{2}", url, ex.Message, ex.InnerException)); - - //it's still new JObject() - we return it like this to avoid error codes which triggers UI warnings - ApplicationContext.ApplicationCache.RuntimeCache.InsertCacheItem>(key, () => result, new TimeSpan(0, 5, 0)); - } - } - - return result; - } - - [ValidateAngularAntiForgeryToken] - public async Task> GetLessonSteps(string path, string baseUrl = "https://our.umbraco.org") - { - var url = string.Format(baseUrl + "/Umbraco/Documentation/Lessons/GetStepsForPath?path={0}", path); - using (var web = new HttpClient()) - { - //fetch dashboard json and parse to JObject - var json = await web.GetStringAsync(url); - return JsonConvert.DeserializeObject>(json); - } - - - } - - 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 = "lesson")] - public class Lesson - { - [DataMember(Name = "name")] - public string Name { get; set; } - - [DataMember(Name = "path")] - public string Path { get; set; } - - [DataMember(Name = "level")] - public string Level { get; set; } - - [DataMember(Name = "url")] - public string Url { get; set; } - - [DataMember(Name = "directories")] - public IEnumerable Directories { get; set; } - } - - - [DataContract(Name = "LesssonStep")] - public class LessonStep - { - [DataMember(Name = "name")] - public string Name { get; set; } - - [DataMember(Name = "content")] - public string Content { get; set; } - - } - - [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 417b6ac184..c86b86db30 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -323,7 +323,6 @@ -