mirror of
https://github.com/glanceapp/glance.git
synced 2025-06-21 18:31:24 +02:00
Add Widget-Content-Frameless option to extension widget
This commit is contained in:
parent
b44b7b80ff
commit
495eaa0a37
@ -29,6 +29,9 @@ Used to specify the title of the widget. If not provided, the widget's title wil
|
||||
### `Widget-Content-Type`
|
||||
Used to specify the content type that will be returned by the extension. If not provided, the content will be shown as plain text.
|
||||
|
||||
### `Widget-Content-Frameless`
|
||||
When set to `true`, the widget's content will be displayed without the default background or "frame".
|
||||
|
||||
## Content Types
|
||||
|
||||
> [!NOTE]
|
||||
|
@ -1,5 +1,7 @@
|
||||
{{ template "widget-base.html" . }}
|
||||
|
||||
{{ define "widget-content-classes" }}{{ if .Extension.Frameless }}widget-content-frameless{{ end }}{{ end }}
|
||||
|
||||
{{ define "widget-content" }}
|
||||
{{ .Extension.Content }}
|
||||
{{ end }}
|
||||
|
@ -76,8 +76,9 @@ var extensionStringToType = map[string]extensionType{
|
||||
}
|
||||
|
||||
const (
|
||||
extensionHeaderTitle = "Widget-Title"
|
||||
extensionHeaderContentType = "Widget-Content-Type"
|
||||
extensionHeaderTitle = "Widget-Title"
|
||||
extensionHeaderContentType = "Widget-Content-Type"
|
||||
extensionHeaderContentFrameless = "Widget-Content-Frameless"
|
||||
)
|
||||
|
||||
type extensionRequestOptions struct {
|
||||
@ -88,8 +89,9 @@ type extensionRequestOptions struct {
|
||||
}
|
||||
|
||||
type extension struct {
|
||||
Title string
|
||||
Content template.HTML
|
||||
Title string
|
||||
Content template.HTML
|
||||
Frameless bool
|
||||
}
|
||||
|
||||
func convertExtensionContent(options extensionRequestOptions, content []byte, contentType extensionType) template.HTML {
|
||||
@ -148,6 +150,10 @@ func fetchExtension(options extensionRequestOptions) (extension, error) {
|
||||
}
|
||||
}
|
||||
|
||||
if stringToBool(response.Header.Get(extensionHeaderContentFrameless)) {
|
||||
extension.Frameless = true
|
||||
}
|
||||
|
||||
extension.Content = convertExtensionContent(options, body, contentType)
|
||||
|
||||
return extension, nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user