generated from ElnuDev/go-project
Compare commits
No commits in common. "3a7d33203b3e875026941ae4914789e500ecd5c4" and "293941c011dca0dc5b899969b627942b17b5c967" have entirely different histories.
3a7d33203b
...
293941c011
7 changed files with 16 additions and 122 deletions
47
dict/main.go
47
dict/main.go
|
@ -136,12 +136,7 @@ type Entry struct {
|
||||||
|
|
||||||
type Definition struct {
|
type Definition struct {
|
||||||
Definition string
|
Definition string
|
||||||
PartOfSpeech []PartOfSpeech
|
PartOfSpeech []string
|
||||||
}
|
|
||||||
|
|
||||||
type PartOfSpeech struct {
|
|
||||||
Description string
|
|
||||||
Type string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseEntry(entry *jmdict.JmdictEntry, furiganaInfo *string) Entry {
|
func ParseEntry(entry *jmdict.JmdictEntry, furiganaInfo *string) Entry {
|
||||||
|
@ -164,31 +159,9 @@ func ParseEntry(entry *jmdict.JmdictEntry, furiganaInfo *string) Entry {
|
||||||
definition += "; " + glossary.Content
|
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{
|
definitions[i] = Definition{
|
||||||
Definition: definition,
|
Definition: definition,
|
||||||
PartOfSpeech: pos,
|
PartOfSpeech: sense.PartsOfSpeech,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 1:ねが;3:いた
|
// 1:ねが;3:いた
|
||||||
|
@ -431,20 +404,6 @@ func main() {
|
||||||
},
|
},
|
||||||
[]string{http.MethodGet},
|
[]string{http.MethodGet},
|
||||||
))
|
))
|
||||||
r.NotFoundHandler = http.HandlerFunc(httputils.GenerateHandler(
|
r.PathPrefix("/").Handler(http.FileServer(http.Dir("static")))
|
||||||
func(w http.ResponseWriter, r *http.Request) bool { return true },
|
|
||||||
httputils.NewTemplateSet("index.html", "404.html"),
|
|
||||||
func(w http.ResponseWriter, r *http.Request) (template string, data any) {
|
|
||||||
w.WriteHeader(http.StatusNotFound)
|
|
||||||
return "404.html", nil
|
|
||||||
},
|
|
||||||
[]string{http.MethodGet},
|
|
||||||
))
|
|
||||||
r.Path("/logo.svg").Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
http.ServeFile(w, r, "static/logo.svg")
|
|
||||||
}))
|
|
||||||
r.Path("/overrides.css").Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
http.ServeFile(w, r, "static/overrides.css")
|
|
||||||
}))
|
|
||||||
log.Fatal(http.ListenAndServe(":3334", r))
|
log.Fatal(http.ListenAndServe(":3334", r))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
: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;
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
{{- define "title" }}404 Not Found - {{ template "sitetitle" . }}{{- end -}}
|
|
||||||
|
|
||||||
{{- define "results" -}}
|
|
||||||
{{- template "404" . }}
|
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{- template "index" . -}}
|
|
|
@ -6,7 +6,17 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>{{ block "title" . }}{{ template "sitetitle" . }}{{ end }}</title>
|
<title>{{ block "title" . }}{{ template "sitetitle" . }}{{ end }}</title>
|
||||||
<link rel="stylesheet" href="https://unpkg.com/missing.css@1.0.9/dist/missing.min.css">
|
<link rel="stylesheet" href="https://unpkg.com/missing.css@1.0.9/dist/missing.min.css">
|
||||||
<link rel="stylesheet" href="/overrides.css">
|
<style>
|
||||||
|
li {
|
||||||
|
margin-top: 0.75em;
|
||||||
|
}
|
||||||
|
#results .box h3 a {
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
#results .box h3 a:not(:hover) {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<script src="https://unpkg.com/htmx.org@1.9.3"></script>
|
<script src="https://unpkg.com/htmx.org@1.9.3"></script>
|
||||||
</head>
|
</head>
|
||||||
<body hx-boost="true">
|
<body hx-boost="true">
|
||||||
|
@ -34,7 +44,6 @@
|
||||||
<li><a href="https://www.edrdg.org/wiki/index.php/JMdict-EDICT_Dictionary_Project" target="_blank"><b>JMdict</b></a> for providing free and open dictionary data</li>
|
<li><a href="https://www.edrdg.org/wiki/index.php/JMdict-EDICT_Dictionary_Project" target="_blank"><b>JMdict</b></a> for providing free and open dictionary data</li>
|
||||||
<li><a href="https://foosoft.net/" target="_blank">Alexei Yatskov</a> a.k.a. Foosoft Productions for providing the <a href="https:/foosoft.net/projects/jmdict">foosoft.net/projects/jmdict</a> Go package for parsing JMdict, and also for creating Yomichan, a great inspiration</li>
|
<li><a href="https://foosoft.net/" target="_blank">Alexei Yatskov</a> a.k.a. Foosoft Productions for providing the <a href="https:/foosoft.net/projects/jmdict">foosoft.net/projects/jmdict</a> Go package for parsing JMdict, and also for creating Yomichan, a great inspiration</li>
|
||||||
<li>Doublevil for providing <a href="https://github.com/Doublevil/JmdictFurigana">JmdictFurigana</a></li>
|
<li>Doublevil for providing <a href="https://github.com/Doublevil/JmdictFurigana">JmdictFurigana</a></li>
|
||||||
<li><a href="https://htmx.org/">htmx</a></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
{{ define "404" }}
|
|
||||||
<div class="center">
|
|
||||||
<br>
|
|
||||||
<h1>404 Not Found</h1>
|
|
||||||
<img src="https://tenor.com/view/fumo-touhou-reimu-reimu-peek-peeking-gif-22922061.gif" style="width: 256px" alt="Reimu fumo can't find nothin">
|
|
||||||
<p>Looks like this page doesn't exist?</p>
|
|
||||||
</div>
|
|
||||||
{{ end }}
|
|
|
@ -1,3 +1,3 @@
|
||||||
{{- define "definition" -}}
|
{{- define "definition" -}}
|
||||||
{{ if .PartOfSpeech }}<small>{{ range .PartOfSpeech }}<chip class="{{ .Type }}">{{ .Description }}</chip> {{ end }}</small><br>{{ end }}{{ highlight .Definition -}}
|
{{ if .PartOfSpeech }}<small><chip>{{ .PartOfSpeech }}</chip></small><br>{{ end }}{{ highlight .Definition -}}
|
||||||
{{ end }}
|
{{ end }}
|
|
@ -1,9 +1,5 @@
|
||||||
{{- define "title" }}{{ if .Entry }}{{ .Entry.Kanji }}{{ else }}404 Not Found{{ end }} - {{ template "sitetitle" . }}{{- end -}}
|
{{- define "title" }}{{ .Entry.Kanji }} - {{ template "sitetitle" . }}{{- end -}}
|
||||||
{{- define "results" -}}
|
{{- define "results" -}}
|
||||||
{{- if .Entry -}}
|
|
||||||
{{- template "entryfull" .Entry -}}
|
{{- template "entryfull" .Entry -}}
|
||||||
{{- else -}}
|
|
||||||
{{- template "404" . }}
|
|
||||||
{{- end -}}
|
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- template "index" . -}}
|
{{- template "index" . -}}
|
Reference in a new issue