Example #1
0
File: App.cs Project: Websilk/Home
        public Inject StaticUrl(string url)
        {
            if (S.isSessionLost()) { return lostInject(); } //check session

            if (!string.IsNullOrEmpty(url))
            {
                var arrUrl = url.Split('\"');
                if (arrUrl[0].IndexOf("+") < 0)
                {
                    //found page with no query in url
                    var page = new Page(S);

                    //parse URL
                    page.Url = page.parseUrl(url.ToLower().Replace(" ", "-"));

                    //get page Info
                    page.getPageInfoFromUrl();

                    //get static page class
                    if(page.pageService != "")
                    {
                        var service = page.getStaticPage(page.pageService);
                        var response = service.LoadSubPage(page.Url.path.Replace(page.pagePathName + "/", ""));
                        S.javascript.Add("static-page", "S.url.push('" + page.pageTitle + "','" + url.Replace(" ", "-") + "');");
                        response.js =
                            S.cssFiles.renderCssFiles(false) + "\n" +
                            S.javascriptFiles.renderJavascriptFiles(false, S.javascript.renderJavascript(false));
                        return response;
                    }
                }
            }
            return new Inject();
        }
Example #2
0
        public PageRequest(Server server, HttpContext context)
        {
            //the Pipeline.PageRequest is simply the first page request for a Websilk website.

            S = new Core(server, context);
            var page = new Page(S);
            S.isFirstLoad = true;

            if (S.isFirstLoad == true)
            {
                getUserAgent(context);
            }

            //parse URL
            page.Url = page.parseUrl(S.Request.Path.ToString().ToLower().Replace(" ", "-"));

            //get page Info
            page.getPageInfoFromUrl();

            //register initial javascript
            S.javascript.Add("init", "S.init(" + (S.User.useAjax ? "true" : "false") + "," + page.pageId + "," + page.pageType + ",'" + page.pagePathName + "','" + page.pageTitle + "','" + page.PageTitleForBrowserTab + "'," + page.websiteId + ",'" + page.websiteTitle + "', '" + (S.Request.IsHttps ? "https://" : "http://") + "','" + page.Url.host + "');");

            //render the page
            var response = page.Render();

            //unload the core (before sending response)
            S.Unload();

            //render the server response
            S.Response.ContentType = "text/html";
            S.Response.WriteAsync(response);
        }
Example #3
0
File: App.cs Project: Websilk/Home
        public PageRequest Url(string url)
        {
            if (S.isSessionLost()) { return lostPageRequest(); } //check session

            var response = new PageRequest();
            if (!string.IsNullOrEmpty(url))
            {
                var arrUrl = url.Split('\"');
                if (arrUrl[0].IndexOf("+") < 0)
                {
                    //found page with no query in url
                    var page = new Page(S);

                    //parse URL
                    page.Url = page.parseUrl(url.ToLower().Replace(" ", "-"));

                    //get page Info
                    page.getPageInfoFromUrl();

                    //load page content
                    page.Render();

                    //write to console
                    Console.WriteLine("Load page: " + page.pageTitle);

                    //set up response
                    response.components = new List<PageComponent>();
                    response.css = "";
                    response.editor = "";
                    response.js = "";
                    response.pageTitle = page.pageTitle;
                    response.url = url;
                    response.pageId = page.pageId;
                    response.already = true;

                    //load page components, excluding components from the currently loaded page

                    //render each component for the page

                }
            }
            return response;
        }
Example #4
0
File: Init.cs Project: Websilk/Home
        private void GeneratePage(string name)
        {
            var P = new Page(S);
            var page = new Page.structPage();
            var scaffold = new Scaffold(S, "/App/Content/themes/default/layout.html");
            var panels = P.loadLayout(scaffold);
            var panelHead = panels[0];
            var panelBody = panels[1];
            var panelFoot = panels[2];

            page.layers = new List<int>();
            page.panels = new List<Panel>();
            page.components = new List<Component>();

            if (name == "home")
            {
                //generate a home page
                P.Url = P.parseUrl("/home");
                P.getPageInfoFromUrl();

            }else if (name == "login")
            {
                //generate login page
                P.Url = P.parseUrl("/login");
                P.getPageInfoFromUrl();
                var cLogin = P.loadComponent(new Websilk.Components.Login(), panelBody, panelBody.cells[0], true);
                var posLogin = cLogin.position[4];
                posLogin.padding.top = 50;
                cLogin.position[4] = posLogin;

            }else if (name == "access-denied")
            {
                //generate login page
                P.Url = P.parseUrl("/access-denied");
                P.getPageInfoFromUrl();
                var cLogin = P.loadComponent(new Websilk.Components.Login(), panelBody, panelBody.cells[0], true);
                var posLogin = cLogin.position[4];
                posLogin.padding.top = 50;
                cLogin.position[4] = posLogin;
            }

            page.pageId = P.pageId;

            //add components from head, body, & foot
            foreach (var component in panelHead.cells[0].components)
            {
                page.components.Add(component);
            }

            foreach (var component in panelBody.cells[0].components)
            {
                page.components.Add(component);
            }

            foreach (var component in panelFoot.cells[0].components)
            {
                page.components.Add(component);
            }

            //save page to file
            S.Util.Serializer.SaveToFile(page, S.Server.MapPath("/App/Content/websites/1/pages/" + page.pageId + "/page.json"), Newtonsoft.Json.Formatting.None);
        }