Skip to content

Commit

Permalink
deploy: a541fcb
Browse files Browse the repository at this point in the history
  • Loading branch information
HoshinoRei committed Aug 16, 2024
1 parent 510af44 commit 0d38361
Show file tree
Hide file tree
Showing 27 changed files with 74 additions and 74 deletions.
2 changes: 1 addition & 1 deletion feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<title>星野玲的数字花园</title>
<link href="https://digital-garden.bling.moe/feed.xml" rel="self" >
<link href="https://digital-garden.bling.moe" >
<updated>2024-08-10T11:31:42Z</updated>
<updated>2024-08-16T01:57:08Z</updated>
<id>https://digital-garden.bling.moe</id>
<entry>
<title>
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ <h1 style="text-align:center">星野玲的数字花园</h1>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/flexsearch.bundle.js"></script>
<script>document.addEventListener("DOMContentLoaded",init,!1),document.addEventListener("DOMContentLoaded",setCorrectShortcut,!1),window.toggleSearch=function(){document.getElementById("globalsearch").classList.contains("active")?document.getElementById("globalsearch").classList.remove("active"):(document.getElementById("globalsearch").classList.add("active"),document.getElementById("term").focus())},window.toggleTagSearch=function(e){console.log(e.textContent);const t=e.textContent;t&&(window.document.getElementById("term").value=t.trim(),window.toggleSearch(),window.search())};const loadingSvg='\n <svg width="100" height="100" viewBox="0 0 45 45" xmlns="http://www.w3.org/2000/svg" stroke="#fff">\n <g fill="none" fill-rule="evenodd" transform="translate(1 1)" stroke-width="2">\n <circle cx="22" cy="22" r="6" stroke-opacity="0">\n <animate attributeName="r"\n begin="1.5s" dur="3s"\n values="6;22"\n calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="stroke-opacity"\n begin="1.5s" dur="3s"\n values="1;0" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="stroke-width"\n begin="1.5s" dur="3s"\n values="2;0" calcMode="linear"\n repeatCount="indefinite" />\n </circle>\n <circle cx="22" cy="22" r="6" stroke-opacity="0">\n <animate attributeName="r"\n begin="3s" dur="3s"\n values="6;22"\n calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="stroke-opacity"\n begin="3s" dur="3s"\n values="1;0" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="stroke-width"\n begin="3s" dur="3s"\n values="2;0" calcMode="linear"\n repeatCount="indefinite" />\n </circle>\n <circle cx="22" cy="22" r="8">\n <animate attributeName="r"\n begin="0s" dur="1.5s"\n values="6;1;2;3;4;5;6"\n calcMode="linear"\n repeatCount="indefinite" />\n </circle>\n </g>\n </svg>';function debounce(e,t,n){var a;return function(){var r=this,i=arguments,c=n&&!a;clearTimeout(a),a=setTimeout((function(){a=null,n||e.apply(r,i)}),t),c&&e.apply(r,i)}}function setCorrectShortcut(){navigator.platform.toUpperCase().indexOf("MAC")>=0&&document.querySelectorAll(".search-keys").forEach((e=>e.innerHTML="⌘ + K"))}function createIndex(e){const t=e=>e.toLowerCase().split(/([^a-z]|[^\x00-\x7F])/),n=new FlexSearch.Document({cache:!0,charset:"latin:extra",optimize:!0,index:[{field:"content",tokenize:"reverse",encode:t},{field:"title",tokenize:"forward",encode:t},{field:"tags",tokenize:"forward",encode:t}]});return e.forEach(((e,t)=>{n.add({id:t,title:e.title,content:e.content,tags:e.tags})})),n}async function init(){let e=!0;if(localStorage.getItem("searchIndex")){let{date:t,docs:n}=JSON.parse(localStorage.getItem("searchIndex"));if("2024-08-10T11:31:42.028Z"===t){e=!1;let t=createIndex(n);window.docs=n,window.index=t}}if(e){let e=await(await fetch("/searchIndex.json?v=2024-08-10T11:31:42.028Z")).json(),t=createIndex(e);localStorage.setItem("searchIndex",JSON.stringify({date:"2024-08-10T11:31:42.028Z",docs:e})),window.docs=e,window.index=t}document.addEventListener("keydown",(e=>{if((e.ctrlKey||e.metaKey)&&"k"===e.key&&(e.preventDefault(),toggleSearch()),"Escape"===e.key&&document.getElementById("globalsearch").classList.remove("active"),document.getElementById("globalsearch").classList.contains("active")){if("ArrowDown"===e.key){e.preventDefault();let t=document.querySelector(".searchresult.active");t?(t.classList.remove("active"),t.nextElementSibling?t.nextElementSibling.classList.add("active"):document.querySelector(".searchresult").classList.add("active")):document.querySelector(".searchresult").classList.add("active");let n=document.querySelector(".searchresult.active");n&&n.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}if("ArrowUp"===e.key){e.preventDefault();let t=document.querySelector(".searchresult.active");t?(t.classList.remove("active"),t.previousElementSibling?t.previousElementSibling.classList.add("active"):document.querySelectorAll(".searchresult").forEach((e=>{e.nextElementSibling||e.classList.add("active")}))):document.querySelectorAll(".searchresult").forEach((e=>{e.nextElementSibling&&e.classList.add("active")}));let n=document.querySelector(".searchresult.active");n&&n.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}if("Enter"===e.key){e.preventDefault();let t=document.querySelector(".searchresult.active");t&&(window.location.href=t.querySelector("a").href)}}}));const t=debounce(search,200,!1);field=document.querySelector("#term"),field.addEventListener("keydown",(e=>{"ArrowDown"!==e.key&&"ArrowUp"!==e.key&&t()})),resultsDiv=document.querySelector("#search-results");const n=new URL(location.href).searchParams;n.get("q")&&(field.setAttribute("value",n.get("q")),toggleSearch(),search())}async function search(){let e=field.value.trim();if(!e)return;if(e==lastSearch)return;console.log(`search for ${e}`),window.lastSearch=e,resultsDiv.innerHTML=loadingSvg;let t=offlineSearch(e),n="";if(!t.length){let t=document.createElement("p");return t.innerText=`No results for "${e}"`,resultsDiv.innerHTML="",void resultsDiv.appendChild(t)}n+='<div style="max-width:100%;">',t.forEach((e=>{e.tags&&e.tags.length>0?n+=`<div class="searchresult">\n <a class="search-link" href="${e.url}">${e.title}</a>\n <div onclick="window.location='${e.url}'">\n <div class="header-meta">\n <div class="header-tags">\n ${e.tags.map((e=>'<a class="tag" href="JavaScript:Void(0);">#'+e+"</a>")).join("")}\n </div>\n </div>\n ${e.content}\n </div>\n </div>`:n+=`<div class="searchresult">\n <a class="search-link" href="${e.url}">${e.title}</a>\n <div onclick="window.location='${e.url}'">\n ${e.content}\n </div>\n </div>`})),n+="</div>",resultsDiv.innerHTML=n}function truncate(e,t){return(e=e.replaceAll(/<[^>]*>/g,"")).length<t?e:e.substring(0,t-3)+"..."}function offlineSearch(e){let t=window.docs,n="#"===e[0]&&e.length>1?index.search(e.substring(1),[{field:"tags"}]):index.search(e,[{field:"title",limit:5},{field:"content",weight:10}]);const a=e=>{const t=n.filter((t=>t.field===e));return 0===t.length?[]:[...t[0].result]};return[...new Set([...a("title"),...a("content"),...a("tags")])].map((e=>{let n=t[e];return n.content=truncate(n.content,400),n.tags=n.tags.filter((e=>"gardenEntry"!=e&&"note"!=e)),n}))}window.lastSearch=""</script>
<script>document.addEventListener("DOMContentLoaded",init,!1),document.addEventListener("DOMContentLoaded",setCorrectShortcut,!1),window.toggleSearch=function(){document.getElementById("globalsearch").classList.contains("active")?document.getElementById("globalsearch").classList.remove("active"):(document.getElementById("globalsearch").classList.add("active"),document.getElementById("term").focus())},window.toggleTagSearch=function(e){console.log(e.textContent);const t=e.textContent;t&&(window.document.getElementById("term").value=t.trim(),window.toggleSearch(),window.search())};const loadingSvg='\n <svg width="100" height="100" viewBox="0 0 45 45" xmlns="http://www.w3.org/2000/svg" stroke="#fff">\n <g fill="none" fill-rule="evenodd" transform="translate(1 1)" stroke-width="2">\n <circle cx="22" cy="22" r="6" stroke-opacity="0">\n <animate attributeName="r"\n begin="1.5s" dur="3s"\n values="6;22"\n calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="stroke-opacity"\n begin="1.5s" dur="3s"\n values="1;0" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="stroke-width"\n begin="1.5s" dur="3s"\n values="2;0" calcMode="linear"\n repeatCount="indefinite" />\n </circle>\n <circle cx="22" cy="22" r="6" stroke-opacity="0">\n <animate attributeName="r"\n begin="3s" dur="3s"\n values="6;22"\n calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="stroke-opacity"\n begin="3s" dur="3s"\n values="1;0" calcMode="linear"\n repeatCount="indefinite" />\n <animate attributeName="stroke-width"\n begin="3s" dur="3s"\n values="2;0" calcMode="linear"\n repeatCount="indefinite" />\n </circle>\n <circle cx="22" cy="22" r="8">\n <animate attributeName="r"\n begin="0s" dur="1.5s"\n values="6;1;2;3;4;5;6"\n calcMode="linear"\n repeatCount="indefinite" />\n </circle>\n </g>\n </svg>';function debounce(e,t,n){var a;return function(){var r=this,i=arguments,c=n&&!a;clearTimeout(a),a=setTimeout((function(){a=null,n||e.apply(r,i)}),t),c&&e.apply(r,i)}}function setCorrectShortcut(){navigator.platform.toUpperCase().indexOf("MAC")>=0&&document.querySelectorAll(".search-keys").forEach((e=>e.innerHTML="⌘ + K"))}function createIndex(e){const t=e=>e.toLowerCase().split(/([^a-z]|[^\x00-\x7F])/),n=new FlexSearch.Document({cache:!0,charset:"latin:extra",optimize:!0,index:[{field:"content",tokenize:"reverse",encode:t},{field:"title",tokenize:"forward",encode:t},{field:"tags",tokenize:"forward",encode:t}]});return e.forEach(((e,t)=>{n.add({id:t,title:e.title,content:e.content,tags:e.tags})})),n}async function init(){let e=!0;if(localStorage.getItem("searchIndex")){let{date:t,docs:n}=JSON.parse(localStorage.getItem("searchIndex"));if("2024-08-16T01:57:08.090Z"===t){e=!1;let t=createIndex(n);window.docs=n,window.index=t}}if(e){let e=await(await fetch("/searchIndex.json?v=2024-08-16T01:57:08.090Z")).json(),t=createIndex(e);localStorage.setItem("searchIndex",JSON.stringify({date:"2024-08-16T01:57:08.090Z",docs:e})),window.docs=e,window.index=t}document.addEventListener("keydown",(e=>{if((e.ctrlKey||e.metaKey)&&"k"===e.key&&(e.preventDefault(),toggleSearch()),"Escape"===e.key&&document.getElementById("globalsearch").classList.remove("active"),document.getElementById("globalsearch").classList.contains("active")){if("ArrowDown"===e.key){e.preventDefault();let t=document.querySelector(".searchresult.active");t?(t.classList.remove("active"),t.nextElementSibling?t.nextElementSibling.classList.add("active"):document.querySelector(".searchresult").classList.add("active")):document.querySelector(".searchresult").classList.add("active");let n=document.querySelector(".searchresult.active");n&&n.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}if("ArrowUp"===e.key){e.preventDefault();let t=document.querySelector(".searchresult.active");t?(t.classList.remove("active"),t.previousElementSibling?t.previousElementSibling.classList.add("active"):document.querySelectorAll(".searchresult").forEach((e=>{e.nextElementSibling||e.classList.add("active")}))):document.querySelectorAll(".searchresult").forEach((e=>{e.nextElementSibling&&e.classList.add("active")}));let n=document.querySelector(".searchresult.active");n&&n.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}if("Enter"===e.key){e.preventDefault();let t=document.querySelector(".searchresult.active");t&&(window.location.href=t.querySelector("a").href)}}}));const t=debounce(search,200,!1);field=document.querySelector("#term"),field.addEventListener("keydown",(e=>{"ArrowDown"!==e.key&&"ArrowUp"!==e.key&&t()})),resultsDiv=document.querySelector("#search-results");const n=new URL(location.href).searchParams;n.get("q")&&(field.setAttribute("value",n.get("q")),toggleSearch(),search())}async function search(){let e=field.value.trim();if(!e)return;if(e==lastSearch)return;console.log(`search for ${e}`),window.lastSearch=e,resultsDiv.innerHTML=loadingSvg;let t=offlineSearch(e),n="";if(!t.length){let t=document.createElement("p");return t.innerText=`No results for "${e}"`,resultsDiv.innerHTML="",void resultsDiv.appendChild(t)}n+='<div style="max-width:100%;">',t.forEach((e=>{e.tags&&e.tags.length>0?n+=`<div class="searchresult">\n <a class="search-link" href="${e.url}">${e.title}</a>\n <div onclick="window.location='${e.url}'">\n <div class="header-meta">\n <div class="header-tags">\n ${e.tags.map((e=>'<a class="tag" href="JavaScript:Void(0);">#'+e+"</a>")).join("")}\n </div>\n </div>\n ${e.content}\n </div>\n </div>`:n+=`<div class="searchresult">\n <a class="search-link" href="${e.url}">${e.title}</a>\n <div onclick="window.location='${e.url}'">\n ${e.content}\n </div>\n </div>`})),n+="</div>",resultsDiv.innerHTML=n}function truncate(e,t){return(e=e.replaceAll(/<[^>]*>/g,"")).length<t?e:e.substring(0,t-3)+"..."}function offlineSearch(e){let t=window.docs,n="#"===e[0]&&e.length>1?index.search(e.substring(1),[{field:"tags"}]):index.search(e,[{field:"title",limit:5},{field:"content",weight:10}]);const a=e=>{const t=n.filter((t=>t.field===e));return 0===t.length?[]:[...t[0].result]};return[...new Set([...a("title"),...a("content"),...a("tags")])].map((e=>{let n=t[e];return n.content=truncate(n.content,400),n.tags=n.tags.filter((e=>"gardenEntry"!=e&&"note"!=e)),n}))}window.lastSearch=""</script>
<main class="content cm-s-obsidian">
<header>
<h1></h1>
Expand Down
Loading

0 comments on commit 0d38361

Please sign in to comment.