From 6c195035966d1b1d2cac50f9aacc3617b3a0e475 Mon Sep 17 00:00:00 2001 From: Jieiku Date: Mon, 5 Aug 2024 18:07:12 -0700 Subject: simplify switching search library --- templates/404.html | 2 +- templates/archive.html | 2 +- templates/base.html | 6 +++--- templates/categories/list.html | 2 +- templates/categories/single.html | 2 +- templates/index.html | 3 ++- templates/macros/create_stork_toml.html | 15 --------------- templates/macros/macros.html | 18 +++++++++--------- templates/partials/head.html | 4 ++-- templates/partials/head_js.html | 8 +++----- templates/stork_toml.html | 9 --------- templates/tags/list.html | 2 +- templates/tags/single.html | 2 +- 13 files changed, 25 insertions(+), 50 deletions(-) delete mode 100644 templates/macros/create_stork_toml.html delete mode 100644 templates/stork_toml.html (limited to 'templates') diff --git a/templates/404.html b/templates/404.html index fee5607..40fb731 100644 --- a/templates/404.html +++ b/templates/404.html @@ -1,6 +1,6 @@ {% extends "base.html" %} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} -{%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} +{%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set uglyurls = true %}{% endif %}{% endif %} {%- block seo %} {{ super() }} diff --git a/templates/archive.html b/templates/archive.html index 587d7ea..e078bdd 100644 --- a/templates/archive.html +++ b/templates/archive.html @@ -5,7 +5,7 @@ This Template can also be used as the rendering template for Sections, eg: examp {% extends "base.html" %} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} -{%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} +{%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set uglyurls = true %}{% endif %}{% endif %} {%- block seo %} {{- super() }} diff --git a/templates/base.html b/templates/base.html index 1604dbe..3096ac2 100644 --- a/templates/base.html +++ b/templates/base.html @@ -5,7 +5,7 @@ {%- if not i18n -%}{%- set i18n = load_data(path="themes/abridge/i18n/" ~ lang ~ ".toml", required=false) -%}{%- endif %} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} -{%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} +{%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set uglyurls = true %}{% endif %}{% endif %} @@ -98,10 +98,10 @@
{%- endif %} diff --git a/templates/categories/list.html b/templates/categories/list.html index 506613c..b01b37f 100644 --- a/templates/categories/list.html +++ b/templates/categories/list.html @@ -1,6 +1,6 @@ {% extends "base.html" %} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} -{%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} +{%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set uglyurls = true %}{% endif %}{% endif %} {%- block seo %} {{- super() }} diff --git a/templates/categories/single.html b/templates/categories/single.html index be219aa..ba86397 100644 --- a/templates/categories/single.html +++ b/templates/categories/single.html @@ -1,6 +1,6 @@ {% extends "base.html" %} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} -{%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} +{%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set uglyurls = true %}{% endif %}{% endif %} {%- block seo %} {{- super() }} diff --git a/templates/index.html b/templates/index.html index 0b1e83f..802f328 100644 --- a/templates/index.html +++ b/templates/index.html @@ -5,7 +5,8 @@ This Template can also be used directly for the index eg: example.com/ or as the {%- extends "base.html" %} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} -{%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} +{%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set uglyurls = true %}{% endif %}{% endif %} + {%- block seo %} {{- super() }} diff --git a/templates/macros/create_stork_toml.html b/templates/macros/create_stork_toml.html deleted file mode 100644 index ee1d765..0000000 --- a/templates/macros/create_stork_toml.html +++ /dev/null @@ -1,15 +0,0 @@ -{%- macro from_section(section) -%} -{%- set section = get_section(path=section) -%} -{%- for post in section.pages -%} -{%- if not post.draft %} {path = {{ '.' ~ post.path ~ 'index.html' | json_encode | safe }}, url = {{ post.permalink | json_encode | safe }}, title = {{ post.title | striptags | json_encode | safe }}} -{%- set found = true -%} -{%- if not loop.last -%}, -{% endif -%} -{%- endif -%} -{%- endfor -%} -{%- if found and section.subsections -%}, -{% for subsection in section.subsections -%} -{{ self::from_section(section=subsection) }} -{%- endfor -%} -{%- endif -%} -{%- endmacro from_section -%} diff --git a/templates/macros/macros.html b/templates/macros/macros.html index dd3fcff..dd7b975 100644 --- a/templates/macros/macros.html +++ b/templates/macros/macros.html @@ -4,7 +4,7 @@ {%- macro page_listing(page, config) %} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} -{%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} +{%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set uglyurls = true %}{% endif %}{% endif %}
{{ page.title }}
@@ -13,7 +13,7 @@ {%- macro series_link(inner, page, config) %} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} -{%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} +{%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set uglyurls = true %}{% endif %}{% endif %} {%- if inner.content == page.content %}
  • {{ inner.title }}
  • {% else %} @@ -24,7 +24,7 @@ {%- macro title_post(page, config) %} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} -{%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} +{%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set uglyurls = true %}{% endif %}{% endif %}

    {{ page.title }}

    {%- endmacro title_post %} @@ -36,7 +36,7 @@ {%- if not i18n -%}{%- set i18n = load_data(path="themes/abridge/i18n/" ~ lang ~ ".toml", required=false) -%}{%- endif %} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} -{%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} +{%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set uglyurls = true %}{% endif %}{% endif %} {#- Author #} @@ -99,7 +99,7 @@ {%- macro title_index(page, config) %} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} -{%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} +{%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set uglyurls = true %}{% endif %}{% endif %}

    {% if config.extra.title_size_index %}{% endif %}{{ page.title }}{% if config.extra.title_size_index %}{% endif %}

    {%- endmacro title_index %} @@ -110,7 +110,7 @@ {%- set i18n = load_data(path="i18n/" ~ lang ~ '.toml', required=false) -%} {%- if not i18n -%}{%- set i18n = load_data(path="themes/abridge/i18n/" ~ lang ~ ".toml", required=false) -%}{%- endif %} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} -{%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} +{%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set uglyurls = true %}{% endif %}{% endif %} {#- Author #} @@ -173,7 +173,7 @@ {%- macro footer(page, config) %} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} -{%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} +{%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set uglyurls = true %}{% endif %}{% endif %} {#- prev/next content page nextprev title pagination #} {%- if not config.extra.hide_page_nextprev_titles | default(value=false) %} {%- if page.lower or page.higher %} @@ -197,7 +197,7 @@ {%- macro pagination(paginator, config)%} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} -{%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} +{%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set uglyurls = true %}{% endif %}{% endif %} {%- if paginator.number_pagers > 1 %} {%- if paginator.number_pagers <= 5 %} {# 5 or less pager is simple, just display all 5 #} {%- set start = 1 %} @@ -304,7 +304,7 @@ {%- macro numpagination(paginator, config)%} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} -{%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} +{%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set uglyurls = true %}{% endif %}{% endif %} {%- if paginator.number_pagers > 1 %} {%- if paginator.number_pagers <= 5 %} {# 5 or less pager is simple, just display all 5 #} {%- set start = 1 %} diff --git a/templates/partials/head.html b/templates/partials/head.html index 98d2382..1b95cc8 100644 --- a/templates/partials/head.html +++ b/templates/partials/head.html @@ -1,7 +1,7 @@ {#- Theme Switcher Button to toggle between dark/light #} {%- set integrity = config.extra.integrity | default(value=true) -%} - {%- if config.extra.offline %}{% set integrity = false %}{% endif %} + {%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set integrity = false %}{% endif %}{% endif %} {%- if config.extra.js_switcher | default(value=true) %} {%- set js_theme="js/theme.min.js" %} @@ -90,7 +90,7 @@ {#- Style Sheets Preload #} {%- set integrity = config.extra.integrity | default(value=true) -%} - {%- if config.extra.offline %}{% set integrity = false %}{% endif %} + {%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set integrity = false %}{% endif %}{% endif %} {%- if config.extra.fonts %}{%- for i in config.extra.fonts %} {%- if i.url is matching("^http[s]?://") %} diff --git a/templates/partials/head_js.html b/templates/partials/head_js.html index 33088ec..2a16b6d 100644 --- a/templates/partials/head_js.html +++ b/templates/partials/head_js.html @@ -1,6 +1,6 @@ {#- JAVASCRIPT #} {%- set integrity = config.extra.integrity | default(value=true) -%} - {%- if config.extra.offline %}{% set integrity = false %}{% endif %} + {%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set integrity = false %}{% endif %}{% endif %} {%- set search_library=config.extra.search_library | default(value="elasticlunr") -%} {%- set preStyle = false %} @@ -75,8 +75,6 @@ {%- if search_library == "tinysearch" %} - {%- elif search_library == "stork" %} - {%- elif config.build_search_index %} {%- set search_index_format="elasticlunr_json" -%} @@ -87,7 +85,7 @@ {%- endif %} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} - {%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} + {%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set uglyurls = true %}{% endif %}{% endif %} {%- if search_index_format == "elasticlunr_javascript" %}{#- Javascript index format #} @@ -163,4 +161,4 @@ -{#- End of head_js partial -#} \ No newline at end of file +{#- End of head_js partial -#} diff --git a/templates/stork_toml.html b/templates/stork_toml.html deleted file mode 100644 index 816fcd4..0000000 --- a/templates/stork_toml.html +++ /dev/null @@ -1,9 +0,0 @@ -{%- import "macros/create_stork_toml.html" as create_stork_toml -%} - -{%- if config.extra.search_library %}{%- if config.extra.search_library == "stork" %} -[input] -base_directory = "public" -files = [ -{{ create_stork_toml::from_section(section="_index.md", config=config) }} -] -{%- endif %}{%- endif %} \ No newline at end of file diff --git a/templates/tags/list.html b/templates/tags/list.html index 8ed7b5c..5e7650f 100644 --- a/templates/tags/list.html +++ b/templates/tags/list.html @@ -1,6 +1,6 @@ {% extends "base.html" %} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} -{%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} +{%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set uglyurls = true %}{% endif %}{% endif %} {%- block seo %} {{- super() }} diff --git a/templates/tags/single.html b/templates/tags/single.html index a57b1f7..723a47e 100644 --- a/templates/tags/single.html +++ b/templates/tags/single.html @@ -1,6 +1,6 @@ {% extends "base.html" %} {%- set uglyurls = config.extra.uglyurls | default(value=false) -%} -{%- if config.extra.offline %}{% set uglyurls = true %}{% endif %} +{%- if config.extra.search_library %}{%- if config.extra.search_library == "offline" %}{% set uglyurls = true %}{% endif %}{% endif %} {%- block seo %} {{- super() }} -- cgit v1.3.1