/// <summary> /// /// </summary> /// <param name="path">The path in the documentation folder structure that you wish to start from & list descendants</param> /// <param name="userType">Future Use: Backoffice Usertype requesting lessons</param> /// <param name="allowedSections">Future Use: AllowedSections of BackOffice User</param> /// <param name="lang">Future Use: Backoffice Users langunage</param> /// <param name="version">Umbraco CMS Version as a string</param> /// <returns> /// A partial part of the documentation tree, that lists out folders /// This is used in the new Starter Kit in conjuction with 'Lessons' /// </returns> public List <DocumentationUpdater.SiteMapItem> 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 DocumentationUpdater(); //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.OrderBy(x => x.Sort).ToList()); }
public bool DownloadDocs() { var docsUpdater = new DocumentationUpdater(); docsUpdater.EnsureGitHubDocs(); return(true); }
/// <summary> /// Gets Steps (Children of a lesson as rendered HTML from the markdown file) /// </summary> /// <param name="path"></param> /// <returns></returns> public List <LessonStep> GetStepsForPath(string path) { var docs = new DocumentationUpdater(); var rootFolder = global::Umbraco.Core.IO.IOHelper.MapPath("/Documentation/" + path); var mdFiles = System.IO.Directory.GetFiles(rootFolder, "*.md"); var result = new List <LessonStep>(); 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(new LessonStep() { Name = name, Content = html }); } return(result); }