Beispiel #1
0
 private static void CreateWebsite(string siteName, string siteType, string siteTitle, string domain, string path, Tenant tenant)
 {
     context.AddObject(Website.Create(siteType, siteName, domain, path, siteTitle, tenant));
     //context.AddObject(Website.Create(WEBSITE_TYPE.WIKI, siteName + " Wiki", domain, "/wiki", siteTitle + " Wiki and Documentation", tenant));
     //context.AddObject(Website.Create(WEBSITE_TYPE.BLOG, siteName + " Blog", domain, "/blog", siteTitle + " Blogs", tenant));
     context.SaveChanges();
 }
Beispiel #2
0
        private static void Setup()
        {
            var resources = new string[]
            {
                "avatar.png",
                "logo.png",
                "mia.png",
                "ee1.PNG",
                "ee2.PNG",
                "ee3.PNG",
                "ee4.PNG"
            };

            var main = Layout.Create()
                       .Add("models", Controller.From <AIController>())
                       .Add("games-main", Controller.From <GameController>())
                       .Add("games-ggj", Controller.From <GGJController>())
                       .Add("games-eternal", Controller.From <EternalController>())
                       .Add("systems", Controller.From <SystemController>())
                       .Add("reports", Controller.From <ReportController>())
                       .Add("user", ModScriban.Page(Resource.FromAssembly("user.html")).Title("Internal Systems"))
                       .Index(ModScriban.Page(Resource.FromFile("Pages/index.html")).Title("Home"));


            foreach (var resource in resources)
            {
                main.Add(resource, Download.From(Resource.FromAssembly(resource)));
            }

            var menu = Menu.Empty()
                       .Add("{website}", "Home")
                       .Add("/games-main/", "Games - Main", GameController.Links())
                       .Add("/games-eternal/", "Games - Eternal", EternalController.Links())
                       .Add("/games-ggj/", "Games - GGJ", GGJController.Links())
                       .Add("/models/", "AI Models", AIController.Links())
                       .Add("/systems/", "Systems", SystemController.Links());

            var website = Website.Create()
                          .Theme(GetAdminLTE())
                          .Menu(menu)
                          .Content(main);

            Host.Create()
            .Defaults()
            .Console()
            .Handler(website)
            .Run();
        }
Beispiel #3
0
        private static IHandlerBuilder Setup()
        {
            var content = Layout.Create()
                          .Index(Page.From("Home", "This is the home page"))
                          .Add("content", Page.From("Content", "This is additional content"));

            var main = Layout.Create()
                       .Index(ModScriban.Page(Data.FromResource("Index.html")).Title("GenHTTP Themes"));

            foreach (var entry in GetThemes())
            {
                var website = Website.Create()
                              .Theme(entry.Theme)
                              .Content(content);

                main.Add(entry.Name, website);
            }

            return(main);
        }
        public static IHandlerBuilder Create()
        {
            var auth = BasicAuthentication.Create(AccessControl.AuthenticateAsync);

            var resources = Resources.From(ResourceTree.FromAssembly("Resources"));

            var logo = Content.From(Resource.FromAssembly("eye.png"));

            var theme = Theme.Create()
                        .Title("Blickkontakt")
                        .FooterRight(RenderFooterRight)
                        .UserProfile(RenderUser)
                        .Logo(logo);

            var content = Layout.Create()
                          .Fallback(Controller.From <DashboardController>())
                          .AddController <CustomerController>("customers")
                          .AddController <AnnounceController>("announces")
                          .AddController <LetterController>("letters")
                          .AddController <AccountController>("accounts")
                          .Add("static", resources)
                          .Authentication(auth);

            var menu = Menu.Empty()
                       .Add("{website}", "Übersicht")
                       .Add("/customers/", "Kunden")
                       .Add("/announces/", "Anzeigen")
                       .Add("/letters/", "Infobriefe")
                       .Add("/accounts/", "Mitarbeiter");

            return(Website.Create()
                   .Theme(theme)
                   .Content(content)
                   .Menu(menu)
                   .AddScript("jquery-validate.js", Resource.FromAssembly("jquery.validate.min.js"))
                   .AddStyle("project.css", Resource.FromAssembly("project.css")));
        }
