diff --git a/zero.Backoffice.UI/public/assets/zero-2-light.png b/zero.Backoffice.UI/public/assets/zero-2-light.png new file mode 100644 index 00000000..bf58a593 Binary files /dev/null and b/zero.Backoffice.UI/public/assets/zero-2-light.png differ diff --git a/zero.Backoffice.UI/public/assets/zero-2.png b/zero.Backoffice.UI/public/assets/zero-2.png new file mode 100644 index 00000000..083da3de Binary files /dev/null and b/zero.Backoffice.UI/public/assets/zero-2.png differ diff --git a/zero.Backoffice.UI/public/assets/zero-dark.png b/zero.Backoffice.UI/public/assets/zero-dark.png new file mode 100644 index 00000000..d8447c3e Binary files /dev/null and b/zero.Backoffice.UI/public/assets/zero-dark.png differ diff --git a/zero.Backoffice.UI/public/assets/zero-dark.svg b/zero.Backoffice.UI/public/assets/zero-dark.svg new file mode 100644 index 00000000..8330855d --- /dev/null +++ b/zero.Backoffice.UI/public/assets/zero-dark.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/zero.Backoffice.UI/public/assets/zero-icon.png b/zero.Backoffice.UI/public/assets/zero-icon.png new file mode 100644 index 00000000..683dc936 Binary files /dev/null and b/zero.Backoffice.UI/public/assets/zero-icon.png differ diff --git a/zero.Backoffice.UI/public/assets/zero-icon.svg b/zero.Backoffice.UI/public/assets/zero-icon.svg new file mode 100644 index 00000000..37e8f11a --- /dev/null +++ b/zero.Backoffice.UI/public/assets/zero-icon.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/zero.Backoffice.UI/public/assets/zero.png b/zero.Backoffice.UI/public/assets/zero.png new file mode 100644 index 00000000..e7d94bd6 Binary files /dev/null and b/zero.Backoffice.UI/public/assets/zero.png differ diff --git a/zero.Backoffice.UI/public/assets/zero.svg b/zero.Backoffice.UI/public/assets/zero.svg new file mode 100644 index 00000000..19ffb2ca --- /dev/null +++ b/zero.Backoffice.UI/public/assets/zero.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/zero.Backoffice.UI/public/resources/icons/feather.svg b/zero.Backoffice.UI/public/resources/icons/feather.svg new file mode 100644 index 00000000..bb63c4cb --- /dev/null +++ b/zero.Backoffice.UI/public/resources/icons/feather.svg @@ -0,0 +1,492 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/zero.Backoffice.UI/public/resources/icons/gg.svg b/zero.Backoffice.UI/public/resources/icons/gg.svg new file mode 100644 index 00000000..93e07bd6 --- /dev/null +++ b/zero.Backoffice.UI/public/resources/icons/gg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/zero.Backoffice.UI/public/test.txt b/zero.Backoffice.UI/public/test.txt new file mode 100644 index 00000000..abc5dfba --- /dev/null +++ b/zero.Backoffice.UI/public/test.txt @@ -0,0 +1,2 @@ + +uff \ No newline at end of file diff --git a/zero.Backoffice.UI/vite.config.js b/zero.Backoffice.UI/vite.config.js index c04f6bc9..adfb1e04 100644 --- a/zero.Backoffice.UI/vite.config.js +++ b/zero.Backoffice.UI/vite.config.js @@ -99,17 +99,11 @@ let config = defineConfig({ build: { manifest: true, outDir: 'dist/zero', - minify: false, - terserOptions: { - compress: false - }, - //alias: { - // 'tiptap': 'tiptap/dist/tiptap.esm.js', + minify: 'esbuild', + //terserOptions: { + // compress: false //}, rollupOptions: { - external: { - '@vue/compat': 'xoo/xoo.js' - }, output: { format: 'es', entryFileNames: `[name].js`, @@ -120,18 +114,10 @@ let config = defineConfig({ } }); -//console.log('root: ' + config.root); - if (process.env.NODE_ENV === 'production') { config.base = '/zero/'; - //config.alias.tiptap = 'node_modules/tiptap/dist/tiptap.esm.js'; - - //config.alias.tiptap = 'node_modules/tiptap/dist/tiptap.esm.js'; - //config.alias.underscore = 'node_modules/underscore/underscore-esm.js'; - //config.alias.axios = 'node_modules/axios/dist/axios.js'; config.resolve.alias.dayjs = 'node_modules/dayjs/esm/index.js'; - //config.alias.tiptap = 'node_modules/tiptap/dist/tiptap.esm.js'; } export default config; \ No newline at end of file diff --git a/zero.Backoffice/BackofficeResourceFileSystem.cs b/zero.Backoffice/BackofficeResourceFileSystem.cs new file mode 100644 index 00000000..784a98d0 --- /dev/null +++ b/zero.Backoffice/BackofficeResourceFileSystem.cs @@ -0,0 +1,11 @@ +namespace zero.Backoffice; + +public class BackofficeResourceFileSystem : PhysicalFileSystem, IBackofficeResourceFileSystem +{ + public BackofficeResourceFileSystem(string root) : base(root) { } +} + + +public interface IBackofficeResourceFileSystem : IFileSystem +{ +} \ No newline at end of file diff --git a/zero.Backoffice/Configuration/BackofficeOptions.cs b/zero.Backoffice/Configuration/BackofficeOptions.cs index 5eafc93c..20a7ba76 100644 --- a/zero.Backoffice/Configuration/BackofficeOptions.cs +++ b/zero.Backoffice/Configuration/BackofficeOptions.cs @@ -2,6 +2,11 @@ public class BackofficeOptions { + /// + /// Hash for all zero assets + /// + public string AssetHash { get; set; } + /// /// Public path to zero assets /// diff --git a/zero.Backoffice/Controllers/ZeroIndexController.cs b/zero.Backoffice/Controllers/ZeroIndexController.cs index dcf30b78..7dbcda5f 100644 --- a/zero.Backoffice/Controllers/ZeroIndexController.cs +++ b/zero.Backoffice/Controllers/ZeroIndexController.cs @@ -14,12 +14,14 @@ public class ZeroIndexController : Controller IZeroOptions Options { get; set; } IIconService IconRepository { get; set; } IWebHostEnvironment Env { get; set; } + IBackofficeAssetFileSystem AssetFileSystem { get; set; } - public ZeroIndexController(IZeroOptions options, IIconService iconRepository, IWebHostEnvironment env) + public ZeroIndexController(IZeroOptions options, IIconService iconRepository, IWebHostEnvironment env, IBackofficeAssetFileSystem assetFileSystem) { Options = options; IconRepository = iconRepository; Env = env; + AssetFileSystem = assetFileSystem; } @@ -30,7 +32,9 @@ public class ZeroIndexController : Controller return RedirectToAction("ZeroBackoffice", "Setup"); } - int port = Options.For().DevServer.Port; + BackofficeOptions options = Options.For(); + + int port = options.DevServer.Port; string domain = "http://localhost:" + port; Dictionary model = new() @@ -40,14 +44,19 @@ public class ZeroIndexController : Controller { "svg", await IconRepository.GetCompiledSvg() } }; - if (!Env.IsDevelopment() || true) + if (!Env.IsDevelopment()) { - model["bottom"] = String.Empty; - model["top"] = @" - - - - "; + string html = System.IO.File.ReadAllText(Path.Combine(Env.WebRootPath, "zero/index.html")); + return Content(html, "text/html"); + //string assetHash = options.AssetHash; + //string suffix = assetHash.HasValue() ? "?v=" + assetHash : String.Empty; + + //model["bottom"] = String.Empty; + //model["top"] = @$" + // + // + // + //"; } string content = TokenReplacement.Apply(await LoadTemplate("zero.Backoffice.Resources.backoffice.tpl.html"), model); diff --git a/zero.Backoffice/Plugin.cs b/zero.Backoffice/Plugin.cs index a51b7c9a..11ac9413 100644 --- a/zero.Backoffice/Plugin.cs +++ b/zero.Backoffice/Plugin.cs @@ -19,7 +19,7 @@ public class ZeroBackofficePlugin : ZeroPlugin public ZeroBackofficePlugin() { Options.Name = "zero.Backoffice"; - Options.LocalizationPaths.Add("~/Resources/Localization/zero.{lang}.json"); + Options.LocalizationPaths.Add("Resources/Localization/zero.{lang}.json"); } @@ -42,6 +42,13 @@ public class ZeroBackofficePlugin : ZeroPlugin return new(Path.Combine(env.WebRootPath, options.Value.AssetPath)); }); + services.AddSingleton(svc => + { + IOptions options = svc.GetRequiredService>(); + IWebHostEnvironment env = svc.GetRequiredService(); + return new(env.ContentRootPath); + }); + services.AddZeroBackofficeUIComposition(); //services.AddTransient(); diff --git a/zero.Backoffice/Resources/backoffice.tpl.html b/zero.Backoffice/Resources/backoffice.tpl.html index 12eb4d88..29302f78 100644 --- a/zero.Backoffice/Resources/backoffice.tpl.html +++ b/zero.Backoffice/Resources/backoffice.tpl.html @@ -8,9 +8,9 @@ - - - + + + {top} zero diff --git a/zero.Backoffice/Services/Resources/ResourceService.cs b/zero.Backoffice/Services/Resources/ResourceService.cs index 6fa5565d..08c4f315 100644 --- a/zero.Backoffice/Services/Resources/ResourceService.cs +++ b/zero.Backoffice/Services/Resources/ResourceService.cs @@ -1,4 +1,6 @@ -using Microsoft.Extensions.Logging; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Newtonsoft.Json.Linq; using System.IO; @@ -10,26 +12,32 @@ public class ResourceService : IResourceService { protected IOptions Options { get; set; } - protected IBackofficeAssetFileSystem FileSystem { get; set; } + protected IBackofficeAssetFileSystem AssetFileSystem { get; set; } + + protected IBackofficeResourceFileSystem ResourceFileSystem { get; set; } protected ILogger Logger { get; set; } protected IEnumerable Plugins { get; set; } + protected IWebHostEnvironment Env { get; set; } - public ResourceService(IOptions options, IBackofficeAssetFileSystem fileSystem, ILogger logger, IEnumerable plugins) + + public ResourceService(IOptions options, IBackofficeAssetFileSystem assetFileSystem, IBackofficeResourceFileSystem resourceFileSystem, ILogger logger, IEnumerable plugins, IWebHostEnvironment env) { Options = options; - FileSystem = fileSystem; + AssetFileSystem = assetFileSystem; + ResourceFileSystem = resourceFileSystem; Logger = logger; Plugins = plugins; + Env = env; } /// public Task> GetTranslations(string cultureIsoCode) { - var zeroTranslations = CreateTranslationsForFile("O:/zero/zero.Backoffice/Resources/Localization/zero.en-us.json", cultureIsoCode); // TODO + Dictionary zeroTranslations = new(); // CreateTranslationsForFile("O:/zero/zero.Backoffice/Resources/Localization/zero.en-us.json", cultureIsoCode); // TODO foreach (IZeroPlugin plugin in Plugins) { @@ -54,20 +62,21 @@ public class ResourceService : IResourceService Dictionary CreateTranslationsForFile(string path, string culture) { Dictionary items = new(); - culture = culture?.ToLower(); + culture = culture.ToLower(); - if (!culture.IsNullOrEmpty() && culture != "en-us") + if (path.Contains("{lang}")) { - items = CreateTranslationsForFile(path, "en-us"); - path = path.Replace("en-us", culture); + path = path.Replace("{lang}", culture); } - if (!File.Exists(path)) + string fullpath = Env.IsDevelopment() ? Path.Combine(AppContext.BaseDirectory, path) : ResourceFileSystem.Map(path); + + if (!File.Exists(fullpath)) { return items; } - string text = File.ReadAllText(path, Encoding.GetEncoding("ISO-8859-1")); + string text = File.ReadAllText(fullpath, Encoding.GetEncoding("ISO-8859-1")); JObject json = JObject.Parse(text); IEnumerable tokens = json.Descendants().Where(p => !p.Any()); diff --git a/zero.Backoffice/zero.Backoffice.csproj b/zero.Backoffice/zero.Backoffice.csproj index 03485234..b58d1024 100644 --- a/zero.Backoffice/zero.Backoffice.csproj +++ b/zero.Backoffice/zero.Backoffice.csproj @@ -17,8 +17,28 @@ + + + + + + + + + + Always + + + Always + + + Always + + + Always +