diff --git a/dict/main.go b/dict/main.go index 6ba40da..422f92e 100644 --- a/dict/main.go +++ b/dict/main.go @@ -36,7 +36,7 @@ type Entry struct { type Definition struct { Definition string - PartOfSpeech string + PartOfSpeech []string } func ParseEntry(entry jmdict.JmdictEntry) Entry { @@ -49,18 +49,18 @@ func ParseEntry(entry jmdict.JmdictEntry) Entry { reading = entry.Readings[0].Reading } var definitions []Definition - if len(entry.Sense) > 0 && len(entry.Sense[0].Glossary) > 0 { - definitions = make([]Definition, len(entry.Sense[0].Glossary)) - for i, glossary := range entry.Sense[0].Glossary { - var pos string - if len(entry.Sense[0].PartsOfSpeech) > i+1 { - pos = entry.Sense[0].PartsOfSpeech[i] - } - definitions[i] = Definition{ - Definition: glossary.Content, - PartOfSpeech: pos, + definitions = make([]Definition, len(entry.Sense)) + for i, sense := range entry.Sense { + definition := sense.Glossary[0].Content + if len(sense.Glossary) > 1 { + for _, glossary := range sense.Glossary[1:] { + definition += "; " + glossary.Content } } + definitions[i] = Definition{ + Definition: definition, + PartOfSpeech: sense.PartsOfSpeech, + } } return Entry{ Kanji: kanji, diff --git a/dict/static/index.html b/dict/static/index.html index cfebb64..3ebf623 100644 --- a/dict/static/index.html +++ b/dict/static/index.html @@ -5,6 +5,11 @@ jidict + diff --git a/dict/templates/definition.html b/dict/templates/definition.html index b85c3ed..86595c7 100644 --- a/dict/templates/definition.html +++ b/dict/templates/definition.html @@ -1,3 +1,3 @@ -{{ define "definition" }} -{{ if .PartOfSpeech }}{{ .PartOfSpeech }} {{ end }}{{ .Definition -}} +{{- define "definition" -}} +{{ if .PartOfSpeech }}{{ .PartOfSpeech }}
{{ end }}{{ .Definition -}} {{ end }} \ No newline at end of file diff --git a/dict/templates/search.html b/dict/templates/search.html index 3ee8e32..7679286 100644 --- a/dict/templates/search.html +++ b/dict/templates/search.html @@ -1,5 +1,5 @@

{{ $count := (len .) }}{{ if eq $count 0 }}No results{{ else }}{{ $count }} result{{ if ne $count 1}}s{{ end }}{{ end }}.

-{{- range . -}} +{{ range . -}}

{{- if .Kanji -}} @@ -13,7 +13,9 @@ {{- else -}}
    {{- range .Definitions }} -
  1. {{- template "definition" . -}}
  2. +
  3. + {{ template "definition" . }} +
  4. {{- end }}
{{- end }}