Skip to content

Commit f7c1357

Browse files
authored
Replaced epub.js by foliate-js
1 parent eb2f9c9 commit f7c1357

39 files changed

+82414
-389
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ A personal documents server, Coreander indexes the documents (EPUBs and PDFs wit
1515
* Web interface available in english, spanish and french, more languages can be easily added.
1616
* New documents added or removed to/from the library folder are automatically indexed (Linux only).
1717
* [Send to email supported](#send-to-email).
18-
* Read indexed epubs and PDFs from Coreander's interface thanks to [epub.js](http://futurepress.org/) and [pdf.js](https://mozilla.github.io/pdf.js/).
18+
* Read indexed epubs and PDFs from Coreander's interface thanks to [foliate-js](https://github.com/johnfactotum/foliate-js).
1919
* Restrictable access only to registered users.
2020
* Upload documents through the web interface.
2121

internal/metadata/epub.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func words(documentFullPath string) (int, error) {
198198

199199
func extractCover(r *zip.ReadCloser, coverFile string, coverMaxWidth int) ([]byte, error) {
200200
for _, f := range r.File {
201-
if f.Name != fmt.Sprintf("OEBPS/%s", coverFile) && f.Name != fmt.Sprintf("OPS/%s", coverFile) {
201+
if f.Name != fmt.Sprintf("OEBPS/%s", coverFile) && f.Name != fmt.Sprintf("OPS/%s", coverFile) && f.Name != coverFile {
202202
continue
203203
}
204204
rc, err := f.Open()

internal/webserver/controller/document/reader.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ func (d *Controller) Reader(c *fiber.Ctx) error {
2020
return fiber.ErrNotFound
2121
}
2222

23-
template := "epub-reader"
24-
if strings.ToLower(filepath.Ext(document.ID)) == ".pdf" {
25-
template = "pdf-reader"
26-
}
23+
template := "reader"
2724

2825
title := fmt.Sprintf("%s | Coreander", document.Title)
2926
authors := strings.Join(document.Authors, ", ")
+233
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
:root {
2+
--active-bg: rgba(0, 0, 0, .05);
3+
}
4+
@supports (color-scheme: light dark) {
5+
@media (prefers-color-scheme: dark) {
6+
:root {
7+
--active-bg: rgba(255, 255, 255, .1);
8+
}
9+
}
10+
}
11+
html {
12+
height: 100%;
13+
}
14+
body {
15+
margin: 0 auto;
16+
height: 100%;
17+
font: menu;
18+
font-family: system-ui, sans-serif;
19+
}
20+
#spinner-container {
21+
height: 100vh;
22+
display: flex;
23+
align-items: center;
24+
justify-content: center;
25+
text-align: center;
26+
}
27+
.icon {
28+
display: block;
29+
fill: none;
30+
stroke: currentcolor;
31+
stroke-width: 2px;
32+
}
33+
.empty-state-icon {
34+
margin: auto;
35+
}
36+
.toolbar {
37+
box-sizing: border-box;
38+
position: absolute;
39+
z-index: 1;
40+
display: flex;
41+
align-items: center;
42+
justify-content: space-between;
43+
width: 100%;
44+
height: 48px;
45+
padding: 6px;
46+
transition: opacity 250ms ease;
47+
visibility: hidden;
48+
}
49+
.toolbar button {
50+
padding: 3px;
51+
border-radius: 6px;
52+
background: none;
53+
border: 0;
54+
color: GrayText;
55+
}
56+
.toolbar button:hover {
57+
background: rgba(0, 0, 0, .1);
58+
color: currentcolor;
59+
}
60+
#header-bar {
61+
top: 0;
62+
}
63+
#nav-bar {
64+
bottom: 0;
65+
}
66+
#progress-slider {
67+
flex-grow: 1;
68+
margin: 0 12px;
69+
visibility: hidden;
70+
}
71+
#side-bar {
72+
visibility: hidden;
73+
box-sizing: border-box;
74+
position: absolute;
75+
z-index: 2;
76+
top: 0;
77+
left: 0;
78+
height: 100%;
79+
width: 320px;
80+
transform: translateX(-320px);
81+
display: flex;
82+
flex-direction: column;
83+
background: Canvas;
84+
color: CanvasText;
85+
box-shadow: 0 0 0 1px rgba(0, 0, 0, .2), 0 0 40px rgba(0, 0, 0, .2);
86+
transition: visibility 0s linear 300ms, transform 300ms ease;
87+
}
88+
#side-bar.show {
89+
visibility: visible;
90+
transform: translateX(0);
91+
transition-delay: 0s;
92+
}
93+
#dimming-overlay {
94+
visibility: hidden;
95+
position: fixed;
96+
z-index: 2;
97+
top: 0;
98+
left: 0;
99+
width: 100%;
100+
height: 100%;
101+
background: rgba(0, 0, 0, .2);
102+
opacity: 0;
103+
transition: visibility 0s linear 300ms, opacity 300ms ease;
104+
}
105+
#dimming-overlay.show {
106+
visibility: visible;
107+
opacity: 1;
108+
transition-delay: 0s;
109+
}
110+
#side-bar-header {
111+
padding: 1rem;
112+
display: flex;
113+
border-bottom: 1px solid rgba(0, 0, 0, .1);
114+
align-items: center;
115+
}
116+
#side-bar-cover {
117+
height: 10vh;
118+
min-height: 60px;
119+
max-height: 180px;
120+
border-radius: 3px;
121+
border: 0;
122+
background: lightgray;
123+
box-shadow: 0 0 1px rgba(0, 0, 0, .1), 0 0 16px rgba(0, 0, 0, .1);
124+
margin-inline-end: 1rem;
125+
}
126+
#side-bar-cover:not([src]) {
127+
display: none;
128+
}
129+
#side-bar-title {
130+
margin: .5rem 0;
131+
font-size: inherit;
132+
}
133+
#side-bar-author {
134+
margin: .5rem 0;
135+
font-size: small;
136+
color: GrayText;
137+
}
138+
#toc-view {
139+
padding: .5rem;
140+
overflow-y: scroll;
141+
}
142+
#toc-view li, #toc-view ol {
143+
margin: 0;
144+
padding: 0;
145+
list-style: none;
146+
}
147+
#toc-view a, #toc-view span {
148+
display: block;
149+
border-radius: 6px;
150+
padding: 8px;
151+
margin: 2px 0;
152+
}
153+
#side-bar a {
154+
color: CanvasText;
155+
text-decoration: none;
156+
}
157+
#toc-view a:hover {
158+
background: var(--active-bg);
159+
}
160+
#toc-view span {
161+
color: GrayText;
162+
}
163+
#toc-view svg {
164+
margin-inline-start: -24px;
165+
padding-inline-start: 5px;
166+
padding-inline-end: 6px;
167+
fill: CanvasText;
168+
cursor: default;
169+
transition: transform .2s ease;
170+
opacity: .5;
171+
}
172+
#toc-view svg:hover {
173+
opacity: 1;
174+
}
175+
#toc-view [aria-current] {
176+
font-weight: bold;
177+
background: var(--active-bg);
178+
}
179+
#toc-view [aria-expanded="false"] svg {
180+
transform: rotate(-90deg);
181+
}
182+
#toc-view [aria-expanded="false"] + [role="group"] {
183+
display: none;
184+
}
185+
.menu-container {
186+
position: relative;
187+
}
188+
.menu, .menu ul {
189+
list-style: none;
190+
padding: 0;
191+
margin: 0;
192+
}
193+
.menu {
194+
visibility: hidden;
195+
position: absolute;
196+
right: 0;
197+
background: Canvas;
198+
color: CanvasText;
199+
border-radius: 6px;
200+
box-shadow: 0 0 0 1px rgba(0, 0, 0, .2), 0 0 16px rgba(0, 0, 0, .1);
201+
padding: 6px;
202+
cursor: default;
203+
}
204+
.menu.show {
205+
visibility: visible;
206+
}
207+
.menu li {
208+
padding: 6px 12px;
209+
padding-left: 24px;
210+
border-radius: 6px;
211+
}
212+
.menu li:hover {
213+
background: var(--active-bg);
214+
}
215+
.menu li[aria-checked="true"] {
216+
background-position: center left;
217+
background-repeat: no-repeat;
218+
background-image: url('data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%3E%3Ccircle%20cx%3D%2212%22%20cy%3D%2212%22%20r%3D%223%22%2F%3E%3C%2Fsvg%3E');
219+
}
220+
.popover {
221+
background: Canvas;
222+
color: CanvasText;
223+
border-radius: 6px;
224+
box-shadow: 0 0 0 1px rgba(0, 0, 0, .2), 0 0 16px rgba(0, 0, 0, .1), 0 0 32px rgba(0, 0, 0, .1);
225+
}
226+
.popover-arrow-down {
227+
fill: Canvas;
228+
filter: drop-shadow(0 -1px 0 rgba(0, 0, 0, .2));
229+
}
230+
.popover-arrow-up {
231+
fill: Canvas;
232+
filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .2));
233+
}

internal/webserver/embedded/js/epub.min.js

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 John Factotum
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)