summaryrefslogtreecommitdiff
path: root/sysret.org/themes/tabi-lean/templates/shortcodes/remote_text.html
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/remote_text.html
parentd8b9cf1f61cc07d625f1c37ccc28adfd58918416 (diff)
parent2c13119932765c6d788f08fb53abc244407c0d80 (diff)
Merge commit '6a7d3111b31e73fc66af5360149d41f690fbcaa4'
Diffstat (limited to 'sysret.org/themes/tabi-lean/templates/shortcodes/remote_text.html')
-rw-r--r--sysret.org/themes/tabi-lean/templates/shortcodes/remote_text.html30
1 files changed, 30 insertions, 0 deletions
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 -}}