source: binary-improvements2/WebServer/src/WebMod.cs@ 426

Last change on this file since 426 was 426, checked in by alloc, 19 months ago

*Updated web permissions system
*Fixed webpermissions command
*Moved API "webmods" to "mods", also lists non-webmod mods

File size: 1.3 KB
RevLine 
[391]1using System.IO;
[402]2using Webserver.FileCache;
[391]3using Webserver.UrlHandlers;
4
5namespace Webserver {
6 public class WebMod {
7 private const string modsBaseUrl = "/webmods/";
8 private const string reactBundleName = "bundle.js";
9 private const string stylingFileName = "styling.css";
10
11 public readonly Mod ParentMod;
12 public readonly string ReactBundle; // Absolute web path to the React bundle if the mod has one, e.g. "/webmods/myMod/bundle.js"
13 public readonly string CssPath; // Absolute web path to a CSS if the mod has one, e.g. "/webmods/myMod/styling.css";
[426]14 public readonly bool IsWebMod;
[391]15
16 public WebMod (Web _parentWeb, Mod _parentMod, bool _useStaticCache) {
[426]17 ParentMod = _parentMod;
18
[402]19 string folder = $"{_parentMod.Path}/WebMod";
[426]20 IsWebMod = Directory.Exists (folder);
[391]21
[426]22 if (IsWebMod) {
23 string urlWebModBase = $"{modsBaseUrl}{_parentMod.FolderName}/";
[391]24
[426]25 ReactBundle = $"{folder}/{reactBundleName}";
26 ReactBundle = File.Exists (ReactBundle) ? $"{urlWebModBase}{reactBundleName}" : null;
[391]27
[426]28 CssPath = $"{folder}/{stylingFileName}";
29 CssPath = File.Exists (CssPath) ? $"{urlWebModBase}{stylingFileName}" : null;
[391]30
[426]31 _parentWeb.RegisterPathHandler (urlWebModBase, new StaticHandler (
32 folder,
33 _useStaticCache ? new SimpleCache () : new DirectAccess (),
34 false)
35 );
[391]36 }
37 }
38 }
39}
Note: See TracBrowser for help on using the repository browser.