diff options
Diffstat (limited to 'management')
-rw-r--r-- | management/editor/editor.go | 1 | ||||
-rw-r--r-- | management/editor/elements.go | 18 | ||||
-rw-r--r-- | management/manager/process.go | 6 |
3 files changed, 15 insertions, 10 deletions
diff --git a/management/editor/editor.go b/management/editor/editor.go index 2a9183b..6b55a38 100644 --- a/management/editor/editor.go +++ b/management/editor/editor.go @@ -9,7 +9,6 @@ import ( // Editable ensures data is editable type Editable interface { - ContentName() string Editor() *Editor MarshalEditor() ([]byte, error) } diff --git a/management/editor/elements.go b/management/editor/elements.go index 4a95150..4a8ae55 100644 --- a/management/editor/elements.go +++ b/management/editor/elements.go @@ -341,7 +341,15 @@ func Tags(fieldName string, p interface{}, attrs map[string]string) []byte { // get the saved tags if this is already an existing post values := valueFromStructField(fieldName, p) - tags := strings.Split(values, "__ponzu") + var tags []string + if strings.Contains(values, "__ponzu") { + tags = strings.Split(values, "__ponzu") + } + + // case where there is only one tag stored, thus has no separator + if len(values) > 0 && !strings.Contains(values, "__ponzu") { + tags = append(tags, values) + } html := ` <div class="col s12 __ponzu-tags ` + name + `"> @@ -375,7 +383,7 @@ func Tags(fieldName string, p interface{}, attrs map[string]string) []byte { var input = $('<input>'); input.attr({ - class: 'tag '+chip.tag, + class: '__ponzu-tag '+chip.tag.split(' ').join('__'), name: '` + name + `.'+String(tags.find('input[type=hidden]').length), value: chip.tag, type: 'hidden' @@ -386,9 +394,7 @@ func Tags(fieldName string, p interface{}, attrs map[string]string) []byte { chips.on('chip.delete', function(e, chip) { // convert tag string to class-like selector "some tag" -> ".some.tag" - var sel = '.__ponzu-tag.'+chip.tag.split(' ').join('.'); - console.log(sel); - console.log(chips.parent().find(sel)); + var sel = '.__ponzu-tag.' + chip.tag.split(' ').join('__'); chips.parent().find(sel).remove(); // iterate through all hidden tag inputs to re-name them with the correct ` + name + `.index @@ -404,9 +410,9 @@ func Tags(fieldName string, p interface{}, attrs map[string]string) []byte { }); tags.append(input); - return; } + // re-name hidden storage elements in necessary format for (var i = 0; i < hidden.length; i++) { $(hidden[i]).attr('name', '` + name + `.'+String(i)); } diff --git a/management/manager/process.go b/management/manager/process.go index ec09e45..ad6da94 100644 --- a/management/manager/process.go +++ b/management/manager/process.go @@ -5,16 +5,16 @@ import ( "strings" "unicode" - "github.com/bosssauce/ponzu/management/editor" + "github.com/bosssauce/ponzu/content" "golang.org/x/text/transform" "golang.org/x/text/unicode/norm" ) // Slug returns a URL friendly string from the title of a post item -func Slug(e editor.Editable) (string, error) { +func Slug(i content.Identifiable) (string, error) { // get the name of the post item - name := strings.TrimSpace(e.ContentName()) + name := strings.TrimSpace(i.String()) // filter out non-alphanumeric character or non-whitespace slug, err := stringToSlug(name) |