summaryrefslogtreecommitdiff
path: root/sysret.org/themes/tabi-lean/templates/shortcodes
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2025-09-13 15:01:06 -0600
committerAlejandro Soto <alejandro@34project.org>2025-09-13 15:01:06 -0600
commitf4fcda54638685899c730b3fa90a87d80d6dbef5 (patch)
tree0737e627cce304c3a9c4e757bc5f6571a7456091 /sysret.org/themes/tabi-lean/templates/shortcodes
parentd8b9cf1f61cc07d625f1c37ccc28adfd58918416 (diff)
parent2c13119932765c6d788f08fb53abc244407c0d80 (diff)
Merge commit '6a7d3111b31e73fc66af5360149d41f690fbcaa4'
Diffstat (limited to 'sysret.org/themes/tabi-lean/templates/shortcodes')
-rw-r--r--sysret.org/themes/tabi-lean/templates/shortcodes/add_src_to_code_block.html1
-rw-r--r--sysret.org/themes/tabi-lean/templates/shortcodes/admonition.html12
-rw-r--r--sysret.org/themes/tabi-lean/templates/shortcodes/aside.html5
-rw-r--r--sysret.org/themes/tabi-lean/templates/shortcodes/dimmable_image.html31
-rw-r--r--sysret.org/themes/tabi-lean/templates/shortcodes/dual_theme_image.html45
-rw-r--r--sysret.org/themes/tabi-lean/templates/shortcodes/force_text_direction.html5
-rw-r--r--sysret.org/themes/tabi-lean/templates/shortcodes/full_width_image.html22
-rw-r--r--sysret.org/themes/tabi-lean/templates/shortcodes/iine.html5
-rw-r--r--sysret.org/themes/tabi-lean/templates/shortcodes/image_hover.html50
-rw-r--r--sysret.org/themes/tabi-lean/templates/shortcodes/image_toggler.html57
-rw-r--r--sysret.org/themes/tabi-lean/templates/shortcodes/invertible_image.html32
-rw-r--r--sysret.org/themes/tabi-lean/templates/shortcodes/mermaid.html8
-rw-r--r--sysret.org/themes/tabi-lean/templates/shortcodes/multilingual_quote.html37
-rw-r--r--sysret.org/themes/tabi-lean/templates/shortcodes/references.html3
-rw-r--r--sysret.org/themes/tabi-lean/templates/shortcodes/remote_text.html30
-rw-r--r--sysret.org/themes/tabi-lean/templates/shortcodes/spoiler.html13
-rw-r--r--sysret.org/themes/tabi-lean/templates/shortcodes/toc.html2
-rw-r--r--sysret.org/themes/tabi-lean/templates/shortcodes/wide_container.html3
18 files changed, 361 insertions, 0 deletions
diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/add_src_to_code_block.html b/sysret.org/themes/tabi-lean/templates/shortcodes/add_src_to_code_block.html
new file mode 100644
index 0000000..907e092
--- /dev/null
+++ b/sysret.org/themes/tabi-lean/templates/shortcodes/add_src_to_code_block.html
@@ -0,0 +1 @@
+<span class="code-source hidden" data-source="{{ src | safe }}"></span>
diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/admonition.html b/sysret.org/themes/tabi-lean/templates/shortcodes/admonition.html
new file mode 100644
index 0000000..3519527
--- /dev/null
+++ b/sysret.org/themes/tabi-lean/templates/shortcodes/admonition.html
@@ -0,0 +1,12 @@
+{%- set type = type | default(value="info") -%}
+{%- set title = title | default(value=type | upper) -%}
+{%- set icon = icon | default(value=type) -%}
+{%- set text = text | default(value=body) -%}
+
+<div class="admonition {{ type }}">
+ <div class="admonition-icon admonition-icon-{{ icon }}"></div>
+ <div class="admonition-content">
+ <strong class="admonition-title">{{ title | safe }}</strong>
+ {{ text | markdown | safe }}
+ </div>
+</div>
diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/aside.html b/sysret.org/themes/tabi-lean/templates/shortcodes/aside.html
new file mode 100644
index 0000000..ca337f9
--- /dev/null
+++ b/sysret.org/themes/tabi-lean/templates/shortcodes/aside.html
@@ -0,0 +1,5 @@
+{%- set text = text | default(value=body) -%}
+
+<aside {% if position %}data-position="{{ position }}"{% endif %}>
+ {{ text | markdown | safe }}
+</aside>
diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/dimmable_image.html b/sysret.org/themes/tabi-lean/templates/shortcodes/dimmable_image.html
new file mode 100644
index 0000000..a72720c
--- /dev/null
+++ b/sysret.org/themes/tabi-lean/templates/shortcodes/dimmable_image.html
@@ -0,0 +1,31 @@
+{#- Determine image path based on whether the src is remote or local -#}
+{%- if src is starting_with("http") or raw_path -%}
+ {%- set image_url = src -%}
+{%- else -%}
+ {%- set colocated_path = page.colocated_path | default(value="") -%}
+ {%- set relative_path = colocated_path ~ src -%}
+ {%- set meta = get_image_metadata(path=relative_path, allow_missing=true) -%}
+
+ {#- Fallback to absolute path if relative path doesn't work -#}
+ {%- if not meta -%}
+ {%- set meta = get_image_metadata(path=src, allow_missing=true) -%}
+ {%- set image_url = get_url(path=src, cachebust=true) -%}
+ {%- else -%}
+ {%- set image_url = get_url(path=relative_path, cachebust=true) -%}
+ {%- endif -%}
+{%- endif -%}
+
+{%- set lazy_loading = lazy_loading | default(value=true) -%}
+
+{%- set class_list = "dimmable-image" -%}
+{%- if inline -%}
+ {%- set class_list = class_list ~ " inline" -%}
+{%- endif -%}
+
+{%- if full_width -%}
+ <div class="full-width">
+{%- endif -%}
+<img class="{{ class_list }}" src="{{ image_url }}"{% if lazy_loading %} loading="lazy"{% endif %}{% if alt %} alt="{{ alt }}"{% endif %}{% if meta.width %} width="{{ meta.width }}"{% endif %}{% if meta.height %} height="{{ meta.height }}" {% endif %}/>
+{%- if full_width -%}
+ </div>
+{%- endif -%}
diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/dual_theme_image.html b/sysret.org/themes/tabi-lean/templates/shortcodes/dual_theme_image.html
new file mode 100644
index 0000000..5eadc09
--- /dev/null
+++ b/sysret.org/themes/tabi-lean/templates/shortcodes/dual_theme_image.html
@@ -0,0 +1,45 @@
+{%- set colocated_path = page.colocated_path | default(value="") -%}
+{%- set lazy_loading = lazy_loading | default(value=true) -%}
+{%- set inline = inline | default(value=false) -%}
+
+{%- set light_class_list = "img-light" -%}
+{%- set dark_class_list = "img-dark" -%}
+{%- if inline -%}
+ {%- set light_class_list = light_class_list ~ " inline" -%}
+ {%- set dark_class_list = dark_class_list ~ " inline" -%}
+{%- endif -%}
+
+{# Handling for light mode image #}
+{%- if light_src is starting_with("http") or raw_path -%}
+ {%- set light_image_url = light_src -%}
+{%- else -%}
+ {%- set relative_light_path = colocated_path ~ light_src -%}
+ {%- set light_meta = get_image_metadata(path=relative_light_path, allow_missing=true) -%}
+ {%- if not light_meta -%}
+ {%- set light_image_url = get_url(path=light_src, cachebust=true) -%}
+ {%- else -%}
+ {%- set light_image_url = get_url(path=relative_light_path, cachebust=true) -%}
+ {%- endif -%}
+{%- endif -%}
+
+{# Handling for dark mode image #}
+{%- if dark_src is starting_with("http") or raw_path -%}
+ {%- set dark_image_url = dark_src -%}
+{%- else -%}
+ {%- set relative_dark_path = colocated_path ~ dark_src -%}
+ {%- set dark_meta = get_image_metadata(path=relative_dark_path, allow_missing=true) -%}
+ {%- if not dark_meta -%}
+ {%- set dark_image_url = get_url(path=dark_src, cachebust=true) -%}
+ {%- else -%}
+ {%- set dark_image_url = get_url(path=relative_dark_path, cachebust=true) -%}
+ {%- endif -%}
+{%- endif -%}
+
+{%- if full_width -%}
+ <div class="full-width">
+{%- endif -%}
+<img class="{{ light_class_list }}" src="{{ light_image_url }}"{% if lazy_loading %} loading="lazy"{% endif %}{% if alt %} alt="{{ alt }}"{% endif %}{% if light_meta.width %} width="{{ light_meta.width }}"{% endif %}{% if light_meta.height %} height="{{ light_meta.height }}" {% endif %}>
+<img class="{{ dark_class_list }}" src="{{ dark_image_url }}"{% if lazy_loading %} loading="lazy"{% endif %}{% if alt %} alt="{{ alt }}"{% endif %}{% if dark_meta.width %} width="{{ dark_meta.width }}"{% endif %}{% if dark_meta.height %} height="{{ dark_meta.height }}" {% endif %}>
+{%- if full_width -%}
+ </div>
+{%- endif -%}
diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/force_text_direction.html b/sysret.org/themes/tabi-lean/templates/shortcodes/force_text_direction.html
new file mode 100644
index 0000000..79d9697
--- /dev/null
+++ b/sysret.org/themes/tabi-lean/templates/shortcodes/force_text_direction.html
@@ -0,0 +1,5 @@
+{%- set direction = direction | default(value="ltr") -%}
+
+<div data-force-text-direction="{{ direction }}">
+ {{ body | markdown | safe }}
+</div>
diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/full_width_image.html b/sysret.org/themes/tabi-lean/templates/shortcodes/full_width_image.html
new file mode 100644
index 0000000..a50bf10
--- /dev/null
+++ b/sysret.org/themes/tabi-lean/templates/shortcodes/full_width_image.html
@@ -0,0 +1,22 @@
+{#- Set paths based on whether the src is remote or local -#}
+{%- if src is starting_with("http") or raw_path -%}
+ {%- set image_url = src -%}
+{%- else -%}
+ {%- set colocated_path = page.colocated_path | default(value="") -%}
+ {%- set relative_path = colocated_path ~ src -%}
+ {%- set meta = get_image_metadata(path=relative_path, allow_missing=true) -%}
+
+ {#- Fallback to absolute path if relative path doesn't work -#}
+ {%- if not meta -%}
+ {%- set meta = get_image_metadata(path=src, allow_missing=true) -%}
+ {%- set image_url = get_url(path=src, cachebust=true) -%}
+ {%- else %}
+ {%- set image_url = get_url(path=relative_path, cachebust=true) -%}
+ {%- endif -%}
+{%- endif -%}
+
+{%- set lazy_loading = lazy_loading | default(value=true) -%}
+
+<div class="full-width">
+ <img src="{{ image_url }}"{% if alt %} alt="{{ alt }}"{% endif %}{% if meta.width %} width="{{ meta.width }}"{% endif %}{% if meta.height %} height="{{ meta.height }}"{% endif %}{% if lazy_loading %} loading="lazy"{% endif %}/>
+</div>
diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/iine.html b/sysret.org/themes/tabi-lean/templates/shortcodes/iine.html
new file mode 100644
index 0000000..d37211d
--- /dev/null
+++ b/sysret.org/themes/tabi-lean/templates/shortcodes/iine.html
@@ -0,0 +1,5 @@
+{% set button_icon = icon | default(value="heart") %}
+{% set label = label | default(value="Like this post") %}
+{% set slug = slug | default(value=page.path) %}
+
+{% include "partials/iine_button.html" %}
diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/image_hover.html b/sysret.org/themes/tabi-lean/templates/shortcodes/image_hover.html
new file mode 100644
index 0000000..443329b
--- /dev/null
+++ b/sysret.org/themes/tabi-lean/templates/shortcodes/image_hover.html
@@ -0,0 +1,50 @@
+{%- set colocated_path = page.colocated_path | default(value="") -%}
+{%- set lazy_loading = lazy_loading | default(value=true) -%}
+{%- set inline = inline | default(value=false) -%}
+
+{#- Determine the tag for container elements -#}
+{#- Necessary for inline images -#}
+{%- set tag = "div" -%}
+{%- if inline -%}
+ {%- set tag = "span" -%}
+{%- endif -%}
+
+{%- set img_class_list = "" -%}
+{%- if inline -%}
+ {%- set img_class_list = img_class_list ~ " inline" -%}
+{%- endif -%}
+
+{#- Direct or relative URL handling for default image -#}
+{%- if default_src is starting_with("http") or raw_path -%}
+ {%- set default_image_url = default_src -%}
+{%- else -%}
+ {%- set relative_default_path = colocated_path ~ default_src -%}
+ {%- set default_meta = get_image_metadata(path=relative_default_path, allow_missing=true) -%}
+ {%- if not default_meta -%}
+ {%- set default_image_url = get_url(path=default_src, cachebust=true) -%}
+ {%- else -%}
+ {%- set default_image_url = get_url(path=relative_default_path, cachebust=true) -%}
+ {%- endif -%}
+{%- endif -%}
+
+{#- Direct or relative URL handling for hovered image -#}
+{%- if hovered_src is starting_with("http") or raw_path -%}
+ {%- set hovered_image_url = hovered_src -%}
+{%- else -%}
+ {%- set relative_hovered_path = colocated_path ~ hovered_src -%}
+ {%- set hovered_meta = get_image_metadata(path=relative_hovered_path, allow_missing=true) -%}
+ {%- if not hovered_meta -%}
+ {%- set hovered_image_url = get_url(path=hovered_src, cachebust=true) -%}
+ {%- else -%}
+ {%- set hovered_image_url = get_url(path=relative_hovered_path, cachebust=true) -%}
+ {%- endif -%}
+{%- endif -%}
+
+<{{ tag }} class="image-hover-container{% if full_width %} full-width{% endif %}">
+ <{{ tag }} class="image-default">
+ <img class="{{ img_class_list }}" src="{{ default_image_url }}"{% if lazy_loading %} loading="lazy"{% endif %}{% if default_alt %} alt="{{ default_alt }}"{% endif %}{% if default_meta.width %} width="{{ default_meta.width }}"{% endif %}{% if default_meta.height %} height="{{ default_meta.height }}"{% endif %}>
+ </{{ tag }}>
+ <{{ tag }} class="image-hovered">
+ <img class="{{ img_class_list }}" src="{{ hovered_image_url }}"{% if lazy_loading %} loading="lazy"{% endif %}{% if hovered_alt %} alt="{{ hovered_alt }}"{% endif %}{% if hovered_meta.width %} width="{{ hovered_meta.width }}"{% endif %}{% if hovered_meta.height %} height="{{ hovered_meta.height }}"{% endif %}>
+ </{{ tag }}>
+</{{ tag }}>
diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/image_toggler.html b/sysret.org/themes/tabi-lean/templates/shortcodes/image_toggler.html
new file mode 100644
index 0000000..991d5f5
--- /dev/null
+++ b/sysret.org/themes/tabi-lean/templates/shortcodes/image_toggler.html
@@ -0,0 +1,57 @@
+{# The `random_id` ensures that each instance of the shortcode has a "unique" id #}
+{# allowing individual interactive elements (like toggles) to function correctly. #}
+{# This avoids conflicts when multiple instances of the shortcode are used. #}
+{%- set random_id = get_random(end=100000) -%}
+{%- set colocated_path = page.colocated_path | default(value="") -%}
+{%- set lazy_loading = lazy_loading | default(value=true) -%}
+{%- set inline = inline | default(value=false) -%}
+
+{#- Determine the class for the images -#}
+{#- Necessary for inline images -#}
+{%- set tag = "div" -%}
+{%- if inline -%}
+ {%- set tag = "span" -%}
+{%- endif -%}
+
+{%- set img_class_list = "" -%}
+{%- if inline -%}
+ {%- set img_class_list = img_class_list ~ " inline" -%}
+{%- endif -%}
+
+{# Direct or relative URL handling for default image #}
+{%- if default_src is starting_with("http") or raw_path -%}
+ {%- set default_image_url = default_src -%}
+{%- else -%}
+ {%- set relative_default_path = colocated_path ~ default_src -%}
+ {%- set default_meta = get_image_metadata(path=relative_default_path, allow_missing=true) -%}
+ {%- if not default_meta -%}
+ {%- set default_image_url = get_url(path=default_src, cachebust=true) -%}
+ {%- else -%}
+ {%- set default_image_url = get_url(path=relative_default_path, cachebust=true) -%}
+ {%- endif -%}
+{%- endif -%}
+
+{# Direct or relative URL handling for toggled image #}
+{%- if toggled_src is starting_with("http") or raw_path -%}
+ {%- set toggled_image_url = toggled_src -%}
+{%- else -%}
+ {%- set relative_toggled_path = colocated_path ~ toggled_src -%}
+ {%- set toggled_meta = get_image_metadata(path=relative_toggled_path, allow_missing=true) -%}
+ {%- if not toggled_meta -%}
+ {%- set toggled_image_url = get_url(path=toggled_src, cachebust=true) -%}
+ {%- else -%}
+ {%- set toggled_image_url = get_url(path=relative_toggled_path, cachebust=true) -%}
+ {%- endif -%}
+{%- endif -%}
+
+<{{ tag }} class="image-toggler-container {% if full_width %}full-width{% endif %}">
+ <input type="checkbox" id="toggle-img-{{ random_id }}" class="image-toggler-toggle">
+ <label for="toggle-img-{{ random_id }}" class="image-label">
+ <{{ tag }} class="image-default">
+ <img class="{{ img_class_list }}" src="{{ default_image_url }}"{% if lazy_loading %} loading="lazy"{% endif %}{% if default_alt %} alt="{{ default_alt }}"{% endif %}{% if default_meta.width %} width="{{ default_meta.width }}"{% endif %}{% if default_meta.height %} height="{{ default_meta.height }}"{% endif %}>
+ </{{ tag }}>
+ <{{ tag }} class="image-toggled">
+ <img class="{{ img_class_list }}" src="{{ toggled_image_url }}"{% if lazy_loading %} loading="lazy"{% endif %}{% if toggled_alt %} alt="{{ toggled_alt }}"{% endif %}{% if toggled_meta.width %} width="{{ toggled_meta.width }}"{% endif %}{% if toggled_meta.height %} height="{{ toggled_meta.height }}"{% endif %}>
+ </{{ tag }}>
+ </label>
+</{{ tag }}>
diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/invertible_image.html b/sysret.org/themes/tabi-lean/templates/shortcodes/invertible_image.html
new file mode 100644
index 0000000..0e3c920
--- /dev/null
+++ b/sysret.org/themes/tabi-lean/templates/shortcodes/invertible_image.html
@@ -0,0 +1,32 @@
+{#- Determine if src is a remote URL or a local path -#}
+{%- if src is starting_with("http") or raw_path -%}
+ {%- set image_url = src -%}
+{%- else -%}
+ {%- set colocated_path = page.colocated_path | default(value="") -%}
+ {%- set relative_path = colocated_path ~ src -%}
+ {%- set meta = get_image_metadata(path=relative_path, allow_missing=true) -%}
+
+ {#- Fallback to absolute path if relative path doesn't work -#}
+ {%- if not meta -%}
+ {%- set meta = get_image_metadata(path=src, allow_missing=true) -%}
+ {%- set image_url = get_url(path=src, cachebust=true) -%}
+ {%- else %}
+ {%- set image_url = get_url(path=relative_path, cachebust=true) -%}
+ {%- endif -%}
+{%- endif -%}
+
+{%- set lazy_loading = lazy_loading | default(value=true) -%}
+{%- set inline = inline | default(value=false) -%}
+
+{%- set class_list = "invertible-image" -%}
+{%- if inline -%}
+ {%- set class_list = class_list ~ " inline" -%}
+{%- endif -%}
+
+{%- if full_width -%}
+ <div class="full-width">
+{%- endif -%}
+<img class="{{ class_list }}" src="{{ image_url }}"{% if lazy_loading %} loading="lazy"{% endif %}{% if alt %} alt="{{ alt }}"{% endif %}{% if meta.width %} width="{{ meta.width }}"{% endif %}{% if meta.height %} height="{{ meta.height }}" {% endif %}/>
+{%- if full_width -%}
+ </div>
+{%- endif -%}
diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/mermaid.html b/sysret.org/themes/tabi-lean/templates/shortcodes/mermaid.html
new file mode 100644
index 0000000..88bbdc4
--- /dev/null
+++ b/sysret.org/themes/tabi-lean/templates/shortcodes/mermaid.html
@@ -0,0 +1,8 @@
+{% set invertible = invertible | default(value=true) %}
+{% set full_width = full_width | default(value=false) %}
+<noscript>
+ <strong>⚠️ JavaScript is required to render the diagram.</strong>
+</noscript>
+<pre class="mermaid{% if invertible %} invertible-image{% endif %}{% if full_width %} full-width{% endif %}">
+ {{ body | safe }}
+</pre>
diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/multilingual_quote.html b/sysret.org/themes/tabi-lean/templates/shortcodes/multilingual_quote.html
new file mode 100644
index 0000000..7ea9849
--- /dev/null
+++ b/sysret.org/themes/tabi-lean/templates/shortcodes/multilingual_quote.html
@@ -0,0 +1,37 @@
+{%- import "macros/translate.html" as macros_translate -%}
+{# Load internationalisation data #}
+{%- set language_strings = load_data(path="i18n/" ~ lang ~ '.toml', required=false) -%}
+{%- if not language_strings -%}
+ {%- set language_strings = load_data(path="themes/tabi/i18n/" ~ lang ~ ".toml", required=false) -%}
+{%- endif -%}
+
+{%- set open_quote = macros_translate::translate(key="open_quotation_mark", default="“", language_strings=language_strings) -%}
+{%- set close_quote = macros_translate::translate(key="close_quotation_mark", default="”", language_strings=language_strings) -%}
+
+{#- The `random_id` ensures that each instance of the shortcode has a "unique" id -#}
+{#- allowing individual interactive elements (like toggles) to function correctly. -#}
+{#- This avoids conflicts when multiple instances of the shortcode are used. -#}
+{#- More context: https://github.com/welpo/tabi/issues/82 -#}
+{%- set random_id = get_random(end=100000) -%}
+
+<div class="quote-container">
+ <input type="checkbox" id="toggle-{{ random_id }}" class="quote-toggle">
+ <div class="quote">
+ <div class="translated">
+ <blockquote>
+ <p>{{ open_quote ~ translated ~ close_quote }}</p>
+ <p>{% if author %}— {{ author | safe }}{% endif %} <label for="toggle-{{ random_id }}" class="quote-label quote-label-original">
+ ({{- macros_translate::translate(key="show_original_quote", default="Show original quote", language_strings=language_strings) -}})
+ </label></p>
+ </blockquote>
+ </div>
+ <div class="original">
+ <blockquote>
+ <p>{{ open_quote ~ original ~ close_quote }}</p>
+ <p>{% if author %}— {{ author | safe }}{% endif %} <label for="toggle-{{ random_id }}" class="quote-label quote-label-translate">
+ ({{- macros_translate::translate(key="show_translation", default="Show translation", language_strings=language_strings) -}})
+ </label></p>
+ </blockquote>
+ </div>
+ </div>
+</div>
diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/references.html b/sysret.org/themes/tabi-lean/templates/shortcodes/references.html
new file mode 100644
index 0000000..1894479
--- /dev/null
+++ b/sysret.org/themes/tabi-lean/templates/shortcodes/references.html
@@ -0,0 +1,3 @@
+<div class="references">
+ {{ body | markdown | safe }}
+</div>
diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/remote_text.html b/sysret.org/themes/tabi-lean/templates/shortcodes/remote_text.html
new file mode 100644
index 0000000..70fd33a
--- /dev/null
+++ b/sysret.org/themes/tabi-lean/templates/shortcodes/remote_text.html
@@ -0,0 +1,30 @@
+{%- set start = start | default(value=1) -%}
+{%- set end = end | default(value=0) -%}
+
+{#- load_data uses different arguments based on whether it's a remote or local file -#}
+{%- if src is starting_with("http") -%}
+ {%- set response = load_data(url=src, format="plain") -%}
+{%- else -%}
+ {#- Try to load the file from a relative path -#}
+ {%- set colocated_path = page.colocated_path | default(value="") -%}
+ {%- set relative_path = colocated_path ~ src -%}
+ {%- set response = load_data(path=relative_path, format="plain", required=false) -%}
+ {#- If relative path fails, try absolute path -#}
+ {%- if not response -%}
+ {%- set response = load_data(path=src, format="plain") -%}
+ {%- endif -%}
+{%- endif -%}
+
+{%- set lines = response | trim_end | split(pat="\n") -%}
+
+{%- if start > 0 -%}
+ {%- set start = start - 1 -%}
+{%- endif -%}
+
+{%- if end == 0 or end > lines | length -%}
+ {%- set end = lines | length -%}
+{%- endif -%}
+
+{%- set lines = lines | slice(start=start, end=end) -%}
+
+{{- lines | join(sep="\n") | safe -}}
diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/spoiler.html b/sysret.org/themes/tabi-lean/templates/shortcodes/spoiler.html
new file mode 100644
index 0000000..ff9e695
--- /dev/null
+++ b/sysret.org/themes/tabi-lean/templates/shortcodes/spoiler.html
@@ -0,0 +1,13 @@
+{# The `random_id` ensures that each instance of the shortcode has a "unique" id #}
+{# allowing individual interactive elements (like toggles) to function correctly. #}
+{# This avoids conflicts when multiple instances of the shortcode are used. #}
+{# More context: https://github.com/welpo/tabi/issues/82 #}
+{%- set random_id = get_random(end=100000) -%}
+{%- set fixed_blur = fixed_blur | default(value=false) -%}
+
+<label class="spoiler-container{% if fixed_blur %} fixed-blur{% endif %}">
+ <input type="checkbox" id="spoiler-{{random_id}}" class="spoiler-toggle" role="button" aria-pressed="false" />
+ <span class="spoiler-content" title="reveal spoiler" tabindex="0">
+ <span class="spoiler-hidden">{{ text | markdown | trim_start_matches(pat="<p>") | trim_start_matches(pat="</p>") | safe }}</span>
+ </span>
+</label>
diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/toc.html b/sysret.org/themes/tabi-lean/templates/shortcodes/toc.html
new file mode 100644
index 0000000..8756586
--- /dev/null
+++ b/sysret.org/themes/tabi-lean/templates/shortcodes/toc.html
@@ -0,0 +1,2 @@
+{# Inserts special string to add the Table of Contents anywhere on a post #}
+<!-- toc -->
diff --git a/sysret.org/themes/tabi-lean/templates/shortcodes/wide_container.html b/sysret.org/themes/tabi-lean/templates/shortcodes/wide_container.html
new file mode 100644
index 0000000..6268e63
--- /dev/null
+++ b/sysret.org/themes/tabi-lean/templates/shortcodes/wide_container.html
@@ -0,0 +1,3 @@
+<div class="full-width">
+ {{ body | markdown | safe }}
+</div>