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 (
Version string = "0.69.0"
Version string = "0.69.1"
)
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(`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((fileType.Css(queryParams, fileUri, filePath, fileName, mimeType)))
htmlBody.WriteString(fileType.Css)
htmlBody.WriteString(`</style>`)
htmlBody.WriteString((fileType.Title(queryParams, fileUri, filePath, fileName, mimeType)))
htmlBody.WriteString(`</head><body>`)

View File

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

View File

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

View File

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

View File

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

View File

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