feat: Link kanjis to jitenon
This commit is contained in:
parent
b2f7990876
commit
fe68c07e2c
|
@ -34,6 +34,10 @@ class KanjiController extends AbstractController
|
|||
|
||||
$taiwan = $this->charList->getList('taiwan');
|
||||
|
||||
$jiten = json_decode(file_get_contents(
|
||||
"{$this->getParameter('kernel.project_dir')}/data/kanken-links.json",
|
||||
), true);
|
||||
|
||||
$chars = [];
|
||||
foreach (range(intval("{$start}0", 16), intval("{$end}f", 16)) as $codepoint) {
|
||||
$charStr = mb_chr($codepoint, 'UTF-8');
|
||||
|
@ -47,6 +51,9 @@ class KanjiController extends AbstractController
|
|||
'unicode' => in_array($charStr, $unicodeKanji, true),
|
||||
'taiwan' => key_exists($charStr, $taiwan['chars']),
|
||||
],
|
||||
'jiten_href' => key_exists($charStr, $jiten)
|
||||
? "https://kanji.jitenon.jp/kanji{$jiten[$charStr]}"
|
||||
: null
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -8,12 +8,6 @@
|
|||
<div class="d-flex flex-wrap m-2">
|
||||
{% for char in characters %}
|
||||
<div style="width: calc(100% / 16);">
|
||||
<a
|
||||
target="_blank"
|
||||
href="{{ path('app_kanji_register', {
|
||||
codepoint: char.codepoint
|
||||
}) }}"
|
||||
>
|
||||
<div
|
||||
class="border text-center rounded"
|
||||
style="
|
||||
|
@ -31,16 +25,36 @@
|
|||
{{ char.lists.sln ? 'bg-danger text-white' : '' }}
|
||||
{{ char.lists.sn ? 'bg-warning text-black' : '' }}
|
||||
">
|
||||
{% if char.jiten_href != null %}
|
||||
<a
|
||||
target="_blank"
|
||||
href="{{- char.jiten_href -}}"
|
||||
class="border-bottom"
|
||||
>
|
||||
{{- char.str -}}
|
||||
</a>
|
||||
{% else %}
|
||||
{{- char.str -}}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div style="
|
||||
font-size: 0.5em;
|
||||
padding-bottom: 2px;
|
||||
">
|
||||
{% if not char.lists.unicode %}
|
||||
<a
|
||||
target="_blank"
|
||||
href="{{ path('app_kanji_register', {
|
||||
codepoint: char.codepoint
|
||||
}) }}"
|
||||
>
|
||||
{{ char.codepoint }}
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{% else %}
|
||||
{{ char.codepoint }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue