Add "Japanese sentences (nb)" template

This commit is contained in:
Nikolay Belikov 2021-12-26 15:40:44 +03:00
parent b66a69ccdd
commit f5b05deea5
9 changed files with 711 additions and 0 deletions

View file

@ -0,0 +1,42 @@
<div class="wrap">
{{FrontSide}}
<hr>
<div lang="en">{{SentEng}}</div>
<div class="strokeorder">{{VocabKanji}}</div>
{{#VocabKanji}}
<div class="vocab">
{{VocabPitchPattern}}
{{^VocabPitchPattern}}{{kana:VocabFurigana}}{{/VocabPitchPattern}}
【{{VocabKanji}}】
</div>
{{/VocabKanji}}
{{#VocabDef}}
<div class="definitions">
{{edit:furigana:VocabDef}}
</div>
{{/VocabDef}}
{{#Notes}}
<div class="notes">
<div class="tags">Notes</div>
<div>{{furigana:Notes}}</div>
</div>
{{/Notes}}
{{#Source}}<div class="source">{{Source}}</div>{{/Source}}
<hr>
<footer>{{#SentKanji}}<a title="Translate with SimplyTranslate" href="https://translate.metalune.xyz/?engine=google&text={{text:kanji:SentKanji}}&sl=ja&tl=en">Translate</a><a href="https://jisho.org/search?keyword={{text:kanji:SentKanji}}"
title="Sentence on Jisho">Jisho</a><a href="https://www.google.co.jp/search?q={{text:kanji:SentKanji}}&tbm=isch"
title="Search images">Images</a>{{/SentKanji}}{{#VocabKanji}}<a
href="http://www.weblio.jp/content/{{text:VocabKanji}}" title="Vocab on Weblio">Weblio</a><a
href="https://wadoku.de/search/?q={{text:VocabKanji}}" title="Vocab on Wadoku">Wadoku</a>{{/VocabKanji}}
</footer>
</div> <!-- /wrap -->

View file

@ -0,0 +1,48 @@
{{#MakeProductionCard}}
<div class="wrap">
<header>{{#Tags}}<div class="tags">{{Tags}}</div>{{/Tags}}</header>
{{#Image}}<div class="images">{{Image}}</div>{{/Image}}
<div class="sent-center">
<div class="jpsentence production">
{{edit:furigana:SentFurigana}}
{{^SentFurigana}}<b>{{edit:furigana:VocabFurigana}}</b>{{/SentFurigana}}
</div>
<div>{{VocabAudio}}{{SentAudio}}</div>
</div>
</div> <!-- /wrap -->
<script>
function threeDots() {
const sent = document.getElementsByClassName("production")[0];
if (sent) {
for (const hidden of sent.getElementsByTagName("b")) {
hidden.style.visibility = "visible";
hidden.innerText = "【" + hidden.innerText.replace(/[^ぁ-んァ-ン]/g, "") + "】";
}
}
}
/* Splits tags into separate divs */
function splitTagDiv() {
const header = document.querySelector("header");
if (!header) return;
const split = `{{Tags}}`.split(' ');
header.innerHTML = "";
for (const tag of split) {
if (tag.length < 1)
continue;
const tag_elem = document.createElement("div");
tag_elem.className = "tags";
tag_elem.innerHTML = tag;
header.appendChild(tag_elem);
}
}
threeDots()
splitTagDiv()
</script>
{{/MakeProductionCard}}

View file

@ -0,0 +1,91 @@
# Japanese sentences (nb)
This is Tatsumoto's [Japanese sentences][] template which I've altered to my
liking. I'm not sure why would anyone prefer this one, but in such unlikely
case it is here for your convenience.
## What's different?
In this document I will only mention the modifications to the original
template; for general information about it refer to the link above.
### Single template for both targeted sentence cards and word cards
The template was altered to show `VocabKanji`/`VocabFurigana` pair in place of
`SentKanji`/`SentFurigana` when the former are empty. This makes it suitable
not only for sentence cards, but for word cards too. In fact, I have converted
my entire collection (which contains both mined notes and the entirety of
[Ankidrone Starter Pack][]) to this note type and enjoy the following benefits
of having single card type for all purposes:
* Whenever I want to convert a word card to a TSC card or the other way
around, I don't have to do a full database upload on the next sync.
* If I want to change the appearance of my cards, there is only one place to
make edits to, instead of two or more.
### Added fields, removed fields
* `Source` field was added for sake of recording the origin of a mined
sentence. It is displayed in less prominent fashion than the `Notes` field
and doesn't distract you from the actual notes that you might have. This
feature was shamelessly borrowed from cyphar's [Japanese Mined Sentences][]
template.
* `MorphManFocus` field was removed together with its related JavaScript and
styling, since I don't use MorphMan.
* `VocabPitchNum` field was removed together with pitch accent colorizing
script. I found the colorization annoying, and apart from machine
processing, pitch numbers are superseded by proper pitch accent annotations
presented in the `VocabPitchPattern` field.
## Screenshots
Below are the screenshots of *Recognition* cards. *Production* cards are not
much different.
![Sentence card](sentence_card.webp)<br/>
*A sentence card. Notice the `Source` field below the image.*
![Word card](word_card.webp)<br/>
*A word card.*
## Configuration
Most of the instructions for *Japanese sentences* template apply here as well,
with few changes.
### *Yomichan* settings
I prefer letting [AJT Pitch Accent][] add-on generate pitch accents instead of
*Yomichan*, as HTML produced by the former is much cleaner than that of the
latter. Therefore, *Yomichan*'s card format configuration becomes even
simpler:
| Field | Value |
| --------------- | ------------------------------------------------- |
| `SentKanji` | `{cloze-prefix}<b>{cloze-body}</b>{cloze-suffix}` |
| `VocabKanji` | `{expression}` |
| `VocabFurigana` | `{furigana-plain}` |
| `VocabDef` | `{glossary-brief}` |
### *mpvacious* settings
Make sure that your `subs2srs.conf` contains these lines:
miscinfo_enable=yes
miscinfo_field=Source
## Tips and tricks
* If you want to try this template out, you don't need to say goodbye to
contents of `MorphManFocus` and `VocabPitchNum` fields in your cards.
Import the template, then manually add these two fields back. After that,
you can convert your notes with no data loss. `antp.sh update` will work
safely as well.
* *Ankidrone Starter Pack* decks *N2* and *N1* contain item numbers in the
`Notes` field. When converting them, you may want to map `Notes` to
`Source`.
[AJT Pitch Accent]: https://ankiweb.net/shared/info/1225470483
[Ankidrone Starter Pack]: https://tatsumoto.neocities.org/blog/basic-vocabulary.html#anki-deck
[Japanese Mined Sentences]: ../Japanese%20Mined%20Sentences%20(cyphar)
[Japanese sentences]: ../Japanese%20sentences

View file

@ -0,0 +1,65 @@
<div class="wrap">
<div class="fside">{{FrontSide}}</div>
<div class="sent-center">
<div class="jpsentence" lang="ja">
{{edit:furigana:SentFurigana}}
{{^SentFurigana}}
{{edit:furigana:SentKanji}}
{{^SentKanji}}<b>
{{edit:furigana:VocabFurigana}}
{{^VocabFurigana}}
{{edit:furigana:VocabKanji}}
{{/VocabFurigana}}
</b>{{/SentKanji}}
{{/SentFurigana}}
</div>
{{#SentEng}}
<div class="ensentence" lang="en">{{hint:SentEng}}</div>
{{/SentEng}}
</div>
<div class="vocab">
{{VocabAudio}}{{SentAudio}}{{VocabPitchPattern}}
{{^VocabPitchPattern}}{{text:kana:VocabFurigana}}{{/VocabPitchPattern}}
{{#VocabKanji}}【{{text:kanji:VocabKanji}}】{{/VocabKanji}}
</div>
{{#VocabDef}}
<div class="definitions">{{edit:furigana:VocabDef}}</div>
{{/VocabDef}}
{{#Notes}}
<div class="notes">
<div class="tags">Notes</div>
<div>{{furigana:Notes}}</div>
</div>
{{/Notes}}
{{#Image}}
<div class="images">{{Image}}</div>
{{/Image}}
{{#Source}}
<div class="source">{{Source}}</div>
{{/Source}}
<hr />
<footer>
{{#SentKanji}}<a title="Translate with SimplyTranslate"
href="https://translate.metalune.xyz/?engine=google&text={{text:kanji:SentKanji}}&sl=ja&tl=en">Translate</a><a
href="https://jisho.org/search?keyword={{text:kanji:SentKanji}}" title="Sentence on Jisho">Jisho</a><a
href="https://www.google.co.jp/search?q={{text:kanji:SentKanji}}&tbm=isch"
title="Search images">Images</a>{{/SentKanji}}{{#VocabKanji}}<a
href="http://www.weblio.jp/content/{{text:VocabKanji}}" title="Vocab on Weblio">Weblio</a><a
href="https://wadoku.de/search/?q={{text:VocabKanji}}" title="Vocab on Wadoku">Wadoku</a>{{/VocabKanji}}
</footer>
</div> <!-- /wrap -->
<script>
function tweak_reveal_text() {
const elem = document.querySelector("div.ensentence > a.hint");
if (elem) {
elem.innerText = "Reveal English translation";
}
}
tweak_reveal_text();
</script>

View file

@ -0,0 +1,48 @@
<!--
mpvacious cards, version 13.0
Sat Nov 27 11:10:04 AM UTC 2021
-->
<div class="wrap">
<header>
{{#Tags}}
<div class="tags">{{Tags}}</div>
{{/Tags}}
</header>
<div class="sent-center">
<div class="jpsentence" lang="ja">
{{edit:furigana:SentKanji}}
{{^SentKanji}}
<nokana>{{edit:kanji:SentFurigana}}</nokana>
{{^SentFurigana}}<b>
{{edit:furigana:VocabKanji}}
{{^VocabKanji}}
<nokana>{{edit:kanji:VocabFurigana}}</nokana>
{{/VocabKanji}}
</b>{{/SentFurigana}}
{{/SentKanji}}
</div>
</div>
</div> <!-- /wrap -->
<script>
/* Splits tags into separate divs */
function splitTagDiv() {
const header = document.querySelector("header");
if (!header) return;
const split = `{{Tags}}`.split(" ");
header.innerHTML = "";
for (const tag of split) {
if (tag.length < 1) continue;
const tag_elem = document.createElement("div");
tag_elem.className = "tags";
tag_elem.innerHTML = tag;
header.appendChild(tag_elem);
}
}
splitTagDiv();
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

View file

@ -0,0 +1,395 @@
@charset "utf-8";
@font-face {
font-family: "KanjiStrokeOrders";
src: local("KanjiStrokeOrders"), url("_kso.ttf");
}
@font-face {
font-family: "Yu Mincho";
src: local("Yu Mincho"), local("游明朝"), url("_yumin.ttf");
}
@font-face {
font-family: "Yu Mincho";
src: local("Yu Mincho Demibold"), local("游明朝 Demibold"), url("_yumindb.ttf");
font-weight: 600;
}
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
.card {
background-color: #fffaf0;
color: #2a1b0a;
font-family: "Noto Serif", "Noto Serif CJK JP", Yu Mincho, "Liberation Serif", "Times New Roman", Times, Georgia,
Serif;
font-size: 24px;
text-align: left;
line-height: 1.4;
margin: 0 auto;
}
.card1 {
color: inherit;
}
.card2 .jpsentence ruby rt {
opacity: 0;
}
.card2 .jpsentence:hover ruby rt {
opacity: 1;
}
@media screen and (min-width: 820px) {
.card {
background-color: #e5d7c9;
display: flex;
justify-content: center;
}
.wrap {
width: 800px;
padding: 0 5px 0;
background-color: #fffaf0;
border-left: 1px solid #c9bcbc;
border-right: 1px solid #c9bcbc;
min-height: 100vh;
}
.wrap .wrap {
width: auto;
padding: 0;
min-height: 0;
border: 0;
}
}
hr {
margin: 2px 0;
clear: both;
border: 0;
border-top: 1px solid #c9bcbc;
}
b {
font-weight: 600;
}
/* links */
a {
color: #532f2f;
}
a:hover {
color: #722a2a;
}
a.hint {
text-decoration: none;
text-align: center;
display: block;
}
/* Hide furigana on front */
nokana ruby rt {
opacity: 0;
font-size: 0;
display: none;
}
notext b {
background-color: black;
color: transparent;
}
/* Top */
header {
display: flex;
clear: both;
}
header .tags {
border-radius: 0px 0px 3px 3px;
}
header > div:not(:last-child) {
margin-right: 3px;
}
/* Space between elements */
.images {
margin-top: 16px;
}
.images > img {
margin-bottom: 16px;
}
.sent-center {
display: flex;
align-items: center;
justify-content: center;
flex-flow: column nowrap;
}
/* Japanese sentence */
.jpsentence {
font-size: 35px;
}
.jpsentence b { color: Maroon; }
/* Hide front side when the back is shown. */
.fside .jpsentence {
display: none;
}
/* English */
div.ensentence > a.hint {
color: #555;
font-size: 14px;
display: block;
border: 1px solid #ccc;
border-radius: 2.2px;
padding: 2px 10px;
margin: 4px 0;
}
div.ensentence > a.hint:hover {
color: #111;
background-color: rgba(0, 0, 0, 0.03);
}
/* Tags */
.tags {
font-family: "Noto Sans", "Noto Sans CJK JP", "Liberation Sans", Arial, Sans, sans-serif;
text-align: center;
display: inline-block;
background-color: #333;
color: #fffaf0;
font-weight: bold;
padding: 1px 3px;
margin: 0;
cursor: pointer;
border-radius: 3px;
font-size: 12px;
line-height: 14px;
}
/* AnkiDroid replay button */
.replaybutton {
margin: 0;
margin-right: 3px;
text-decoration: none;
}
.replaybutton span {
padding: 0;
font-size: 16px;
}
.replaybutton span svg {
fill: #fffaf0;
background: #333;
border-radius: 3px;
vertical-align: top;
min-width: 16px;
min-height: 16px;
}
/* PC replay button */
a.replay-button {
top: -0.125em;
position: relative;
margin: 0;
}
a.replay-button svg {
height: 1em;
width: 1em;
}
a.replay-button svg path {
fill: #fffaf0;
}
a.replay-button svg circle {
fill: #333;
}
/* Footer and links */
footer {
font-size: 16px;
text-align: center;
}
footer > a {
text-decoration: none;
}
footer > a:after {
content: "·";
color: brown;
display: inline-block;
width: 6px;
}
footer > a:last-child:after {
content: "";
width: 0;
}
/* Source */
.source {
font-size: 16px;
text-align: center;
}
/* Vocab */
.vocab {
margin-top: 16px;
}
.vocab div {
display: inline-block;
}
.vocab br {
display: none;
}
.vocab > .tags {
vertical-align: top;
}
.notes > .tags {
vertical-align: bottom;
}
/* Images */
.images {
display: flex;
flex-wrap: wrap;
flex-direction: row;
align-items: flex-start;
align-content: space-between;
justify-content: space-evenly;
}
.images > img {
max-width: 47%;
border-radius: 4px;
filter: sepia(33%);
}
.images > img:only-child {
max-width: 100%;
}
/* Production cards */
.production b {
visibility: hidden;
}
.strokeorder {
text-align: center;
font-size: 150px;
font-family: KanjiStrokeOrders;
}
/* Fix for Yomichan defs */
ul,
ol {
list-style-type: none;
display: inline;
margin: 0px;
padding: 0px;
}
/* Fix for Yomichan pitch accents */
.vocab ol > li {
display: inline;
}
.vocab ol > li:after {
content: "・";
}
.vocab ol > li:last-child:after {
content: "";
}
/* Night Mode */
.nightMode.card {
color: #FFFFFF;
background-color: black;
}
.nightMode .wrap {
background-color: #2F2F31;
}
.nightMode .tags {
background-color: #FFFFFF;
color: #2F2F31;
}
.nightMode a.replay-button svg path {
fill: #2F2F31;
}
.nightMode a.replay-button svg circle {
fill: #FFFFFF;
}
.nightMode .replaybutton span svg {
fill: #2F2F31;
background: #FFFFFF;
}
.nightMode a {
color: #c7493a;
}
.nightMode a:hover {
color: #a33327;
}
.nightMode .jpsentence b {
color: NavajoWhite;
}
.nightMode .images > img {
filter: sepia(0%);
}
.nightMode div.ensentence > a.hint {
color: #FFFFFF;
border: 1px solid #FFFFFF;
}
.nightMode div.ensentence > a.hint:hover {
color: gray;
background-color: rgba(0, 0, 0, 0.20);
}
/* Don't select furigana */
.jpsentence ruby rt {
user-select: none;
}

View file

@ -0,0 +1,22 @@
{
"modelName": "Japanese sentences (nb)",
"inOrderFields": [
"SentKanji",
"SentFurigana",
"SentEng",
"SentAudio",
"VocabKanji",
"VocabFurigana",
"VocabPitchPattern",
"VocabDef",
"VocabAudio",
"Notes",
"Image",
"Source",
"MakeProductionCard"
],
"cardTemplates": [
"Recognition",
"Production"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB