Beispiel #1
0
        public object Clone()
        {
            AppMetaManager clone = new AppMetaManager();

            clone.CopyProperties(this);
            return(clone);
        }
Beispiel #2
0
        public void WriteBooks(AppConf appConfig)
        {
            AppName = appConfig.Name;
            FireEvent(AppInitializing, new WebBookEventArgs(appConfig));
            Fs appFs = appConfig.AppRoot;
            // get all the pages
            AppMetaManager manager   = new AppMetaManager(appConfig.BamConf);
            List <string>  pageNames = new List <string>(manager.GetPageNames(appConfig.Name));

            WritePageList(appFs, pageNames.ToArray());
            // read all the pages
            pageNames.Each(pageName =>
            {
                FireEvent(WritingBook, new WebBookEventArgs(appConfig));
                CurrentPage = pageName;
                // create a new book for every page
                WebBook book = new WebBook {
                    Name = pageName
                };
                string content = appFs.ReadAllText("pages", "{0}.html"._Format(pageName));
                // get all the [data-navigate-to] and a elements
                CQ cq          = CQ.Create(content);
                CQ navElements = cq["a, [data-navigate-to]"];
                navElements.Each(nav =>
                {
                    // create a WebBookPage for each target
                    string href  = nav.Attributes["href"];
                    string navTo = nav.Attributes["data-navigate-to"];
                    string url   = string.IsNullOrEmpty(navTo) ? href : navTo;
                    if (!string.IsNullOrEmpty(url))
                    {
                        url           = url.Contains('?') ? url.Split('?')[0] : url;
                        string layout = nav.Attributes["data-layout"];
                        layout        = string.IsNullOrEmpty(layout) ? "basic" : layout;
                        if (pageNames.Contains(url))
                        {
                            book.Pages.Add(new WebBookPage {
                                Name = url, Layout = layout
                            });
                        }
                    }
                });
                WriteBook(appFs, book);
                FireEvent(WroteBook, new WebBookEventArgs(appConfig));
            });
            FireEvent(AppInitialized, new WebBookEventArgs(appConfig));
        }