mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
fix(reader): add unsafe-eval to CSP and improve formatting
- Add 'unsafe-eval' to Content-Security-Policy script-src directive to support dynamic module evaluation required by ES modules - Standardize HTML formatting: - Use lowercase doctype declaration - Use double quotes consistently - Improve indentation for readability - Format CSS properties (box-shadow, transition) across multiple lines - Close void elements with / for consistency The CSP change is necessary for the ES module system to function correctly in the browser environment.
This commit is contained in:
+68
-33
@@ -1,17 +1,20 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8" />
|
||||||
<meta name="color-scheme" content="light dark">
|
<meta name="color-scheme" content="light dark" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self' blob:; script-src 'self'; style-src 'self' blob: 'unsafe-inline'; img-src 'self' blob: data:; connect-src 'self' blob: data: *; frame-src blob: data:; object-src blob: data:; form-action 'none';">
|
<meta
|
||||||
|
http-equiv="Content-Security-Policy"
|
||||||
|
content="default-src 'self' blob:; script-src 'self' 'unsafe-eval'; style-src 'self' blob: 'unsafe-inline'; img-src 'self' blob: data:; connect-src 'self' blob: data: *; frame-src blob: data:; object-src blob: data:; form-action 'none';"
|
||||||
|
/>
|
||||||
<title>E-Book Reader</title>
|
<title>E-Book Reader</title>
|
||||||
<style>
|
<style>
|
||||||
:root {
|
:root {
|
||||||
--active-bg: rgba(0, 0, 0, .05);
|
--active-bg: rgba(0, 0, 0, 0.05);
|
||||||
}
|
}
|
||||||
@supports (color-scheme: light dark) {
|
@supports (color-scheme: light dark) {
|
||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
:root {
|
:root {
|
||||||
--active-bg: rgba(255, 255, 255, .1);
|
--active-bg: rgba(255, 255, 255, 0.1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,7 +76,7 @@ body {
|
|||||||
color: GrayText;
|
color: GrayText;
|
||||||
}
|
}
|
||||||
.toolbar button:hover {
|
.toolbar button:hover {
|
||||||
background: rgba(0, 0, 0, .1);
|
background: rgba(0, 0, 0, 0.1);
|
||||||
color: currentcolor;
|
color: currentcolor;
|
||||||
}
|
}
|
||||||
#header-bar {
|
#header-bar {
|
||||||
@@ -101,8 +104,12 @@ body {
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
background: Canvas;
|
background: Canvas;
|
||||||
color: CanvasText;
|
color: CanvasText;
|
||||||
box-shadow: 0 0 0 1px rgba(0, 0, 0, .2), 0 0 40px rgba(0, 0, 0, .2);
|
box-shadow:
|
||||||
transition: visibility 0s linear 300ms, transform 300ms ease;
|
0 0 0 1px rgba(0, 0, 0, 0.2),
|
||||||
|
0 0 40px rgba(0, 0, 0, 0.2);
|
||||||
|
transition:
|
||||||
|
visibility 0s linear 300ms,
|
||||||
|
transform 300ms ease;
|
||||||
}
|
}
|
||||||
#side-bar.show {
|
#side-bar.show {
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
@@ -117,9 +124,11 @@ body {
|
|||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background: rgba(0, 0, 0, .2);
|
background: rgba(0, 0, 0, 0.2);
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition: visibility 0s linear 300ms, opacity 300ms ease;
|
transition:
|
||||||
|
visibility 0s linear 300ms,
|
||||||
|
opacity 300ms ease;
|
||||||
}
|
}
|
||||||
#dimming-overlay.show {
|
#dimming-overlay.show {
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
@@ -129,7 +138,7 @@ body {
|
|||||||
#side-bar-header {
|
#side-bar-header {
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
border-bottom: 1px solid rgba(0, 0, 0, .1);
|
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
#side-bar-cover {
|
#side-bar-cover {
|
||||||
@@ -139,31 +148,35 @@ body {
|
|||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
border: 0;
|
border: 0;
|
||||||
background: lightgray;
|
background: lightgray;
|
||||||
box-shadow: 0 0 1px rgba(0, 0, 0, .1), 0 0 16px rgba(0, 0, 0, .1);
|
box-shadow:
|
||||||
|
0 0 1px rgba(0, 0, 0, 0.1),
|
||||||
|
0 0 16px rgba(0, 0, 0, 0.1);
|
||||||
margin-inline-end: 1rem;
|
margin-inline-end: 1rem;
|
||||||
}
|
}
|
||||||
#side-bar-cover:not([src]) {
|
#side-bar-cover:not([src]) {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
#side-bar-title {
|
#side-bar-title {
|
||||||
margin: .5rem 0;
|
margin: 0.5rem 0;
|
||||||
font-size: inherit;
|
font-size: inherit;
|
||||||
}
|
}
|
||||||
#side-bar-author {
|
#side-bar-author {
|
||||||
margin: .5rem 0;
|
margin: 0.5rem 0;
|
||||||
font-size: small;
|
font-size: small;
|
||||||
color: GrayText;
|
color: GrayText;
|
||||||
}
|
}
|
||||||
#toc-view {
|
#toc-view {
|
||||||
padding: .5rem;
|
padding: 0.5rem;
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
}
|
}
|
||||||
#toc-view li, #toc-view ol {
|
#toc-view li,
|
||||||
|
#toc-view ol {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
#toc-view a, #toc-view span {
|
#toc-view a,
|
||||||
|
#toc-view span {
|
||||||
display: block;
|
display: block;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
@@ -185,8 +198,8 @@ body {
|
|||||||
padding-inline-end: 6px;
|
padding-inline-end: 6px;
|
||||||
fill: CanvasText;
|
fill: CanvasText;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
transition: transform .2s ease;
|
transition: transform 0.2s ease;
|
||||||
opacity: .5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
#toc-view svg:hover {
|
#toc-view svg:hover {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
@@ -204,7 +217,8 @@ body {
|
|||||||
.menu-container {
|
.menu-container {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
.menu, .menu ul {
|
.menu,
|
||||||
|
.menu ul {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -216,7 +230,9 @@ body {
|
|||||||
background: Canvas;
|
background: Canvas;
|
||||||
color: CanvasText;
|
color: CanvasText;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
box-shadow: 0 0 0 1px rgba(0, 0, 0, .2), 0 0 16px rgba(0, 0, 0, .1);
|
box-shadow:
|
||||||
|
0 0 0 1px rgba(0, 0, 0, 0.2),
|
||||||
|
0 0 16px rgba(0, 0, 0, 0.1);
|
||||||
padding: 6px;
|
padding: 6px;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
@@ -234,28 +250,38 @@ body {
|
|||||||
.menu li[aria-checked="true"] {
|
.menu li[aria-checked="true"] {
|
||||||
background-position: center left;
|
background-position: center left;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
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');
|
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");
|
||||||
}
|
}
|
||||||
.popover {
|
.popover {
|
||||||
background: Canvas;
|
background: Canvas;
|
||||||
color: CanvasText;
|
color: CanvasText;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
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);
|
box-shadow:
|
||||||
|
0 0 0 1px rgba(0, 0, 0, 0.2),
|
||||||
|
0 0 16px rgba(0, 0, 0, 0.1),
|
||||||
|
0 0 32px rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
.popover-arrow-down {
|
.popover-arrow-down {
|
||||||
fill: Canvas;
|
fill: Canvas;
|
||||||
filter: drop-shadow(0 -1px 0 rgba(0, 0, 0, .2));
|
filter: drop-shadow(0 -1px 0 rgba(0, 0, 0, 0.2));
|
||||||
}
|
}
|
||||||
.popover-arrow-up {
|
.popover-arrow-up {
|
||||||
fill: Canvas;
|
fill: Canvas;
|
||||||
filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .2));
|
filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.2));
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<input type="file" id="file-input" hidden>
|
<input type="file" id="file-input" hidden />
|
||||||
<div id="drop-target" class="filter">
|
<div id="drop-target" class="filter">
|
||||||
<div>
|
<div>
|
||||||
<svg class="icon empty-state-icon" width="72" height="72" aria-hidden="true">
|
<svg
|
||||||
<path d="M36 18s-6-6-12-6-15 6-15 6v42s9-6 15-6 12 6 12 6c4-4 8-6 12-6s12 2 15 6V18c-6-4-12-6-15-6-4 0-8 2-12 6m0 0v42"/>
|
class="icon empty-state-icon"
|
||||||
|
width="72"
|
||||||
|
height="72"
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M36 18s-6-6-12-6-15 6-15 6v42s9-6 15-6 12 6 12 6c4-4 8-6 12-6s12 2 15 6V18c-6-4-12-6-15-6-4 0-8 2-12 6m0 0v42"
|
||||||
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
<h1>Drop a book here!</h1>
|
<h1>Drop a book here!</h1>
|
||||||
<p>Or <button id="file-button">choose a file</button> to open it.</p>
|
<p>Or <button id="file-button">choose a file</button> to open it.</p>
|
||||||
@@ -264,7 +290,7 @@ body {
|
|||||||
<div id="dimming-overlay" aria-hidden="true"></div>
|
<div id="dimming-overlay" aria-hidden="true"></div>
|
||||||
<div id="side-bar">
|
<div id="side-bar">
|
||||||
<div id="side-bar-header">
|
<div id="side-bar-header">
|
||||||
<img id="side-bar-cover">
|
<img id="side-bar-cover" />
|
||||||
<div>
|
<div>
|
||||||
<h1 id="side-bar-title"></h1>
|
<h1 id="side-bar-title"></h1>
|
||||||
<p id="side-bar-author"></p>
|
<p id="side-bar-author"></p>
|
||||||
@@ -281,7 +307,9 @@ body {
|
|||||||
<div id="menu-button" class="menu-container">
|
<div id="menu-button" class="menu-container">
|
||||||
<button aria-label="Show settings" aria-haspopup="true">
|
<button aria-label="Show settings" aria-haspopup="true">
|
||||||
<svg class="icon" width="24" height="24" aria-hidden="true">
|
<svg class="icon" width="24" height="24" aria-hidden="true">
|
||||||
<path d="M5 12.7a7 7 0 0 1 0-1.4l-1.8-2 2-3.5 2.7.5a7 7 0 0 1 1.2-.7L10 3h4l.9 2.6 1.2.7 2.7-.5 2 3.4-1.8 2a7 7 0 0 1 0 1.5l1.8 2-2 3.5-2.7-.5a7 7 0 0 1-1.2.7L14 21h-4l-.9-2.6a7 7 0 0 1-1.2-.7l-2.7.5-2-3.4 1.8-2Z"/>
|
<path
|
||||||
|
d="M5 12.7a7 7 0 0 1 0-1.4l-1.8-2 2-3.5 2.7.5a7 7 0 0 1 1.2-.7L10 3h4l.9 2.6 1.2.7 2.7-.5 2 3.4-1.8 2a7 7 0 0 1 0 1.5l1.8 2-2 3.5-2.7-.5a7 7 0 0 1-1.2.7L14 21h-4l-.9-2.6a7 7 0 0 1-1.2-.7l-2.7.5-2-3.4 1.8-2Z"
|
||||||
|
/>
|
||||||
<circle cx="12" cy="12" r="3" />
|
<circle cx="12" cy="12" r="3" />
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
@@ -293,7 +321,14 @@ body {
|
|||||||
<path d="M 15 6 L 9 12 L 15 18" />
|
<path d="M 15 6 L 9 12 L 15 18" />
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
<input id="progress-slider" type="range" min="0" max="1" step="any" list="tick-marks">
|
<input
|
||||||
|
id="progress-slider"
|
||||||
|
type="range"
|
||||||
|
min="0"
|
||||||
|
max="1"
|
||||||
|
step="any"
|
||||||
|
list="tick-marks"
|
||||||
|
/>
|
||||||
<datalist id="tick-marks"></datalist>
|
<datalist id="tick-marks"></datalist>
|
||||||
<button id="right-button" aria-label="Go right">
|
<button id="right-button" aria-label="Go right">
|
||||||
<svg class="icon" width="24" height="24" aria-hidden="true">
|
<svg class="icon" width="24" height="24" aria-hidden="true">
|
||||||
|
|||||||
Reference in New Issue
Block a user