templates: cyphar: add source field

Update the "Japanese Mined Sentences (cyphar)" template to include the
source field (which is now supported by mpvacious). Also rename the
model name to match the actual name I use in Anki (but keep the template
directory name the same).

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
Aleksa Sarai 2021-05-03 11:04:42 +10:00
parent 77b2e21f84
commit 9df5db9269
No known key found for this signature in database
GPG key ID: 9D94B96321B9D012
5 changed files with 23 additions and 2 deletions

View file

@ -25,6 +25,15 @@ template][original-template], with the following modifications made to the
I find that if both definitions are visible, my eyes immediately go to the
bilingual definition even if it wasn't necessary for me to do so.
* A new field is added `Source`, which is useful for storing information about
where you mined a sentence from (be it from mpvacious or Yomichan when
browsing some website). This can be quite handy if you find that you need to
adjust the sentence some time later (or add a different image on the back).
To use this with mpvacious, you need to be using a version which includes
[this pull-request I wrote][mpvacious-pr36], which adds support for
specifying a "miscellaneous information". Set `miscinfo_field=Source`.
I personally use these cards for sentence mining with Yomichan and Mpvacious.
| Front |
@ -36,6 +45,7 @@ I personally use these cards for sentence mining with Yomichan and Mpvacious.
| ![back](card_back_monolingual.webp) | ![back](card_back_multilingual.webp) |
[original-template]: ../Japanese%20sentences/
[mpvacious-pr36]: https://github.com/Ajatt-Tools/mpvacious/pull/36
## Included card types
@ -80,6 +90,16 @@ front), use `{sentence}` instead. Note that Yomichan can be a bit peculiar when
deciding how much of a conjugated verb counts as "part" of the verb, so double
check that you're happy with the automatic highlighting.
Note that Yomichan will happily include the URL (and screenshot) of the
standalone search window (such as when you're using the clipboard monitor with
mpvacious), which isn't very useful. The card type has some JavaScript which
will auto-hide URLs that have the `moz-extension://` protocol (as well as
images if there was only `moz-extension://` URL sources from Yomichan), but
you'll need to make sure you use the format described above -- it will only
work if it's wrapped in a `id="yomichan-source"` node. Alternatively, you can
create a conditional profile for `moz-extension://` pages in Yomichan so that
URLs aren't included when using the search window (this is what I do).
## Japanese Support settings
If you use the [Japanese Support add-on][anki-jpn], make sure to modify

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View file

