コード例 #1
0
ファイル: Layout.cs プロジェクト: smack0007/Gatsby
        public string Run(string content, SiteContent page, RazorRenderer razorRenderer, Site site)
        {
            this.Content = content;
            this.Model = new DynamicValue(page);

            this.InitGatsbyRazorTemplate(razorRenderer, site);

            return this.ExecuteTemplate();
        }
コード例 #2
0
ファイル: RazorRenderer.cs プロジェクト: smack0007/Gatsby
        public string LayoutContent(string layoutName, string content, SiteContent page, Site site)
        {
            if (!this.layouts.ContainsKey(layoutName))
                throw new GatsbyException(string.Format("Layout \"{0}\" was not found.", layoutName));

            var layout = this.layouts[layoutName];

            try
            {
                content = layout.Run(content, page, this, site);
            }
            catch (Exception ex)
            {
                throw new GatsbyException(string.Format("Failed while rendering layout \"{0}\":\n\t{1}", layoutName, ex.Message));
            }

            if (string.IsNullOrEmpty(layout.Parent))
                return content;

            return this.LayoutContent(layout.Parent, content, page, site);
        }
コード例 #3
0
ファイル: SiteBuilder.cs プロジェクト: smack0007/Gatsby
        private void WriteContent(Config config, SiteContent page, Site site)
        {
            string content = page.Content;

            if (!string.IsNullOrEmpty(page.Layout))
                content = this.razorRenderer.LayoutContent(page.Layout, content, page, site);

            string destination = Path.Combine(config.Destination, page.Permalink);

            string directory = Path.GetDirectoryName(destination);
            if (!string.IsNullOrEmpty(directory))
                Directory.CreateDirectory(directory);

            File.WriteAllText(destination, content);
        }
コード例 #4
0
ファイル: SiteBuilder.cs プロジェクト: smack0007/Gatsby
 private void SetDefaultsForContent(SiteContent content)
 {
     if (content.LastUpdate == null)
         content.LastUpdate = content.Date;
 }
コード例 #5
0
ファイル: Disqus.cs プロジェクト: smack0007/zacharysnow.net
	public string GetUrl(SiteContent content)
	{
		return "http://zacharysnow.net/" + content.Permalink;
	}