generated from ElnuDev/go-project
Better part of speech display
This commit is contained in:
parent
8421aca007
commit
33ecd1a539
4 changed files with 86 additions and 14 deletions
31
dict/main.go
31
dict/main.go
|
@ -136,7 +136,12 @@ type Entry struct {
|
|||
|
||||
type Definition struct {
|
||||
Definition string
|
||||
PartOfSpeech []string
|
||||
PartOfSpeech []PartOfSpeech
|
||||
}
|
||||
|
||||
type PartOfSpeech struct {
|
||||
Description string
|
||||
Type string
|
||||
}
|
||||
|
||||
func ParseEntry(entry *jmdict.JmdictEntry, furiganaInfo *string) Entry {
|
||||
|
@ -159,9 +164,31 @@ func ParseEntry(entry *jmdict.JmdictEntry, furiganaInfo *string) Entry {
|
|||
definition += "; " + glossary.Content
|
||||
}
|
||||
}
|
||||
pos := make([]PartOfSpeech, len(sense.PartsOfSpeech))
|
||||
for i, posFull := range sense.PartsOfSpeech {
|
||||
class := ""
|
||||
if strings.Contains(posFull, "noun") {
|
||||
class = "noun"
|
||||
} else if strings.Contains(posFull, "adjective") {
|
||||
class = "adjective"
|
||||
} else if strings.Contains(posFull, "adverb") {
|
||||
class = "adverb"
|
||||
} else if strings.Contains(posFull, "verb") {
|
||||
class = "verb"
|
||||
} else if strings.Contains(posFull, "particle") {
|
||||
class = "particle"
|
||||
} else if strings.Contains(posFull, "phrase") {
|
||||
class = "phrase"
|
||||
}
|
||||
pos[i] = PartOfSpeech{
|
||||
Description: posFull,
|
||||
Type: class,
|
||||
}
|
||||
}
|
||||
|
||||
definitions[i] = Definition{
|
||||
Definition: definition,
|
||||
PartOfSpeech: sense.PartsOfSpeech,
|
||||
PartOfSpeech: pos,
|
||||
}
|
||||
}
|
||||
// 1:ねが;3:いた
|
||||
|
|
55
dict/static/overrides.css
Normal file
55
dict/static/overrides.css
Normal file
|
@ -0,0 +1,55 @@
|
|||
:root {
|
||||
--bg: #282828 !important;
|
||||
--fg: #ebdbb2 !important;
|
||||
|
||||
--box-bg: #3c3836 !important; /* bg1 */
|
||||
--graphical-fg: #928374 !important; /* gray */
|
||||
|
||||
--info-graphical-fg: red !important;
|
||||
}
|
||||
|
||||
chip {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.noun {
|
||||
--box-bg: #79740e;
|
||||
--accent: #b8bb26;
|
||||
--graphical-fg: #98971a;
|
||||
}
|
||||
|
||||
.adjective {
|
||||
--box-bg: #9d0006;
|
||||
--accent: #fb4934;
|
||||
--graphical-fg: #cc241d;
|
||||
}
|
||||
|
||||
.verb, .adverb {
|
||||
--box-bg: #076678;
|
||||
--accent: #83a598;
|
||||
--graphical-fg: #458588;
|
||||
}
|
||||
|
||||
.particle {
|
||||
--box-bg: #b57614;
|
||||
--accent: #fabd2f;
|
||||
--graphical-fg: #d79921;
|
||||
}
|
||||
|
||||
.phrase {
|
||||
--box-bg: #8f3f71;
|
||||
--accent: #d3869b;
|
||||
--graphical-fg: #b16286;
|
||||
}
|
||||
|
||||
li {
|
||||
margin-top: 0.75em;
|
||||
}
|
||||
|
||||
#results .box h3 a {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
#results .box h3 a:not(:hover) {
|
||||
text-decoration: none;
|
||||
}
|
|
@ -6,17 +6,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{ block "title" . }}{{ template "sitetitle" . }}{{ end }}</title>
|
||||
<link rel="stylesheet" href="https://unpkg.com/missing.css@1.0.9/dist/missing.min.css">
|
||||
<style>
|
||||
li {
|
||||
margin-top: 0.75em;
|
||||
}
|
||||
#results .box h3 a {
|
||||
color: inherit;
|
||||
}
|
||||
#results .box h3 a:not(:hover) {
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="/overrides.css">
|
||||
<script src="https://unpkg.com/htmx.org@1.9.3"></script>
|
||||
</head>
|
||||
<body hx-boost="true">
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{{- define "definition" -}}
|
||||
{{ if .PartOfSpeech }}<small><chip>{{ .PartOfSpeech }}</chip></small><br>{{ end }}{{ highlight .Definition -}}
|
||||
{{ if .PartOfSpeech }}<small>{{ range .PartOfSpeech }}<chip class="{{ .Type }}">{{ .Description }}</chip> {{ end }}</small><br>{{ end }}{{ highlight .Definition -}}
|
||||
{{ end }}
|
Reference in a new issue