@ -1,5 +1,5 @@
{
"modelName": "Japanese Mined Sentences (cyphar)",
"modelName": "Japanese Mined Sentences",
"inOrderFields": [
"SentKanji",
"SentFurigana",
@ -15,6 +15,7 @@
"VocabAudio",
"Image",
"Notes",
"Source",
"MakeProductionCard"
],
"css": "@font-face {font-family: \"KanjiStrokeOrders\"; src: url('_kso.ttf'); }\n@font-face {font-family: \"Yu Mincho\"; src: url(\"_yumin.ttf\"); }\n@font-face {font-family: \"Yu Mincho\"; src: url(\"_yumindb.ttf\"); font-weight: 600; }\n\n* { box-sizing: border-box; padding: 0; margin: 0; }\n.card {\n\tbackground-color: #FFFAF0;\n\tcolor: #2A1B0A;\n\tfont-family:\t\"Noto Serif\",\n\t\t\t\t\t\t\t\t\t\"Noto Serif CJK JP\",\n\t\t\t\t\t\t\t\t\tYu Mincho,\n\t\t\t\t\t\t\t\t\t\"Liberation Serif\",\n\t\t\t\t\t\t\t\t\t\"Times New Roman\",\n\t\t\t\t\t\t\t\t\tTimes,\n\t\t\t\t\t\t\t\t\tGeorgia,\n\t\t\t\t\t\t\t\t\tSerif;\n\tfont-size: 24px;\n\ttext-align: left;\n\tline-height: 1.4;\n}\n.card1 { }\n.card2 .jpsentence ruby rt { opacity: 0; }\n.card2 .jpsentence:hover ruby rt { opacity: 1; }\n\nhr { margin: 2px 0; clear: both; }\nb { font-weight: 600; }\n\n/* links */\na { color: #585858; }\na:hover { color: #222; }\na.hint { text-decoration: none; text-align: center; display: block; }\n\n/* Hide furigana on front */\nnokana ruby rt { opacity:0.0; font-size:0; display: none; }\nnotext b { background-color: black; color:transparent; }\n\n/* Top */\nheader { font-size: 14px; line-height: 14px; clear: both; }\n\n/* Space between elements */\n.images { margin-top: 16px; }\n.images > img { margin-bottom: 16px; }\n\n/* Japanese sentence */\n.jpsentence { font-size: 35px; }\n\n.tags {\n\tfont-family: \"Noto Sans\", \"Noto Sans CJK JP\", \"Liberation Sans\", Arial, Sans, sans-serif;\n\ttext-align: center;\n\tdisplay: inline-block;\n\ttext-transform: lowercase;\n\tbackground-color: #333;\n\tcolor: #FFFAF0;\n\tfont-weight: bold;\n\tpadding: 1px 3px;\n\tmargin: 0;\n\tcursor: pointer;\n\tborder-radius: 3px;\n\tfont-size: 12px;\n\tline-height: 14px;\n}\n\n/* AnkiDroid peplay button */\n.replaybutton { margin: 0; margin-right: 3px; text-decoration: none; }\n.replaybutton span { padding: 0; font-size: 16px; }\n.replaybutton span svg {\n\tfill: #FFFAF0;\n\tbackground: #333;\n\tborder-radius: 3px;\n\tvertical-align: top; \n\tmin-width: 16px;\n\tmin-height: 16px;\n}\n\n/* PC peplay button */\na.replay-button { top: -.125em; position: relative; }\na.replay-button svg {\n\theight: 1em;\n\twidth: 1em;\n}\na.replay-button svg path { fill: #FFFAF0; }\na.replay-button svg circle { fill: #333; }\n\nfooter { font-size: 16px; text-align: center; }\nfooter>a { text-decoration: none; }\n\n.vocab { margin-top: 16px; }\n.vocab div { display: inline-block; }\n.vocab br { display: none; }\n.vocab > .tags { vertical-align: top; }\n.notes > .tags { vertical-align: bottom; }\n\n.images {\n\tdisplay: flex;\n\tflex-wrap: wrap;\n\tflex-direction: row;\n\talign-items: flex-start;\n\talign-content: space-between;\n\tjustify-content: space-evenly;\n}\n.images > img {\n\tmax-width: 47%;\n\tborder-radius: 4px;\n\tfilter: sepia(33%);\n}\n.images>img:only-child {\n max-width: 100%;\n}\n\n/* Production cards */\n.production b { visibility: hidden; }\n.strokeorder {\n\ttext-align: center;\n\tfont-size: 150px;\n\tfont-family: KanjiStrokeOrders;\n}\n\n/* Morphman coloring */\n.fside .jpsentence:hover [mtype=unknown] { background-color: #ffff99; }\n.fside .jpsentence:hover [mtype=seen] { background-color: #ffd1b3; }\n.fside .jpsentence:hover [mtype=known] { background-color: #b3e6cc; }\n.fside .jpsentence:hover [mtype=mature] { background-color: transparent; }\n.fside .jpsentence:hover [priority=true] { }\n.fside .jpsentence:hover [frequency=true] { }\n\ndel.MorphManHide {display:none;}\n\n/* Fix for Yomichan defs */\nul, ol {\n list-style-type: none; \n display: inline;\n margin: 0px;\n padding: 0px;\n}\n/* Fix for Yomichan pitch accents */\n.vocab ol > li { display: inline; }\n.vocab ol > li:after { content: \"\u30fb\"; }\n.vocab ol > li:last-child:after { content: \"\"; }",
@ -22,7 +23,7 @@
{
"Name": "Recognition",
"Front": "<!--\nmpvacious cards, version 5.0\nWed Jan 6 11:41:21 PM UTC 2021\nModified by Aleksa Sarai <cyphar@cyphar.com>.\n-->\n\n<header>\n\t{{#MorphManFocus}}\n\t\t<div class=\"tags\">{{MorphManFocus}}</div>\n\t{{/MorphManFocus}}\n\t{{#Tags}}\n\t\t<div class=\"tags\">{{Tags}}</div>\n\t{{/Tags}}\n</header>\n\n<div class=\"jpsentence\" lang=\"ja\">\n\t{{morphHighlight:furigana:SentKanji}}\n\t{{^SentKanji}}\n\t\t<nokana>{{kanji:SentFurigana}}</nokana>\n\t{{/SentKanji}}\n</div>\n\n<div style=\"display:none;\">\n\t<div id=\"pitchnum_hidden\">{{VocabPitchNum}}</div>\n\t<div id=\"kanaword_hidden\">{{kana:VocabFurigana}}</div>\n</div>\n\n<script>\n\tfunction boxTargetWord() {\n\t\tfor (sentence of document.getElementsByClassName(\"jpsentence\")) {\n\t\t\tfor (word of sentence.getElementsByTagName(\"b\")) {\n\t\t\t\tword.style[\"border\"] = \"1px\";\n\t\t\t\tword.style[\"border-style\"] = \"dotted\";\n\t\t\t\tword.style[\"border-color\"] = \"#9a9a9a9a\";\n\t\t\t}\n\t\t}\n\t}\n\tdocument.addEventListener('DOMContentLoaded', boxTargetWord(), false);\n</script>",
"Back": "<div class=\"fside\">{{FrontSide}}</div>\n<hr id=\"answer\">\n<div class=\"jpsentence\" lang=\"ja\">\n\t{{edit:furigana:SentFurigana}}\n\t{{^SentFurigana}}{{furigana:SentKanji}}{{/SentFurigana}}\n</div>\n\n{{#SentEng}}\n\t<div lang=\"en\">\n\t\t{{hint:SentEng}}\n\t</div>\n{{/SentEng}}\n\n<div class=\"vocab\">\n{{VocabAudio}}{{SentAudio}}\n{{VocabPitchPattern}}{{^VocabPitchPattern}}{{kana:VocabFurigana}}{{/VocabPitchPattern}}\n{{#VocabPitchNum}}<span class=\"tags\" id=\"pitchnum\">{{VocabPitchNum}}</span>{{/VocabPitchNum}}{{#VocabKanji}}\u3010{{VocabKanji}}\u3011{{/VocabKanji}}\n</div>\n\n{{#VocabDefMonolingual}}\n<div class=\"definitions\">{{edit:furigana:VocabDefMonolingual}}</div>\n{{/VocabDefMonolingual}}\n\n{{#VocabDef}}\n{{#VocabDefMonolingual}}\n<div class=\"definitions\">{{edit:hint:furigana:VocabDef}}</div>\n{{/VocabDefMonolingual}}\n{{^VocabDefMonolingual}}\n<div class=\"definitions\">{{edit:furigana:VocabDef}}</div>\n{{/VocabDefMonolingual}}\n{{/VocabDef}}\n\n{{#Notes}}\t\n<div class=\"notes\">\n\t<div class=\"tags\">Notes</div>\n\t<div>{{furigana:Notes}}</div>\n</div>\n{{/Notes}}\n\n{{#Image}}<div class=\"images\" >{{Image}}</div>{{/Image}}\n\n<hr>\n<footer>\n\t{{#SentKanji}}\n\t\t<a href=\"https://jisho.org/search?keyword={{kanji:text:SentKanji}}\" title=\"Sentence on Jisho\">Jisho</a>\n\t\t<a href=\"https://www.google.co.jp/search?q={{kanji:text:SentKanji}}&tbm=isch\" title=\"Search images\">Images</a>\n\t{{/SentKanji}}\n\t{{#VocabKanji}}\n\t\t<a href=\"http://www.weblio.jp/content/{{text:VocabKanji}}\">Weblio</a>\n\t\t<a href=\"https://wadoku.de/search/?q={{text:VocabKanji}}\">Wadoku</a>\n\t{{/VocabKanji}}\n</footer>\n<script>\n/*\nPaints the question word according to its Pitch Accent number.\n\tblue for \u5e73\u677f\n\tred for \u982d\u9ad8\n\torange for \u4e2d\u9ad8\n\tgreen for \u5c3e\u9ad8\n*/\n\n\tfunction markPitch() {\n\t\tvar pitchNumber = document.getElementById(\"pitchnum_hidden\");\n\t\tif (pitchNumber === null) {\n\t\t\treturn;\n\t\t} else {\n\t\t\tpitchNumber = pitchNumber.innerHTML.match(/\\d/);\n\t\t}\n\t\tif (pitchNumber === null) {\n\t\t\treturn;\n\t\t} else {\n\t\t\tpitchNumber = Number(pitchNumber);\n\t\t}\n\n\t\t/* Then decide what color to use and change font color accordingly. */\n\t\tif ( pitchNumber == 0 ) {\n\t\t\t// use blue for \u5e73\u677f\n\t\t\tpaintTargetWord(\"#3366CC\");\n\t\t} else if ( pitchNumber == 1 ) {\n\t\t\t// use red for \u982d\u9ad8\n\t\t\tpaintTargetWord(\"red\");\n\t\t} else if ( pitchNumber > 1 ) {\n\t\t\tif ( odaka(pitchNumber) ) {\n\t\t\t\t// use green for \u5c3e\u9ad8\n\t\t\t\tpaintTargetWord(\"green\");\n\t\t\t} else {\n\t\t\t\t// use orange for \u4e2d\u9ad8\n\t\t\t\tpaintTargetWord(\"#ff6207\");\n\t\t\t}\n\t\t}\n\t}\n\t\n\tfunction paintTargetWord(color) {\n\t\tfor (sentence of document.getElementsByClassName(\"jpsentence\")) {\n\t\t\tfor (word of sentence.getElementsByTagName(\"b\")) {\n\t\t\t\tword.style.color = color;\n\t\t\t\t// clear border on back side of cards\n\t\t\t\tword.style[\"border\"] = \"0px\";\n\t\t\t\tword.style[\"border-style\"] = \"none\";\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction odaka(pitch_num) {\n\t\t// word is odaka if number of moras is equal to pitch accent position\n\t\tconst vocab_kana = document.getElementById(\"kanaword_hidden\");\n\t\tif (vocab_kana === null) {\n\t\t\treturn false;\n\t\t}\n\t\t// small \u3063 is one mora; \u3083\u3085\u3087 are parts of single mora\n\t\tconst n_moras = vocab_kana.innerHTML.replace(/[\u30e3\u30e5\u30e7\u3083\u3085\u3087]/g, '').length;\n\t\tif ( n_moras == pitch_num ) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tfunction removePitchBrackets() {\n\t\tconst tags = document.getElementById(\"pitchnum\");\n\t\tif (tags !== null) {\n\t\t\ttags.innerHTML = tags.innerHTML.replace(/(\\[(?=\\d)|(?<=\\d)\\])/g, \"\");\n\t\t}\n\t}\n\n\tdocument.addEventListener('DOMContentLoaded', markPitch(), false);\n\tdocument.addEventListener('DOMContentLoaded', removePitchBrackets(), false);\t\n</script>"
"Back": "<div class=\"fside\">{{FrontSide}}</div>\n<hr id=\"answer\">\n<div class=\"jpsentence\" lang=\"ja\">\n\t{{edit:furigana:SentFurigana}}\n\t{{^SentFurigana}}{{furigana:SentKanji}}{{/SentFurigana}}\n</div>\n\n{{#SentEng}}\n\t<div lang=\"en\">\n\t\t{{hint:SentEng}}\n\t</div>\n{{/SentEng}}\n\n<div class=\"vocab\">\n{{VocabAudio}}{{SentAudio}}\n{{VocabPitchPattern}}{{^VocabPitchPattern}}{{kana:VocabFurigana}}{{/VocabPitchPattern}}\n{{#VocabPitchNum}}<span class=\"tags\" id=\"pitchnum\">{{VocabPitchNum}}</span>{{/VocabPitchNum}}{{#VocabKanji}}\u3010{{VocabKanji}}\u3011{{/VocabKanji}}\n</div>\n\n{{#VocabDefMonolingual}}\n<div class=\"definitions\">{{edit:furigana:VocabDefMonolingual}}</div>\n{{/VocabDefMonolingual}}\n\n{{#VocabDef}}\n{{#VocabDefMonolingual}}\n<div class=\"definitions\">{{edit:hint:furigana:VocabDef}}</div>\n{{/VocabDefMonolingual}}\n{{^VocabDefMonolingual}}\n<div class=\"definitions\">{{edit:furigana:VocabDef}}</div>\n{{/VocabDefMonolingual}}\n{{/VocabDef}}\n\n{{#Notes}}\t\n<div class=\"notes\">\n\t<div class=\"tags\">Notes</div>\n\t<div>{{furigana:Notes}}</div>\n</div>\n{{/Notes}}\n\n{{#Image}}<div class=\"images\">{{Image}}</div>{{/Image}}\n\n\n<hr>\n<footer>\n\t{{#SentKanji}}\n\t\t<a href=\"https://jisho.org/search?keyword={{kanji:text:SentKanji}}\" title=\"Sentence on Jisho\">Jisho</a>\n\t\t<a href=\"https://www.google.co.jp/search?q={{kanji:text:SentKanji}}&tbm=isch\" title=\"Search images\">Images</a>\n\t{{/SentKanji}}\n\t{{#VocabKanji}}\n\t\t<a href=\"http://www.weblio.jp/content/{{text:VocabKanji}}\">Weblio</a>\n\t\t<a href=\"https://wadoku.de/search/?q={{text:VocabKanji}}\">Wadoku</a>\n\t{{/VocabKanji}}\n\t{{#Source}}\n\t<div>\n\t\t<div class=\"tags\">Source</div>\n\t\t<div id=\"source-ref\">{{Source}}</div>\n\t</div>\n\t{{/Source}}\n</footer>\n\n<script>\n/*\nPaints the question word according to its Pitch Accent number.\n\tblue for \u5e73\u677f\n\tred for \u982d\u9ad8\n\torange for \u4e2d\u9ad8\n\tgreen for \u5c3e\u9ad8\n*/\n\n\tfunction markPitch() {\n\t\tvar pitchNumber = document.getElementById(\"pitchnum_hidden\");\n\t\tif (pitchNumber === null) {\n\t\t\treturn;\n\t\t} else {\n\t\t\tpitchNumber = pitchNumber.innerHTML.match(/\\d/);\n\t\t}\n\t\tif (pitchNumber === null) {\n\t\t\treturn;\n\t\t} else {\n\t\t\tpitchNumber = Number(pitchNumber);\n\t\t}\n\n\t\t/* Then decide what color to use and change font color accordingly. */\n\t\tif ( pitchNumber == 0 ) {\n\t\t\t// use blue for \u5e73\u677f\n\t\t\tpaintTargetWord(\"#3366CC\");\n\t\t} else if ( pitchNumber == 1 ) {\n\t\t\t// use red for \u982d\u9ad8\n\t\t\tpaintTargetWord(\"red\");\n\t\t} else if ( pitchNumber > 1 ) {\n\t\t\tif ( odaka(pitchNumber) ) {\n\t\t\t\t// use green for \u5c3e\u9ad8\n\t\t\t\tpaintTargetWord(\"green\");\n\t\t\t} else {\n\t\t\t\t// use orange for \u4e2d\u9ad8\n\t\t\t\tpaintTargetWord(\"#ff6207\");\n\t\t\t}\n\t\t}\n\t}\n\t\n\tfunction paintTargetWord(color) {\n\t\tfor (sentence of document.getElementsByClassName(\"jpsentence\")) {\n\t\t\tfor (word of sentence.getElementsByTagName(\"b\")) {\n\t\t\t\tword.style.color = color;\n\t\t\t\t// clear border on back side of cards\n\t\t\t\tword.style[\"border\"] = \"0px\";\n\t\t\t\tword.style[\"border-style\"] = \"none\";\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction odaka(pitch_num) {\n\t\t// word is odaka if number of moras is equal to pitch accent position\n\t\tconst vocab_kana = document.getElementById(\"kanaword_hidden\");\n\t\tif (vocab_kana === null) {\n\t\t\treturn false;\n\t\t}\n\t\t// small \u3063 is one mora; \u3083\u3085\u3087 are parts of single mora\n\t\tconst n_moras = vocab_kana.innerHTML.replace(/[\u30e3\u30e5\u30e7\u3083\u3085\u3087]/g, '').length;\n\t\tif ( n_moras == pitch_num ) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tfunction removePitchBrackets() {\n\t\tconst tags = document.getElementById(\"pitchnum\");\n\t\tif (tags === null)\n\t\t\treturn;\n\t\ttags.innerHTML = tags.innerHTML.replace(/(\\[(?=\\d)|(?<=\\d)\\])/g, \"\");\n\t}\n\n\tfunction hideBadSource() {\n\t\tconst yomi_source = document.getElementById(\"yomichan-source\");\n\t\tif (yomi_source === null)\n\t\t\treturn;\n\t\tvar any_valid = false;\n\t\tfor (link of yomi_source.getElementsByTagName(\"a\")) {\n\t\t\ttry {\n\t\t\t\tlet url = new URL(link.href);\n\t\t\t\tif (url.protocol === \"moz-extension:\")\n\t\t\t\t\tlink.style[\"display\"] = \"none\";\n\t\t\t\telse\n\t\t\t\t\tany_valid = true;\n\t\t\t} catch {\n\t\t\t\t// ...\n\t\t\t}\n\t\t}\n\t\tif (!any_valid) {\n\t\t\tyomi_source.style[\"display\"] = \"none\";\n\t\t\tconst yomi_screenshot = document.getElementById(\"yomichan-screenshot\");\n\t\t\tif (yomi_screenshot !== null)\n\t\t\t\tyomi_screenshot.style[\"display\"] = \"none\";\n\t\t}\n\t}\n\n\tdocument.addEventListener('DOMContentLoaded', markPitch(), false);\n\tdocument.addEventListener('DOMContentLoaded', removePitchBrackets(), false);\t\n\tdocument.addEventListener('DOMContentLoaded', hideBadSource(), false);\n</script>"
},
{
"Name": "Production",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 20 KiB