コード例 #1
0
ファイル: SiteMapFactory.cs プロジェクト: niemandr/champ
 private static Node ProcessPages(DirectoryInfo path, dynamic globalSettings, string sitePath = "Home", Node parentNode = null)
 {
     var node = new DirectoryNode(path, sitePath);
       // Process each file
       foreach (var file in path.GetFiles("*.md"))
       {
     node.AddChild(new PageNode(file, globalSettings));
       }
       // Check for a syndication file
       FileInfo syndicationFile;
       if (path.TryGetFile("rss.xml", out syndicationFile))
       {
     node.AddChild(new SyndicationNode());
       }
       // Process each subdirectory
       foreach (var dir in path.GetDirectories())
       {
     var subNode = ProcessPages(dir, globalSettings, dir.Name);
     node.AddChild(subNode);
       }
       return node;
 }
コード例 #2
0
ファイル: Node.cs プロジェクト: niemandr/champ
 public void AddChild(Node node)
 {
     node.Parent = this;
       Children.Add(node);
 }
コード例 #3
0
ファイル: SiteBuilder.cs プロジェクト: niemandr/champ
 private void ProcessPages(Node node)
 {
     if (node is DirectoryNode)
       {
     var directory = node as DirectoryNode;
     var destinationPath = directory.Path.FullName.Replace(_sourcePath.Subdirectory(Constants.PAGES).FullName, _outputPath.FullName);
     if (!Directory.Exists(destinationPath)) { Directory.CreateDirectory(destinationPath); }
       }
       else if (node is PageNode)
       {
     var page = node as PageNode;
     var raw = _markdown.Transform(page.GetRawContent());
     var template = Razor.GetTemplate("~/" + page.Template + ".cshtml");
     var output = Razor.ExecuteContent(template, model: new { page = page, Content = raw });
     var outputPath = page.GetOutputFileName().Replace(_sourcePath.Subdirectory(Constants.PAGES).FullName, _outputPath.FullName);
     File.WriteAllText(outputPath, output.Result);
       }
       foreach (var child in node.Children)
       {
     ProcessPages(child);
       }
 }