@taekwondo-db/web-app 0.0.0-stage → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +297 -2
  3. package/assets/css/abstracts/base.css +54 -0
  4. package/assets/css/abstracts/variables.css +125 -0
  5. package/assets/css/components/breadcrumb.css +14 -0
  6. package/assets/css/components/card.css +35 -0
  7. package/assets/css/components/categories.css +200 -0
  8. package/assets/css/components/detail.css +591 -0
  9. package/assets/css/components/grade.css +79 -0
  10. package/assets/css/components/header.css +131 -0
  11. package/assets/css/components/language.css +38 -0
  12. package/assets/css/components/layout.css +151 -0
  13. package/assets/css/components/link.css +26 -0
  14. package/assets/css/components/result.css +123 -0
  15. package/assets/css/components/search.css +193 -0
  16. package/assets/css/components/tag.css +137 -0
  17. package/assets/css/style.css +17 -0
  18. package/assets/fonts/noto-serif-kr.css +28 -0
  19. package/assets/js/email.js +11 -0
  20. package/assets/js/gallery.js +30 -0
  21. package/assets/js/language.js +11 -0
  22. package/assets/js/main.js +17 -0
  23. package/assets/js/pwa.js +48 -0
  24. package/assets/js/search.js +276 -0
  25. package/assets/js/sorting.js +26 -0
  26. package/bin/taekwondo-db.js +145 -0
  27. package/content/_content.gotmpl +27 -0
  28. package/hugo.toml +32 -0
  29. package/i18n/de.json +107 -0
  30. package/i18n/en.json +107 -0
  31. package/i18n/ko.json +107 -0
  32. package/layouts/404.html +23 -0
  33. package/layouts/_partials/breadcrumb.html +11 -0
  34. package/layouts/_partials/categories.html +17 -0
  35. package/layouts/_partials/category-cards.html +36 -0
  36. package/layouts/_partials/category-group.html +7 -0
  37. package/layouts/_partials/category-section.html +15 -0
  38. package/layouts/_partials/category-tile.html +4 -0
  39. package/layouts/_partials/description.html +10 -0
  40. package/layouts/_partials/email.html +6 -0
  41. package/layouts/_partials/favicons.html +42 -0
  42. package/layouts/_partials/fonts.html +33 -0
  43. package/layouts/_partials/grade-badge.html +11 -0
  44. package/layouts/_partials/grade-name.html +14 -0
  45. package/layouts/_partials/head.html +17 -0
  46. package/layouts/_partials/header.html +38 -0
  47. package/layouts/_partials/historic.html +23 -0
  48. package/layouts/_partials/icon.html +13 -0
  49. package/layouts/_partials/language-label.html +3 -0
  50. package/layouts/_partials/language.html +13 -0
  51. package/layouts/_partials/page-title.html +13 -0
  52. package/layouts/_partials/scripts.html +25 -0
  53. package/layouts/_partials/search-form.html +11 -0
  54. package/layouts/_partials/search-index.html +40 -0
  55. package/layouts/_partials/source-entry.html +13 -0
  56. package/layouts/_partials/t.html +2 -0
  57. package/layouts/_partials/technique/photo.html +45 -0
  58. package/layouts/_partials/technique/word-meaning.html +33 -0
  59. package/layouts/_partials/technique-name.html +5 -0
  60. package/layouts/_partials/technique-row.html +17 -0
  61. package/layouts/_partials/term/list.html +24 -0
  62. package/layouts/_partials/term-name.html +4 -0
  63. package/layouts/_partials/url.html +11 -0
  64. package/layouts/_shortcodes/email.html +2 -0
  65. package/layouts/_shortcodes/operator.html +18 -0
  66. package/layouts/baseof.html +39 -0
  67. package/layouts/group/page.html +24 -0
  68. package/layouts/groups.html +48 -0
  69. package/layouts/home.html +19 -0
  70. package/layouts/page.html +17 -0
  71. package/layouts/source/page.html +67 -0
  72. package/layouts/technique/page.html +160 -0
  73. package/layouts/term/page.html +97 -0
  74. package/lib/database.js +33 -0
  75. package/lib/export.js +423 -0
  76. package/lib/service-worker.js +167 -0
  77. package/lib/validate.js +179 -0
  78. package/package.json +42 -5
