public object Clone() { BamApplicationManager clone = new BamApplicationManager(); clone.CopyProperties(this); return(clone); }
public void WriteBooks(AppConf appConfig) { AppName = appConfig.Name; FireEvent(AppInitializing, new WebBookEventArgs(appConfig)); // get all the pages BamApplicationManager manager = new BamApplicationManager(appConfig.BamConf); List <string> pageNames = new List <string>(manager.GetPageNames(appConfig.Name)); // read all the pages pageNames.Each(pageName => { FireEvent(WritingBook, new WebBookEventArgs(appConfig)); CurrentPage = pageName; Fs appFs = appConfig.AppRoot; // 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 }); } } }); appFs.WriteFile("~/books/{0}.json"._Format(book.Name), book.ToJson(true), true); FireEvent(WroteBook, new WebBookEventArgs(appConfig)); }); FireEvent(AppInitialized, new WebBookEventArgs(appConfig)); }
protected static internal string[] GetPageScripts(AppConf appConf) { BamApplicationManager manager = new BamApplicationManager(appConf.BamConf); string[] pageNames = manager.GetPageNames(appConf.Name); List <string> results = new List <string>(); pageNames.Each(pageName => { string script = "/" + Fs.CleanPath(Path.Combine("pages", pageName + ".js")).Replace("\\", "/"); // for use in html if (appConf.AppRoot.FileExists(script)) { results.Add(script); } }); return(results.ToArray()); }