Add logo feature

This commit is contained in:
Pim van Pelt
2025-12-03 12:32:36 +01:00
parent 60a149b669
commit 99ad6fbff1
3 changed files with 119 additions and 42 deletions

View File

@@ -168,6 +168,7 @@ type Options struct {
Verbose bool
DryRun bool
ShowIndexFiles bool
WatermarkURL string
}
type FileEntry struct {
@@ -211,17 +212,19 @@ func ProcessDir(topDir string, opts *Options) error {
})
templateData := struct {
DirName string
Entries []FileEntry
DirAppend bool
OutputFile string
IsRoot bool
DirName string
Entries []FileEntry
DirAppend bool
OutputFile string
IsRoot bool
WatermarkURL string
}{
DirName: dirName,
Entries: entries,
DirAppend: opts.DirAppend,
OutputFile: opts.OutputFile,
IsRoot: false, // Local filesystem always shows parent directory
DirName: dirName,
Entries: entries,
DirAppend: opts.DirAppend,
OutputFile: opts.OutputFile,
IsRoot: false, // Local filesystem always shows parent directory
WatermarkURL: opts.WatermarkURL,
}
if opts.DryRun {
@@ -467,6 +470,15 @@ const htmlTemplateString = `<!DOCTYPE html>
overflow-x: hidden;
text-overflow: ellipsis;
color: #999;
display: flex;
align-items: center;
}
.watermark {
height: 24px;
width: auto;
margin-right: 8px;
vertical-align: middle;
}
h1 a {
@@ -943,7 +955,7 @@ const htmlTemplateString = `<!DOCTYPE html>
</defs>
</svg>
<header>
<h1>{{.DirName}}</h1>
<h1>{{if .WatermarkURL}}<img src="{{.WatermarkURL}}" class="watermark" alt="Logo">{{end}}{{.DirName}}</h1>
</header>
<main>
<div class="listing">