mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-05-24 00:52:23 -04:00
* From previous fix, added the other locking conditions on the update series metadata. * Fixed a bug where custom series, collection tag, and reading list covers weren't being removed on cleanup. * Ensure reading list detail has a margin to align to the standard * Refactored some event stuff to use dedicated consts. Introduced a new event when users read something, which can update progress bars on cards. * Added recomended and library tags to the library detail page. This will eventually offer more custom analytics * Cleanup some code onc arousel * Adjusted scale to height/width css to better fit * Small css tweaks to better center images in the manga reader in both axis. This takes care of double page rendering as well. * When a special has a Title set in the metadata, on series detail page, show that on the card rather than filename. * Fixed a bug where when paging in manga reader, the scroll to top wasn't working due to changing where scrolling is done * More css goodness for rendering images in manga reader * Fixed a bug where clearing a typeahead externally wouldn't clear the x button * Fixed a bug where filering then using keyboard would select wrong option * Added a new sorting field for Last Chapter Added (new field) to get a similar on deck feel. * Tweaked recently updated to hit the NFR of 500ms (300ms fresh start) and still give a much better experience. * Refactored On deck to now go to all series and also sort by last updated. Recently Added Series now loads all series with sort by created. * Some tweaks on css for cover image chooser * Fixed a bug in pagination control where multiple pagination events could trigger on load and thus multiple requests for data on parent controller. * Updated edit series modal to show when the last chapter was added and when user last read it. * Implemented a highlight on the fitler button when a filter is active. * Refactored metadata filter screens to perserve the filters in the url and thus when navigating back and forth, it will retain. users should click side nav to reset the state. * Hide middle section on companion bar on phones * Cleaned up some prefilters and console.logs * Don't open drawer by default when a filter is active
151 lines
4.7 KiB
C#
151 lines
4.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using API.Data.Metadata;
|
|
using API.Entities;
|
|
using API.Entities.Enums;
|
|
using API.Entities.Metadata;
|
|
using API.Extensions;
|
|
using API.Parser;
|
|
using API.Services.Tasks;
|
|
|
|
namespace API.Data
|
|
{
|
|
/// <summary>
|
|
/// Responsible for creating Series, Volume, Chapter, MangaFiles for use in <see cref="ScannerService"/>
|
|
/// </summary>
|
|
public static class DbFactory
|
|
{
|
|
public static Series Series(string name)
|
|
{
|
|
return new Series
|
|
{
|
|
Name = name,
|
|
OriginalName = name,
|
|
LocalizedName = name,
|
|
NormalizedName = Parser.Parser.Normalize(name),
|
|
SortName = name,
|
|
Volumes = new List<Volume>(),
|
|
Metadata = SeriesMetadata(Array.Empty<CollectionTag>())
|
|
};
|
|
}
|
|
|
|
public static Volume Volume(string volumeNumber)
|
|
{
|
|
return new Volume()
|
|
{
|
|
Name = volumeNumber,
|
|
Number = (int) Parser.Parser.MinimumNumberFromRange(volumeNumber),
|
|
Chapters = new List<Chapter>()
|
|
};
|
|
}
|
|
|
|
public static Chapter Chapter(ParserInfo info)
|
|
{
|
|
var specialTreatment = info.IsSpecialInfo();
|
|
var specialTitle = specialTreatment ? info.Filename : info.Chapters;
|
|
return new Chapter()
|
|
{
|
|
Number = specialTreatment ? "0" : Parser.Parser.MinimumNumberFromRange(info.Chapters) + string.Empty,
|
|
Range = specialTreatment ? info.Filename : info.Chapters,
|
|
Title = (specialTreatment && info.Format == MangaFormat.Epub)
|
|
? info.Title
|
|
: specialTitle,
|
|
Files = new List<MangaFile>(),
|
|
IsSpecial = specialTreatment,
|
|
};
|
|
}
|
|
|
|
public static SeriesMetadata SeriesMetadata(ComicInfo info)
|
|
{
|
|
return SeriesMetadata(Array.Empty<CollectionTag>());
|
|
}
|
|
|
|
public static SeriesMetadata SeriesMetadata(ICollection<CollectionTag> collectionTags)
|
|
{
|
|
return new SeriesMetadata()
|
|
{
|
|
CollectionTags = collectionTags,
|
|
Summary = string.Empty
|
|
};
|
|
}
|
|
|
|
public static CollectionTag CollectionTag(int id, string title, string summary, bool promoted)
|
|
{
|
|
return new CollectionTag()
|
|
{
|
|
Id = id,
|
|
NormalizedTitle = API.Parser.Parser.Normalize(title?.Trim()).ToUpper(),
|
|
Title = title?.Trim(),
|
|
Summary = summary?.Trim(),
|
|
Promoted = promoted
|
|
};
|
|
}
|
|
|
|
public static ReadingList ReadingList(string title, string summary, bool promoted)
|
|
{
|
|
return new ReadingList()
|
|
{
|
|
NormalizedTitle = API.Parser.Parser.Normalize(title?.Trim()).ToUpper(),
|
|
Title = title?.Trim(),
|
|
Summary = summary?.Trim(),
|
|
Promoted = promoted,
|
|
Items = new List<ReadingListItem>()
|
|
};
|
|
}
|
|
|
|
public static ReadingListItem ReadingListItem(int index, int seriesId, int volumeId, int chapterId)
|
|
{
|
|
return new ReadingListItem()
|
|
{
|
|
Order = index,
|
|
ChapterId = chapterId,
|
|
SeriesId = seriesId,
|
|
VolumeId = volumeId
|
|
};
|
|
}
|
|
|
|
public static Genre Genre(string name, bool external)
|
|
{
|
|
return new Genre()
|
|
{
|
|
Title = name.Trim().SentenceCase(),
|
|
NormalizedTitle = Parser.Parser.Normalize(name),
|
|
ExternalTag = external
|
|
};
|
|
}
|
|
|
|
public static Tag Tag(string name, bool external)
|
|
{
|
|
return new Tag()
|
|
{
|
|
Title = name.Trim().SentenceCase(),
|
|
NormalizedTitle = Parser.Parser.Normalize(name),
|
|
ExternalTag = external
|
|
};
|
|
}
|
|
|
|
public static Person Person(string name, PersonRole role)
|
|
{
|
|
return new Person()
|
|
{
|
|
Name = name.Trim(),
|
|
NormalizedName = Parser.Parser.Normalize(name),
|
|
Role = role
|
|
};
|
|
}
|
|
|
|
public static MangaFile MangaFile(string filePath, MangaFormat format, int pages)
|
|
{
|
|
return new MangaFile()
|
|
{
|
|
FilePath = filePath,
|
|
Format = format,
|
|
Pages = pages,
|
|
LastModified = File.GetLastWriteTime(filePath) // NOTE: Changed this from DateTime.Now
|
|
};
|
|
}
|
|
|
|
}
|
|
}
|