package config import ( "github.com/ponzu-cms/ponzu/management/editor" "github.com/ponzu-cms/ponzu/system/item" ) // Config represents the confirgurable options of the system type Config struct { item.Item Name string `json:"name"` Domain string `json:"domain"` HTTPPort string `json:"http_port"` HTTPSPort string `json:"https_port"` AdminEmail string `json:"admin_email"` ClientSecret string `json:"client_secret"` Etag string `json:"etag"` CacheInvalidate []string `json:"cache"` } // String partially implements item.Identifiable and overrides Item's String() func (c *Config) String() string { return c.Name } // MarshalEditor writes a buffer of html to edit a Post and partially implements editor.Editable func (c *Config) MarshalEditor() ([]byte, error) { view, err := editor.Form(c, editor.Field{ View: editor.Input("Name", c, map[string]string{ "label": "Site Name", "placeholder": "Add a name to this site (internal use only)", }), }, editor.Field{ View: editor.Input("Domain", c, map[string]string{ "label": "Domain Name (required for SSL certificate)", "placeholder": "e.g. www.example.com or example.com", }), }, editor.Field{ View: editor.Input("HTTPPort", c, map[string]string{ "type": "hidden", }), }, editor.Field{ View: editor.Input("HTTPSPort", c, map[string]string{ "type": "hidden", }), }, editor.Field{ View: editor.Input("AdminEmail", c, map[string]string{ "label": "Adminstrator Email (will be notified of internal system information)", }), }, editor.Field{ View: editor.Input("ClientSecret", c, map[string]string{ "label": "Client Secret (used to validate requests, DO NOT SHARE)", "disabled": "true", }), }, editor.Field{ View: editor.Input("ClientSecret", c, map[string]string{ "type": "hidden", }), }, editor.Field{ View: editor.Input("Etag", c, map[string]string{ "label": "Etag Header (used for static asset cache)", "disabled": "true", }), }, editor.Field{ View: editor.Input("Etag", c, map[string]string{ "type": "hidden", }), }, editor.Field{ View: editor.Checkbox("CacheInvalidate", c, map[string]string{ "label": "Invalidate cache on save", }, map[string]string{ "invalidate": "Invalidate Cache", }), }, ) if err != nil { return nil, err } open := []byte(`
System Configuration
`) close := []byte(`
`) script := []byte(` `) view = append(open, view...) view = append(view, close...) view = append(view, script...) return view, nil }