From ac82561825ab76f2b5db5c4086541e590fcb70cb Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Wed, 11 Jan 2017 11:37:56 -0800 Subject: extending the "addon" platform within ponzu to register, present and manage addons --- system/addon/addon.go | 6 +++--- system/addon/manager.go | 8 +++++--- system/admin/config/config.go | 12 +++++++----- 3 files changed, 15 insertions(+), 11 deletions(-) (limited to 'system') diff --git a/system/addon/addon.go b/system/addon/addon.go index 22e2114..a423d07 100644 --- a/system/addon/addon.go +++ b/system/addon/addon.go @@ -38,9 +38,9 @@ type Addon struct { Meta } -// New constructs a new addon to be registered. Meta is a addon.Meta and fn is a -// closure returning a pointer to your own addon type -func New(m Meta, fn func() interface{}) Addon { +// Register constructs a new addon and registers it with the system. Meta is a +// addon.Meta and fn is a closure returning a pointer to your own addon type +func Register(m Meta, fn func() interface{}) Addon { // get or create the reverse DNS identifier if m.PonzuAddonReverseDNS == "" { revDNS, err := reverseDNS(m) diff --git a/system/addon/manager.go b/system/addon/manager.go index 3757421..acd779a 100644 --- a/system/addon/manager.go +++ b/system/addon/manager.go @@ -15,11 +15,11 @@ const defaultInput = `` const managerHTML = `
+
+
{{ .AddonName }}
+
{{ .DefaultInputs }} {{ .Editor }} -
- -
` @@ -27,6 +27,7 @@ const managerHTML = ` type manager struct { DefaultInputs template.HTML Editor template.HTML + AddonName string } // Manage ... @@ -77,6 +78,7 @@ func Manage(data url.Values, reverseDNS string) ([]byte, error) { m := manager{ DefaultInputs: template.HTML(inputs.Bytes()), Editor: template.HTML(v), + AddonName: data.Get("addon_name"), } // execute html template into buffer for func return val diff --git a/system/admin/config/config.go b/system/admin/config/config.go index 2bc80c6..7b57dc0 100644 --- a/system/admin/config/config.go +++ b/system/admin/config/config.go @@ -8,7 +8,6 @@ import ( // Config represents the confirgurable options of the system type Config struct { item.Item - editor editor.Editor Name string `json:"name"` Domain string `json:"domain"` @@ -23,9 +22,6 @@ type Config struct { // String partially implements item.Identifiable and overrides Item's String() func (c *Config) String() string { return c.Name } -// Editor partially implements editor.Editable -func (c *Config) Editor() *editor.Editor { return &c.editor } - // 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, @@ -90,7 +86,13 @@ func (c *Config) MarshalEditor() ([]byte, error) { return nil, err } - open := []byte(`
`) + open := []byte(` +
+
+
System Configuration
+
+ + `) close := []byte(`
`) script := []byte(`