Esempio n. 1
0
 public ContentSite(byte[] fetchBlock, WebSite site, PreparedData data)
 {
     OwnContent   = fetchBlock;
     Site         = site;
     PreparedData = data;
 }
Esempio n. 2
0
        public WebDisplay(MainBot bot) : base(bot)
        {
            Util.Init(ref sites);

            var baseDir = new DirectoryInfo(Path.Combine("..", "..", "Web", "Interface"));
            Func <DirectoryInfo, string, FileInfo> dirFile = (d, s) => d.GetFiles(s, SearchOption.TopDirectoryOnly).FirstOrDefault();

            Index = new WebIndexFile("index.html", new FileProvider().Set(dirFile(baseDir, "index.html")), GetWebsite)
            {
                MimeType = "text/html"
            };
            PrepareSite(Index);
            PrepareSite(Index, string.Empty);
            PrepareSite(new WebStaticSite("main", dirFile(baseDir, "main.html"))
            {
                MimeType = "text/css"
            });
            PrepareSite(new WebStaticSite("styles.css", dirFile(baseDir, "styles.css"))
            {
                MimeType = "text/css"
            });
            PrepareSite(new WebStaticSite("scripts.js", dirFile(baseDir, "scripts.js"))
            {
                MimeType = "application/javascript"
            });
            PrepareSite(new WebStaticSite("favicon.ico", "TS3AudioBot.Web.Interface.favicon.ico")
            {
                MimeType = "image/x-icon", Encoding = Encoding.ASCII
            });
            Site404 = new WebStaticSite("404", "TS3AudioBot.Web.Interface.favicon.ico")
            {
                MimeType = "text/plain"
            };
            PrepareSite(Site404);
            PrepareSite(new WebHistorySearch("historysearch", MainBot)
            {
                MimeType = "text/plain"
            });
            var historystatic = new WebHistorySearchList("historystatic", MainBot)
            {
                MimeType = "text/html"
            };

            PrepareSite(historystatic);
            PrepareSite(new WebJSFillSite("history", new FileProvider().Set(dirFile(baseDir, "history.html")), historystatic)
            {
                MimeType = "text/html"
            });
            PrepareSite(new WebStaticSite("playcontrols", dirFile(baseDir, "playcontrols.html"))
            {
                MimeType = "text/html"
            });
            PrepareSite(new WebPlayControls("control", MainBot)
            {
                MimeType = "text/html"
            });
            PrepareSite(new SongChangedEvent("playdata", MainBot));
            var devupdate = new SiteChangedEvent("devupdate");

            PrepareSite(devupdate);
            folderWatcher = Util.RegisterFolderEvents(baseDir, (s, e) =>
            {
                if (e.ChangeType == WatcherChangeTypes.Changed && !e.Name.EndsWith("~", StringComparison.Ordinal))
                {
                    devupdate.InvokeEvent();
                }
            });
            if (folderWatcher == null)
            {
                Log.Write(Log.Level.Info, "Devupdate disabled");
            }
        }
Esempio n. 3
0
        public void PrepareSite(WebSite site, string page)
        {
            var genUrl = new Uri(dummy, page);

            sites.Add(genUrl.AbsolutePath, site);
        }
Esempio n. 4
0
 public WebJSFillSite(string sitePath, FileProvider provider, WebSite innerSite) : this(sitePath, provider)
 {
     this.innerSite = innerSite;
 }
Esempio n. 5
0
 public void PrepareSite(WebSite site) => PrepareSite(site, site.SitePath);