refinements to the media page
This commit is contained in:
@@ -178,7 +178,10 @@ func (ch *CaddyHugo) serveMediaPage(w http.ResponseWriter, r *http.Request) (int
|
|||||||
}
|
}
|
||||||
|
|
||||||
io.WriteString(w, `<html>
|
io.WriteString(w, `<html>
|
||||||
<head><style>.img { float: left; text-align: center; }</style></head>
|
<head><style>
|
||||||
|
.img { float: left; text-align: center; max-width: 19.9vw; min-height: 120px;}
|
||||||
|
.copy { cursor: pointer; }
|
||||||
|
</style></head>
|
||||||
<body>
|
<body>
|
||||||
<div style="position: fixed; top: 0; height: 10vh; width: 100%;">
|
<div style="position: fixed; top: 0; height: 10vh; width: 100%;">
|
||||||
<div style="float: left; width: 100%; height: 10vh;">
|
<div style="float: left; width: 100%; height: 10vh;">
|
||||||
@@ -193,17 +196,31 @@ func (ch *CaddyHugo) serveMediaPage(w http.ResponseWriter, r *http.Request) (int
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, m := range media {
|
for _, m := range media {
|
||||||
fmt.Fprintf(w, `<div class="img">`)
|
|
||||||
|
|
||||||
src, width, height, err := ch.Media.ThumbMax(*m, 100)
|
src, width, height, err := ch.Media.ThumbMax(*m, 100)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(w, `<div class="img">error rendering %q: %v</div>`, m.Name, err)
|
fmt.Fprintf(w, `<div class="img">error rendering %q: %v</div>`, m.Name, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fmt.Fprintf(w, `<div class="img"><img width=%d height=%d src=%q /><br /><input type="text" disabled value=%q /></div>`, width, height, src, src)
|
fmt.Fprintf(w, `<div class="img"><img width=%d height=%d src=%q /><br /><input type="text" readonly value=%q /><span class="copy">📋</span></div>`, width, height, src, src)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
io.WriteString(w, `</body><html>`)
|
io.WriteString(w, `<script>
|
||||||
|
document.querySelector('body').onclick = function (evt) {
|
||||||
|
if (evt.target.tagName === "INPUT" && evt.target.type === "text") {
|
||||||
|
evt.target.select();
|
||||||
|
}
|
||||||
|
if (evt.target.tagName === "SPAN" && evt.target.className === "copy") {
|
||||||
|
evt.target.previousSibling.select();
|
||||||
|
document.execCommand("copy");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
document.querySelector('body').onmouseup = function (evt) {
|
||||||
|
if (evt.target.tagName === "INPUT" && evt.target.type === "text") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script></body><html>`)
|
||||||
return 200, nil
|
return 200, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user