mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-03 03:15:31 -04:00
Implement sort_title getter, setter
This commit is contained in:
parent
3a932d7b0a
commit
ab799af866
@ -8,6 +8,9 @@ class Entry
|
|||||||
size : String, pages : Int32, id : String, encoded_path : String,
|
size : String, pages : Int32, id : String, encoded_path : String,
|
||||||
encoded_title : String, mtime : Time, err_msg : String?
|
encoded_title : String, mtime : Time, err_msg : String?
|
||||||
|
|
||||||
|
@[YAML::Field(ignore: true)]
|
||||||
|
@sort_title : String?
|
||||||
|
|
||||||
def initialize(@zip_path, @book)
|
def initialize(@zip_path, @book)
|
||||||
storage = Storage.default
|
storage = Storage.default
|
||||||
@encoded_path = URI.encode @zip_path
|
@encoded_path = URI.encode @zip_path
|
||||||
@ -66,6 +69,27 @@ class Entry
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sort_title
|
||||||
|
sort_title_cached = @sort_title
|
||||||
|
return sort_title_cached if sort_title_cached
|
||||||
|
sort_title = Storage.default.get_entry_sort_title id
|
||||||
|
if sort_title
|
||||||
|
@sort_title = sort_title
|
||||||
|
return sort_title
|
||||||
|
end
|
||||||
|
@sort_title = @title
|
||||||
|
@title
|
||||||
|
end
|
||||||
|
|
||||||
|
def sort_title=(sort_title : String | Nil)
|
||||||
|
Storage.default.set_entry_sort_title id, sort_title
|
||||||
|
@sort_title = sort_title
|
||||||
|
end
|
||||||
|
|
||||||
|
def sort_title_db
|
||||||
|
Storage.default.get_entry_sort_title id
|
||||||
|
end
|
||||||
|
|
||||||
def display_name
|
def display_name
|
||||||
@book.display_name @title
|
@book.display_name @title
|
||||||
end
|
end
|
||||||
|
@ -10,6 +10,8 @@ class Title
|
|||||||
entry_cover_url_cache : Hash(String, String)?
|
entry_cover_url_cache : Hash(String, String)?
|
||||||
setter entry_cover_url_cache : Hash(String, String)?
|
setter entry_cover_url_cache : Hash(String, String)?
|
||||||
|
|
||||||
|
@[YAML::Field(ignore: true)]
|
||||||
|
@sort_title : String?
|
||||||
@[YAML::Field(ignore: true)]
|
@[YAML::Field(ignore: true)]
|
||||||
@entry_display_name_cache : Hash(String, String)?
|
@entry_display_name_cache : Hash(String, String)?
|
||||||
@[YAML::Field(ignore: true)]
|
@[YAML::Field(ignore: true)]
|
||||||
@ -286,6 +288,27 @@ class Title
|
|||||||
ary.join " and "
|
ary.join " and "
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sort_title
|
||||||
|
sort_title_cached = @sort_title
|
||||||
|
return sort_title_cached if sort_title_cached
|
||||||
|
sort_title = Storage.default.get_title_sort_title id
|
||||||
|
if sort_title
|
||||||
|
@sort_title = sort_title
|
||||||
|
return sort_title
|
||||||
|
end
|
||||||
|
@sort_title = @title
|
||||||
|
@title
|
||||||
|
end
|
||||||
|
|
||||||
|
def sort_title=(sort_title : String | Nil)
|
||||||
|
Storage.default.set_title_sort_title id, sort_title
|
||||||
|
@sort_title = sort_title
|
||||||
|
end
|
||||||
|
|
||||||
|
def sort_title_db
|
||||||
|
Storage.default.get_title_sort_title id
|
||||||
|
end
|
||||||
|
|
||||||
def tags
|
def tags
|
||||||
Storage.default.get_title_tags @id
|
Storage.default.get_title_tags @id
|
||||||
end
|
end
|
||||||
|
@ -342,6 +342,44 @@ class Storage
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_title_sort_title(title_id : String)
|
||||||
|
sort_title = nil
|
||||||
|
MainFiber.run do
|
||||||
|
get_db do |db|
|
||||||
|
sort_title = db.query_one? "Select sort_title from titles where id = (?)", title_id, as: String | Nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
sort_title
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_title_sort_title(title_id : String, sort_title : String | Nil)
|
||||||
|
sort_title = nil if sort_title == ""
|
||||||
|
MainFiber.run do
|
||||||
|
get_db do |db|
|
||||||
|
db.exec "update titles set sort_title = (?) where id = (?)", sort_title, title_id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_entry_sort_title(entry_id : String)
|
||||||
|
sort_title = nil
|
||||||
|
MainFiber.run do
|
||||||
|
get_db do |db|
|
||||||
|
sort_title = db.query_one? "Select sort_title from ids where id = (?)", entry_id, as: String | Nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
sort_title
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_entry_sort_title(entry_id : String, sort_title : String | Nil)
|
||||||
|
sort_title = nil if sort_title == ""
|
||||||
|
MainFiber.run do
|
||||||
|
get_db do |db|
|
||||||
|
db.exec "update ids set sort_title = (?) where id = (?)", sort_title, entry_id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def save_thumbnail(id : String, img : Image)
|
def save_thumbnail(id : String, img : Image)
|
||||||
MainFiber.run do
|
MainFiber.run do
|
||||||
get_db do |db|
|
get_db do |db|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user