preview: better title element
This commit is contained in:
parent
7407353dfb
commit
6453700648
22
preview.go
22
preview.go
@ -16,10 +16,30 @@ func (this *Server) handlePreview(w http.ResponseWriter, fileIDList string) {
|
||||
|
||||
fileIDs := strings.Split(fileIDList, `-`)
|
||||
|
||||
// Early get metadata for the first listed element
|
||||
specialTitle := ""
|
||||
if len(fileIDs) == 1 {
|
||||
mFirst, err := this.Metadata(fileIDs[0])
|
||||
if err != nil { // Same error handling as below -
|
||||
if os.IsNotExist(err) {
|
||||
http.Error(w, "Not found", 404)
|
||||
return
|
||||
}
|
||||
|
||||
log.Println(err.Error())
|
||||
http.Error(w, "Internal error", 500)
|
||||
return
|
||||
}
|
||||
|
||||
specialTitle = mFirst.Filename + " (" + fileIDs[0] + ")"
|
||||
} else {
|
||||
specialTitle = fmt.Sprintf("%d images", len(fileIDs))
|
||||
}
|
||||
|
||||
tmpl := `<!DOCTYPE html>
|
||||
<html prefix="og: http://ogp.me/ns#">
|
||||
<head>
|
||||
<title>` + html.EscapeString(this.opts.ServerPublicProperties.AppTitle) + `</title>
|
||||
<title>` + html.EscapeString(specialTitle+" | "+this.opts.ServerPublicProperties.AppTitle) + `</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta property="og:title" content="` + html.EscapeString(this.opts.ServerPublicProperties.AppTitle) + `" />
|
||||
<meta property="og:site_name" content="` + html.EscapeString(this.opts.ServerPublicProperties.AppTitle) + `" />
|
||||
|
Loading…
Reference in New Issue
Block a user