Changeset 426 for binary-improvements2/WebServer/src/WebMod.cs
- Timestamp:
- Apr 24, 2023, 2:40:34 PM (19 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/WebServer/src/WebMod.cs
r402 r426 12 12 public readonly string ReactBundle; // Absolute web path to the React bundle if the mod has one, e.g. "/webmods/myMod/bundle.js" 13 13 public readonly string CssPath; // Absolute web path to a CSS if the mod has one, e.g. "/webmods/myMod/styling.css"; 14 public readonly bool IsWebMod; 14 15 15 16 public WebMod (Web _parentWeb, Mod _parentMod, bool _useStaticCache) { 16 string folder = $"{_parentMod.Path}/WebMod";17 if (!Directory.Exists (folder)) {18 throw new InvalidDataException("No WebMod folder in mod");19 }20 21 string urlWebModBase = $"{modsBaseUrl}{_parentMod.FolderName}/";22 23 ReactBundle = $"{folder}/{reactBundleName}";24 ReactBundle = File.Exists (ReactBundle) ? $"{urlWebModBase}{reactBundleName}" : null;25 26 CssPath = $"{folder}/{stylingFileName}";27 CssPath = File.Exists (CssPath) ? $"{urlWebModBase}{stylingFileName}" : null;28 29 if (ReactBundle == null && CssPath == null) {30 throw new InvalidDataException($"WebMod folder has neither a {reactBundleName} nor a {stylingFileName}");31 }32 33 17 ParentMod = _parentMod; 34 18 35 _parentWeb.RegisterPathHandler (urlWebModBase, new StaticHandler ( 36 folder, 37 _useStaticCache ? new SimpleCache () : new DirectAccess (), 38 false) 39 ); 19 string folder = $"{_parentMod.Path}/WebMod"; 20 IsWebMod = Directory.Exists (folder); 21 22 if (IsWebMod) { 23 string urlWebModBase = $"{modsBaseUrl}{_parentMod.FolderName}/"; 24 25 ReactBundle = $"{folder}/{reactBundleName}"; 26 ReactBundle = File.Exists (ReactBundle) ? $"{urlWebModBase}{reactBundleName}" : null; 27 28 CssPath = $"{folder}/{stylingFileName}"; 29 CssPath = File.Exists (CssPath) ? $"{urlWebModBase}{stylingFileName}" : null; 30 31 _parentWeb.RegisterPathHandler (urlWebModBase, new StaticHandler ( 32 folder, 33 _useStaticCache ? new SimpleCache () : new DirectAccess (), 34 false) 35 ); 36 } 40 37 } 41 38 }
Note:
See TracChangeset
for help on using the changeset viewer.