Allow empty content

master
Jan-Lukas Else 2020-01-12 17:30:32 +01:00
parent 2136265825
commit f71738cde4
1 changed files with 68 additions and 72 deletions

View File

@ -79,9 +79,9 @@ func createEntryFromValueMap(values map[string][]string) (*Entry, error) {
if h, ok := values["h"]; ok && (len(h) != 1 || h[0] != "entry") {
return nil, errors.New("only entry type is supported so far")
}
if _, ok := values["content"]; ok {
entry := &Entry{
content: values["content"][0],
entry := &Entry{}
if content, ok := values["content"]; ok {
entry.content = content[0]
}
if name, ok := values["name"]; ok {
entry.title = name[0]
@ -121,16 +121,14 @@ func createEntryFromValueMap(values map[string][]string) (*Entry, error) {
}
return entry, nil
}
return nil, errors.New("error parsing the entry")
}
func createEntryFromMicroformat(mfEntry *MicroformatItem) (*Entry, error) {
if len(mfEntry.Type) != 1 || mfEntry.Type[0] != "h-entry" {
return nil, errors.New("only entry type is supported so far")
}
entry := &Entry{}
if mfEntry.Properties != nil && len(mfEntry.Properties.Content) == 1 && len(mfEntry.Properties.Content[0]) > 0 {
entry := &Entry{
content: mfEntry.Properties.Content[0],
entry.content = mfEntry.Properties.Content[0]
}
if len(mfEntry.Properties.Name) == 1 {
entry.title = mfEntry.Properties.Name[0]
@ -159,8 +157,6 @@ func createEntryFromMicroformat(mfEntry *MicroformatItem) (*Entry, error) {
}
return entry, nil
}
return nil, errors.New("error parsing the entry")
}
func computeExtraSettings(entry *Entry) error {
now := time.Now()