Website-Redesign/public/search/index.html

320 lines
8.0 KiB
HTML

<!DOCTYPE html>
<html class="" lang="en"><head>
<meta name="viewport" content="width=device-width" />
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<link
rel="icon"
href='/favicon.png'
/>
<link
rel="shortcut icon"
href='/favicon.ico'
type="image/x-icon"
/>
<link
rel="apple-touch-icon"
href='/apple-touch-icon.png'
/>
<link
rel="icon"
href='/logo.svg'
type="image/svg+xml"
/>
<title>
Search &ndash;
Fbi&#39;s Epic Blog
</title>
<link href="/symbols-nerd-font/symbols-nerd-font.css" rel="stylesheet" integrity="sha512-lydow8GLOLlYNOtHlksNCmGWWCBsbIEtikXpHzfWqx78HLlyQZHOzyLwPpKol4Th6aCwLUXOfODVYgwrd3nwKQ=="/>
<link href="/jetbrains-mono/jetbrains-mono.css" rel="stylesheet" integrity="sha512-tJxlgL6v1Y7kFf+qB8SloaAMKnOAw6WouknxXtIjkBux9Y/9aX81EUWOJO8c/3l98DmjG8brr4to7zaez606Fg=="/>
<link type="text/css" rel="stylesheet" href=https://fbievan.live/css/styles.abbd6311bb4b6ca58f8e7398140529245ae0f6428b759fcd830742eee2619eabb900ba9914a9affb82aa9a16a9b9ea727bb315315a976a0db0e7513a5f12c504.css integrity="sha512-q71jEbtLbKWPjnOYFAUpJFrg9kKLdZ/NgwdC7uJhnqu5ALqZFKmv&#43;4Kqmhapuepye7MVMVqXag2w51E6XxLFBA==" />
<meta name="author" content="fbievan" />
<meta name="description" content="" />
<meta property="og:site_name"
content='Fbi&#39;s Epic Blog' />
<meta property="og:title" content="Search" />
<meta property="og:type" content="article" />
<meta
property="article:author" content="fbievan" />
<meta
property="article:published_time"
content='0001-01-01T00:00:00Z&#43;0000' />
<meta property="og:url" content="https://fbievan.live/search/" />
<meta property="og:image"
content="https://fbievan.live/icon512.png" />
<meta property="og:description" content="" />
<meta name="twitter:card" content="summary_large_image" />
<meta property="twitter:domain"
content='fbievan.live'
/>
<meta property="twitter:url" content="https://fbievan.live/search/" />
<meta name="twitter:title" content="Search" />
<meta name="twitter:image"
content="https://fbievan.live/icon512.png" />
<meta name="twitter:description" content="" />
<link rel="manifest" href="/manifest/index.json" />
</head>
<body>
<div id="baseContainer"><header class="">
<div class="titleAndSearchContainer">
<div id="titleContainer">
<a class="unstyledLink" href="/">
<img src='/logo.svg' alt='Logo'/>
</a>
<div class="rightOfLogo">
<div class="titleAndHamburger">
<h1>
<a class="unstyledLink" href="/">Fbi&#39;s Epic Blog</a>
</h1>
</div>
<div id="wide_nav"><nav>
<ul id="main-nav">
<li><a href="/">Home</a></li>
<li><a href="/posts">Posts</a></li>
<li><a href="/about/">About</a></li>
<li><a href="/tags">Tags</a></li>
</ul>
</nav>
</div>
</div>
</div>
</div>
<div id="links">
<a
rel="noreferrer"
target="_blank"
class="nerdlink"
href="/index.xml">
&#xf09e;
<span>
RSS
</span>
</a>
<a
rel="noreferrer"
target="_blank"
class="nerdlink"
href="https://gitlab.com/gabmus">
&#xf296;
<span>
GitLab
</span>
</a>
<a
rel="noreferrer"
target="_blank"
class="nerdlink"
href="https://gitlab.gnome.org/gabmus">
&#xf7ab;
<span>
GNOME GitLab
</span>
</a>
</div>
</header>
<div id="contentContainer">
<div id="content">
<main>
<noscript>
You need to enable JavaScript to be able to search.
</noscript><div class="search">
<input id="searchbar" type="text" placeholder='Search' />
<a class="nerdlink" onclick="newSearch();">&#xf002;</a>
</div>
<script>
function newSearch() {
let term = searchbar.value.trim();
if (!term) return;
location.href = `/search?q=${term}`;
}
searchbar.onkeyup = (ev) => {if (ev.keyCode == 13) newSearch()};
</script>
<div class="postlist " id="postlist">
</div><script>
function renderTags(tags) {
if (tags.length <= 0) return '';
let res = `| <span title='Tags'> </span>`;
for (let tag of tags) {
// regular space
res += `<a href="/tags/${tag}">#${tag}</a>&#32;`;
}
return res;
}
function renderImage(image, link, alt) {
if (!image) return '';
return `<a href="${link}"><img src="${image}" alt="${alt}" /></a>`;
}
function renderSingleArticle(article) {
return `
<article class="card postlistitem">
<div>
<h2>
<a href="${article.link}">${article.title}</a>
</h2>
<p class="date">
<span title='Date'> </span>
${article.date}
${renderTags(article.tags)}
</p>
<div class="articlePreview">
<p>${article.summary}</p>
<p><a href="${article.link}">Continue reading </a></p>
</div>
</div>
<hr />
</article>
`;
}
function renderArticles(articles) {
let rendered = articles.map(a => renderSingleArticle(a)).join('\n');
document.getElementById('postlist').innerHTML += rendered;
}
</script>
<script>
function matchTags(page, term) {
for (let tag of page.tags) {
if (tag.includes(term)) return true;
}
return false;
}
function performSearch(term) {
document.getElementById('postlist').innerHTML = '';
term = term.toLowerCase();
fetch('/search/index.json').then(res => res.json())
.then(res => {
let articles = res.pages.filter(page => (
page.title.toLowerCase().includes(term) ||
matchTags(page, term) ||
page.text.includes(term)
));
if (articles.length > 0) renderArticles(articles);
else document.getElementById('postlist').innerHTML = `
<h3>No results found</h3>
`;
});
}
var url = location.href;
var baseUrl = url.split('?')[0];
var searchbar = document.getElementById('searchbar');
if (url.includes('?')) {
var urlParams = new URLSearchParams(url.split('?')[1]);
if (urlParams.has('q')) {
let searchTerm = urlParams.get('q');
searchbar.value = searchTerm;
performSearch(searchTerm);
}
}
</script>
</main><footer>
<hr />
<p><small>
2023 &copy;
</small></p>
<p><small>
<a href='https://gitlab.com/gabmus/hugo-ficurinia'>Ficurinia theme</a> for <a href='https://gohugo.io'>Hugo</a> by <a href='https://gabmus.org'>Gabriele Musco</a>. Licensed under <a href='https://www.gnu.org/licenses/agpl-3.0.html'>GNU AGPLv3</a>.
</small></p>
</footer>
</div>
</div>
</div>
<script
async
defer
data-domain="example.com"
src="https://something.com/..."
></script>
<script
async
defer
data-website-id="example-tracking-code"
src="https://something.com/..."
></script>
</body>
</html>