comparison Tools/DocGen/Program.Web.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f990fcb411a9
1 using System;
2 using System.IO;
3
4 namespace DocGen
5 {
6 partial class Program
7 {
8 static readonly string _template = Path.GetFullPath(@"..\..\content\WebTemplate.html");
9
10 static FileAction FilterFile(string fileName)
11 {
12 var name = Path.GetFileName(fileName).ToLower();
13
14 switch (name)
15 {
16 case "home.htm" : return FileAction.Skip;
17 default : return FileAction.Process;
18 }
19 }
20
21 static void CreateTarget(FileItem files)
22 {
23 new Generator().Generate(
24 new FileItem(),
25 _template, new[] { "Source" }, destPath, @"..\..\..\..\", false, true,
26 fileName =>
27 {
28 var name = Path.GetFileName(fileName).ToLower();
29
30 if (name == "assemblyinfo.cs")
31 return FileAction.Skip;
32
33 var ext = Path.GetExtension(fileName).ToLower();
34
35 switch (ext)
36 {
37 case ".cs": return FileAction.Process;
38 default : return FileAction.Skip;
39 }
40 });
41
42 CreateSitemap(files);
43 }
44
45 static void CreateSitemap(FileItem files)
46 {
47 var sm = "";
48
49 foreach (var file in files.GetFiles())
50 {
51 var s = file.Name.Replace(destPath, "http://www.bltoolkit.net/").Replace("\\", "/");
52
53 if (s == "http://www.bltoolkit.net/index.htm")
54 continue;
55
56 sm += string.Format(@"
57 <url>
58 <loc>{0}</loc>
59 <lastmod>{1:yyyy-MM-dd}</lastmod>
60 <changefreq>weekly</changefreq>
61 </url>",
62 s, DateTime.Now);
63 }
64
65 using (var sw = File.CreateText(destPath + "sitemap.xml"))
66 {
67 sw.WriteLine(string.Format(@"<?xml version=""1.0"" encoding=""UTF-8""?>
68 <urlset xmlns=""http://www.google.com/schemas/sitemap/0.84"">
69 <url>
70 <loc>http://www.bltoolkit.net/</loc>
71 <lastmod>{0:yyyy-MM-dd}</lastmod>
72 <changefreq>weekly</changefreq>
73 </url>{1}
74 </urlset>",
75 DateTime.Now, sm));
76 }
77 }
78 }
79 }