Exemplo n.º 1
0
        private Program(TopLevelConfig topLevelConfig)
        {
            config = topLevelConfig.Config;
            handlebarsConverter = new HandlebarsConverter(topLevelConfig);

            this.topLevelConfig = topLevelConfig;
        }
Exemplo n.º 2
0
        public HandlebarsConverter(TopLevelConfig topLevelConfig)
        {
            this.topLevelConfig = topLevelConfig;

            handlebars = Handlebars.Create();

            handlebars.RegisterHelper("include", IncludeHelper);
            handlebars.RegisterHelper("markdown", MarkdownHelper);
            handlebars.RegisterHelper("set", SetHelper);
            handlebars.RegisterHelper("ifeq", IfEqHelper);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Entry-point. This is the first method that gets called by the .NET runtime.
        /// </summary>
        /// <param name="args">An array of command line arguments.</param>
        public static void Main(string[] args)
        {
            TopLevelConfig topLevelConfig = ReadConfig("config.yaml");
            var            program        = new Program(topLevelConfig);

            switch (args[0])
            {
            case "--build":
                DateTime start = DateTime.Now;

                program.ConvertPosts();
                program.ConvertPages();
                program.CopyStaticAssets();

                DateTime end = DateTime.Now;

                LogInfo($"Done rebuilding site in {(int) (end - start).TotalMilliseconds} ms");
                Console.WriteLine();

                break;

            case "--posts":
                program.ConvertPosts();
                break;

            case "--post":
                var blogPostConverter = new BlogPostConverter(topLevelConfig, program.handlebarsConverter);

                blogPostConverter.ProcessBlogPost(args[1]);
                break;

            default:
                if (args.Length == 2)
                {
                    string sourcePath = args[0];
                    string targetPath = args[1];

                    program.ConvertHandlebarsFile(sourcePath, targetPath);
                }
                else
                {
                    Console.WriteLine(
                        "Syntax: sitegen --build | --posts | --post <src-file> | <src-file> <target-file>");
                    Environment.Exit(1);
                }

                break;
            }
        }
Exemplo n.º 4
0
 public BlogPostConverter(TopLevelConfig topLevelConfig, HandlebarsConverter handlebarsConverter)
 {
     this.topLevelConfig      = topLevelConfig;
     this.handlebarsConverter = handlebarsConverter;
 }