Skip to content

A self-hosted dashboard that puts all your feeds in one place

Add Widget-Content-Frameless option to extension widget

Svilen Markov495eaa0a373b
diff --git a/docs/extensions.md b/docs/extensions.md
index 06db1ae..b1fa4fa 100644
--- a/docs/extensions.md
+++ b/docs/extensions.md
@@ -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]
diff --git a/internal/glance/templates/extension.html b/internal/glance/templates/extension.html
index e5794c8..2973246 100644
--- a/internal/glance/templates/extension.html
+++ b/internal/glance/templates/extension.html
@@ -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 }}
diff --git a/internal/glance/widget-extension.go b/internal/glance/widget-extension.go
index da69621..63885bf 100644
--- a/internal/glance/widget-extension.go
+++ b/internal/glance/widget-extension.go
@@ -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