Exemplo n.º 1
0
        /// <summary>
        /// Initializes the file system from the embedded zip resource
        /// that represents a bare bones app.
        /// </summary>
        public override void Initialize()
        {
            OnAppInitializing();
            WriteAppScripts();
            WriteCompiledTemplates();

            AppRoot.WriteFile("appConf.json", AppConf.ToJson(true));

            OnAppInitialized();
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        public void Save()
        {
            string json = this.ToJson(true);

            ContentRoot.WriteFile(FileName, json);
        }