Replaced cssFunction with string literal, since no customization should be needed

This commit is contained in:
Seednode 2023-09-11 19:43:18 -05:00
parent 26bdedb5a2
commit 93799e16fe
7 changed files with 10 additions and 21 deletions

View File

@ -12,7 +12,7 @@ import (
) )
const ( const (
Version string = "0.69.0" Version string = "0.69.1"
) )
var ( var (

View File

@ -266,7 +266,7 @@ func serveMedia(paths []string, Regexes *Regexes, index *Index, registeredFormat
htmlBody.WriteString(`a{color:inherit;display:block;height:100%;width:100%;text-decoration:none;}`) htmlBody.WriteString(`a{color:inherit;display:block;height:100%;width:100%;text-decoration:none;}`)
htmlBody.WriteString(`img{margin:auto;display:block;max-width:97%;max-height:97%;object-fit:scale-down;`) htmlBody.WriteString(`img{margin:auto;display:block;max-width:97%;max-height:97%;object-fit:scale-down;`)
htmlBody.WriteString(`position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);}`) htmlBody.WriteString(`position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);}`)
htmlBody.WriteString((fileType.Css(queryParams, fileUri, filePath, fileName, mimeType))) htmlBody.WriteString(fileType.Css)
htmlBody.WriteString(`</style>`) htmlBody.WriteString(`</style>`)
htmlBody.WriteString((fileType.Title(queryParams, fileUri, filePath, fileName, mimeType))) htmlBody.WriteString((fileType.Title(queryParams, fileUri, filePath, fileName, mimeType)))
htmlBody.WriteString(`</head><body>`) htmlBody.WriteString(`</head><body>`)

View File

@ -10,9 +10,7 @@ import (
func RegisterAudioFormats() *SupportedFormat { func RegisterAudioFormats() *SupportedFormat {
return &SupportedFormat{ return &SupportedFormat{
Css: func(queryParams, fileUri, filePath, fileName, mime string) string { Css: ``,
return ``
},
Title: func(queryParams, fileUri, filePath, fileName, mime string) string { Title: func(queryParams, fileUri, filePath, fileName, mime string) string {
return fmt.Sprintf(`<title>%s</title>`, fileName) return fmt.Sprintf(`<title>%s</title>`, fileName)
}, },

View File

@ -24,9 +24,7 @@ type Dimensions struct {
func RegisterImageFormats() *SupportedFormat { func RegisterImageFormats() *SupportedFormat {
return &SupportedFormat{ return &SupportedFormat{
Css: func(queryParams, fileUri, filePath, fileName, mime string) string { Css: ``,
return ``
},
Title: func(queryParams, fileUri, filePath, fileName, mime string) string { Title: func(queryParams, fileUri, filePath, fileName, mime string) string {
dimensions, err := ImageDimensions(filePath) dimensions, err := ImageDimensions(filePath)
if err != nil { if err != nil {

View File

@ -13,9 +13,7 @@ import (
func RegisterTextFormats() *SupportedFormat { func RegisterTextFormats() *SupportedFormat {
return &SupportedFormat{ return &SupportedFormat{
Css: func(queryParams, fileUri, filePath, fileName, mime string) string { Css: `pre{margin:.5rem;}`,
return `pre{margin:.5rem;}`
},
Title: func(queryParams, fileUri, filePath, fileName, mime string) string { Title: func(queryParams, fileUri, filePath, fileName, mime string) string {
return fmt.Sprintf(`<title>%s</title>`, fileName) return fmt.Sprintf(`<title>%s</title>`, fileName)
}, },

View File

@ -10,16 +10,13 @@ import (
"os" "os"
) )
type FormatFunction func(queryParams, fileUri, filePath, fileName, mime string) string
type ValidateFunction func(filePath string) bool
type SupportedFormat struct { type SupportedFormat struct {
Css FormatFunction Css string
Title FormatFunction Title func(queryParams, fileUri, filePath, fileName, mime string) string
Body FormatFunction Body func(queryParams, fileUri, filePath, fileName, mime string) string
Extensions []string Extensions []string
MimeTypes []string MimeTypes []string
Validate ValidateFunction Validate func(filePath string) bool
} }
type SupportedFormats struct { type SupportedFormats struct {

View File

@ -10,9 +10,7 @@ import (
func RegisterVideoFormats() *SupportedFormat { func RegisterVideoFormats() *SupportedFormat {
return &SupportedFormat{ return &SupportedFormat{
Css: func(queryParams, fileUri, filePath, fileName, mime string) string { Css: ``,
return ``
},
Title: func(queryParams, fileUri, filePath, fileName, mime string) string { Title: func(queryParams, fileUri, filePath, fileName, mime string) string {
return fmt.Sprintf(`<title>%s</title>`, fileName) return fmt.Sprintf(`<title>%s</title>`, fileName)
}, },