Ejemplo n.º 1
0
        static void GeneratePost(Site site, Post p, PostTemplate postTemplate, IndexTemplate indexTemplate)
        {
            string dirPath  = Path.Combine(site.WebPath, p.Path);
            string htmlPath = Path.Combine(dirPath, "index.html");

            Directory.CreateDirectory(dirPath);
            if (Directory.Exists(p.SourceDir))
            {
                FileManager.Clone(p.SourceDir, dirPath);
            }

            var inst = indexTemplate.Create(site);

            inst["title"]    = p.Title;
            inst["tabs"]     = GenerateTabs(site, null, p);
            inst["contents"] = postTemplate.Generate(site, p);
            inst.Write(htmlPath);
        }
Ejemplo n.º 2
0
        static void GenerateIndex(IndexTemplate template, Site site)
        {
            var indexInstance = template.Create(site);

            if (site.GetPage("index") != null)
            {
                return;
            }

            var compactPostTemplate = new CompactPostTemplate(site);

            indexInstance["title"]    = site.Title;
            indexInstance["tabs"]     = GenerateTabs(site, null, null);
            indexInstance["contents"] = new Html();
            foreach (Post p in site.Posts)
            {
                indexInstance["contents"] += compactPostTemplate.Generate(site, p);
            }
            indexInstance.Write(Path.Combine(site.WebPath, "index.html"));
        }
Ejemplo n.º 3
0
        static void GeneratePost(Site site, Post p, PostTemplate postTemplate, IndexTemplate indexTemplate)
        {
            string dirPath  = Path.Combine(site.WebPath, p.Path);
            string htmlPath = Path.Combine(dirPath, "index.html");

            Directory.CreateDirectory(dirPath);
            if (Directory.Exists(p.SourceDir))
            {
                FileManager.Clone(p.SourceDir, dirPath);
            }

            var inst = indexTemplate.Create(site);

            inst["title"]    = p.Title;
            inst["author"]   = p.Author;
            inst["date"]     = p.Date.ToString("yyyy-MM-dd hh:mm:ss");
            inst["tabs"]     = GenerateTabs(site, null, p);
            inst["contents"] = postTemplate.Generate(site, p);
            inst["metatags"] = Html.Raw(p.MetaTags.ToHtml(inst));
            inst.Write(htmlPath);
        }
Ejemplo n.º 4
0
        static void GeneratePage(Site site, Page p, PageTemplate pageTemplate, IndexTemplate indexTemplate)
        {
            string dirPath = Path.Combine(site.WebPath, p.Path);

            if (p.Path == "index/")
            {
                dirPath = site.WebPath;
            }
            Directory.CreateDirectory(dirPath);
            if (Directory.Exists(p.SourceDir))
            {
                FileManager.Clone(p.SourceDir, dirPath);
            }

            var indexInstance = indexTemplate.Create(site);

            indexInstance["title"]    = p.Title;
            indexInstance["tabs"]     = GenerateTabs(site, p, null);
            indexInstance["contents"] = pageTemplate.Generate(site, p);
            indexInstance.Write(Path.Combine(dirPath, "index.html"));
        }