Changeset 426 for binary-improvements2/WebServer/src/WebAPI/APIs/Mods.cs
- Timestamp:
- Apr 24, 2023, 2:40:34 PM (19 months ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements2/WebServer/src/WebAPI/APIs/Mods.cs
r425 r426 1 1 using JetBrains.Annotations; 2 2 using Utf8Json; 3 using Webserver.Permissions; 3 4 4 5 namespace Webserver.WebAPI.APIs { 5 6 [UsedImplicitly] 6 public class WebMods : AbsRestApi {7 public class Mods : AbsRestApi { 7 8 private readonly byte[] loadedWebMods; 8 9 9 public WebMods (Web _parent) {10 public Mods (Web _parent) { 10 11 JsonWriter writer = new JsonWriter (); 11 12 writer.WriteBeginArray (); … … 13 14 for (int i = 0; i < _parent.webMods.Count; i++) { 14 15 WebMod webMod = _parent.webMods [i]; 15 16 16 17 if (i > 0) { 17 18 writer.WriteValueSeparator (); 18 19 } 19 20 20 21 writer.WriteBeginObject (); 21 22 22 writer.WriteString ("name"); 23 writer.WriteNameSeparator (); 24 writer.WriteString (webMod.ParentMod.Name); 23 writeModJson (ref writer, webMod); 25 24 26 string webModReactBundle = webMod.ReactBundle; 27 if (webModReactBundle != null) { 25 if (webMod.ReactBundle != null || webMod.CssPath != null) { 28 26 writer.WriteValueSeparator (); 29 writer.WriteString ("bundle");30 writer.WriteNameSeparator ();31 writer.WriteString (webModReactBundle);32 }33 27 34 string webModCssFile = webMod.CssPath; 35 if (webModCssFile != null) { 36 writer.WriteValueSeparator (); 37 writer.WriteString ("css"); 38 writer.WriteNameSeparator (); 39 writer.WriteString (webModCssFile); 28 writer.WritePropertyName ("web"); 29 writer.WriteBeginObject (); 30 31 string webModReactBundle = webMod.ReactBundle; 32 if (webModReactBundle != null) { 33 writer.WritePropertyName ("bundle"); 34 writer.WriteString (webModReactBundle); 35 } 36 37 string webModCssFile = webMod.CssPath; 38 if (webModCssFile != null) { 39 if (webModReactBundle != null) { 40 writer.WriteValueSeparator (); 41 } 42 43 writer.WritePropertyName ("css"); 44 writer.WriteString (webModCssFile); 45 } 46 47 writer.WriteEndObject (); 40 48 } 41 49 … … 54 62 } 55 63 56 public override int DefaultPermissionLevel () => 2000; 64 public override int DefaultPermissionLevel () => AdminWebModules.PermissionLevelGuest; 65 66 private void writeModJson (ref JsonWriter _writer, WebMod _webMod) { 67 _writer.WritePropertyName ("name"); 68 _writer.WriteString (_webMod.ParentMod.Name); 69 70 _writer.WriteValueSeparator (); 71 _writer.WritePropertyName ("displayName"); 72 JsonCommons.WriteStringOrNull (ref _writer, _webMod.ParentMod.DisplayName); 73 74 _writer.WriteValueSeparator (); 75 _writer.WritePropertyName ("description"); 76 JsonCommons.WriteStringOrNull (ref _writer, _webMod.ParentMod.Description); 77 78 _writer.WriteValueSeparator (); 79 _writer.WritePropertyName ("author"); 80 JsonCommons.WriteStringOrNull (ref _writer, _webMod.ParentMod.Author); 81 82 _writer.WriteValueSeparator (); 83 _writer.WritePropertyName ("version"); 84 JsonCommons.WriteStringOrNull (ref _writer, _webMod.ParentMod.VersionString); 85 86 _writer.WriteValueSeparator (); 87 _writer.WritePropertyName ("website"); 88 JsonCommons.WriteStringOrNull (ref _writer, _webMod.ParentMod.Website); 89 } 57 90 } 58 91 }
Note:
See TracChangeset
for help on using the changeset viewer.