Пример #1
0
        public static void CreateScriptProject(ILog log, FsPath workdir, string ApiReferencePath)
        {
            log.Info("Creating scripts project...");
            Project p = new Project
            {
                Sdk           = "Microsoft.NET.Sdk",
                PropertyGroup = new PropertyGroup
                {
                    Nullable        = "enable",
                    TargetFramework = "netstandard2.1"
                },
                ItemGroup = new ItemGroup
                {
                    Reference = new Reference
                    {
                        Include  = "BookGen.Api",
                        HintPath = Path.Combine(ApiReferencePath, "BookGen.Api.dll")
                    }
                }
            };
            FsPath csProj = workdir.Combine(ScriptProject);

            csProj.SerializeXml(p, log);

            ResourceHandler.ExtractKnownFile(KnownFile.ScriptTemplateCs, workdir.Combine("Scripts").ToString(), log);
        }
Пример #2
0
 public MiddlewareContext(string sourcePath, string outputPath = "", string pluginPath = "")
 {
     SourcePath = new FsPath(sourcePath);
     if (string.IsNullOrWhiteSpace(outputPath))
     {
         outputPath = "_output";
     }
     OutputPath = SourcePath.Combine(outputPath);
     if (string.IsNullOrWhiteSpace(pluginPath))
     {
         pluginPath = "plugins";
     }
     PluginPath = SourcePath.Combine(pluginPath);
 }
Пример #3
0
        private void SaveImage(FsPath file, FsPath targetdir, ILog log, SKData data, string?extensionOverride)
        {
            FsPath target = targetdir.Combine(file.Filename);

            if (extensionOverride != null)
            {
                var newname = Path.ChangeExtension(file.Filename, extensionOverride);
                target = targetdir.Combine(newname);
            }
            using (var stream = target.CreateStream(log))
            {
                log.Detail("Saving image: {0}", target);
                data.SaveTo(stream);
            }
        }
Пример #4
0
        internal static void DoCreateTasks(ILog log, FsPath workDir)
        {
            Domain.VsTasks.VsTaskRoot Tasks = VsTaskFactory.CreateTasks();
            FsPath file = workDir.Combine(".vscode\\tasks.json");

            file.SerializeJson(Tasks, log);
        }
Пример #5
0
        public static void ExtractTemplates(ILog log, FsPath workdir)
        {
            var templatedir = workdir.Combine("Templates").ToString();
            var assetsdir   = workdir.Combine("Templates\\Assets").ToString();

            ResourceHandler.ExtractKnownFile(KnownFile.TemplateEpubHtml, templatedir, log);
            ResourceHandler.ExtractKnownFile(KnownFile.TemplatePrintHtml, templatedir, log);
            ResourceHandler.ExtractKnownFile(KnownFile.TemplateWebHtml, templatedir, log);

            ResourceHandler.ExtractKnownFile(KnownFile.PrismCss, assetsdir, log);
            ResourceHandler.ExtractKnownFile(KnownFile.PrismJs, assetsdir, log);
            ResourceHandler.ExtractKnownFile(KnownFile.BootstrapMinCss, assetsdir, log);
            ResourceHandler.ExtractKnownFile(KnownFile.BootstrapMinJs, assetsdir, log);
            ResourceHandler.ExtractKnownFile(KnownFile.JqueryMinJs, assetsdir, log);
            ResourceHandler.ExtractKnownFile(KnownFile.PopperMinJs, assetsdir, log);
            ResourceHandler.ExtractKnownFile(KnownFile.TurbolinksJs, assetsdir, log);
        }
Пример #6
0
        public static bool FallbackTemplateRequired(FsPath workingDirectory, BuildConfig buildConfig)
        {
            if (string.IsNullOrEmpty(buildConfig.TemplateFile))
            {
                return(true);
            }

            FsPath templatePath = workingDirectory.Combine(buildConfig.TemplateFile);

            return(!templatePath.IsExisting);
        }
Пример #7
0
        public InitializeViewModel(ILog log, FsPath WorkDir)
        {
            _log           = log;
            _workDir       = WorkDir;
            _configFile    = WorkDir.Combine("bookgen.json");
            ExecuteCommand = new DelegateCommand(OnExecute);
            CancelCommand  = new DelegateCommand(() => View?.ExitApp());

            CreateConfig    = true;
            CreateMdFiles   = true;
            CreateTemplates = false;
            CreateScripts   = false;
            CreateVsTasks   = true;
        }
Пример #8
0
        private void DocumentType(Type type, XElement documentation, FsPath outputDir)
        {
            MarkdownDocument document = new MarkdownDocument();

            CreatePageTitle(document, type);
            document.Paragraph(DocumentSelectors.GetPropertyOrTypeSummary(documentation, type.FullName));

            if (type.IsEnum)
            {
                EnumDocumenter.DocumentEnum(document, type, documentation);
            }
            else
            {
                PropertyDocumenter.DocumentPropertes(document, type, documentation);
                MethodDocumenter.DocumentMethods(document, type, documentation);
            }

            var file = outputDir.Combine(type.Name + ".md");

            file.WriteFile(_log, document.ToString());
        }
Пример #9
0
        private void DocumentType(Type type, XElement documentation, FsPath outputDir)
        {
            MarkdownDocument document = new MarkdownDocument();

            CreatePageTitle(document, type);
            document.Paragraph(DocumentSelectors.GetPropertyOrTypeSummary(documentation, type?.FullName ?? string.Empty));

            if (type?.IsEnum == true)
            {
                _enumDocumenter.Document(document, type, documentation);
            }
            else
            {
                _propertyDocumenter.Document(document, type !, documentation);
                _methodDocumenter.Document(document, type !, documentation);
            }

            var file = outputDir.Combine(type?.Name + ".md");

            file.WriteFile(_log, document.ToString());
        }
Пример #10
0
        public static string LoadTemplate(FsPath workingDirectory,
                                          BuildConfig buildConfig,
                                          ILog log,
                                          string FallBackTemplate)
        {
            if (string.IsNullOrEmpty(buildConfig.TemplateFile))
            {
                return(FallBackTemplate);
            }

            FsPath templatePath = workingDirectory.Combine(buildConfig.TemplateFile);

            if (!templatePath.IsExisting)
            {
                log.Warning("Template not found: {0}", buildConfig.TemplateFile);
                log.Info("Switching to built-in template.");
                return(FallBackTemplate);
            }

            return(templatePath.ReadFile(log));
        }
Пример #11
0
 protected override FsPath ConfigureOutputDirectory(FsPath workingDirectory)
 {
     return(workingDirectory.Combine(Settings.Configuration.TargetWordpress.OutPutDirectory));
 }
Пример #12
0
 protected override FsPath ConfigureOutputDirectory(FsPath workingDirectory)
 {
     return workingDirectory.Combine(Settings.Configuration.TargetEpub.OutPutDirectory);
 }
Пример #13
0
 public FsPath Append(string p)
 {
     return(FsPath.Combine(this, new FsPath(p)));
 }
Пример #14
0
 public FsPath Append(FsPath p)
 {
     return(FsPath.Combine(this, p));
 }