Manga Reader Work (#1729)
* Instead of augmenting prefetcher to move across chapter bounds, let's try to instead just load 5 images (which the browser will cache) from next/prev so when it loads, it's much faster. * Trialing loading next/prev chapters 5 pages to have better next page loading experience. * Tweaked GetChapterInfo API to actually apply conditional includeDimensions parameter. * added a basic language file for upcoming work * Moved the bottom menu up a bit for iOS devices with handlebars. * Fixed fit to width on phones still having a horizontal scrollbar * Fixed a bug where there is extra space under the image when fit to width and on a phone due to pagination going to far. * Changed which variable we use for right pagination calculation * Fixing fit to height - Fixing height calc to account for horizontal scroll bar height. * Added a comment for the height scrollbar fix * Adding screenfull package # Added: - Added screenfull package to handle cross-platform browser fullscreen code # Removed: - Removed custom fullscreen code * Fixed a bug where switching from webtoon reader to other layout modes wouldn't render anything. Webtoon continuous scroll down is now broken. * Fixed it back to how it was and all is good. Need to call detectChanges explicitly. * Removed an additional undeeded save progress call on loadPage * Laid out the test case to move the page snapping to the backend with full unit tests. Current code is broken just like UI layer. * Refactored the snap points into the backend and ensure that it works correctly. * Fixed a broken unit test * Filter out spammy hubs/messages calls in the logs * Swallow all noisy messages that are from RequestLoggingMiddleware when the log level is on Information or above. * Added a common loading component to the app. Have yet to refactor all screens to use this. * Bump json5 from 2.2.0 to 2.2.3 in /UI/Web Bumps [json5](https://github.com/json5/json5) from 2.2.0 to 2.2.3. - [Release notes](https://github.com/json5/json5/releases) - [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md) - [Commits](https://github.com/json5/json5/compare/v2.2.0...v2.2.3) --- updated-dependencies: - dependency-name: json5 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Alrigned all the loading messages and styles throughout the app * Webtoon reader will use max width of all images to ensure images align well. * On Original scaling mode, users can use the keyboard to scroll around the images without pagination kicking off. * Removed console logs * Fixed a public vs private issue * Fixed an issue around some cached files getting locked due to NetVips holding them during file size calculations. Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Robbie Davis <robbie@therobbiedavis.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
parent
22442d745c
commit
2464a30bc2
37 changed files with 367 additions and 390 deletions
|
|
@ -95,7 +95,6 @@
|
|||
</PackageReference>
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="7.0.6" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.24.0" />
|
||||
<PackageReference Include="System.IO.Abstractions" Version="17.2.3" />
|
||||
<PackageReference Include="VersOne.Epub" Version="3.3.0-alpha1" />
|
||||
|
|
|
|||
|
|
@ -204,9 +204,14 @@ public class ReaderController : BaseApiController
|
|||
ChapterTitle = dto.ChapterTitle ?? string.Empty,
|
||||
Subtitle = string.Empty,
|
||||
Title = dto.SeriesName,
|
||||
PageDimensions = _cacheService.GetCachedFileDimensions(chapterId)
|
||||
};
|
||||
|
||||
if (includeDimensions)
|
||||
{
|
||||
info.PageDimensions = _cacheService.GetCachedFileDimensions(chapterId);
|
||||
info.DoublePairs = _readerService.GetPairs(info.PageDimensions);
|
||||
}
|
||||
|
||||
if (info.ChapterTitle is {Length: > 0}) {
|
||||
info.Title += " - " + info.ChapterTitle;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,15 @@ public class ChapterInfoDto : IChapterInfoDto
|
|||
/// </summary>
|
||||
/// <remarks>Usually just series name, but can include chapter title</remarks>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// List of all files with their inner archive structure maintained in filename and dimensions
|
||||
/// </summary>
|
||||
/// <remarks>This is optionally returned by includeDimensions</remarks>
|
||||
public IEnumerable<FileDimensionDto> PageDimensions { get; set; }
|
||||
/// <summary>
|
||||
/// For Double Page reader, this will contain snap points to ensure the reader always resumes on correct page
|
||||
/// </summary>
|
||||
/// <remarks>This is optionally returned by includeDimensions</remarks>
|
||||
public IDictionary<int, int> DoublePairs { get; set; }
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,4 +10,5 @@ public class FileDimensionDto
|
|||
/// </summary>
|
||||
/// <example>chapter01_page01.png</example>
|
||||
public string FileName { get; set; } = default!;
|
||||
public bool IsWide { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,10 +66,20 @@ public static class LogLevelOptions
|
|||
|
||||
private static bool ShouldIncludeLogStatement(LogEvent e)
|
||||
{
|
||||
if (e.Properties.ContainsKey("SourceContext") &&
|
||||
e.Properties["SourceContext"].ToString().Replace("\"", string.Empty) == "Serilog.AspNetCore.RequestLoggingMiddleware")
|
||||
var isRequestLoggingMiddleware = e.Properties.ContainsKey("SourceContext") &&
|
||||
e.Properties["SourceContext"].ToString().Replace("\"", string.Empty) ==
|
||||
"Serilog.AspNetCore.RequestLoggingMiddleware";
|
||||
|
||||
// If Minimum log level is Information, swallow all Request Logging messages
|
||||
if (isRequestLoggingMiddleware && LogLevelSwitch.MinimumLevel >= LogEventLevel.Information)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isRequestLoggingMiddleware)
|
||||
{
|
||||
if (e.Properties.ContainsKey("Path") && e.Properties["Path"].ToString().Replace("\"", string.Empty) == "/api/health") return false;
|
||||
if (e.Properties.ContainsKey("Path") && e.Properties["Path"].ToString().Replace("\"", string.Empty) == "/hubs/messages") return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ public interface IBookmarkService
|
|||
[DisableConcurrentExecution(timeoutInSeconds: 2 * 60 * 60), AutomaticRetry(Attempts = 0)]
|
||||
Task ConvertAllBookmarkToWebP();
|
||||
Task ConvertAllCoverToWebP();
|
||||
Task ConvertBookmarkToWebP(int bookmarkId);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -232,7 +233,7 @@ public class BookmarkService : IBookmarkService
|
|||
/// <summary>
|
||||
/// This is a job that runs after a bookmark is saved
|
||||
/// </summary>
|
||||
private async Task ConvertBookmarkToWebP(int bookmarkId)
|
||||
public async Task ConvertBookmarkToWebP(int bookmarkId)
|
||||
{
|
||||
var bookmarkDirectory =
|
||||
(await _unitOfWork.SettingsRepository.GetSettingAsync(ServerSettingKey.BookmarkDirectory)).Value;
|
||||
|
|
|
|||
|
|
@ -73,17 +73,31 @@ public class CacheService : ICacheService
|
|||
}
|
||||
|
||||
var dimensions = new List<FileDimensionDto>();
|
||||
for (var i = 0; i < files.Length; i++)
|
||||
var originalCacheSize = Cache.MaxFiles;
|
||||
try
|
||||
{
|
||||
var file = files[i];
|
||||
using var image = Image.NewFromFile(file, memory:false, access: Enums.Access.SequentialUnbuffered);
|
||||
dimensions.Add(new FileDimensionDto()
|
||||
Cache.MaxFiles = 0;
|
||||
for (var i = 0; i < files.Length; i++)
|
||||
{
|
||||
PageNumber = i,
|
||||
Height = image.Height,
|
||||
Width = image.Width,
|
||||
FileName = file.Replace(path, string.Empty)
|
||||
});
|
||||
var file = files[i];
|
||||
using var image = Image.NewFromFile(file, memory: false, access: Enums.Access.SequentialUnbuffered);
|
||||
dimensions.Add(new FileDimensionDto()
|
||||
{
|
||||
PageNumber = i,
|
||||
Height = image.Height,
|
||||
Width = image.Width,
|
||||
IsWide = image.Width > image.Height,
|
||||
FileName = file.Replace(path, string.Empty)
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError("There was an error calculating image dimensions for {ChapterId}", chapterId);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Cache.MaxFiles = originalCacheSize;
|
||||
}
|
||||
|
||||
_logger.LogDebug("File Dimensions call for {Length} images took {Time}ms", dimensions.Count, sw.ElapsedMilliseconds);
|
||||
|
|
@ -250,7 +264,7 @@ public class CacheService : ICacheService
|
|||
{
|
||||
// Calculate what chapter the page belongs to
|
||||
var path = GetCachePath(chapterId);
|
||||
// TODO: We can optimize this by extracting and renaming, so we don't need to scan for the files and can do a direct access
|
||||
// NOTE: We can optimize this by extracting and renaming, so we don't need to scan for the files and can do a direct access
|
||||
var files = _directoryService.GetFilesWithExtension(path, Tasks.Scanner.Parser.Parser.ImageFileExtensions)
|
||||
.OrderByNatural(Path.GetFileNameWithoutExtension)
|
||||
.ToArray();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
|
@ -32,6 +33,7 @@ public interface IReaderService
|
|||
Task MarkChaptersUntilAsRead(AppUser user, int seriesId, float chapterNumber);
|
||||
Task MarkVolumesUntilAsRead(AppUser user, int seriesId, int volumeNumber);
|
||||
HourEstimateRangeDto GetTimeEstimate(long wordCount, int pageCount, bool isEpub);
|
||||
IDictionary<int, int> GetPairs(IEnumerable<FileDimensionDto> dimensions);
|
||||
}
|
||||
|
||||
public class ReaderService : IReaderService
|
||||
|
|
@ -285,17 +287,17 @@ public class ReaderService : IReaderService
|
|||
/// <returns></returns>
|
||||
public async Task<int> CapPageToChapter(int chapterId, int page)
|
||||
{
|
||||
if (page < 0)
|
||||
{
|
||||
page = 0;
|
||||
}
|
||||
|
||||
var totalPages = await _unitOfWork.ChapterRepository.GetChapterTotalPagesAsync(chapterId);
|
||||
if (page > totalPages)
|
||||
{
|
||||
page = totalPages;
|
||||
}
|
||||
|
||||
if (page < 0)
|
||||
{
|
||||
page = 0;
|
||||
}
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
|
|
@ -610,6 +612,49 @@ public class ReaderService : IReaderService
|
|||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is used exclusively for double page renderer. The goal is to break up all files into pairs respecting the reader.
|
||||
/// wide images should count as 2 pages.
|
||||
/// </summary>
|
||||
/// <param name="dimensions"></param>
|
||||
/// <returns></returns>
|
||||
public IDictionary<int, int> GetPairs(IEnumerable<FileDimensionDto> dimensions)
|
||||
{
|
||||
var pairs = new Dictionary<int, int>();
|
||||
var files = dimensions.ToList();
|
||||
if (files.Count == 0) return pairs;
|
||||
|
||||
var pairStart = true;
|
||||
var previousPage = files[0];
|
||||
pairs.Add(previousPage.PageNumber, previousPage.PageNumber);
|
||||
|
||||
foreach(var dimension in files.Skip(1))
|
||||
{
|
||||
if (dimension.IsWide)
|
||||
{
|
||||
pairs.Add(dimension.PageNumber, dimension.PageNumber);
|
||||
pairStart = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (previousPage.IsWide || previousPage.PageNumber == 0)
|
||||
{
|
||||
pairs.Add(dimension.PageNumber, dimension.PageNumber);
|
||||
pairStart = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
pairs.Add(dimension.PageNumber, pairStart ? dimension.PageNumber - 1 : dimension.PageNumber);
|
||||
pairStart = !pairStart;
|
||||
}
|
||||
}
|
||||
|
||||
previousPage = dimension;
|
||||
}
|
||||
|
||||
return pairs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Formats a Chapter name based on the library it's in
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue