summaryrefslogtreecommitdiff
path: root/ext/data/templates
diff options
context:
space:
mode:
authorStefanVukovic99 <stefanvukovic44@gmail.com>2024-06-20 19:27:02 +0200
committerGitHub <noreply@github.com>2024-06-20 17:27:02 +0000
commitd2c930a94d6e445053bcb5e5bb629851165425fc (patch)
tree94ff7034e7d3ab36ed663f353aeb5486bd294d1c /ext/data/templates
parent1a866b3997310a04fc146b91eb47a59a3f049589 (diff)
support css file in dictionaries (#1080)
* get styles in db * get styles in settings * use styles * fix test * scope * fix comma separated * escape dict name in css selector * g regex * get styles in anki * fix tests * more specificity * whitespace * test importing * test handlebars * add styles to glossary-first
Diffstat (limited to 'ext/data/templates')
-rw-r--r--ext/data/templates/anki-field-templates-upgrade-v41.handlebars129
-rw-r--r--ext/data/templates/default-anki-field-templates.handlebars32
2 files changed, 156 insertions, 5 deletions
diff --git a/ext/data/templates/anki-field-templates-upgrade-v41.handlebars b/ext/data/templates/anki-field-templates-upgrade-v41.handlebars
new file mode 100644
index 00000000..4da7d1bb
--- /dev/null
+++ b/ext/data/templates/anki-field-templates-upgrade-v41.handlebars
@@ -0,0 +1,129 @@
+{{<<<<<<<}}
+{{~#*inline "glossary"~}}
+ <div style="text-align: left;">
+ {{~#scope~}}
+ {{~#if (op "===" definition.type "term")~}}
+ {{~#unless (op "&&" selectedDictionary (op "!=" selectedDictionary definition.dictionary))~}}
+ {{~> glossary-single definition brief=brief noDictionaryTag=noDictionaryTag ~}}
+ {{~/unless~}}
+ {{~else if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}}
+ {{~#if (op ">" definition.definitions.length 1)~}}
+ <ol>
+ {{~#each definition.definitions~}}
+ {{~#unless (op "&&" ../selectedDictionary (op "!=" ../selectedDictionary dictionary))~}}
+ <li>
+ {{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
+ </li>
+ {{~/unless~}}
+ {{~/each~}}
+ </ol>
+ {{~else~}}
+ {{~#each definition.definitions~}}
+ {{~#unless (op "&&" ../selectedDictionary (op "!=" ../selectedDictionary dictionary))~}}
+ {{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
+ {{~/unless~}}
+ {{~/each~}}
+ {{~/if~}}
+ {{~else if (op "===" definition.type "kanji")~}}
+ {{~#if (op ">" definition.glossary.length 1)~}}
+ <ol>{{#each definition.glossary}}<li>{{.}}</li>{{/each}}</ol>
+ {{~else~}}
+ {{~#each definition.glossary~}}{{.}}{{~/each~}}
+ {{~/if~}}
+ {{~/if~}}
+ {{~/scope~}}
+ </div>
+{{~/inline~}}
+{{=======}}
+{{~#*inline "glossary"~}}
+ <div style="text-align: left;" class="yomitan-glossary">
+ {{~#scope~}}
+ {{~#if (op "===" definition.type "term")~}}
+ {{~#unless (op "&&" selectedDictionary (op "!=" selectedDictionary definition.dictionary))~}}
+ {{~> glossary-single definition brief=brief noDictionaryTag=noDictionaryTag ~}}
+ {{~#if definition.glossaryScopedStyles~}}
+ <style>{{{definition.glossaryScopedStyles}}}</style>
+ {{~/if~}}
+ {{~/unless~}}
+ {{~else if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}}
+ {{~#if (op ">" definition.definitions.length 1)~}}
+ <ol>
+ {{~#each definition.definitions~}}
+ {{~#unless (op "&&" ../selectedDictionary (op "!=" ../selectedDictionary dictionary))~}}
+ <li data-dictionary="{{dictionary}}">
+ {{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
+ </li>
+ {{~#if dictScopedStyles~}}
+ <style>{{{dictScopedStyles}}}</style>
+ {{~/if~}}
+ {{~/unless~}}
+ {{~/each~}}
+ </ol>
+ {{~else~}}
+ {{~#each definition.definitions~}}
+ {{~#unless (op "&&" ../selectedDictionary (op "!=" ../selectedDictionary dictionary))~}}
+ {{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
+ {{~#if glossaryScopedStyles~}}
+ <style>{{{glossaryScopedStyles}}}</style>
+ {{~/if~}}
+ {{~/unless~}}
+ {{~/each~}}
+ {{~/if~}}
+ {{~else if (op "===" definition.type "kanji")~}}
+ {{~#if (op ">" definition.glossary.length 1)~}}
+ <ol>{{#each definition.glossary}}<li>{{.}}</li>{{/each}}</ol>
+ {{~else~}}
+ {{~#each definition.glossary~}}{{.}}{{~/each~}}
+ {{~/if~}}
+ {{~/if~}}
+ {{~/scope~}}
+ </div>
+{{~/inline~}}
+{{>>>>>>>}}
+
+{{<<<<<<<}}
+{{~#*inline "glossary-first"~}}
+ <div style="text-align: left;">
+ {{~#scope~}}
+ {{~#if (op "===" definition.type "term")~}}
+ {{~> glossary-single definition brief=brief noDictionaryTag=noDictionaryTag ~}}
+ {{~else if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}}
+ {{~#if (op ">" definition.definitions.length 1)~}}
+ {{~#with definition.definitions.[0]~}}{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}{{~/with~}}
+ {{~else~}}
+ {{~#with definition.definitions.[0]~}}{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}{{~/with~}}
+ {{~/if~}}
+ {{~/if~}}
+ {{~/scope~}}
+ </div>
+{{~/inline~}}
+{{=======}}
+{{~#*inline "glossary-first"~}}
+ <div style="text-align: left;" class="yomitan-glossary">
+ {{~#scope~}}
+ {{~#if (op "===" definition.type "term")~}}
+ {{~> glossary-single definition brief=brief noDictionaryTag=noDictionaryTag ~}}
+ {{~#if definition.glossaryScopedStyles~}}
+ <style>{{{definition.glossaryScopedStyles}}}</style>
+ {{~/if~}}
+ {{~else if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}}
+ {{~#if (op ">" definition.definitions.length 1)~}}
+ {{~#with definition.definitions.[0]~}}
+ {{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
+ {{~#if glossaryScopedStyles~}}
+ <style>{{{glossaryScopedStyles}}}</style>
+ {{~/if~}}
+ {{~/with~}}
+ {{~else~}}
+ {{~#with definition.definitions.[0]~}}
+ {{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
+ {{~#if glossaryScopedStyles~}}
+ <style>{{{glossaryScopedStyles}}}</style>
+ {{~/if~}}
+ {{~/with~}}
+ {{~/if~}}
+ {{~/if~}}
+ {{~/scope~}}
+ </div>
+{{~/inline~}}
+{{>>>>>>>}} \ No newline at end of file
diff --git a/ext/data/templates/default-anki-field-templates.handlebars b/ext/data/templates/default-anki-field-templates.handlebars
index 44741866..2ac12934 100644
--- a/ext/data/templates/default-anki-field-templates.handlebars
+++ b/ext/data/templates/default-anki-field-templates.handlebars
@@ -98,20 +98,26 @@
{{/inline}}
{{~#*inline "glossary"~}}
- <div style="text-align: left;">
+ <div style="text-align: left;" class="yomitan-glossary">
{{~#scope~}}
{{~#if (op "===" definition.type "term")~}}
{{~#unless (op "&&" selectedDictionary (op "!=" selectedDictionary definition.dictionary))~}}
{{~> glossary-single definition brief=brief noDictionaryTag=noDictionaryTag ~}}
+ {{~#if definition.glossaryScopedStyles~}}
+ <style>{{{definition.glossaryScopedStyles}}}</style>
+ {{~/if~}}
{{~/unless~}}
{{~else if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}}
{{~#if (op ">" definition.definitions.length 1)~}}
<ol>
{{~#each definition.definitions~}}
{{~#unless (op "&&" ../selectedDictionary (op "!=" ../selectedDictionary dictionary))~}}
- <li>
+ <li data-dictionary="{{dictionary}}">
{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
</li>
+ {{~#if dictScopedStyles~}}
+ <style>{{{dictScopedStyles}}}</style>
+ {{~/if~}}
{{~/unless~}}
{{~/each~}}
</ol>
@@ -119,6 +125,9 @@
{{~#each definition.definitions~}}
{{~#unless (op "&&" ../selectedDictionary (op "!=" ../selectedDictionary dictionary))~}}
{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
+ {{~#if glossaryScopedStyles~}}
+ <style>{{{glossaryScopedStyles}}}</style>
+ {{~/if~}}
{{~/unless~}}
{{~/each~}}
{{~/if~}}
@@ -142,15 +151,28 @@
{{/inline}}
{{~#*inline "glossary-first"~}}
- <div style="text-align: left;">
+ <div style="text-align: left;" class="yomitan-glossary">
{{~#scope~}}
{{~#if (op "===" definition.type "term")~}}
{{~> glossary-single definition brief=brief noDictionaryTag=noDictionaryTag ~}}
+ {{~#if definition.glossaryScopedStyles~}}
+ <style>{{{definition.glossaryScopedStyles}}}</style>
+ {{~/if~}}
{{~else if (op "||" (op "===" definition.type "termGrouped") (op "===" definition.type "termMerged"))~}}
{{~#if (op ">" definition.definitions.length 1)~}}
- {{~#with definition.definitions.[0]~}}{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}{{~/with~}}
+ {{~#with definition.definitions.[0]~}}
+ {{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
+ {{~#if glossaryScopedStyles~}}
+ <style>{{{glossaryScopedStyles}}}</style>
+ {{~/if~}}
+ {{~/with~}}
{{~else~}}
- {{~#with definition.definitions.[0]~}}{{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}{{~/with~}}
+ {{~#with definition.definitions.[0]~}}
+ {{~> glossary-single . brief=../brief noDictionaryTag=../noDictionaryTag ~}}
+ {{~#if glossaryScopedStyles~}}
+ <style>{{{glossaryScopedStyles}}}</style>
+ {{~/if~}}
+ {{~/with~}}
{{~/if~}}
{{~/if~}}
{{~/scope~}}