Exemple #1
0
        public static void Generate(GeneratorContext context)
        {
            LoadData(context.Site);

            //Read templates
            var siteIndexTemplate = new SiteIndexTemplate(context);
            var indexTemplate     = new IndexTemplate(context);

            //Clean web target
            FileManager.Clean(context.Site.WebPath);
            //Copy static: Done in calling bash script
            FileManager.Clone(context.Site.StaticPath, context.Site.WebPath);

            //Generate news
            siteIndexTemplate["site:news"] = GenerateNews(context.Site);
            indexTemplate["site:news"]     = GenerateNews(context.Site);

            var pageTemplate = new PageTemplate(context);
            var postTemplate = new PostTemplate(context);

            //Generate all files
            GenerateIndex(siteIndexTemplate, context);
            GenerateFeed(context);
            foreach (Page p in context.Site.Pages)
            {
                GeneratePage(context.Site, p, pageTemplate, indexTemplate);
            }
            foreach (Post p in context.Site.Posts)
            {
                GeneratePost(context.Site, p, postTemplate, indexTemplate);
            }
            GenerateNewPostPageTemplate(context.Site);

            Compressor.CompressDirectoryRecursive(context.Site.WebPath);
        }
Exemple #2
0
        static void GenerateIndex(SiteIndexTemplate template, GeneratorContext context)
        {
            var indexInstance = template.Create(context.Site);

            if (context.Site.GetPage("index") != null || File.Exists(Path.Combine(context.Site.StaticPath, "index.html")))
            {
                return;
            }

            var compactPostTemplate = new CompactPostTemplate(context);

            indexInstance["title"]    = context.Site.Title;
            indexInstance["tabs"]     = GenerateTabs(context.Site, null, null);
            indexInstance["contents"] = new Html();
            foreach (Post p in context.Site.Posts)
            {
                indexInstance["contents"] += compactPostTemplate.Generate(context.Site, p);
            }
            indexInstance.Write(Path.Combine(context.Site.WebPath, "index.html"));
        }