public void RunStep(RuntimeSettings settings, ILog log) { if (Content == null) { throw new DependencyException(nameof(Content)); } if (Template == null) { throw new DependencyException(nameof(Template)); } Content.Metadata = FillMeta(settings.Configuration); log.Info("Generating search page..."); GenerateSearchContents(settings, log); _buffer.Append(ResourceHandler.GetFile(KnownFile.SearchformHtml)); FsPath?target = settings.OutputDirectory.Combine("search.html"); Content.Title = settings.Configuration.Translations[Translations.SearchPageTitle]; Content.Content = _buffer.ToString(); var html = Template.Render(); target.WriteFile(log, html); }
protected override string ConfigureTemplateContent() { return(TemplateLoader.LoadTemplate(Settings.SourceDirectory, Settings.Configuration.TargetPrint, _log, ResourceHandler.GetFile(KnownFile.TemplatePrintHtml))); }
public string Generate(IArguments arguments) { var contentsDiv = arguments.GetArgumentOrThrow <string>("ContentsDiv"); var targetDiv = arguments.GetArgumentOrThrow <string>("TargetDiv"); StringBuilder writer = new StringBuilder(); var pagetoc = ResourceHandler.GetFile(KnownFile.PageTocJs); var code = pagetoc.Replace("{{contents}}", contentsDiv).Replace("{{target}}", targetDiv); return(writer.WriteJavaScript(code).ToString()); }
public override bool Execute(string[] arguments) { Md2HtmlParameters args = new Md2HtmlParameters(); if (!ArgumentParser.ParseArguments(arguments, args)) { return(false); } var log = new ConsoleLog(LogLevel.Info); string md = args.InputFile.ReadFile(log); string pageTemplate = ResourceHandler.GetFile(KnownFile.TemplateSinglePageHtml); string cssForInline = ""; if (args.Css.IsExisting) { cssForInline = args.Css.ReadFile(log); } using var pipeline = new BookGenPipeline(BookGenPipeline.Preview); pipeline.InjectPath(args.InputFile.GetDirectory()); pipeline.SetSyntaxHighlightTo(!args.NoSyntax); var mdcontent = pipeline.RenderMarkdown(md); string rendered; if (args.RawHtml) { rendered = mdcontent; } else { rendered = pageTemplate.Replace("<!--{css}-->", cssForInline); rendered = rendered.Replace("<!--{content}-->", mdcontent); } if (args.OutputFile == new FsPath("con")) { Console.WriteLine(rendered); } else { args.OutputFile.WriteFile(log, rendered); } return(true); }
public string Generate(IArguments arguments) { var currentconfig = _settings.CurrentBuildConfig; if (currentconfig.TemplateOptions.TryGetOption(TemplateOptions.CookieDisplayBannerEnabled, out bool value) && value) { _log.Detail("Cookies enabled for current target. Generating Code..."); return(ResourceHandler.GetFile(KnownFile.CookieWarningHtml)); } else { _log.Detail("Cookies not enalbed for current target."); return(string.Empty); } }
public PreviewRenderHandler(string directory, ILog log) { _directory = directory; _log = log; _processor = new TemplateProcessor(new Core.Configuration.Config(), new ShortCodeParser(new List <ITemplateShortCode>(), new Scripts.CsharpScriptHandler(_log), new Core.Configuration.Translations(), _log), new StaticTemplateContent()); _processor.TemplateContent = ResourceHandler.GetFile(KnownFile.PreviewHtml); _mdpipeline = new BookGenPipeline(BookGenPipeline.Preview); _mdpipeline.SetSyntaxHighlightTo(false); }
public EmbededResourceRequestHandler() { _knownFiles = new Dictionary <string, Func <string> > { { "/bootstrap.min.css", () => ResourceHandler.GetFile(KnownFile.BootstrapMinCss) }, { "/bootstrap.min.js", () => ResourceHandler.GetFile(KnownFile.BootstrapMinJs) }, { "/jquery.min.js", () => ResourceHandler.GetFile(KnownFile.JqueryMinJs) }, { "/popper.min.js", () => ResourceHandler.GetFile(KnownFile.PopperMinJs) }, { "/jsonview.css", () => ResourceHandler.GetFile(KnownFile.JsonviewCss) }, { "/jsonview.js", () => ResourceHandler.GetFile(KnownFile.JsonviewJs) }, { "/ace.min.js", () => ResourceHandler.GetFile(KnownFile.AceMinJs) }, { "/keybinding-vscode.min.js", () => ResourceHandler.GetFile(KnownFile.AceKeybindingVsCodeMinJs) }, { "/markdown.min.js", () => ResourceHandler.GetFile(KnownFile.AceMarkdownMinJs) }, { "/mode-markdown.min.js", () => ResourceHandler.GetFile(KnownFile.AceModeMarkdownMinJs) }, { "/theme-github.min.js", () => ResourceHandler.GetFile(KnownFile.AceThemeGithubMinJs) }, { "/EditorApp.js", () => ResourceHandler.GetFile(KnownFile.EditorAppJs) } }; }
public void Serve(string AbsoluteUri, HttpListenerResponse response, ILog log) { string str = ""; if (AbsoluteUri == "/" || AbsoluteUri == "/index.html") { str = ResourceHandler.GetFile(KnownFile.IndexHtml); } else if (AbsoluteUri == "/editor.html") { str = ResourceHandler.GetFile(KnownFile.EditorHtml); } else if (AbsoluteUri == "/config.html") { str = ResourceHandler.GetFile(KnownFile.ConfigViewHtml); } response.WriteHtmlString(str); }