mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-03 03:15:31 -04:00
Cache entries' cover_url
This commit is contained in:
parent
8d84a3c502
commit
244f97a68e
@ -81,9 +81,17 @@ class Entry
|
|||||||
|
|
||||||
def cover_url
|
def cover_url
|
||||||
return "#{Config.current.base_url}img/icon.png" if @err_msg
|
return "#{Config.current.base_url}img/icon.png" if @err_msg
|
||||||
|
|
||||||
|
unless @book.entry_cover_url_cache
|
||||||
|
TitleInfo.new @book.dir do |info|
|
||||||
|
@book.entry_cover_url_cache = info.entry_cover_url
|
||||||
|
end
|
||||||
|
end
|
||||||
|
entry_cover_url = @book.entry_cover_url_cache
|
||||||
|
|
||||||
url = "#{Config.current.base_url}api/cover/#{@book.id}/#{@id}"
|
url = "#{Config.current.base_url}api/cover/#{@book.id}/#{@id}"
|
||||||
TitleInfo.new @book.dir do |info|
|
if entry_cover_url
|
||||||
info_url = info.entry_cover_url[@title]?
|
info_url = entry_cover_url[@title]?
|
||||||
unless info_url.nil? || info_url.empty?
|
unless info_url.nil? || info_url.empty?
|
||||||
url = File.join Config.current.base_url, info_url
|
url = File.join Config.current.base_url, info_url
|
||||||
end
|
end
|
||||||
|
@ -3,9 +3,12 @@ require "../archive"
|
|||||||
class Title
|
class Title
|
||||||
getter dir : String, parent_id : String, title_ids : Array(String),
|
getter dir : String, parent_id : String, title_ids : Array(String),
|
||||||
entries : Array(Entry), title : String, id : String,
|
entries : Array(Entry), title : String, id : String,
|
||||||
encoded_title : String, mtime : Time, signature : UInt64
|
encoded_title : String, mtime : Time, signature : UInt64,
|
||||||
|
entry_cover_url_cache : Hash(String, String)?
|
||||||
|
setter entry_cover_url_cache : Hash(String, String)?
|
||||||
|
|
||||||
@entry_display_name_cache : Hash(String, String)?
|
@entry_display_name_cache : Hash(String, String)?
|
||||||
|
@entry_cover_url_cache : Hash(String, String)?
|
||||||
|
|
||||||
def initialize(@dir : String, @parent_id)
|
def initialize(@dir : String, @parent_id)
|
||||||
storage = Storage.default
|
storage = Storage.default
|
||||||
|
Loading…
x
Reference in New Issue
Block a user