private IActionResult buildAsPage(PageStack pageStack, String layout) { HtmlDocumentRenderer dr = new HtmlDocumentRenderer(templateEnvironment); dr.addTransform(new HashTreeMenus(fileFinder)); dr.addTransform(new ExpandRootedPaths(this.HttpContext.Request.PathBase)); pageStack.pushLayout(layout); return(build(pageStack, dr)); }
public void buildPage(String relativeFile) { relativeFile = relativeFile.TrimStartingPathChars(); var outFile = Path.Combine(this.outDir, relativeFile); if (OutputExtension != null) { outFile = Path.ChangeExtension(outFile, OutputExtension); } ITargetFileInfo fileInfo = fileInfoProvider.GetFileInfo(relativeFile, null); TemplateEnvironment environment = new TemplateEnvironment(fileInfo.FileNoExtension, fileFinder, overrideValuesProvider.OverrideVars, version, true); PageStack pageStack = new PageStack(environment, fileFinder); pageStack.ContentFile = fileInfo.HtmlFile; if (pageStack.Visible) { var pageSettings = fileFinder.GetProjectPageDefinition(fileInfo); var layout = pageSettings.Layout; if (OutputExtension != null) { layout = Path.ChangeExtension(layout, OutputExtension); } pageStack.pushLayout(layout); var pathBase = environment.PathBase; HtmlDocumentRenderer dr = new HtmlDocumentRenderer(environment); dr.addTransform(new HashTreeMenus(fileFinder)); dr.addTransform(new ExpandRootedPaths(pathBase)); if (!String.IsNullOrEmpty(pathBase)) { //Safe to fix relative urls last since it wont replace any that already start with the path base. dr.addTransform(new FixRelativeUrls(pathBase)); } var document = dr.getDocument(pageStack.Pages); var outDir = Path.GetDirectoryName(outFile); if (!Directory.Exists(outDir)) { Directory.CreateDirectory(outDir); } using (var writer = new StreamWriter(File.Open(outFile, FileMode.Create, FileAccess.Write, FileShare.None))) { writer.Write(document.DocumentNode.OuterHtml); } fileFinder.CopyLinkedFiles(this.outDir, pageStack); } }
private IActionResult buildAsEditor(PageStack pageStack, String layout) { if (!fileFinder.DoesLayoutExist(layout)) { layout = "default.html"; //Change layout to default.html if the layout does not exist, this way we at least return a page } HtmlDocumentRenderer dr = new HtmlDocumentRenderer(templateEnvironment); switch (branchDetector.Phase) { case Phases.Draft: pageStack.pushLayout("draft.html"); foreach (var editStackItem in fileFinder.Project.DraftComponents) { pageStack.pushLayout(editStackItem); } pageStack.pushLayout(layout); pageStack.pushLayout("editarea-noedit.html"); break; case Phases.Edit: pageStack.pushLayout("edit.html"); foreach (var editStackItem in fileFinder.Project.EditComponents) { pageStack.pushLayout(editStackItem); } pageStack.pushLayout(layout); pageStack.pushLayout("editarea-ckeditor.html"); dr.addTransform(new CreateSettingsForm()); dr.addTransform(new CreateTreeMenuEditor()); break; } dr.addTransform(new HashTreeMenus(fileFinder)); dr.addTransform(new ExpandRootedPaths(this.HttpContext.Request.PathBase)); return(build(pageStack, dr)); }