diff --git a/templates/reader.templ b/templates/reader.templ index 9f4f9b0..3c7fd99 100644 --- a/templates/reader.templ +++ b/templates/reader.templ @@ -5,14 +5,20 @@ import ( "fmt" ) -func readerInitExpr(metadata ReaderMetadata) string { - config := map[string]string{ +func readerInitExpr(metadata ReaderMetadata, progress ReadingProgress) string { + config := map[string]interface{}{ "mediaItemId": metadata.MediaItemID, "fileUrl": metadata.FileURL, "formatGroup": metadata.FormatGroup, "readingDirection": metadata.ReadingDirection, "mangaType": metadata.MangaType, } + if progress.Percentage > 0 { + config["savedPercentage"] = progress.Percentage + } + if progress.EpubCfi != "" { + config["savedCfi"] = progress.EpubCfi + } jsonBytes, _ := json.Marshal(config) return fmt.Sprintf("initReader(%s)", string(jsonBytes)) } @@ -32,7 +38,7 @@ templ Reader(user User, metadata ReaderMetadata, progress ReadingProgress, bookm
@ReaderChrome(user, metadata, progress) diff --git a/templates/reader_templ.go b/templates/reader_templ.go index 78c3c8d..800d00d 100644 --- a/templates/reader_templ.go +++ b/templates/reader_templ.go @@ -13,14 +13,20 @@ import ( "fmt" ) -func readerInitExpr(metadata ReaderMetadata) string { - config := map[string]string{ +func readerInitExpr(metadata ReaderMetadata, progress ReadingProgress) string { + config := map[string]interface{}{ "mediaItemId": metadata.MediaItemID, "fileUrl": metadata.FileURL, "formatGroup": metadata.FormatGroup, "readingDirection": metadata.ReadingDirection, "mangaType": metadata.MangaType, } + if progress.Percentage > 0 { + config["savedPercentage"] = progress.Percentage + } + if progress.EpubCfi != "" { + config["savedCfi"] = progress.EpubCfi + } jsonBytes, _ := json.Marshal(config) return fmt.Sprintf("initReader(%s)", string(jsonBytes)) } @@ -53,7 +59,7 @@ func Reader(user User, metadata ReaderMetadata, progress ReadingProgress, bookma var templ_7745c5c3_Var2 string templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(metadata.Title) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reader.templ`, Line: 26, Col: 26} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reader.templ`, Line: 32, Col: 26} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { @@ -64,9 +70,9 @@ func Reader(user User, metadata ReaderMetadata, progress ReadingProgress, bookma return templ_7745c5c3_Err } var templ_7745c5c3_Var3 string - templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(readerInitExpr(metadata)) + templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(readerInitExpr(metadata, progress)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reader.templ`, Line: 35, Col: 36} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reader.templ`, Line: 41, Col: 46} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -156,7 +162,7 @@ func ReaderChrome(user User, metadata ReaderMetadata, progress ReadingProgress) var templ_7745c5c3_Var5 templ.SafeURL templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinURLErrs("/media/" + metadata.MediaItemID) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reader.templ`, Line: 73, Col: 46} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reader.templ`, Line: 79, Col: 46} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { @@ -169,7 +175,7 @@ func ReaderChrome(user User, metadata ReaderMetadata, progress ReadingProgress) var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(metadata.Title) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reader.templ`, Line: 76, Col: 54} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reader.templ`, Line: 82, Col: 54} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { @@ -182,7 +188,7 @@ func ReaderChrome(user User, metadata ReaderMetadata, progress ReadingProgress) var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d/%d", progress.CurrentPage, progress.TotalPages)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reader.templ`, Line: 152, Col: 70} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reader.templ`, Line: 158, Col: 70} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -321,7 +327,7 @@ func ReaderBookmarksPanel(bookmarks []Bookmark) templ.Component { var templ_7745c5c3_Var12 string templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(bookmark.CfiPosition) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reader.templ`, Line: 368, Col: 38} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reader.templ`, Line: 374, Col: 38} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) if templ_7745c5c3_Err != nil { @@ -334,7 +340,7 @@ func ReaderBookmarksPanel(bookmarks []Bookmark) templ.Component { var templ_7745c5c3_Var13 string templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(bookmark.Title) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reader.templ`, Line: 371, Col: 49} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reader.templ`, Line: 377, Col: 49} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) if templ_7745c5c3_Err != nil { @@ -347,7 +353,7 @@ func ReaderBookmarksPanel(bookmarks []Bookmark) templ.Component { var templ_7745c5c3_Var14 string templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(bookmark.Position) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reader.templ`, Line: 373, Col: 27} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/reader.templ`, Line: 379, Col: 27} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) if templ_7745c5c3_Err != nil { diff --git a/web/src/reader/reader.ts b/web/src/reader/reader.ts index b167328..8f5459f 100644 --- a/web/src/reader/reader.ts +++ b/web/src/reader/reader.ts @@ -22,28 +22,138 @@ interface FontFile { } const FONT_FILES: FontFile[] = [ - { family: '"Literata"', url: "/static/fonts/literata/Literata-Variable.woff2", weight: "100 900", style: "normal" }, - { family: '"Literata"', url: "/static/fonts/literata/Literata-Italic-Variable.woff2", weight: "100 900", style: "italic" }, - { family: '"Crimson Pro"', url: "/static/fonts/crimson/CrimsonPro-Variable.woff2", weight: "100 900", style: "normal" }, - { family: '"Crimson Pro"', url: "/static/fonts/crimson/CrimsonPro-Italic-Variable.woff2", weight: "100 900", style: "italic" }, - { family: '"Source Serif 4"', url: "/static/fonts/source-serif/SourceSerif4-Variable.woff2", weight: "100 900", style: "normal" }, - { family: '"Source Serif 4"', url: "/static/fonts/source-serif/SourceSerif4-Italic-Variable.woff2", weight: "100 900", style: "italic" }, - { family: '"EB Garamond"', url: "/static/fonts/eb-garamond/EBGaramond-Variable.woff2", weight: "100 900", style: "normal" }, - { family: '"EB Garamond"', url: "/static/fonts/eb-garamond/EBGaramond-Italic-Variable.woff2", weight: "100 900", style: "italic" }, - { family: '"Libertinus Serif"', url: "/static/fonts/libertinus/LibertinusSerif-Regular.woff2", weight: "400", style: "normal" }, - { family: '"Libertinus Serif"', url: "/static/fonts/libertinus/LibertinusSerif-Bold.woff2", weight: "700", style: "normal" }, - { family: '"Libertinus Serif"', url: "/static/fonts/libertinus/LibertinusSerif-Italic.woff2", weight: "400", style: "italic" }, - { family: '"Libertinus Serif"', url: "/static/fonts/libertinus/LibertinusSerif-BoldItalic.woff2", weight: "700", style: "italic" }, - { family: '"Noto Serif"', url: "/static/fonts/noto-serif/NotoSerif-Variable.woff2", weight: "100 900", style: "normal" }, - { family: '"Noto Serif"', url: "/static/fonts/noto-serif/NotoSerif-Italic-Variable.woff2", weight: "100 900", style: "italic" }, - { family: '"Charis SIL"', url: "/static/fonts/charis-sil/CharisSIL-Regular.woff2", weight: "400", style: "normal" }, - { family: '"Charis SIL"', url: "/static/fonts/charis-sil/CharisSIL-Bold.woff2", weight: "700", style: "normal" }, - { family: '"Charis SIL"', url: "/static/fonts/charis-sil/CharisSIL-Italic.woff2", weight: "400", style: "italic" }, - { family: '"Charis SIL"', url: "/static/fonts/charis-sil/CharisSIL-BoldItalic.woff2", weight: "700", style: "italic" }, - { family: '"IBM Plex Serif"', url: "/static/fonts/ibm-plex/IBMPlexSerif-Regular.woff2", weight: "400", style: "normal" }, - { family: '"IBM Plex Serif"', url: "/static/fonts/ibm-plex/IBMPlexSerif-Bold.woff2", weight: "700", style: "normal" }, - { family: '"IBM Plex Serif"', url: "/static/fonts/ibm-plex/IBMPlexSerif-Italic.woff2", weight: "400", style: "italic" }, - { family: '"IBM Plex Serif"', url: "/static/fonts/ibm-plex/IBMPlexSerif-BoldItalic.woff2", weight: "700", style: "italic" }, + { + family: '"Literata"', + url: "/static/fonts/literata/Literata-Variable.woff2", + weight: "100 900", + style: "normal", + }, + { + family: '"Literata"', + url: "/static/fonts/literata/Literata-Italic-Variable.woff2", + weight: "100 900", + style: "italic", + }, + { + family: '"Crimson Pro"', + url: "/static/fonts/crimson/CrimsonPro-Variable.woff2", + weight: "100 900", + style: "normal", + }, + { + family: '"Crimson Pro"', + url: "/static/fonts/crimson/CrimsonPro-Italic-Variable.woff2", + weight: "100 900", + style: "italic", + }, + { + family: '"Source Serif 4"', + url: "/static/fonts/source-serif/SourceSerif4-Variable.woff2", + weight: "100 900", + style: "normal", + }, + { + family: '"Source Serif 4"', + url: "/static/fonts/source-serif/SourceSerif4-Italic-Variable.woff2", + weight: "100 900", + style: "italic", + }, + { + family: '"EB Garamond"', + url: "/static/fonts/eb-garamond/EBGaramond-Variable.woff2", + weight: "100 900", + style: "normal", + }, + { + family: '"EB Garamond"', + url: "/static/fonts/eb-garamond/EBGaramond-Italic-Variable.woff2", + weight: "100 900", + style: "italic", + }, + { + family: '"Libertinus Serif"', + url: "/static/fonts/libertinus/LibertinusSerif-Regular.woff2", + weight: "400", + style: "normal", + }, + { + family: '"Libertinus Serif"', + url: "/static/fonts/libertinus/LibertinusSerif-Bold.woff2", + weight: "700", + style: "normal", + }, + { + family: '"Libertinus Serif"', + url: "/static/fonts/libertinus/LibertinusSerif-Italic.woff2", + weight: "400", + style: "italic", + }, + { + family: '"Libertinus Serif"', + url: "/static/fonts/libertinus/LibertinusSerif-BoldItalic.woff2", + weight: "700", + style: "italic", + }, + { + family: '"Noto Serif"', + url: "/static/fonts/noto-serif/NotoSerif-Variable.woff2", + weight: "100 900", + style: "normal", + }, + { + family: '"Noto Serif"', + url: "/static/fonts/noto-serif/NotoSerif-Italic-Variable.woff2", + weight: "100 900", + style: "italic", + }, + { + family: '"Charis SIL"', + url: "/static/fonts/charis-sil/CharisSIL-Regular.woff2", + weight: "400", + style: "normal", + }, + { + family: '"Charis SIL"', + url: "/static/fonts/charis-sil/CharisSIL-Bold.woff2", + weight: "700", + style: "normal", + }, + { + family: '"Charis SIL"', + url: "/static/fonts/charis-sil/CharisSIL-Italic.woff2", + weight: "400", + style: "italic", + }, + { + family: '"Charis SIL"', + url: "/static/fonts/charis-sil/CharisSIL-BoldItalic.woff2", + weight: "700", + style: "italic", + }, + { + family: '"IBM Plex Serif"', + url: "/static/fonts/ibm-plex/IBMPlexSerif-Regular.woff2", + weight: "400", + style: "normal", + }, + { + family: '"IBM Plex Serif"', + url: "/static/fonts/ibm-plex/IBMPlexSerif-Bold.woff2", + weight: "700", + style: "normal", + }, + { + family: '"IBM Plex Serif"', + url: "/static/fonts/ibm-plex/IBMPlexSerif-Italic.woff2", + weight: "400", + style: "italic", + }, + { + family: '"IBM Plex Serif"', + url: "/static/fonts/ibm-plex/IBMPlexSerif-BoldItalic.woff2", + weight: "700", + style: "italic", + }, ]; let fontBlobUrls: Record