From 492a3e5a8d5bffd42f5b6a13b701d22e913b9a7f Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Sun, 4 Jun 2017 16:07:14 +0100 Subject: [PATCH 01/13] Init API Controller to Query partial part of the MD Docs tree & WIP for the markdown alt template --- OurUmbraco.Site/OurUmbraco.Site.csproj | 1 + OurUmbraco.Site/Views/Lesson.cshtml | 12 ++++ .../GithubSourcePull/ZipDownloader.cs | 23 ++++--- .../Busineslogic/MarkdownLogic.cs | 7 ++ .../Controllers/LessonsController.cs | 64 +++++++++++++++++++ OurUmbraco/OurUmbraco.csproj | 1 + 6 files changed, 96 insertions(+), 12 deletions(-) create mode 100644 OurUmbraco.Site/Views/Lesson.cshtml create mode 100644 OurUmbraco/Documentation/Controllers/LessonsController.cs diff --git a/OurUmbraco.Site/OurUmbraco.Site.csproj b/OurUmbraco.Site/OurUmbraco.Site.csproj index dfa78ab7..8832f0d9 100644 --- a/OurUmbraco.Site/OurUmbraco.Site.csproj +++ b/OurUmbraco.Site/OurUmbraco.Site.csproj @@ -4330,6 +4330,7 @@ + web.config diff --git a/OurUmbraco.Site/Views/Lesson.cshtml b/OurUmbraco.Site/Views/Lesson.cshtml new file mode 100644 index 00000000..45c70b7a --- /dev/null +++ b/OurUmbraco.Site/Views/Lesson.cshtml @@ -0,0 +1,12 @@ +@using OurUmbraco.Documentation.Busineslogic +@inherits Umbraco.Web.Mvc.UmbracoTemplatePage +@{ + Layout = null; + + var path = HttpContext.Current.Items[MarkdownLogic.MarkdownPathKey].ToString(); + var ml = new MarkdownLogic(path) { PrefixLinks = false, AppendAltLessonLink = false }; + var markdown = ml.DoTransformation(); +} + + +@Html.Raw(markdown) \ No newline at end of file diff --git a/OurUmbraco/Documentation/Busineslogic/GithubSourcePull/ZipDownloader.cs b/OurUmbraco/Documentation/Busineslogic/GithubSourcePull/ZipDownloader.cs index 1a99b169..2ffd7916 100644 --- a/OurUmbraco/Documentation/Busineslogic/GithubSourcePull/ZipDownloader.cs +++ b/OurUmbraco/Documentation/Busineslogic/GithubSourcePull/ZipDownloader.cs @@ -112,12 +112,11 @@ namespace OurUmbraco.Documentation.Busineslogic.GithubSourcePull FireOnFinish(finishEventArgs); } - public dynamic DocumentationSiteMap(string folder = "") + public SiteMapItem DocumentationSiteMap(string folder = "") { var path = Path.Combine(RootFolder, folder, "sitemap.js"); var json = File.ReadAllText(path); - dynamic documentationSiteMap = JsonConvert.DeserializeObject(json); - return documentationSiteMap; + return JsonConvert.DeserializeObject(json); } public void Process(string url, string foldername) @@ -143,13 +142,13 @@ namespace OurUmbraco.Documentation.Busineslogic.GithubSourcePull public void BuildSitemap(string foldername) { var folder = new DirectoryInfo(Path.Combine(RootFolder, foldername)); - dynamic root = GetFolderStructure(folder, folder.FullName, 0); + var root = GetFolderStructure(folder, folder.FullName, 0); var serializedRoot = JsonConvert.SerializeObject(root, Newtonsoft.Json.Formatting.Indented); File.WriteAllText(Path.Combine(folder.FullName, "sitemap.js"), serializedRoot); } - private class SiteMapItem + public class SiteMapItem { public string name { get; set; } public string path { get; set; } @@ -157,28 +156,28 @@ namespace OurUmbraco.Documentation.Busineslogic.GithubSourcePull public int sort { get; set; } public bool hasChildren { get; set; } public List directories { get; set; } + public string url => $"https://our.umbraco.org/documentation{this.path}?altTemplate=Lesson"; } private SiteMapItem GetFolderStructure(DirectoryInfo dir, string rootPath, int level) { + var list = new List(); + var siteMapItem = new SiteMapItem { name = dir.Name.Replace("-", " "), path = dir.FullName.Substring(rootPath.Length).Replace('\\', '/'), level = level, - sort = GetSort(dir.Name, level) ?? 100 + sort = GetSort(dir.Name, level) ?? 100, + directories = list, + hasChildren = dir.GetDirectories().Any() }; - - if (dir.GetDirectories().Any() == false) - return siteMapItem; - - var list = new List(); + foreach (var child in dir.GetDirectories().Where(x => x.Name != "images")) { list.Add(GetFolderStructure(child, rootPath, level + 1)); } - siteMapItem.hasChildren = true; siteMapItem.directories = list.OrderBy(x => x.sort).ToList(); return siteMapItem; diff --git a/OurUmbraco/Documentation/Busineslogic/MarkdownLogic.cs b/OurUmbraco/Documentation/Busineslogic/MarkdownLogic.cs index daab6610..67485cb5 100644 --- a/OurUmbraco/Documentation/Busineslogic/MarkdownLogic.cs +++ b/OurUmbraco/Documentation/Busineslogic/MarkdownLogic.cs @@ -11,6 +11,7 @@ namespace OurUmbraco.Documentation.Busineslogic public MarkdownLogic(string filePath) { _filePath = filePath; + AppendAltLessonLink = false; } public const string VersionSession = "DocumentationVersion"; @@ -28,6 +29,8 @@ namespace OurUmbraco.Documentation.Busineslogic public bool PrefixLinks { get; set; } + public bool AppendAltLessonLink { get; set; } + public string DoTransformation() { if (File.Exists(_filePath)) @@ -79,6 +82,10 @@ namespace OurUmbraco.Documentation.Busineslogic else mdUrlTag.TrimEnd('/'); + if (AppendAltLessonLink) + { + return mdUrlTag.Replace(rawUrl, $"{rawUrl.EnsureNoDotsInUrl()}?altTemplate=Lesson"); + } return mdUrlTag.Replace(rawUrl, rawUrl.EnsureNoDotsInUrl()); } diff --git a/OurUmbraco/Documentation/Controllers/LessonsController.cs b/OurUmbraco/Documentation/Controllers/LessonsController.cs new file mode 100644 index 00000000..8d537282 --- /dev/null +++ b/OurUmbraco/Documentation/Controllers/LessonsController.cs @@ -0,0 +1,64 @@ +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; +using OurUmbraco.Documentation.Busineslogic.GithubSourcePull; +using OurUmbraco.Documentation.Models; +using Umbraco.Core; +using Umbraco.Web.Mvc; +using Umbraco.Web.WebApi; + +namespace OurUmbraco.Documentation.Controllers +{ + [PluginController("Documentation")] + public class LessonsController : UmbracoApiController + { + /// + /// + /// + /// The path in the documentation folder structure that you wish to start from & list descendants + /// Future Use: Backoffice Usertype requesting lessons + /// Future Use: AllowedSections of BackOffice User + /// Future Use: Backoffice Users langunage + /// Umbraco CMS Version as a string + /// + /// A partial part of the documentation tree, that lists out folders + /// This is used in the new Starter Kit in conjuction with 'Lessons' + /// + public List GetDocsForPath(string path, string userType, string allowedSections, string lang, string version) + { + //Ensure path is not null & empty + if (string.IsNullOrEmpty(path)) + { + var resp = new HttpResponseMessage(HttpStatusCode.BadRequest) + { + Content = new StringContent("Path varibale is null or empty"), + ReasonPhrase = "Documentation Path is invalid" + }; + + throw new HttpResponseException(resp); + } + + //Get the documentation Sitemap JS file that lives on disk everytime we fetch & unpack the markdown docs from GitHub + var docs = new ZipDownloader(); + + //Note: For now the folder param is NOT the folder/subtree but where the JSON file is stored to build up this model + var allDocs = docs.DocumentationSiteMap(); + + + //Split path and ensure we can find each part of the path + //In the array of nested objects + var pathArray = path.Split('/').Where(x => string.IsNullOrEmpty(x) == false).ToArray(); + var currentDirectory = allDocs; + + for (int i = 0; i < pathArray.Length; i++) + { + var pathPart = "/" + string.Join("/", pathArray.Take(i + 1)); + currentDirectory = currentDirectory.directories.First(x => x.path == pathPart); + } + + return currentDirectory.directories; + } + } +} diff --git a/OurUmbraco/OurUmbraco.csproj b/OurUmbraco/OurUmbraco.csproj index 3250b40b..90461fef 100644 --- a/OurUmbraco/OurUmbraco.csproj +++ b/OurUmbraco/OurUmbraco.csproj @@ -401,6 +401,7 @@ + From 706c793cc258983abb3d0ca1f29184daeaa1caa6 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Sun, 4 Jun 2017 16:38:01 +0100 Subject: [PATCH 02/13] Ensure we do not append the altLink to any images as it blows up if we do --- OurUmbraco.Site/Views/Lesson.cshtml | 3 ++- OurUmbraco/Documentation/Busineslogic/MarkdownLogic.cs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/OurUmbraco.Site/Views/Lesson.cshtml b/OurUmbraco.Site/Views/Lesson.cshtml index 45c70b7a..19f21cab 100644 --- a/OurUmbraco.Site/Views/Lesson.cshtml +++ b/OurUmbraco.Site/Views/Lesson.cshtml @@ -4,7 +4,8 @@ Layout = null; var path = HttpContext.Current.Items[MarkdownLogic.MarkdownPathKey].ToString(); - var ml = new MarkdownLogic(path) { PrefixLinks = false, AppendAltLessonLink = false }; + var ml = new MarkdownLogic(path) { PrefixLinks = false, AppendAltLessonLink = true }; + var markdown = ml.DoTransformation(); } diff --git a/OurUmbraco/Documentation/Busineslogic/MarkdownLogic.cs b/OurUmbraco/Documentation/Busineslogic/MarkdownLogic.cs index 67485cb5..87606103 100644 --- a/OurUmbraco/Documentation/Busineslogic/MarkdownLogic.cs +++ b/OurUmbraco/Documentation/Busineslogic/MarkdownLogic.cs @@ -82,7 +82,8 @@ namespace OurUmbraco.Documentation.Busineslogic else mdUrlTag.TrimEnd('/'); - if (AppendAltLessonLink) + //Need to ensure we dont append the image links as they 404 if we add altTemplate + if (AppendAltLessonLink && rawUrl.StartsWith("images/") == false) { return mdUrlTag.Replace(rawUrl, $"{rawUrl.EnsureNoDotsInUrl()}?altTemplate=Lesson"); } From 284ca67dd3ad1b82f0d284f3dbef9c823c3b7e20 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Sun, 4 Jun 2017 16:40:51 +0100 Subject: [PATCH 03/13] Adds trailing slash to ensure all links work as expected when we start off at index.md --- .../Busineslogic/GithubSourcePull/ZipDownloader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OurUmbraco/Documentation/Busineslogic/GithubSourcePull/ZipDownloader.cs b/OurUmbraco/Documentation/Busineslogic/GithubSourcePull/ZipDownloader.cs index 2ffd7916..f881ac9a 100644 --- a/OurUmbraco/Documentation/Busineslogic/GithubSourcePull/ZipDownloader.cs +++ b/OurUmbraco/Documentation/Busineslogic/GithubSourcePull/ZipDownloader.cs @@ -156,7 +156,7 @@ namespace OurUmbraco.Documentation.Busineslogic.GithubSourcePull public int sort { get; set; } public bool hasChildren { get; set; } public List directories { get; set; } - public string url => $"https://our.umbraco.org/documentation{this.path}?altTemplate=Lesson"; + public string url => $"https://our.umbraco.org/documentation{this.path}/?altTemplate=Lesson"; } private SiteMapItem GetFolderStructure(DirectoryInfo dir, string rootPath, int level) From 768525a0c7afbb5283ca60c6358790d508ed4f30 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Sun, 4 Jun 2017 16:54:25 +0100 Subject: [PATCH 04/13] Ensure we sort by the super magical switch sort int property on the object --- OurUmbraco/Documentation/Controllers/LessonsController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OurUmbraco/Documentation/Controllers/LessonsController.cs b/OurUmbraco/Documentation/Controllers/LessonsController.cs index 8d537282..3600d95d 100644 --- a/OurUmbraco/Documentation/Controllers/LessonsController.cs +++ b/OurUmbraco/Documentation/Controllers/LessonsController.cs @@ -58,7 +58,7 @@ namespace OurUmbraco.Documentation.Controllers currentDirectory = currentDirectory.directories.First(x => x.path == pathPart); } - return currentDirectory.directories; + return currentDirectory.directories.OrderBy(x=> x.sort).ToList(); } } } From 614c4f2d368a5fcb9e33881fc794c69820430480 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Sun, 4 Jun 2017 17:25:24 +0100 Subject: [PATCH 05/13] Super basic CSS styling --- OurUmbraco.Site/Views/Lesson.cshtml | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/OurUmbraco.Site/Views/Lesson.cshtml b/OurUmbraco.Site/Views/Lesson.cshtml index 19f21cab..fcd249a3 100644 --- a/OurUmbraco.Site/Views/Lesson.cshtml +++ b/OurUmbraco.Site/Views/Lesson.cshtml @@ -9,5 +9,31 @@ var markdown = ml.DoTransformation(); } + + + + + + + + +
+ @Html.Raw(markdown) +
+ + -@Html.Raw(markdown) \ No newline at end of file From dfb728655f1dcae1f9114b0e4f50897e60ba218a Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Sun, 4 Jun 2017 19:58:10 +0100 Subject: [PATCH 06/13] Tiny CSS changes --- OurUmbraco.Site/Views/Lesson.cshtml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/OurUmbraco.Site/Views/Lesson.cshtml b/OurUmbraco.Site/Views/Lesson.cshtml index fcd249a3..1de8ce25 100644 --- a/OurUmbraco.Site/Views/Lesson.cshtml +++ b/OurUmbraco.Site/Views/Lesson.cshtml @@ -21,13 +21,28 @@ code { background-color: #eeeeee; - display: block; padding: 5px; } + pre { + word-wrap: break-word; + white-space: pre-wrap; + } + + pre > code { + display: block; + } + img { max-width: 90%; } + + blockquote { + border-left: 4px solid #ddd; + padding: 0 15px; + color: #777; + margin: 0; + } From 25858eb870d2d72a5b074794e3077a5948352b17 Mon Sep 17 00:00:00 2001 From: Per Ploug Date: Sun, 4 Jun 2017 20:58:28 +0200 Subject: [PATCH 07/13] added method for pulling steps for lessons --- .../Controllers/LessonsController.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/OurUmbraco/Documentation/Controllers/LessonsController.cs b/OurUmbraco/Documentation/Controllers/LessonsController.cs index 3600d95d..fb802499 100644 --- a/OurUmbraco/Documentation/Controllers/LessonsController.cs +++ b/OurUmbraco/Documentation/Controllers/LessonsController.cs @@ -8,6 +8,8 @@ using OurUmbraco.Documentation.Models; using Umbraco.Core; using Umbraco.Web.Mvc; using Umbraco.Web.WebApi; +using System.Web; +using OurUmbraco.Documentation.Busineslogic; namespace OurUmbraco.Documentation.Controllers { @@ -60,5 +62,26 @@ namespace OurUmbraco.Documentation.Controllers return currentDirectory.directories.OrderBy(x=> x.sort).ToList(); } + + public List GetStepsForPath(string path) + { + var docs = new ZipDownloader(); + var rootFolder = global::Umbraco.Core.IO.IOHelper.MapPath("/Documentation/" + path); + var mdFiles = System.IO.Directory.GetFiles(rootFolder, "*.md"); + + var result = new List(); + foreach(var fpath in mdFiles) + { + var content = System.IO.File.ReadAllText(fpath); + var name = System.IO.Path.GetFileName(path); + var md = new MarkdownLogic(fpath); + var html = md.DoTransformation(); + + result.Add(html); + } + + + return result; + } } } From d9de0447f58b188cfcce274d82c2c0b57da05ea5 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Sun, 4 Jun 2017 20:02:59 +0100 Subject: [PATCH 08/13] Update the path to WIP PR Docs branch so we can pull down the MD files --- OurUmbraco.Site/config/githubpull.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OurUmbraco.Site/config/githubpull.config b/OurUmbraco.Site/config/githubpull.config index be8cab22..b1cbd541 100644 --- a/OurUmbraco.Site/config/githubpull.config +++ b/OurUmbraco.Site/config/githubpull.config @@ -1,6 +1,6 @@  - + From efc11c1f4091dbbac787a4bbbbe969c25804666c Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Sun, 4 Jun 2017 20:06:49 +0100 Subject: [PATCH 09/13] Revert config - as it expects it to be master branch in other places in the code base at the moment --- OurUmbraco.Site/config/githubpull.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OurUmbraco.Site/config/githubpull.config b/OurUmbraco.Site/config/githubpull.config index b1cbd541..be8cab22 100644 --- a/OurUmbraco.Site/config/githubpull.config +++ b/OurUmbraco.Site/config/githubpull.config @@ -1,6 +1,6 @@  - + From 85b72431861c6c548fe4b8e85305cd20639bceb0 Mon Sep 17 00:00:00 2001 From: Per Ploug Date: Mon, 5 Jun 2017 16:56:03 +0200 Subject: [PATCH 10/13] changed branch to WIP Branch for demo --- OurUmbraco.Site/Views/Lesson.cshtml | 24 +++++++++---------- .../GithubSourcePull/ZipDownloader.cs | 7 ++++-- .../Controllers/LessonsController.cs | 17 ++++++++++--- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/OurUmbraco.Site/Views/Lesson.cshtml b/OurUmbraco.Site/Views/Lesson.cshtml index 1de8ce25..50fc2de5 100644 --- a/OurUmbraco.Site/Views/Lesson.cshtml +++ b/OurUmbraco.Site/Views/Lesson.cshtml @@ -3,10 +3,10 @@ @{ Layout = null; - var path = HttpContext.Current.Items[MarkdownLogic.MarkdownPathKey].ToString(); + var path = HttpContext.Current.Items[MarkdownLogic.MarkdownPathKey].ToString(); var ml = new MarkdownLogic(path) { PrefixLinks = false, AppendAltLessonLink = true }; - var markdown = ml.DoTransformation(); + var markdown = ml.DoTransformation(); } @@ -14,33 +14,34 @@ - @@ -50,5 +51,4 @@ @Html.Raw(markdown) - - + \ No newline at end of file diff --git a/OurUmbraco/Documentation/Busineslogic/GithubSourcePull/ZipDownloader.cs b/OurUmbraco/Documentation/Busineslogic/GithubSourcePull/ZipDownloader.cs index f881ac9a..59de1e07 100644 --- a/OurUmbraco/Documentation/Busineslogic/GithubSourcePull/ZipDownloader.cs +++ b/OurUmbraco/Documentation/Busineslogic/GithubSourcePull/ZipDownloader.cs @@ -125,7 +125,7 @@ namespace OurUmbraco.Documentation.Busineslogic.GithubSourcePull RemoveExistingDocumentation(RootFolder); ZipFile.ExtractToDirectory(zip, RootFolder); - var unzippedPath = RootFolder + "\\UmbracoDocs-master\\"; + var unzippedPath = RootFolder + "\\UmbracoDocs-StarterkitLessons\\"; foreach (var directory in new DirectoryInfo(unzippedPath).GetDirectories()) Directory.Move(directory.FullName, RootFolder + "\\" + directory.Name); foreach (var file in new DirectoryInfo(unzippedPath).GetFiles()) @@ -156,7 +156,10 @@ namespace OurUmbraco.Documentation.Busineslogic.GithubSourcePull public int sort { get; set; } public bool hasChildren { get; set; } public List directories { get; set; } - public string url => $"https://our.umbraco.org/documentation{this.path}/?altTemplate=Lesson"; + + public string url => $"http://localhost:24292/documentation{this.path}/?altTemplate=Lesson"; + + //public string url => $"https://our.umbraco.org/documentation{this.path}/?altTemplate=Lesson"; } private SiteMapItem GetFolderStructure(DirectoryInfo dir, string rootPath, int level) diff --git a/OurUmbraco/Documentation/Controllers/LessonsController.cs b/OurUmbraco/Documentation/Controllers/LessonsController.cs index fb802499..c5a3ef2d 100644 --- a/OurUmbraco/Documentation/Controllers/LessonsController.cs +++ b/OurUmbraco/Documentation/Controllers/LessonsController.cs @@ -10,6 +10,7 @@ using Umbraco.Web.Mvc; using Umbraco.Web.WebApi; using System.Web; using OurUmbraco.Documentation.Busineslogic; +using System.Runtime.Serialization; namespace OurUmbraco.Documentation.Controllers { @@ -63,13 +64,13 @@ namespace OurUmbraco.Documentation.Controllers return currentDirectory.directories.OrderBy(x=> x.sort).ToList(); } - public List GetStepsForPath(string path) + public List GetStepsForPath(string path) { var docs = new ZipDownloader(); var rootFolder = global::Umbraco.Core.IO.IOHelper.MapPath("/Documentation/" + path); var mdFiles = System.IO.Directory.GetFiles(rootFolder, "*.md"); - var result = new List(); + var result = new List(); foreach(var fpath in mdFiles) { var content = System.IO.File.ReadAllText(fpath); @@ -77,11 +78,21 @@ namespace OurUmbraco.Documentation.Controllers var md = new MarkdownLogic(fpath); var html = md.DoTransformation(); - result.Add(html); + result.Add(new LessonStep() { Name = name, Content = html }); } return result; } } + + [DataContract(Name = "lessonStep")] + public class LessonStep + { + [DataMember(Name = "name")] + public string Name { get; set; } + + [DataMember(Name = "content")] + public string Content { get; set; } + } } From ab3603318ae5d5b54a882ee497841eed6638f290 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Mon, 5 Jun 2017 16:20:13 +0100 Subject: [PATCH 11/13] Lovely swtich case for now - to give section & tree help context info --- .../Controllers/LessonsController.cs | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/OurUmbraco/Documentation/Controllers/LessonsController.cs b/OurUmbraco/Documentation/Controllers/LessonsController.cs index c5a3ef2d..4cf4fade 100644 --- a/OurUmbraco/Documentation/Controllers/LessonsController.cs +++ b/OurUmbraco/Documentation/Controllers/LessonsController.cs @@ -11,6 +11,8 @@ using Umbraco.Web.WebApi; using System.Web; using OurUmbraco.Documentation.Busineslogic; using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; namespace OurUmbraco.Documentation.Controllers { @@ -64,6 +66,11 @@ namespace OurUmbraco.Documentation.Controllers return currentDirectory.directories.OrderBy(x=> x.sort).ToList(); } + /// + /// Gets Steps (Children of a lesson as rendered HTML from the markdown file) + /// + /// + /// public List GetStepsForPath(string path) { var docs = new ZipDownloader(); @@ -84,6 +91,73 @@ namespace OurUmbraco.Documentation.Controllers return result; } + + /// + /// + /// + /// + /// + public List GetContextHelpDocs(string sectionAlias, string treeAlias) + { + if (sectionAlias.ToLower() == "settings" && treeAlias.ToLower() == "documenttypes") + { + return new List + { + new HelpDocument + { + Name = "Defining Content", + Description = "Here you'll find an explanation of how content is defined and quick guide for your first go at it (based on an empty installation).", + Type = HelpDocType.Doc, + Url = "https://our.umbraco.org/documentation/Getting-Started/Data/Defining-content/" + } + }; + } + + if (sectionAlias.ToLower() == "settings" && treeAlias.ToLower() == "templates") + { + return new List + { + new HelpDocument + { + Name = "Templates", + Description = "Templating in Umbraco builds on the concept of Razor Views from asp.net MVC - if you already know this, then you are ready to create your first template - if not, this is a quick and handy guide.", + Type = HelpDocType.Doc, + Url = "https://our.umbraco.org/documentation/Getting-Started/Design/Templates/" + }, + new HelpDocument + { + Name = "Basic Razor Syntax", + Description = "Shows how to perform common logical tasks in Razor like if/else, foreach loops, switch statements and using the @ character to separate code and markup.", + Type = HelpDocType.Doc, + Url = "https://our.umbraco.org/documentation/Getting-Started/Design/Templates/basic-razor-syntax" + }, + new HelpDocument + { + Name = "Rendering Content", + Description = "The primary task of any template in Umbraco is to render the values of the current page or the result of query against the content cache.", + Type = HelpDocType.Doc, + Url = "https://our.umbraco.org/documentation/Getting-Started/Design/Rendering-Content/" + }, + new HelpDocument + { + Name = "Basic Razor Syntax", + Description = "Shows how to perform common logical tasks in Razor like if/else, foreach loops, switch statements and using the @ character to separate code and markup.", + Type = HelpDocType.Doc, + Url = "https://our.umbraco.org/documentation/Getting-Started/Design/Templates/basic-razor-syntax" + }, + new HelpDocument + { + Name = "View/Razor Examples", + Description = "Lots of examples of using various techniques to render data in a view", + Type = HelpDocType.Doc, + Url = "https://our.umbraco.org/documentation/Reference/Templating/Mvc/examples" + } + }; + } + + //Did not find anything for the combination + return null; + } } [DataContract(Name = "lessonStep")] @@ -95,4 +169,23 @@ namespace OurUmbraco.Documentation.Controllers [DataMember(Name = "content")] public string Content { get; set; } } + + [DataContract(Name = "helpDocument")] + public class HelpDocument + { + [DataMember(Name = "name")] + public string Name { get; set; } + + [DataMember(Name = "url")] + public string Url { get; set; } + + [DataMember(Name = "description")] + public string Description { get; set; } + + [DataMember(Name = "type")] + [JsonConverter(typeof(StringEnumConverter))] + public HelpDocType Type { get; set; } + } + + public enum HelpDocType { Doc, Video } } From 9c4d1baa521cfd9e86a4b3790e4b7ff7f3f62988 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Mon, 5 Jun 2017 16:37:25 +0100 Subject: [PATCH 12/13] Some more docs to the oh so lovely switch statement --- .../Controllers/LessonsController.cs | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/OurUmbraco/Documentation/Controllers/LessonsController.cs b/OurUmbraco/Documentation/Controllers/LessonsController.cs index 4cf4fade..7ead4a55 100644 --- a/OurUmbraco/Documentation/Controllers/LessonsController.cs +++ b/OurUmbraco/Documentation/Controllers/LessonsController.cs @@ -139,6 +139,13 @@ namespace OurUmbraco.Documentation.Controllers Url = "https://our.umbraco.org/documentation/Getting-Started/Design/Rendering-Content/" }, new HelpDocument + { + Name = "Rendering Media", + Description = "Templates can access items in the Media library, to assist in displaying rich content like galleries.", + Type = HelpDocType.Doc, + Url = "https://our.umbraco.org/documentation/Getting-Started/Design/Rendering-Media/" + }, + new HelpDocument { Name = "Basic Razor Syntax", Description = "Shows how to perform common logical tasks in Razor like if/else, foreach loops, switch statements and using the @ character to separate code and markup.", @@ -155,6 +162,48 @@ namespace OurUmbraco.Documentation.Controllers }; } + if (sectionAlias.ToLower() == "media") + { + return new List + { + new HelpDocument + { + Name = "Creating Media", + Description = "Media in Umbraco is handled in much the same way as content. Instead of defining Document Types you define Media Types that act as the base for media items.", + Type = HelpDocType.Doc, + Url = "https://our.umbraco.org/documentation/Getting-Started/Data/Creating-Media/" + } + }; + } + + if (sectionAlias.ToLower() == "developer" && treeAlias.ToLower() == "datatypes") + { + return new List + { + new HelpDocument + { + Name = "Data-Types", + Description = "A Data Type defines the type of input for a property. So when adding a property (on Document Types, Media Types and Members) when selecting the Type you are selecting a Data Type. There are a number of preconfigured Data Types available in Umbraco and more can be added in the Developer section.", + Type = HelpDocType.Doc, + Url = "https://our.umbraco.org/documentation/Getting-Started/Data/Data-Types/" + } + }; + } + + if (sectionAlias.ToLower() == "members") + { + return new List + { + new HelpDocument + { + Name = "Members", + Description = "Members are used for registering and authenticating external users of an Umbraco installation (ie. forum members, intranet users and so forth). Unlike with Document Types and Media Types everything is done in the Members section both defining and creating, and editing members.", + Type = HelpDocType.Doc, + Url = "https://our.umbraco.org/documentation/Getting-Started/Data/Members/" + } + }; + } + //Did not find anything for the combination return null; } From 29d5d293c4f955eca8a683553a32b215f8537a75 Mon Sep 17 00:00:00 2001 From: Per Ploug Date: Wed, 7 Jun 2017 07:40:06 +0200 Subject: [PATCH 13/13] api controller for serving help docs --- .../Controllers/LessonsController.cs | 44 ++++++++++++++++++- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/OurUmbraco/Documentation/Controllers/LessonsController.cs b/OurUmbraco/Documentation/Controllers/LessonsController.cs index 7ead4a55..1182b33c 100644 --- a/OurUmbraco/Documentation/Controllers/LessonsController.cs +++ b/OurUmbraco/Documentation/Controllers/LessonsController.cs @@ -113,7 +113,7 @@ namespace OurUmbraco.Documentation.Controllers }; } - if (sectionAlias.ToLower() == "settings" && treeAlias.ToLower() == "templates") + if (sectionAlias.ToLower() == "settings" && (treeAlias.ToLower() == "templates" || treeAlias.ToLower() == "partialviews") ) { return new List { @@ -186,11 +186,20 @@ namespace OurUmbraco.Documentation.Controllers Description = "A Data Type defines the type of input for a property. So when adding a property (on Document Types, Media Types and Members) when selecting the Type you are selecting a Data Type. There are a number of preconfigured Data Types available in Umbraco and more can be added in the Developer section.", Type = HelpDocType.Doc, Url = "https://our.umbraco.org/documentation/Getting-Started/Data/Data-Types/" + }, + + + new HelpDocument + { + Name = "Property Editors", + Description = "Extend Umbraco with your own property editors ", + Url = "https://our.umbraco.org/documentation/Extending/Property-Editors/", + Type = HelpDocType.Doc } }; } - if (sectionAlias.ToLower() == "members") + if (sectionAlias.ToLower() == "member") { return new List { @@ -204,6 +213,37 @@ namespace OurUmbraco.Documentation.Controllers }; } + if (sectionAlias.ToLower() == "developer") + { + return new List + { + new HelpDocument + { + Name = "Data-Types", + Description = "A Data Type defines the type of input for a property. So when adding a property (on Document Types, Media Types and Members) when selecting the Type you are selecting a Data Type. There are a number of preconfigured Data Types available in Umbraco and more can be added in the Developer section.", + Type = HelpDocType.Doc, + Url = "https://our.umbraco.org/documentation/Getting-Started/Data/Data-Types/" + }, + + + new HelpDocument + { + Name = "Macros", + Description = "A macro is a reusable piece of functionality that you can re-use throughout your site. Macros can be configured with parameters and be inserted into a Rich Text Editor.", + Url = "https://our.umbraco.org/Documentation/Reference/Templating/Macros/", + Type = HelpDocType.Doc + }, + + new HelpDocument + { + Name = "Xslt", + Description = "XSLT will soon be removed from Umbraco - read how you can transition away from it", + Url = "https://our.umbraco.org/Documentation/Reference/Templating/Macros/Xslt/", + Type = HelpDocType.Doc + } + }; + } + //Did not find anything for the combination return null; }