Files
ebooks/static/styles.css
T
arnefandCopilot 2399d8a5a6 Add in-browser EPUB reader (no JavaScript)
- internal/library/reader.go: new Chapter type and Service.ReadChapter/
  ChapterAsset. Parses the EPUB spine, extracts and sanitizes each
  chapter's <body> HTML using golang.org/x/net/html:
  - strips <script>, <style>, <link>, <iframe>, <object>, <embed>,
    <form>, <meta>, <base>, <audio>, <video>, <noscript> and any
    on*-event-handler attributes
  - rewrites relative <img>/xlink:href asset references to
    /read/{id}/asset/{path}
  - rewrites internal chapter links to /read/{id}/{spineIndex},
    neutralizes javascript: hrefs, leaves external links untouched
  - refactored CoverBytes to share the new findEPUBPath helper
- internal/web/handlers.go: GET /read/{id}/{idx} renders a chapter page
  with prev/next navigation; GET /read/{id}/asset/{path...} serves
  embedded chapter assets (images) with a size cap, mirroring the
  existing cover-image guard
- views/pages.templ: new ReaderPage component (renders sanitized HTML
  via templ.Raw); BookPage gets an "Im Browser lesen" button next to
  the existing download button; templ regenerated
- static/styles.css: reader typography/layout, prev/next nav styling
- go.mod/go.sum: golang.org/x/net/html promoted to a direct dependency
- README: documents the new in-browser reader feature

Verified end-to-end with a hand-built test EPUB (spine ordering,
metadata, script/style stripping, event-handler stripping, chapter
link rewriting, image asset rewriting, javascript: neutralization,
external link passthrough, out-of-range chapter handling, and
path-traversal guard on chapter assets); test file removed afterwards
per repo convention (no test suite checked in yet).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-08-15 16:17:16 +02:00

311 lines
4.3 KiB
CSS

:root {
color-scheme: light;
}
html, body {
margin: 0;
padding: 0;
background: #fff;
color: #000;
font-family: Arial, sans-serif;
font-size: 18px;
line-height: 1.45;
}
img {
max-width: 100%;
}
.header {
border-bottom: 2px solid #000;
padding: 0.75rem 1rem;
}
.header-bar {
display: flex;
align-items: center;
gap: 0.5rem;
min-height: 1.2rem;
}
.header h1 {
margin: 0;
font-size: 1.2rem;
line-height: 1.2;
}
.header a {
color: inherit;
text-decoration: none;
}
.header-back {
display: inline-flex;
align-items: center;
justify-content: center;
width: 1.5rem;
height: 1.5rem;
margin: -0.15rem 0;
font-size: 1.2rem;
line-height: 1;
font-weight: bold;
flex: 0 0 1.5rem;
}
.container {
padding: 1rem;
max-width: 42rem;
}
h2 {
margin-top: 0;
font-size: 1.25rem;
}
.page-head {
margin-bottom: 1rem;
}
.page-subtitle {
margin: 0.25rem 0 0;
font-size: 0.95rem;
}
.book-list {
list-style: none;
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 0.5rem;
margin: 0;
padding: 0;
}
.book-item {
box-sizing: border-box;
margin: 0;
border: none;
}
.book-card {
display: flex;
flex-direction: column;
height: 100%;
border: 1px solid #000;
padding: 0.5rem;
color: inherit;
text-decoration: none;
box-sizing: border-box;
}
.book-card-cover {
display: block;
margin-bottom: 0.5rem;
}
.book-card-body {
display: block;
}
.book-detail-cover {
display: block;
}
.book-card-cover,
.book-detail-cover {
text-align: center;
}
.book-cover,
.book-cover-placeholder {
display: inline-block;
width: 100%;
max-width: 100%;
aspect-ratio: 2 / 3;
border: 1px solid #000;
object-fit: cover;
vertical-align: top;
}
.book-cover-placeholder {
text-align: center;
font-size: 0.75rem;
font-weight: bold;
line-height: 1.2;
padding-top: 2.3rem;
box-sizing: border-box;
}
.book-cover-detail,
.book-cover-placeholder-detail {
width: 8rem;
height: 11.5rem;
max-width: none;
margin-bottom: 1rem;
}
.book-card .book-title {
font-weight: bold;
font-size: 0.95rem;
line-height: 1.25;
margin-bottom: 0.25rem;
overflow-wrap: break-word;
word-break: break-word;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
}
.book-author,
.book-author-detail {
display: block;
margin-top: 0.2rem;
overflow-wrap: break-word;
word-break: break-word;
}
.book-author {
font-size: 0.85rem;
line-height: 1.25;
}
.format {
display: block;
margin-top: 0.2rem;
font-size: 0.85rem;
}
.book-detail {
display: block;
}
.book-detail-cover {
margin-bottom: 1rem;
}
.book-meta {
margin: 0 0 1rem;
}
.book-meta div {
margin-bottom: 0.6rem;
}
.book-meta dt {
font-weight: bold;
}
.book-meta dd {
margin: 0.15rem 0 0;
}
.back-link {
color: inherit;
}
.btn + .btn {
margin-left: 0.5rem;
}
.reader {
display: block;
}
.reader-progress {
margin: 0 0 0.5rem;
font-size: 0.85rem;
}
.reader-chapter-title {
margin-top: 0;
}
.reader-content {
line-height: 1.6;
overflow-wrap: break-word;
}
.reader-content img {
display: block;
max-width: 100%;
height: auto;
margin: 0.5rem auto;
}
.reader-content p {
margin: 0 0 1rem;
}
.reader-nav {
display: flex;
justify-content: space-between;
gap: 0.5rem;
margin-top: 1.5rem;
}
.reader-nav .btn + .btn {
margin-left: 0;
}
.reader-nav-next {
margin-left: auto;
}
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
min-height: 44px;
padding: 0.7rem 1rem;
border: 2px solid #000;
background: none;
text-decoration: none;
color: #000;
font-family: inherit;
font-size: inherit;
font-weight: bold;
cursor: pointer;
box-sizing: border-box;
}
code {
border: 1px solid #000;
padding: 0.1rem 0.3rem;
}
/* --- Auth & Upload --- */
.btn-logout {
background: none;
border: 1px solid #000;
cursor: pointer;
padding: 0.3rem 0.6rem;
font-size: 0.9rem;
}
.login-box {
max-width: 22rem;
margin-top: 3rem;
}
.login-form,
.upload-form {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.login-form input,
.upload-form input[type="file"] {
padding: 0.5rem;
font-size: 1rem;
border: 1px solid #000;
}
.error {
border: 2px solid #000;
padding: 0.5rem 0.75rem;
margin-bottom: 0.75rem;
font-weight: bold;
}