Beispiel #5
0
        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // Initialize:
            _url              = null;
            _website          = null;
            _simpleHttpServer = null;
            _firewallRuleName = null;

            // Show the "Loading..." page:
            this.MainContainer.Child = new PageWhenLoading();

            // Read the input parameters:
            string[] args = Environment.GetCommandLineArgs();
            if (args.Length >= 3)
            {
                string localhostOrNotArgument = args[1];
                string outputPathAbsolute     = args[2].Trim('"');

                // Determine if we should use "localhost" or the machine IP:
                bool useLocalhost = (localhostOrNotArgument == "uselocalhost" ? true : false);

                // Determine the IP address to use:
                string ipAddressToUse   = null;
                string exceptionMessage = null;
                bool   cancel           = false;
                if (useLocalhost)
                {
                    ipAddressToUse = "localhost";
                }
                else
                {
                    try
                    {
                        ipAddressToUse = IPHelper.GetLocalIPAddress();
                    }
                    catch (Exception ex)
                    {
                        exceptionMessage = "Error while attempting to determine the machine IP address:\r\n\r\n" + ex.Message;
                    }
                }

                // Start the web server:
                if (ipAddressToUse != null)
                {
                    _url = null;
                    try
                    {
                        //create server with given port:
                        if (useLocalhost)
                        {
                            _simpleHttpServer = new SimpleHTTPServer(outputPathAbsolute);
                            _url = "http://" + ipAddressToUse + ":" + _simpleHttpServer.Port.ToString() + "/";
                        }
                        else
                        {
                            //var ipByteArray = IPAddress.Parse(ipAddressToUse).GetAddressBytes();
                            //_simpleHttpServer = new SimpleHTTPServer(outputDir, ipByteArray);

                            _website = Website.Create(outputPathAbsolute, ip: ipAddressToUse);
                            _website.Start();
                            _url = _website.Url;
                            if (!string.IsNullOrEmpty(ipAddressToUse))
                            {
                                _url = _url.Replace("localhost", ipAddressToUse).Replace("127.0.0.1", ipAddressToUse);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message.Contains("REGDB_E_CLASSNOTREG"))
                        {
                            cancel                   = true;
                            _website                 = null;
                            _simpleHttpServer        = null;
                            this.MainContainer.Child = new PageWhenIISNotInstalled();
                        }
                        else
                        {
                            exceptionMessage = "Error while attempting to start the web server:\r\n\r\n" + ex.Message;
                        }
                    }

                    if (_url != null)
                    {
                        // Display the OK window:
                        this.MainContainer.Child = new PageWhenConnected(_url, useLocalhost);

                        // Attempt to open the firewall:
                        // Note: we use the "Dispatcher" as a "DoEvents" way so that the window appears before any possible error message box related to Windows Firewall.
                        Dispatcher.BeginInvoke((Action)(() =>
                        {
                            try
                            {
                                _firewallRuleName = string.Format("CSHTML5 - Allow port {0}", this.GetPort());
                                Process.Start(new ProcessStartInfo
                                {
                                    FileName = "netsh",
                                    Arguments = string.Format("advfirewall firewall add rule name=\"{0}\" dir=in protocol=tcp localport={1} remoteip=localsubnet action=allow", _firewallRuleName, this.GetPort()),
                                    Verb = "runas",
                                    UseShellExecute = true,
                                    WindowStyle = ProcessWindowStyle.Normal
                                }).WaitForExit();
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(
                                    string.Format(
                                        "We were unable to automatically configure the Windows Firewall for you.\r\n\r\nTo allow your mobile device to connect to this computer, please temporarily disable the Windows Firewall, or manually set the Windows Firewall to allow incoming connections to: {0}\r\n\r\nIf the problem persists, please report it to [email protected]\r\n\r\n------------------------------\r\nException details:\r\n" + ex.Message,
                                        _url));
                            }

                            //// Ensure access rights from other machines to the URL:
                            //if (_url != null)
                            //{
                            //    try
                            //    {
                            //        NetAclChecker.AddAddress(_url);
                            //    }
                            //    catch (Exception ex)
                            //    {
                            //        MessageBox.Show("Error while attempting to give access rights to the new web server URL: " + url + "\r\n\r\nException details:\r\n\r\n" + ex.Message);
                            //    }
                            //}
                        }));
                    }
                    else
                    {
                        if (!cancel)
                        {
                            MessageBox.Show(exceptionMessage ?? "Unable to start the web server. Please report this issue to [email protected]");
                            Quit();
                        }
                    }
                }
                else
                {
                    MessageBox.Show(exceptionMessage ?? "Unable to determine the machine IP address. Please report this issue to [email protected]");
                    Quit();
                }
            }
            else
            {
                MessageBox.Show("Invalid startup parameters. Please report this issue to [email protected]");
                Quit();
            }
        }
 public void Setup()
 {
     _website = Website.Create(@"..\..\..\TestHarness");
     _website.Start();
 }