Пример #1
0
        public WebDisplay(WebData webData)
        {
            DirectoryInfo baseDir = null;

            if (string.IsNullOrEmpty(webData.WebinterfaceHostPath))
            {
                for (int i = 0; i < 4; i++)
                {
                    var up       = Path.Combine(Enumerable.Repeat("..", i).ToArray());
                    var checkDir = Path.Combine(up, "WebInterface");
                    if (Directory.Exists(checkDir))
                    {
                        baseDir = new DirectoryInfo(checkDir);
                        break;
                    }
                }
            }
            else if (Directory.Exists(webData.WebinterfaceHostPath))
            {
                baseDir = new DirectoryInfo(webData.WebinterfaceHostPath);
            }

            if (baseDir == null)
            {
                throw new InvalidOperationException("Can't find a WebInterface path to host. Try specifying the path to host in the config");
            }

            var dir = new FolderProvider(baseDir);

            map.Map("/", dir);
            map.Map("/site/", dir);

            Site404 = map.TryGetSite(new Uri("http://localhost/404.html"));
            map.Map("/", map.TryGetSite(new Uri("http://localhost/index.html")));
        }
Пример #2
0
        public WebDisplay(MainBot bot) : base(bot)
        {
            var baseDir = new DirectoryInfo(Path.Combine("..", "..", "Web", "Interface"));
            var dir     = new FolderProvider(baseDir);

            map.Map("/", dir);
            map.Map("/site/", dir);

            Site404 = map.TryGetSite(new Uri("http://localhost/404.html"));
            map.Map("/", map.TryGetSite(new Uri("http://localhost/index.html")));
        }
Пример #3
0
        public WebDisplay(Config.ConfWebInterface webData)
        {
            DirectoryInfo baseDir = null;

            if (string.IsNullOrEmpty(webData.Path))
            {
                for (int i = 0; i < 5; i++)
                {
                    var up       = Path.Combine(Enumerable.Repeat("..", i).ToArray());
                    var checkDir = Path.Combine(up, "WebInterface");
                    if (Directory.Exists(checkDir))
                    {
                        baseDir = new DirectoryInfo(checkDir);
                        break;
                    }
                }
            }
            else if (Directory.Exists(webData.Path))
            {
                baseDir = new DirectoryInfo(webData.Path);
            }

            if (baseDir == null)
            {
                Log.Error("Can't find a WebInterface path to host. Try specifying the path to host in the config");
                return;
            }

            var dir = new FolderProvider(baseDir);

            map.Map("/", dir);
            map.Map("/site/", dir);
            map.Map("/openapi/", new FolderProvider(new DirectoryInfo(Path.Combine(baseDir.FullName, "openapi"))));

            Site404 = map.TryGetSite(new Uri("http://localhost/404.html"));
            map.Map("/", map.TryGetSite(new Uri("http://localhost/index.html")));
        }