예제 #1
0
            public Book(Book pred, string name)
            {
                _pred    = pred;
                _name    = name;
                PredTabs = pred?.Tabs ?? "\t";
                Tabs     = "\t" + PredTabs;

                var url   = PhobosFileName(_name);
                var file  = CombineDir(Context.RootFolder, url);
                var dots  = name.Replace('_', '.');
                var title = dots;

                if (!FileExists(Context.RootFolder, url))
                {
                    var htm = Context.Empty.Replace("%TITLE%", dots);
                    File.WriteAllText(file, htm, Encoding.UTF8);
                    Context.Titles[file] = dots;
                }
                else
                {
                    try { title = Context.Titles[file]; } catch { }
                }

                // header
                var hdr = NewBook.Gen(PredTabs, title, url);

                Context.File.WriteLine(hdr);
            }
예제 #2
0
        static void BuildChangelogBook(string dir)
        {
            Console.WriteLine("building book: Changelog");
            if (!FileExists(dir, "index.html"))
            {
                Console.WriteLine("please create index.html at /changelog");
                return;
            }

            var fileName = CombineDir(RootFolder, "Changelog.hhc");

            using (var fout = new StreamWriter(fileName, false, Encoding.UTF8))
            {
                // header
                fout.WriteLine(NewBook.Gen("\t", "Changelog", "changelog/index.html"));

                // pages
                var tab2 = "\t\t";
                var vers = Directory.GetFiles(dir, "*.???*.htm*")
                           .OrderByDescending(f => f);
                foreach (var fn in vers)
                {
                    var url   = fn.Replace(RootFolder, "");
                    var title = Titles[fn];
                    fout.WriteLine(BookPage.Gen(tab2, title, url));
                }

                //footer
                fout.WriteLine(EndBook.Gen("\t", "", ""));
            }
        }
예제 #3
0
        static void BuildArticlesBook(string dir)
        {
            Console.WriteLine("building book: Articles");
            var content = "index.html";

            if (!FileExists(dir, content))
            {
                content = "articles.html";
            }
            if (!FileExists(dir, content))
            {
                Console.WriteLine("please create articles- or index.html at /articles");
                return;
            }
            var prefx = dir.Replace(RootFolder, "");

            var fileName = CombineDir(RootFolder, "Articles.hhc");

            using (var fout = new StreamWriter(fileName, false, Encoding.UTF8))
            {
                // header
                var hdr = NewBook.Gen("\t", "Articles", Path.Combine(prefx, content));
                fout.WriteLine(hdr);

                // pages
                var doc = new HtmlDocument();
                doc.Load(CombineDir(dir, content), Encoding.UTF8);
                var tab2 = "\t\t";
                // <div class="boxes"> <div class="row">
                //		<div class="item"> <h4><a href="../articles/faq.html">FAQ</a></h4>
                var qry = "//div[@class=\"boxes\"]//a";
                foreach (var el in doc.DocumentNode.SelectNodes(qry))
                {
                    var url = el.GetAttributeValue("href", "");
                    url = CombineDir(dir, url).Replace(RootFolder, "");
                    var title = el.InnerText.ToLine();
                    fout.WriteLine(BookPage.Gen(tab2, title, url));
                }

                //footer
                fout.WriteLine(EndBook.Gen("\t", "", ""));
            }
        }
예제 #4
0
        static void BuildSpecBook(string dir)
        {
            Console.WriteLine("building book: Specification");
            var content = "spec.html";

            if (!FileExists(dir, content))
            {
                content = "index.html";
            }
            if (!FileExists(dir, content))
            {
                Console.WriteLine("please create index- or spec.html at /spec");
                return;
            }
            var prefx = dir.Replace(RootFolder, "");

            var fileName = CombineDir(RootFolder, "Spec.hhc");

            using (var fout = new StreamWriter(fileName, false, Encoding.UTF8))
            {
                // header
                var hdr = NewBook.Gen("\t", "Language Reference", Path.Combine(prefx, content));
                fout.WriteLine(hdr);

                // pages
                var doc = new HtmlDocument();
                doc.Load(CombineDir(dir, content), Encoding.UTF8);
                var tab2 = "\t\t";
                // <div class="hyphenate" id="content"><ul><li><a>
                var qry = "//div[@id=\"content\"]/ul/li/a";
                foreach (var el in doc.DocumentNode.SelectNodes(qry))
                {
                    var url   = Path.Combine(prefx, el.GetAttributeValue("href", ""));
                    var title = el.InnerText.ToLine();
                    fout.WriteLine(BookPage.Gen(tab2, title, url));
                }

                //footer
                fout.WriteLine(EndBook.Gen("\t", "", ""));
            }
        }