diff --git a/.gitignore b/.gitignore index 01e899a..b523ad6 100644 --- a/.gitignore +++ b/.gitignore @@ -56,4 +56,5 @@ nunit-*.xml # DB *.db -appsettings.json \ No newline at end of file +appsettings.json +appsettings.Development.json \ No newline at end of file diff --git a/.idea/.idea.Abyss/.idea/workspace.xml b/.idea/.idea.Abyss/.idea/workspace.xml index 59d545e..19883db 100644 --- a/.idea/.idea.Abyss/.idea/workspace.xml +++ b/.idea/.idea.Abyss/.idea/workspace.xml @@ -10,10 +10,21 @@ + + + + + + + + - + + + + + + - - + + - - + + + + + + + + + + + { "associatedIndex": 3 } @@ -56,31 +79,31 @@ - { - "keyToString": { - ".NET Launch Settings Profile.Abyss: http.executor": "Run", - ".NET Launch Settings Profile.Abyss: https.executor": "Run", - ".NET Project.AbyssCli.executor": "Run", - "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true", - "ModuleVcsDetector.initialDetectionPerformed": "true", - "Publish to folder.Publish Abyss to folder x86.executor": "Run", - "Publish to folder.Publish Abyss to folder.executor": "Run", - "RunOnceActivity.ShowReadmeOnStart": "true", - "RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true", - "RunOnceActivity.git.unshallow": "true", - "XThreadsFramesViewSplitterKey": "0.30266345", - "git-widget-placeholder": "main", - "last_opened_file_path": "/opt/security/https/server", - "node.js.detected.package.eslint": "true", - "node.js.detected.package.tslint": "true", - "node.js.selected.package.eslint": "(autodetect)", - "node.js.selected.package.tslint": "(autodetect)", - "nodejs_package_manager_path": "npm", - "settings.editor.selected.configurable": "preferences.pluginManager", - "vue.rearranger.settings.migration": "true" + - +}]]> + @@ -174,7 +197,20 @@ - + + + + + + + + + + + + + + @@ -194,7 +230,7 @@ - diff --git a/Abyss.sln.DotSettings.user b/Abyss.sln.DotSettings.user index e567e74..152a239 100644 --- a/Abyss.sln.DotSettings.user +++ b/Abyss.sln.DotSettings.user @@ -2,4 +2,6 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded + ForceIncluded ForceIncluded \ No newline at end of file diff --git a/Abyss/Components/Controllers/Media/ImageController.cs b/Abyss/Components/Controllers/Media/ImageController.cs index 969c42d..c5f94fc 100644 --- a/Abyss/Components/Controllers/Media/ImageController.cs +++ b/Abyss/Components/Controllers/Media/ImageController.cs @@ -1,6 +1,9 @@ using Abyss.Components.Services; using Abyss.Components.Static; +using Abyss.Components.Tools; +using Abyss.Model; using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; namespace Abyss.Components.Controllers.Media; @@ -28,7 +31,7 @@ public class ImageController(ILogger logger, ResourceService rs if(r == null) return StatusCode(401, new { message = "Unauthorized" }); - return Ok(r); + return Ok(r.NaturalSort(x => x)); } [HttpGet("{id}")] @@ -42,6 +45,27 @@ public class ImageController(ILogger logger, ResourceService rs return Ok(await System.IO.File.ReadAllTextAsync(d)); } + + [HttpPost("{id}/bookmark")] + public async Task Bookmark(string id, string token, [FromBody] Bookmark bookmark) + { + var d = Helpers.SafePathCombine(ImageFolder, [id, "summary.json"]); + if (d == null) return StatusCode(403, new { message = "403 Denied" }); + + var r = await rs.Update(d, token, Ip); + if (!r) return StatusCode(403, new { message = "403 Denied" }); + + Comic c = JsonConvert.DeserializeObject(await System.IO.File.ReadAllTextAsync(d))!; + + var bookmarkPage = Helpers.SafePathCombine(ImageFolder, [id, bookmark.Page]); + if(!System.IO.File.Exists(bookmarkPage)) + return BadRequest(); + + c.Bookmarks.Add(bookmark); + var o = JsonConvert.SerializeObject(c); + await System.IO.File.WriteAllTextAsync(d, o); + return Ok(); + } [HttpGet("{id}/{file}")] public async Task Get(string id, string file, string token) diff --git a/Abyss/Components/Controllers/Media/VideoController.cs b/Abyss/Components/Controllers/Media/VideoController.cs index 3fccbdd..520a995 100644 --- a/Abyss/Components/Controllers/Media/VideoController.cs +++ b/Abyss/Components/Controllers/Media/VideoController.cs @@ -1,7 +1,10 @@ using System.Diagnostics; using Abyss.Components.Services; using Abyss.Components.Static; +using Abyss.Components.Tools; +using Abyss.Model; using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; namespace Abyss.Components.Controllers.Media; @@ -38,10 +41,24 @@ public class VideoController(ILogger logger, ResourceService rs var d = Helpers.SafePathCombine(VideoFolder, klass); if (d == null) return StatusCode(403, new { message = "403 Denied" }); var r = await rs.Query(d, token, Ip); - if (r == null) return StatusCode(401, new { message = "Unauthorized" }); + + var rv = r.Select(x => + { + return Helpers.SafePathCombine(VideoFolder, [klass, x, "summary.json"]); + }).ToArray(); + + for (int i = 0; i < rv.Length; i++) + { + if(rv[i] == null) continue; + rv[i] = await System.IO.File.ReadAllTextAsync(rv[i] ?? ""); + } + + var sv = rv.Where(x => x!=null).Select(x => x ?? "") + .Select(x => JsonConvert.DeserializeObject