diff options
| author | Jieiku | 2023-09-20 00:25:21 -0700 |
|---|---|---|
| committer | Jieiku | 2023-09-20 00:25:21 -0700 |
| commit | 08f406c44c861a914c8b63fab454250f8a4c4b36 (patch) | |
| tree | a636aa28e60b6b110138b378996ee2523c1e7bf0 /templates/shortcodes | |
| parent | b1be7cc6de3737ebbb1ae1485652e32a2888dbfc (diff) | |
| download | abridge-08f406c44c861a914c8b63fab454250f8a4c4b36.tar.gz abridge-08f406c44c861a914c8b63fab454250f8a4c4b36.tar.bz2 abridge-08f406c44c861a914c8b63fab454250f8a4c4b36.zip | |
refactor nav, blocks, macros, templates. fix image shortcodes
Diffstat (limited to 'templates/shortcodes')
| -rw-r--r-- | templates/shortcodes/img.html | 9 | ||||
| -rw-r--r-- | templates/shortcodes/imgswap.html | 17 | ||||
| -rw-r--r-- | templates/shortcodes/showdata.html | 10 |
3 files changed, 24 insertions, 12 deletions
diff --git a/templates/shortcodes/img.html b/templates/shortcodes/img.html index f5754ce..ac3ba6b 100644 --- a/templates/shortcodes/img.html +++ b/templates/shortcodes/img.html @@ -1,15 +1,16 @@ {%- set img = src | split(pat="/") | last %} {%- set dirtest = src | trim_start_matches(pat="./") %} {%- if dirtest is containing("/") %} {%- set reldir = true %} {%- endif %} +{%- if page.path %}{%- set pagepath = page.path %}{%- elif section.path %}{%- set pagepath = section.path %}{%- endif %} {%- if src is starting_with("./") and reldir %} {# Relative Path #} {%- set path = src | trim_start_matches(pat="./") | split(pat="/") | slice(end=-1) | join(sep="/") | trim_start_matches(pat="/") %} {%- set path = path ~ "/" %} {%- if not w or not h %} {%- if lang != config.default_language %} - {%- set metapath = page.path ~ path ~ img | replace(from=page.path | truncate(length=4, end=""), to="/") %} + {%- set metapath = pagepath ~ path ~ img | replace(from=pagepath | truncate(length=4, end=""), to="/") %} {%- else %} - {%- set metapath = page.path ~ path ~ img %} + {%- set metapath = pagepath ~ path ~ img %} {%- endif %} {%- set meta = get_image_metadata(path=metapath) %} {%- set w = meta.width %} @@ -30,9 +31,9 @@ {%- set path = "" %} {%- if not w or not h %} {%- if lang != config.default_language %} - {%- set metapath = page.path ~ img | replace(from=page.path | truncate(length=4, end=""), to="/") %} + {%- set metapath = pagepath ~ img | replace(from=pagepath | truncate(length=4, end=""), to="/") %} {%- else %} - {%- set metapath = page.path ~ img %} + {%- set metapath = pagepath ~ img %} {%- endif %} {%- set meta = get_image_metadata(path=metapath) %} {%- set w = meta.width %} diff --git a/templates/shortcodes/imgswap.html b/templates/shortcodes/imgswap.html index efcf6e7..80a3b74 100644 --- a/templates/shortcodes/imgswap.html +++ b/templates/shortcodes/imgswap.html @@ -2,15 +2,16 @@ {%- set img = main_src | split(pat="/") | last %} {%- set dirtest = main_src | trim_start_matches(pat="./") %} {%- if dirtest is containing("/") %} {%- set reldir = true %} {%- endif %} + {%- if page.path %}{%- set pagepath = page.path %}{%- elif section.path %}{%- set pagepath = section.path %}{%- endif %} {%- if main_src is starting_with("./") and reldir %} {# Relative Path #} {%- set path = main_src | trim_start_matches(pat="./") | split(pat="/") | slice(end=-1) | join(sep="/") | trim_start_matches(pat="/") %} {%- set path = path ~ "/" %} {%- if not w or not h %} {%- if lang != config.default_language %} - {%- set metapath = page.path ~ path ~ img | replace(from=page.path | truncate(length=4, end=""), to="/") %} + {%- set metapath = pagepath ~ path ~ img | replace(from=pagepath | truncate(length=4, end=""), to="/") %} {%- else %} - {%- set metapath = page.path ~ path ~ img %} + {%- set metapath = pagepath ~ path ~ img %} {%- endif %} {%- set meta = get_image_metadata(path=metapath) %} {%- set w = meta.width %} @@ -31,9 +32,9 @@ {%- set path = "" %} {%- if not w or not h %} {%- if lang != config.default_language %} - {%- set metapath = page.path ~ img | replace(from=page.path | truncate(length=4, end=""), to="/") %} + {%- set metapath = pagepath ~ img | replace(from=pagepath | truncate(length=4, end=""), to="/") %} {%- else %} - {%- set metapath = page.path ~ img %} + {%- set metapath = pagepath ~ img %} {%- endif %} {%- set meta = get_image_metadata(path=metapath) %} {%- set w = meta.width %} @@ -55,9 +56,9 @@ {%- set path = path ~ "/" %} {%- if not w or not h %} {%- if lang != config.default_language %} - {%- set metapath = page.path ~ path ~ img | replace(from=page.path | truncate(length=4, end=""), to="/") %} + {%- set metapath = pagepath ~ path ~ img | replace(from=pagepath | truncate(length=4, end=""), to="/") %} {%- else %} - {%- set metapath = page.path ~ path ~ img %} + {%- set metapath = pagepath ~ path ~ img %} {%- endif %} {%- set meta = get_image_metadata(path=metapath) %} {%- set w = meta.width %} @@ -78,9 +79,9 @@ {%- set path = "" %} {%- if not w or not h %} {%- if lang != config.default_language %} - {%- set metapath = page.path ~ img | replace(from=page.path | truncate(length=4, end=""), to="/") %} + {%- set metapath = pagepath ~ img | replace(from=pagepath | truncate(length=4, end=""), to="/") %} {%- else %} - {%- set metapath = page.path ~ img %} + {%- set metapath = pagepath ~ img %} {%- endif %} {%- set meta = get_image_metadata(path=metapath) %} {%- set w = meta.width %} diff --git a/templates/shortcodes/showdata.html b/templates/shortcodes/showdata.html index 9c14444..7f3d3bc 100644 --- a/templates/shortcodes/showdata.html +++ b/templates/shortcodes/showdata.html @@ -1,3 +1,5 @@ +{# showdata(src="../theme.toml" type="toml" key="min_version") #} + {%- if src and key and type %} {%- if src is matching("^http[s]?://") %} {% set data = load_data(url=src, format=type) %} @@ -5,4 +7,12 @@ {% set data = load_data(path=src, format=type) %} {%- endif %} {{ data[key] }} +{%- else %} + {# Load other file types as plain text #} + {%- if src is matching("^http[s]?://") %} + {% set data = load_data(url=src) %} + {%- else %} + {% set data = load_data(path=src) %} + {%- endif %} + {{ data }} {%- endif %} |
