diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index f312796d..a6438523 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -65,11 +65,12 @@ class Dictionary {
for (let name in this.kanjiDicts) {
const def = this.kanjiDicts[name].c[kanji];
if (def) {
- const [k, o, ...g] = def;
+ const [k, o, t, ...g] = def;
results.push({
character: kanji,
kunyomi: k.split(' '),
onyomi: o.split(' '),
+ tags: t.split(' '),
glossary: g
});
}
diff --git a/ext/bg/js/templates.js b/ext/bg/js/templates.js
index ef26ab81..eec28982 100644
--- a/ext/bg/js/templates.js
+++ b/ext/bg/js/templates.js
@@ -37,30 +37,26 @@ templates['kanji.html'] = template({"1":function(container,depth0,helpers,partia
},"4":function(container,depth0,helpers,partials,data) {
var stack1;
- return "
Meanings\n \n"
- + ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.glossary : depth0),{"name":"each","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
- + " \n";
-},"5":function(container,depth0,helpers,partials,data) {
- var stack1;
-
- return " "
+ return " "
+ container.escapeExpression(container.lambda(depth0, depth0))
- + ((stack1 = helpers.unless.call(depth0 != null ? depth0 : {},(data && data.last),{"name":"unless","hash":{},"fn":container.program(6, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ + ((stack1 = helpers.unless.call(depth0 != null ? depth0 : {},(data && data.last),{"name":"unless","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n";
-},"6":function(container,depth0,helpers,partials,data) {
+},"5":function(container,depth0,helpers,partials,data) {
return ", ";
-},"8":function(container,depth0,helpers,partials,data) {
- var stack1;
+},"7":function(container,depth0,helpers,partials,data) {
+ var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
- return " Kun'yomi\n \n"
- + ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.kunyomi : depth0),{"name":"each","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
- + " \n";
-},"10":function(container,depth0,helpers,partials,data) {
- var stack1;
-
- return " On'yomi\n \n"
- + ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.onyomi : depth0),{"name":"each","hash":{},"fn":container.program(5, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
- + " \n";
+ return " "
+ + alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
+ + "\n";
+},"9":function(container,depth0,helpers,partials,data) {
+ return " "
+ + container.escapeExpression(container.lambda(depth0, depth0))
+ + "\n";
},"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data,blockParams,depths) {
var stack1, helper, alias1=depth0 != null ? depth0 : {};
@@ -68,13 +64,15 @@ templates['kanji.html'] = template({"1":function(container,depth0,helpers,partia
+ ((stack1 = helpers["with"].call(alias1,(depth0 != null ? depth0.options : depth0),{"name":"with","hash":{},"fn":container.program(1, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n "
+ container.escapeExpression(((helper = (helper = helpers.character || (depth0 != null ? depth0.character : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === "function" ? helper.call(alias1,{"name":"character","hash":{},"data":data}) : helper)))
- + "
\n\n \n
\n"
- + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.glossary : depth0),{"name":"if","hash":{},"fn":container.program(4, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
- + "\n"
- + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.kunyomi : depth0),{"name":"if","hash":{},"fn":container.program(8, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
- + "\n"
- + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.onyomi : depth0),{"name":"if","hash":{},"fn":container.program(10, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
- + "
\n
\n\n";
+ + "\n\n \n
\n \n Kunyomi: | \n \n"
+ + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.kunyomi : depth0),{"name":"each","hash":{},"fn":container.program(4, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ + " | \n
\n \n Onyomi: | \n \n"
+ + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.onyomi : depth0),{"name":"each","hash":{},"fn":container.program(4, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ + " | \n
\n
\n
\n\n \n"
+ + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.tags : depth0),{"name":"each","hash":{},"fn":container.program(7, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ + "
\n\n \n
\n"
+ + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.glossary : depth0),{"name":"each","hash":{},"fn":container.program(9, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ + "
\n
\n\n";
},"useData":true,"useDepths":true});
templates['kanji-link.html'] = template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper;
@@ -146,26 +144,14 @@ templates['term.html'] = template({"1":function(container,depth0,helpers,partial
},"11":function(container,depth0,helpers,partials,data) {
var stack1;
- return " \n"
- + ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.rules : depth0),{"name":"each","hash":{},"fn":container.program(12, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
- + "
\n";
-},"12":function(container,depth0,helpers,partials,data) {
- var stack1;
-
return " "
+ container.escapeExpression(container.lambda(depth0, depth0))
+ " "
- + ((stack1 = helpers.unless.call(depth0 != null ? depth0 : {},(data && data.last),{"name":"unless","hash":{},"fn":container.program(13, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ + ((stack1 = helpers.unless.call(depth0 != null ? depth0 : {},(data && data.last),{"name":"unless","hash":{},"fn":container.program(12, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n";
-},"13":function(container,depth0,helpers,partials,data) {
+},"12":function(container,depth0,helpers,partials,data) {
return "«";
-},"15":function(container,depth0,helpers,partials,data) {
- var stack1;
-
- return " \n"
- + ((stack1 = helpers.each.call(depth0 != null ? depth0 : {},(depth0 != null ? depth0.tags : depth0),{"name":"each","hash":{},"fn":container.program(16, data, 0),"inverse":container.noop,"data":data})) != null ? stack1 : "")
- + "
\n";
-},"16":function(container,depth0,helpers,partials,data) {
+},"14":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : {}, alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return " "
+ alias4(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data}) : helper)))
+ "\n";
-},"18":function(container,depth0,helpers,partials,data) {
+},"16":function(container,depth0,helpers,partials,data) {
return " "
+ container.escapeExpression(container.lambda(depth0, depth0))
+ "\n";
@@ -186,12 +172,12 @@ templates['term.html'] = template({"1":function(container,depth0,helpers,partial
+ ((stack1 = helpers["with"].call(alias1,(depth0 != null ? depth0.options : depth0),{"name":"with","hash":{},"fn":container.program(1, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "\n"
+ ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.reading : depth0),{"name":"if","hash":{},"fn":container.program(6, data, 0, blockParams, depths),"inverse":container.program(9, data, 0, blockParams, depths),"data":data})) != null ? stack1 : "")
- + "\n"
- + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.rules : depth0),{"name":"if","hash":{},"fn":container.program(11, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
- + "\n"
- + ((stack1 = helpers["if"].call(alias1,(depth0 != null ? depth0.tags : depth0),{"name":"if","hash":{},"fn":container.program(15, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
- + "\n \n
\n"
- + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.glossary : depth0),{"name":"each","hash":{},"fn":container.program(18, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ + "\n \n"
+ + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.rules : depth0),{"name":"each","hash":{},"fn":container.program(11, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ + "
\n\n \n"
+ + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.tags : depth0),{"name":"each","hash":{},"fn":container.program(14, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ + "
\n\n \n
\n"
+ + ((stack1 = helpers.each.call(alias1,(depth0 != null ? depth0.glossary : depth0),{"name":"each","hash":{},"fn":container.program(16, data, 0, blockParams, depths),"inverse":container.noop,"data":data})) != null ? stack1 : "")
+ "
\n
\n
\n";
},"useData":true,"useDepths":true});
templates['term-list.html'] = template({"1":function(container,depth0,helpers,partials,data,blockParams,depths) {
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index b7fce392..cdcdda28 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -148,7 +148,7 @@ class Translator {
}
}
- return definitions;
+ return this.processKanji(definitions);
}
processTerm(groups, source, tags, rules=[], root='') {
@@ -227,6 +227,39 @@ class Translator {
}
}
+ processKanji(entries) {
+ const results = [];
+ for (let entry of entries) {
+ const tagItems = [];
+ for (let tag of entry.tags) {
+ const tagItem = {
+ class: 'default',
+ order: Number.MAX_SAFE_INTEGER,
+ name: tag
+ };
+
+ const tagMeta = this.tagMeta[tag];
+ if (tagMeta) {
+ for (const tagProp in tagMeta) {
+ tagItem[tagProp] = tagMeta[tagProp] || tagItem[tagProp];
+ }
+ }
+
+ tagItems.push(tagItem);
+ }
+
+ results.push({
+ character: entry.character,
+ kunyomi: entry.kunyomi,
+ onyomi: entry.onyomi,
+ tags: tagItems,
+ glossary: entry.glossary
+ });
+ }
+
+ return results;
+ }
+
static isKanji(c) {
const code = c.charCodeAt(0);
return code >= 0x4e00 && code < 0x9fb0 || code >= 0x3400 && code < 0x4dc0;
diff --git a/ext/fg/css/frame.css b/ext/fg/css/frame.css
index 68efa9c6..e7b5dedc 100644
--- a/ext/fg/css/frame.css
+++ b/ext/fg/css/frame.css
@@ -106,7 +106,7 @@ body {
}
.term-glossary ol {
- padding-left: 1.2em;
+ padding-left: 1.4em;
}
.term-glossary li {
@@ -120,28 +120,36 @@ body {
/* kanji styles */
.kanji-glyph {
- float: right;
font-family: kanji-stroke-orders;
- font-size: 140px;
- line-height: 140px;
+ font-size: 120px;
+ line-height: 120px;
padding: 0.01em;
vertical-align: top;
}
-.kanji-reading {
+.kanji-reading table {
+ padding: 0.3em, 0.3em;
+}
+
+.kanji-reading th {
+ color: #777;
+ font-weight: bold;
+ text-align: right;
+ vertical-align: top;
+}
+
+.kanji-reading td {
font-family: vl-gothic-regular;
}
-.kanji-info {
- display: block;
- overflow: hidden;
+.kanji-glossary ol {
+ padding-left: 1.4em;
}
-.kanji-info dt {
- color: #777;
- font-weight: bold;
+.kanji-glossary li {
+ color: #777;
}
-.kanji-info dd {
- margin-left: 1.2em;
+.kanji-glossary li span {
+ color: #000;
}
diff --git a/tmpl/kanji.html b/tmpl/kanji.html
index 3e148aae..0a0cfe11 100644
--- a/tmpl/kanji.html
+++ b/tmpl/kanji.html
@@ -9,34 +9,38 @@
{{character}}
-
-
- {{#if glossary}}
- - Meanings
- -
- {{#each glossary}}
- {{.}}{{#unless @last}}, {{/unless}}
- {{/each}}
-
- {{/if}}
+
+
+
+ Kunyomi: |
+
+ {{#each kunyomi}}
+ {{.}}{{#unless @last}}, {{/unless}}
+ {{/each}}
+ |
+
+
+ Onyomi: |
+
+ {{#each onyomi}}
+ {{.}}{{#unless @last}}, {{/unless}}
+ {{/each}}
+ |
+
+
+
- {{#if kunyomi}}
- - Kun'yomi
- -
- {{#each kunyomi}}
- {{.}}{{#unless @last}}, {{/unless}}
- {{/each}}
-
- {{/if}}
+
+ {{#each tags}}
+ {{name}}
+ {{/each}}
+
- {{#if onyomi}}
- - On'yomi
- -
- {{#each onyomi}}
- {{.}}{{#unless @last}}, {{/unless}}
- {{/each}}
-
- {{/if}}
-
+
+
+ {{#each glossary}}
+ - {{.}}
+ {{/each}}
+
diff --git a/tmpl/term.html b/tmpl/term.html
index 620b5ace..ca96ab24 100644
--- a/tmpl/term.html
+++ b/tmpl/term.html
@@ -17,21 +17,17 @@
{{#kanjiLinks}}{{expression}}{{/kanjiLinks}}
{{/if}}
- {{#if rules}}
{{#each rules}}
{{.}} {{#unless @last}}«{{/unless}}
{{/each}}
- {{/if}}
- {{#if tags}}
{{#each tags}}
{{name}}
{{/each}}
- {{/if}}