obsidian-templates/zotero.md

136 lines
4.2 KiB
Markdown
Raw Permalink Normal View History

2023-04-28 11:28:14 +00:00
---
tags: {% if itemType == "book" %}
2023-11-13 09:16:38 +00:00
- book{% else %}
- paper{% endif %}
title: "{% if creators -%}{{creators[0].lastName}}
{%- if creators|length == 2 %} & {{creators[1].lastName}}{% endif -%}
{%- if creators|length > 2 %} et al.{% endif -%}
2023-11-13 09:16:38 +00:00
{%- endif -%}
{%- if date %} ({{date | format("YYYY")}}){% endif -%}
{%- if shortTitle %} {{shortTitle | nl2br}} {%- else %} {{title | nl2br}}
{%- endif -%}"
projekte: {% for tag in tags %}{% if "📓" in tag.tag %}
- "[[{{tag.tag | replace("📓 ", "")}}]]"{% endif %}{% endfor %}
created: {{importDate|format("YYYY-MM-DD")}}
modified: {{importDate|format("YYYY-MM-DD")}}
2023-04-28 11:28:14 +00:00
---
{#- METADATA AND PERMANENT INDEX -#}
{#- This part only gets inserted once -#}
{#- You can use this space to take permanent notes, e.g. to create an index or write a summary, or link to other notes #}
{% persist "notes" %}{% if isFirstImport %}
2023-04-28 11:28:14 +00:00
# {{title}}
## 📇 Index
-
2023-11-13 09:16:38 +00:00
> [!info]+ Metadata {% for attachment in attachments | filterby("path", "endswith", ".pdf") %}[PDF{% if not loop.first %} {{loop.index}}{% endif %}]({{attachment.desktopURI|replace("/select/", "/open-pdf/")}}){% if not loop.last %}, {% endif %}{% endfor %}
2023-04-28 11:28:14 +00:00
> {{bibliography}}
>
2023-11-13 09:16:38 +00:00
> - Keywords:
> - Zotero: [Eintrag öffnen]({{select}}){% if relations %}
> - Related: {% for relation in relations %}{% if relation.citekey %}[[@{{relation.citekey}}]]{% if not loop.last %}, {% endif %}{% endif %}{% endfor %}{% endif %}
> [!example]- Abstract
> *{{abstractNote | nl2br}}*
> [!important]- Summary
>
> {% endif %}{% endpersist %}
2023-04-28 11:28:14 +00:00
2023-11-13 09:16:38 +00:00
{#- WARNING: Everything below this line will get overwritten on re-import! -#}
{#- COLOR VARIABLES -#}
2023-04-28 11:28:14 +00:00
{%-
set zoteroColors = {
"#2ea8e5": "blue",
"#5fb236": "green",
"#a28ae5": "purple",
"#ffd400": "yellow",
"#ff6666": "red",
"#f19837": "orange",
"#e56eee": "magenta",
"#aaaaaa": "grey"
}
-%}
{%-
set colorHeading = {
"blue": "⭐ Main",
"green": "✅ Definition",
"purple": "🧩 Methodology",
"yellow": "📚 Further Reading",
"red": "⭕ Questions",
2023-11-13 09:16:38 +00:00
"magenta": "📎 Info",
2023-04-28 11:28:14 +00:00
"other": "Misc"
}
-%}
{#- ANNOTATION TYPES -#}
2023-04-28 11:28:14 +00:00
{%- macro calloutHeader(type) -%}
{%- switch type -%}
{%- case "highlight" -%}
Highlight
{%- case "image" -%}
Image
{%- default -%}
Note
{%- endswitch -%}
{%- endmacro %}
{#- SET CUSTOM ANNOTATION COLORS -#}
2023-04-28 11:28:14 +00:00
{%- set newAnnot = [] -%}
{%- set newAnnotations = [] -%}
{%- set annotations = annotations | filterby("date", "dateafter", lastImportDate) %}
2023-11-13 09:16:38 +00:00
{% if annotations.length > 0 %}*Imported: {{importDate | format("YYYY-MM-DD HH:mm")}}*
2023-04-28 11:28:14 +00:00
{%- for annot in annotations -%}
{%- if annot.color in zoteroColors -%}
{%- set customColor = zoteroColors[annot.color] -%}
{%- elif annot.colorCategory|lower in colorHeading -%}
{%- set customColor = annot.colorCategory|lower -%}
{%- else -%}
{%- set customColor = "other" -%}
{%- endif -%}
{%- set newAnnotations = (newAnnotations.push({"annotation": annot, "customColor": customColor}), newAnnotations) -%}
{%- endfor -%}
{#- INSERT ANNOTATIONS -#}
{#- Loops through each of the available colors and only inserts matching annotations -#}
{#- This is a workaround for inserting categories in a predefined order (instead of using groupby & the order in which they appear in the PDF) -#}
{%- for color, heading in colorHeading -%}
{%- for entry in newAnnotations | filterby ("customColor", "startswith", color) -%}
{%- set annot = entry.annotation -%}
{%- if entry and loop.first %}
### {{colorHeading[color]}}
{%- endif %}
> [!quote{{"|" + color if color != "other"}}]+ {{calloutHeader(annot.type)}} ([p. {{annot.pageLabel}}](zotero://open-pdf/library/items/{{annot.attachment.itemKey}}?page={{annot.pageLabel}}&annotation={{annot.id}}))
{%- if annot.annotatedText %}
> {% if annot.hashTags %}[[{{annot.hashTags|replace("#", "")}}]]: {% endif -%}
{{annot.annotatedText|nl2br}}
{%- endif %}
{%- if annot.imageRelativePath %}
> ![[{{annot.imageRelativePath}}]]
{%- endif %}
{%- if annot.ocrText %}
> {{annot.ocrText}}
{%- endif %}
{%- if annot.comment %}
> → **{{annot.comment|nl2br}}**
2023-04-28 11:28:14 +00:00
{%- endif -%}
{%- endfor -%}
{%- endfor -%}
{% endif -%}