mirror of
https://github.com/glanceapp/glance.git
synced 2025-06-21 18:31:24 +02:00
Also apply to extension widget
This commit is contained in:
parent
a943555d86
commit
176fc896ae
@ -19,12 +19,12 @@ const extensionWidgetDefaultTitle = "Extension"
|
|||||||
|
|
||||||
type extensionWidget struct {
|
type extensionWidget struct {
|
||||||
widgetBase `yaml:",inline"`
|
widgetBase `yaml:",inline"`
|
||||||
URL string `yaml:"url"`
|
URL string `yaml:"url"`
|
||||||
FallbackContentType string `yaml:"fallback-content-type"`
|
FallbackContentType string `yaml:"fallback-content-type"`
|
||||||
Parameters map[string]string `yaml:"parameters"`
|
Parameters queryParametersField `yaml:"parameters"`
|
||||||
AllowHtml bool `yaml:"allow-potentially-dangerous-html"`
|
AllowHtml bool `yaml:"allow-potentially-dangerous-html"`
|
||||||
Extension extension `yaml:"-"`
|
Extension extension `yaml:"-"`
|
||||||
cachedHTML template.HTML `yaml:"-"`
|
cachedHTML template.HTML `yaml:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (widget *extensionWidget) initialize() error {
|
func (widget *extensionWidget) initialize() error {
|
||||||
@ -82,10 +82,10 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type extensionRequestOptions struct {
|
type extensionRequestOptions struct {
|
||||||
URL string `yaml:"url"`
|
URL string `yaml:"url"`
|
||||||
FallbackContentType string `yaml:"fallback-content-type"`
|
FallbackContentType string `yaml:"fallback-content-type"`
|
||||||
Parameters map[string]string `yaml:"parameters"`
|
Parameters queryParametersField `yaml:"parameters"`
|
||||||
AllowHtml bool `yaml:"allow-potentially-dangerous-html"`
|
AllowHtml bool `yaml:"allow-potentially-dangerous-html"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type extension struct {
|
type extension struct {
|
||||||
@ -109,14 +109,7 @@ func convertExtensionContent(options extensionRequestOptions, content []byte, co
|
|||||||
|
|
||||||
func fetchExtension(options extensionRequestOptions) (extension, error) {
|
func fetchExtension(options extensionRequestOptions) (extension, error) {
|
||||||
request, _ := http.NewRequest("GET", options.URL, nil)
|
request, _ := http.NewRequest("GET", options.URL, nil)
|
||||||
|
request.URL.RawQuery = options.Parameters.toQueryString()
|
||||||
query := url.Values{}
|
|
||||||
|
|
||||||
for key, value := range options.Parameters {
|
|
||||||
query.Set(key, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
request.URL.RawQuery = query.Encode()
|
|
||||||
|
|
||||||
response, err := http.DefaultClient.Do(request)
|
response, err := http.DefaultClient.Do(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user