@@ -0,0 +1,19 @@
1
+ {{- /*
2
+ Entry page: the search field, and — as long as nothing has been typed — the
3
+ technique categories as an overview to browse instead of search.
4
+ */ -}}
5
+ {{ define "main" }}
6
+ <div class="stack-lg" data-search data-search-home>
7
+ <div class="home-hero">
8
+ <div class="home-hero__text" data-search-idle>
9
+ <h1>{{ site.Title }}</h1>
10
+ <p>{{ T "home subtitle" }}</p>
11
+ </div>
12
+ {{ partial "search-form.html" (dict "id" "app-search-input") }}
13
+ </div>
14
+
15
+ <div class="search-results" data-search-results hidden></div>
16
+
17
+ {{- partial "category-cards.html" . }}
18
+ </div>
19
+ {{ end }}
@@ -0,0 +1,17 @@
1
+ {{- /* A site's own Markdown pages, e.g. imprint or privacy policy (content/*.md). */ -}}
2
+ {{ define "main" }}
3
+ <div class="detail">
4
+ <article class="detail__body">
5
+ <div class="title-block">
6
+ <div class="title-block__line">
7
+ <h1>{{ .Title }}</h1>
8
+ </div>
9
+ </div>
10
+ <section class="card">
11
+ <div class="card-body">
12
+ {{ .Content }}
13
+ </div>
14
+ </section>
15
+ </article>
16
+ </div>
17
+ {{ end }}
@@ -0,0 +1,67 @@
1
+ {{ define "main" }}
2
+ {{- $source := index hugo.Data.taekwondo.sources .Params.key -}}
3
+ {{- $lang := site.Language.Lang -}}
4
+ {{- $byline := slice -}}
5
+ {{- with $source.author }}{{ $byline = $byline | append . }}{{ end -}}
6
+ {{- with $source.year }}{{ $byline = $byline | append . }}{{ end -}}
7
+
8
+ <div class="detail">
9
+ <article class="detail__body">
10
+ <div class="title-block">
11
+ <span class="pill-outline">{{ partial "t.html" $source.type }}</span>
12
+ <div class="title-block__line">
13
+ <h1>{{ $source.title }}</h1>
14
+ </div>
15
+ {{- with $byline }}
16
+ <p class="title-block__translation">{{ delimit . " · " }}</p>
17
+ {{- end }}
18
+ {{- with index $source.description $lang }}
19
+ <p class="title-block__description">{{ . }}</p>
20
+ {{- end }}
21
+ </div>
22
+
23
+ <div class="info-grid">
24
+ <section class="card">
25
+ <div class="card-body">
26
+ <h2 class="section-title mb-2">{{ T "about the source" }}</h2>
27
+ <dl class="data-list">
28
+ {{- range slice (dict "label" (T "author") "value" $source.author) (dict "label" (T "year") "value" $source.year) (dict "label" "ISBN" "value" $source.isbn) }}
29
+ <div>
30
+ <dt>{{ .label }}</dt>
31
+ <dd>{{ .value | default (T "unknown") }}</dd>
32
+ </div>
33
+ {{- end }}
34
+ </dl>
35
+ {{- with $source.url }}
36
+ <a class="link-external mt-3" href="{{ . }}" target="_blank" rel="noopener noreferrer"><span>{{ T "open source" }}</span>{{ partial "icon.html" (dict "name" "external" "size" 16) }}</a>
37
+ {{- end }}
38
+ </div>
39
+ </section>
40
+
41
+ {{- with $source.historic }}
42
+ <section class="card">
43
+ <div class="card-body">
44
+ <h2 class="section-title mb-2">{{ T "historic data" }}</h2>
45
+ <ul class="link-list">
46
+ {{- range . }}
47
+ <li><span>{{ . }}</span></li>
48
+ {{- end }}
49
+ </ul>
50
+ </div>
51
+ </section>
52
+ {{- end }}
53
+ </div>
54
+
55
+ {{- with $source.techniques }}
56
+ <section class="stack" style="gap: 10px">
57
+ <h2 class="section-title">{{ T "techniques" }} · {{ len . }}</h2>
58
+ <ul class="result-list">
59
+ {{- range . }}
60
+ {{ partial "technique-row.html" . }}
61
+ {{- end }}
62
+ </ul>
63
+ </section>
64
+ {{- end }}
65
+ </article>
66
+ </div>
67
+ {{ end }}
@@ -0,0 +1,160 @@
1
+ {{ define "main" }}
2
+ {{- $db := hugo.Data.taekwondo -}}
3
+ {{- $t := index $db.techniques .Params.key -}}
4
+ {{- $lang := site.Language.Lang -}}
5
+ {{- $korean := eq $lang "ko" -}}
6
+ {{- $name := partial "technique-name.html" $t.name -}}
7
+ {{- $group := partial "url.html" (dict "kind" "group" "key" $t.group) -}}
8
+
9
+ {{- $trail := slice (dict "label" (T "techniques") "href" (relLangURL "groups/")) -}}
10
+ {{- with $group }}{{ $trail = $trail | append (dict "label" (partial "t.html" $t.group) "href" .) }}{{ end -}}
11
+ {{ partial "breadcrumb.html" (dict "trail" $trail "current" $name) }}
12
+
13
+ <div class="detail">
14
+ {{- partial "technique/photo.html" (dict "technique" $t "name" $name) }}
15
+
16
+ <article class="detail__body">
17
+ <div class="title-block">
18
+ <a class="pill-category" data-group="{{ partial "category-group.html" $t.group }}" href="{{ $group }}">
19
+ {{ partial "t.html" $t.group }}
20
+ </a>
21
+
22
+ <div class="title-block__line">
23
+ <h1{{ if $korean }} lang="ko"{{ end }}>{{ $name }}</h1>
24
+ {{- if not $korean }}
25
+ <span class="hangeul" lang="ko">{{ $t.hangeul }}</span>
26
+ {{- end }}
27
+ </div>
28
+
29
+ {{- with index $t.translation $lang }}
30
+ <p class="title-block__translation">{{ . }}</p>
31
+ {{- end }}
32
+
33
+ {{- if or $t.generic $t.grade }}
34
+ <div class="title-block__tags">
35
+ {{- partial "grade-badge.html" $t.name }}
36
+ {{- if $t.generic }}
37
+ <span class="tag">{{ T "generic" }}</span>
38
+ {{- end }}
39
+ </div>
40
+ {{- end }}
41
+ </div>
42
+
43
+ {{- /* The main text of the page — outside the card grid, where it would rank alongside sources and videos. */}}
44
+ {{- with index $t.description $lang }}
45
+ <p class="technique-description">{{ partial "description.html" . }}</p>
46
+ {{- end }}
47
+
48
+ {{- partial "technique/word-meaning.html" $t }}
49
+
50
+ <div class="info-grid">
51
+ {{- with $t.weight }}
52
+ <section class="card card--full">
53
+ <div class="card-body">
54
+ <h2 class="section-title mb-3">{{ T "weight" }}</h2>
55
+ <div class="weight-bar" role="img" aria-label="{{ .front }} % {{ T "front" }}, {{ .back }} % {{ T "back" }}">
56
+ <div class="weight-bar__front" style="flex: {{ .front }}"></div>
57
+ <div class="weight-bar__back" style="flex: {{ .back }}"></div>
58
+ </div>
59
+ <div class="weight-values">
60
+ <div><b>{{ .front }} %</b> <span>{{ T "front" }}</span></div>
61
+ <div><b>{{ .back }} %</b> <span>{{ T "back" }}</span></div>
62
+ </div>
63
+ </div>
64
+ </section>
65
+ {{- end }}
66
+
67
+ {{- with $t.videos }}
68
+ <section class="card">
69
+ <div class="card-body">
70
+ <h2 class="section-title mb-2">{{ T "videos" }}</h2>
71
+ <ul class="link-list">
72
+ {{- range . }}
73
+ <li>
74
+ <a href="{{ .link }}" target="_blank" rel="noopener noreferrer">
75
+ <span>{{ .name }}</span>
76
+ {{ partial "icon.html" (dict "name" "play" "size" 16) }}
77
+ </a>
78
+ </li>
79
+ {{- end }}
80
+ </ul>
81
+ </div>
82
+ </section>
83
+ {{- end }}
84
+
85
+ {{- with $t.references }}
86
+ <section class="card">
87
+ <div class="card-body">
88
+ <h2 class="section-title mb-2">{{ T "references" }}</h2>
89
+ <ul class="link-list">
90
+ {{- range . }}
91
+ <li>
92
+ <a href="{{ partial "url.html" (dict "kind" "technique" "key" .key) }}">
93
+ <span>{{ partial "technique-name.html" .key }}</span>
94
+ <span class="romanization">{{ partial "t.html" .type }}</span>
95
+ </a>
96
+ </li>
97
+ {{- end }}
98
+ </ul>
99
+ </div>
100
+ </section>
101
+ {{- end }}
102
+
103
+ {{- with $t.supplementaryName }}
104
+ <section class="card">
105
+ <div class="card-body">
106
+ <h2 class="section-title mb-2">{{ T "supplementaryName" }}</h2>
107
+ <p class="mb-0">{{ . }}</p>
108
+ </div>
109
+ </section>
110
+ {{- end }}
111
+
112
+ {{- with $t.sources }}
113
+ <section class="card">
114
+ <div class="card-body">
115
+ <h2 class="section-title mb-2">{{ T "sources" }}</h2>
116
+ <div class="source-list">
117
+ {{- range . }}
118
+ {{ partial "source-entry.html" . }}
119
+ {{- end }}
120
+ </div>
121
+ </div>
122
+ </section>
123
+ {{- end }}
124
+
125
+ {{- with $t.historic }}
126
+ <section class="card card--full">
127
+ <div class="card-body">
128
+ <h2 class="section-title mb-2">{{ T "historical names" }}</h2>
129
+ {{- range . }}
130
+ {{ partial "historic.html" . }}
131
+ {{- end }}
132
+ </div>
133
+ </section>
134
+ {{- end }}
135
+ </div>
136
+
137
+ {{- /* Walks the category in its stored order, so training order is preserved. */}}
138
+ {{- if or $t.previous $t.next }}
139
+ <nav class="prev-next" aria-label="{{ partial "t.html" $t.group }}">
140
+ {{- with $t.previous }}
141
+ <a href="{{ partial "url.html" (dict "kind" "technique" "key" .) }}">
142
+ <small>← {{ T "previous" }}</small>
143
+ <b>{{ partial "technique-name.html" . }}</b>
144
+ </a>
145
+ {{- else }}
146
+ <span></span>
147
+ {{- end }}
148
+ {{- with $t.next }}
149
+ <a href="{{ partial "url.html" (dict "kind" "technique" "key" .) }}">
150
+ <small>{{ T "next" }} →</small>
151
+ <b>{{ partial "technique-name.html" . }}</b>
152
+ </a>
153
+ {{- else }}
154
+ <span></span>
155
+ {{- end }}
156
+ </nav>
157
+ {{- end }}
158
+ </article>
159
+ </div>
160
+ {{ end }}
@@ -0,0 +1,97 @@
1
+ {{ define "main" }}
2
+ {{- $db := hugo.Data.taekwondo -}}
3
+ {{- $term := index $db.terms .Params.key -}}
4
+ {{- $lang := site.Language.Lang -}}
5
+ {{- $korean := eq $lang "ko" -}}
6
+
7
+ <div class="detail">
8
+ <article class="detail__body">
9
+ <div class="title-block">
10
+ <span class="pill-outline">{{ T "term" }}</span>
11
+
12
+ <div class="title-block__line">
13
+ <h1{{ if $korean }} lang="ko"{{ end }}>{{ partial "term-name.html" $term.name }}</h1>
14
+ {{- if not $korean }}
15
+ <span class="hangeul" lang="ko">{{ $term.hangeul }}</span>
16
+ {{- end }}
17
+ {{- with $term.hanja }}
18
+ <span class="romanization">{{ . }}</span>
19
+ {{- end }}
20
+ </div>
21
+
22
+ {{- with index $term.description $lang }}
23
+ <p class="title-block__translation">{{ partial "description.html" . }}</p>
24
+ {{- end }}
25
+
26
+ {{- with $term.type }}
27
+ <p class="romanization mb-0">{{ partial "t.html" . }}{{ if $term.forms }} · {{ T "lemma" }}{{ end }}</p>
28
+ {{- end }}
29
+ </div>
30
+
31
+ <div class="info-grid">
32
+ {{- with $term.lemma }}
33
+ <section class="card">
34
+ <div class="card-body">
35
+ <h2 class="section-title mb-2">{{ T "lemma" }}</h2>
36
+ <ul class="link-list">
37
+ <li>
38
+ <a href="{{ partial "url.html" (dict "kind" "term" "key" .) }}">
39
+ <span>{{ partial "term-name.html" . }}</span>
40
+ {{ partial "icon.html" (dict "name" "chevron") }}
41
+ </a>
42
+ </li>
43
+ </ul>
44
+ </div>
45
+ </section>
46
+ {{- end }}
47
+
48
+ {{- partial "term/list.html" (dict "title" "combinedWithTerms" "keys" $term.terms) }}
49
+ {{- partial "term/list.html" (dict "title" "termForms" "keys" $term.forms) }}
50
+ {{- partial "term/list.html" (dict "title" "termCombinations" "keys" $term.combinations) }}
51
+
52
+ {{- with $term.techniques }}
53
+ <section class="stack card--full" style="gap: 10px">
54
+ <h2 class="section-title">{{ T "occurs in" }} · {{ len . }} {{ T "techniques" }}</h2>
55
+ <ul class="result-list">
56
+ {{- range . }}
57
+ {{ partial "technique-row.html" . }}
58
+ {{- end }}
59
+ </ul>
60
+ </section>
61
+ {{- end }}
62
+
63
+ {{- with $term.historic }}
64
+ <section class="card card--full">
65
+ <div class="card-body">
66
+ <h2 class="section-title mb-2">{{ T "historical names" }}</h2>
67
+ {{- range . }}
68
+ {{ partial "historic.html" . }}
69
+ {{- end }}
70
+ </div>
71
+ </section>
72
+ {{- end }}
73
+ </div>
74
+ </article>
75
+
76
+ {{- /* External dictionaries — the one thing this site deliberately does not do itself. */}}
77
+ <aside class="card detail__aside">
78
+ <div class="card-body">
79
+ <h2 class="section-title mb-2">{{ T "look up" }}</h2>
80
+ <ul class="link-list">
81
+ <li>
82
+ <a target="_blank" rel="noopener noreferrer" href="https://en.dict.naver.com/#/search?query={{ $term.hangeul | urlquery }}">
83
+ <span>{{ T "naver dictionary" }}</span>
84
+ {{ partial "icon.html" (dict "name" "external" "size" 16) }}
85
+ </a>
86
+ </li>
87
+ <li>
88
+ <a target="_blank" rel="noopener noreferrer" href="https://translate.google.com/?sl=ko&tl={{ $lang }}&text={{ $term.hangeul | urlquery }}&op=translate">
89
+ <span>{{ T "google translate" }}</span>
90
+ {{ partial "icon.html" (dict "name" "external" "size" 16) }}
91
+ </a>
92
+ </li>
93
+ </ul>
94
+ </div>
95
+ </aside>
96
+ </div>
97
+ {{ end }}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Loads `@taekwondo-db/database`, which ships TypeScript. Node refuses to strip
3
+ * types below node_modules, so a load hook does it for this one package.
4
+ */
5
+ import {
6
+ createRequire,
7
+ registerHooks,
8
+ stripTypeScriptTypes,
9
+ } from "node:module";
10
+
11
+ const require = createRequire(import.meta.url);
12
+ const entry = require.resolve("@taekwondo-db/database");
13
+
14
+ registerHooks({
15
+ load(url, context, nextLoad) {
16
+ if (!url.endsWith(".ts")) return nextLoad(url, context);
17
+ const result = nextLoad(url, { ...context, format: "module" });
18
+ return {
19
+ format: "module",
20
+ shortCircuit: true,
21
+ source: stripTypeScriptTypes(String(result.source)),
22
+ };
23
+ },
24
+ });
25
+
26
+ export const { TaekwondoDatabase, parseDescription, stripRefs } = await import(
27
+ entry
28
+ );
29
+
30
+ export {
31
+ builtinImageDir,
32
+ composeDatabase,
33
+ } from "@taekwondo-db/database/compose";