diff options
| author | Jieiku | 2022-08-14 12:41:15 -0700 |
|---|---|---|
| committer | Jieiku | 2022-08-14 12:41:15 -0700 |
| commit | 830cabab1f638052a8c4ac39eb86370da5a676eb (patch) | |
| tree | f59bc6914105256ea684066277a49ab2dce53300 /templates | |
| parent | cf95ee520261a0a523d5a3dfbc01a3847d67de51 (diff) | |
| download | abridge-1.2.0.tar.gz abridge-1.2.0.tar.bz2 abridge-1.2.0.zip | |
Alternate Search Libraries Tinysearch and Stork1.2.0
Diffstat (limited to 'templates')
| -rw-r--r-- | templates/base.html | 7 | ||||
| -rw-r--r-- | templates/index.html | 7 | ||||
| -rw-r--r-- | templates/macros/create_stork_toml.html | 19 | ||||
| -rw-r--r-- | templates/macros/create_tinysearch_json.html | 26 | ||||
| -rw-r--r-- | templates/macros/head.html | 58 | ||||
| -rw-r--r-- | templates/stork_toml.html | 6 | ||||
| -rw-r--r-- | templates/tinysearch_json.html | 2 |
7 files changed, 105 insertions, 20 deletions
diff --git a/templates/base.html b/templates/base.html index 1022004..9d27f8a 100644 --- a/templates/base.html +++ b/templates/base.html @@ -12,6 +12,7 @@ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> {{- macros_head::stylesheets_preload() }} {{- macros_head::js() }} + <meta name="base" content="{{ config.base_url | safe }}" /> {{- macros_head::feed() }} {%- block seo %} {%- if config.extra.title_separator %} @@ -60,12 +61,12 @@ </div> {%- if config.build_search_index %} <div> - <form class="js" name="goSearch"> + <form autocomplete=off class="js" name="goSearch" id="searchbox"> <div class="searchd"> - <input id="userinput" type="text" placeholder="Search" autocomplete="off" title="Search" /> + <input id="searchinput" type="text" placeholder="Search" title="Search"{% if config.extra.search_library %}{% if config.extra.search_library == "stork" %} data-stork="stork" {% endif %}{% endif %} /> <button type="submit" title="Search">{%- if config.extra.icon_search -%}<i class="{{ config.extra.icon_search }}"></i>{%- else -%}<span class="si">⌕</span>{%- endif -%}</button> </div> - <div><div id="suggestions"></div></div> + <div><div id="suggestions"{% if config.extra.search_library %}{% if config.extra.search_library == "stork" %} data-stork="stork-output" {% endif %}{% endif %}></div></div> </form> </div> {%- endif %} diff --git a/templates/index.html b/templates/index.html index 9c25fa4..1434aee 100644 --- a/templates/index.html +++ b/templates/index.html @@ -33,17 +33,18 @@ {%- if config.extra.meta_index.position == "top" or config.extra.meta_index.position == "both" %} {{- macros::meta_index(page=page) }} {%- endif %}{%- endif %} - <p class="sum"> + <div class="sum"> + <p> {%- if page.summary %} {{ page.summary | markdown(inline=true) | safe }} {%- elif page.description %} {{ page.description | safe }} {%- elif page.content %} - {{ page.content | safe | striptags | truncate(length=150) }} + {{ page.content | striptags | truncate(length=150) | safe }} {%- elif page.extra.static_thumbnail %} {%- endif %} <a href="{{ page.permalink | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">...more</a> - </p> + </div> {%- if config.extra.meta_index.position %} {%- if config.extra.meta_index.position == "bottom" or config.extra.meta_index.position == "both" %} {{- macros::meta_index(page=page) }} diff --git a/templates/macros/create_stork_toml.html b/templates/macros/create_stork_toml.html new file mode 100644 index 0000000..c9ed35c --- /dev/null +++ b/templates/macros/create_stork_toml.html @@ -0,0 +1,19 @@ +{# cargo install stork-search --locked #} +{# cd .dev/abridge #} +{# zola build #} +{# /home/jieiku/.cargo/bin/stork build --input public/data_stork/index.html --output static/stork.st #} + +{%- 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 }}} +{%- if not loop.last -%}, +{% endif -%} +{%- endif -%} +{%- endfor -%} +{%- if section.subsections -%}, +{% for subsection in section.subsections -%} +{{ self::from_section(section=subsection) }} +{%- endfor -%} +{%- endif -%} +{%- endmacro from_section -%}
\ No newline at end of file diff --git a/templates/macros/create_tinysearch_json.html b/templates/macros/create_tinysearch_json.html new file mode 100644 index 0000000..f45ed42 --- /dev/null +++ b/templates/macros/create_tinysearch_json.html @@ -0,0 +1,26 @@ +{%- macro from_section(section) -%} +{%- set section = get_section(path=section) -%} +{%- for post in section.pages -%} +{%- if not post.draft -%} +{ +"title": {{ post.title | striptags | json_encode | safe }}, +"url": {{ post.permalink | json_encode | safe }}, +"meta": {% if post.summary %} + {{- post.summary | striptags | truncate(length=150) | json_encode | safe }} + {%- elif post.description %} + {{- post.description | striptags | truncate(length=150) | json_encode | safe }} + {%- elif post.content %} + {{- post.content | striptags | truncate(length=150) | json_encode | safe }} + {%- endif %}, +"body": {{ post.content | striptags | json_encode | safe }} +} +{%- if not loop.last -%},{%- endif %} +{%- endif -%} +{%- endfor -%} +{%- if section.subsections -%} +, +{%- for subsection in section.subsections -%} +{{ self::from_section(section=subsection) }} +{%- endfor -%} +{%- endif -%} +{%- endmacro from_section -%}
\ No newline at end of file diff --git a/templates/macros/head.html b/templates/macros/head.html index 0fbae7c..c3b217c 100644 --- a/templates/macros/head.html +++ b/templates/macros/head.html @@ -1,3 +1,4 @@ +{#- Theme Switcher Button to toggle between dark/light #} {%- macro theme() %} {%- if config.extra.js_theme %} {%- if config.extra.js_themeButton or config.extra.js_bundle %} @@ -70,19 +71,35 @@ {%- endif %} {%- endif %} -{%- if config.build_search_index and config.extra.js_bundle %} +{%- if config.extra.js_bundle and config.build_search_index or config.extra.js_bundle and config.extra.search_library %} {%- if config.extra.js_search_facade %} - {# dont load the index #} + {#- dont load the index #} + {%- elif config.extra.search_library == "tinysearch" or config.extra.search_library == "stork" %} + {#- dont load the index #} {%- elif config.extra.js_search_index %} <script defer src="{{ get_url(path=config.extra.js_search_index, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.js_search_index, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} - {%- if config.extra.js_bundle %} - <script defer src="{{ get_url(path=config.extra.js_bundle, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.js_bundle, sha_type=384, base64=true) | safe }}"{%- endif %}></script> + + {%- if not config.extra.js_search_facade %} + + {%- if config.extra.js_switcher %} + <script defer src="{{ get_url(path='abridge-bundle-nofacade.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path='abridge-bundle-nofacade.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- else %} + <script defer src="{{ get_url(path='abridge-bundle-noswitcher.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path='abridge-bundle-nofacade.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- endif %} + + {%- elif config.extra.search_library == "tinysearch" %} + <script defer src="{{ get_url(path='abridge-bundle-tinysearch.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path='abridge-bundle-tinysearch.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- elif config.extra.search_library == "stork" %} + <script defer src="{{ get_url(path='abridge-bundle-stork.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path='abridge-bundle-stork.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- else %} + <script defer src="{{ get_url(path='abridge-bundle.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path='abridge-bundle.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} -{%- elif config.build_search_index %} + +{%- elif config.build_search_index or config.extra.search_library %} {#- no bundle #} @@ -90,8 +107,8 @@ {%- if config.extra.js_prestyle %} <script defer src="{{ get_url(path=config.extra.js_prestyle, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.js_prestyle, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} - {%- endif %} + {%- if config.extra.js_theme %} {%- if config.extra.js_themeButton %} <script defer src="{{ get_url(path=config.extra.js_themeButton, trailing_slash=false) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.js_themeButton, sha_type=384, base64=true) | safe }}"{%- endif %}></script> @@ -109,26 +126,39 @@ {%- endif %} {%- if config.extra.js_search_facade %} + {%- if config.extra.search_library %} + {%- if config.extra.search_library == "tinysearch" %} + <script defer src="{{ get_url(path='search_facade_tinysearch.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path='search_facade_tinysearch.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- elif config.extra.search_library == "stork" %} + <script defer src="{{ get_url(path='search_facade_stork.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path='search_facade_stork.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- endif %} + {%- endif %} <script defer src="{{ get_url(path='search_facade.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path='search_facade.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} - {%- if config.extra.js_search_facade %} - <script defer src="{{ get_url(path=config.extra.js_search_facade, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.js_search_facade, sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- if config.extra.js_search_facade or config.extra.search_library %} + {#- dont load the index/search #} {%- elif config.extra.js_search_index %} <script defer src="{{ get_url(path=config.extra.js_search_index, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.js_search_index, sha_type=384, base64=true) | safe }}"{%- endif %}></script> {%- endif %} + {%- if config.extra.js_search_facade %} - {# dont load the index/search #} - {%- elif config.extra.js_search %}{%- for i in config.extra.js_search %} - <script defer src="{{ get_url(path=i, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=i, sha_type=384, base64=true) | safe }}"{%- endif %}></script> - {%- endfor %}{%- endif %} + {#- dont load the index/search #} + {%- else %} + {%- if config.extra.search_library == "tinysearch" %} + <script defer type="module" src="{{ get_url(path='tinysearch.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path='tinysearch.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- elif config.extra.search_library == "stork" %} + <script defer type="module" src="{{ get_url(path='stork.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path='stork.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- else %} + <script defer src="{{ get_url(path='elasticlunr.min.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path='elasticlunr.min.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> + <script defer src="{{ get_url(path='search.js', trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path='search.js', sha_type=384, base64=true) | safe }}"{%- endif %}></script> + {%- endif %} + {%- endif %} {%- elif config.extra.js_bundle %} {#- no search #} - <script defer src="{{ get_url(path=config.extra.js_bundle, trailing_slash=false, cachebust=true) | safe }}"{%- if config.extra.integrity %} integrity="sha384-{{ get_file_hash(path=config.extra.js_bundle, sha_type=384, base64=true) | safe }}"{%- endif %}></script> - {%- else %} {#- no bundle or search #} diff --git a/templates/stork_toml.html b/templates/stork_toml.html new file mode 100644 index 0000000..ba3f714 --- /dev/null +++ b/templates/stork_toml.html @@ -0,0 +1,6 @@ +{%- import "macros/create_stork_toml.html" as create_stork_toml -%} +[input] +base_directory = "public" +files = [ +{{ create_stork_toml::from_section(section="_index.md") }} +] diff --git a/templates/tinysearch_json.html b/templates/tinysearch_json.html new file mode 100644 index 0000000..638833f --- /dev/null +++ b/templates/tinysearch_json.html @@ -0,0 +1,2 @@ +{%- import "macros/create_tinysearch_json.html" as create_tinysearch_json -%} +[{{ create_tinysearch_json::from_section(section="_index.md") }}]
\ No newline at end of file |
