Initial Commit

This commit is contained in:
2021-12-08 09:24:05 -08:00
commit c8bec472be
22 changed files with 3305 additions and 0 deletions

33
templates/base.html Normal file
View File

@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>
<head>
<title>{{template "page" .}} - {{.Config "site.name"}}</title>
<link rel="search" type="application/opensearchdescription+xml" title='{{.Config "site.name"}}' href="/opensearch">
<link rel="stylesheet" href="/static/bulma.min.css">
<script async src="/static/iconify.min.js"></script>
{{if .Card}}
{{.Card.Head}}
{{end}}
</head>
<body>
{{template "body" .}}
{{if .Config "page.results.footer.enabled"}}
<section id="footer" class="px-4 py-0 has-background-light is-fullwidth mt-3">
<div class="columns">
<div class="column is-one-quarter has-text-left is-hidden-mobile">
<p>Rendered in {{.LoadTime}}</p>
</div>
<div class="column has-text-right has-text-centered-mobile">
<p class="is-hidden-mobile">Powered by Scope &mdash; A simple and minimal metasearch engine</span>
<div>
Licensed under the
<a href="https://www.gnu.org/licenses/agpl-3.0-standalone.html">AGPLv3</a>.
<a href='{{.Config "site.sourceURL"}}'>Source Code</a>.
</div>
</div>
</div>
</section>
{{end}}
</body>
</html>

16
templates/error.html Normal file
View File

@@ -0,0 +1,16 @@
{{define "page"}}
Error
{{end}}
{{define "body"}}
<section class="hero is-fullheight">
<div class="hero-body">
<div class="container has-text-centered">
<p class="title">{{.Message}} ({{.Status}})</p>
{{if .ErrExists}}
<p>{{.Error}}</p>
{{end}}
</div>
</div>
</section>
{{end}}

27
templates/home.html Normal file
View File

@@ -0,0 +1,27 @@
{{define "page"}}
Home
{{end}}
{{define "body"}}
<section class="hero is-fullheight">
<div class="hero-body">
<div class="container has-text-centered">
<p class="title">
{{.Config "site.name"}}
</p>
<form action="/search">
<dic class="columns is-centered">
<div class="column is-three-quarters">
<input id="search-input" class="input is-link is-rounded" type="text" name="q"
placeholder="Search...">
</div>
</dic>
<button class="button is-link is-rounded" type="submit">
<span class="iconify" data-icon="fe:search"></span>&nbsp;
Search
</button>
</form>
</div>
</div>
</section>
{{end}}

10
templates/opensearch.xml Normal file
View File

@@ -0,0 +1,10 @@
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>{{.Config "site.name"}}</ShortName>
<Description>{{.Config "site.name"}} — A simple and minimal metasearch engine</Description>
<InputEncoding>UTF-8</InputEncoding>
<Url type="text/html" template='{{.Config "site.baseURL"}}/search'>
<Param name="q" value="{searchTerms}"/>
</Url>
<moz:SearchForm>{{.Config "site.baseURL"}}/search</moz:SearchForm>
</OpenSearchDescription>

96
templates/result.html Normal file
View File

@@ -0,0 +1,96 @@
{{define "page"}}
{{- .Keyword -}}
{{end}}
{{define "body"}}
<!-- Search bar -->
<section id="search" class="section p-4">
<form action="/search">
<div class="columns">
{{if .Config "page.results.searchbar.homeBtn"}}
<div class="column has-text-centered px-1 is-1">
<a class="button is-fullwidth is-success is-rounded" href="/">
<span class="iconify" data-icon="fluent:home-12-regular"></span>
</a>
</div>
{{end}}
<div id="search-bar" class="column">
<input id="search-input" class="input is-link is-rounded" type="text" name="q" placeholder="Search"
value="{{.Keyword}}">
</div>
<div class="column has-text-centered px-1 is-1">
<button class="button is-fullwidth is-link is-rounded" type="submit">
<span class="iconify" data-icon="fe:search"></span>
</button>
</div>
{{if .Config "page.results.searchbar.resetBtn"}}
<div class="column has-text-centered px-1 is-1">
<a class="button is-fullwidth is-danger is-rounded" href="#"
onclick="document.getElementById('search-input').value = ''">
<span class="iconify" data-icon="akar-icons:cross"></span>
</a>
</div>
{{end}}
</div>
</form>
</section>
{{if .Card}}
<div id="answer" class="container py-6">
<div class="card has-background-light">
<div class="card-content">
<p class="title" id="card-title">{{.Card.Title}}</p>
<div class="content">
{{html .Card.Content}}
</div>
</div>
{{.Card.Footer}}
</div>
</div>
{{end}}
<!-- Results -->
<section id="results" class="section container py-4 px-6">
{{if eq (len .Results) 0}}
<p class="has-text-centered">No results</p>
{{end}}
{{- range $index, $result := .Results }}
<div id="result-{{$index}}">
<a href="{{$result.Link}}">{{$result.Title}}</a>
<p>{{$result.Desc}}</p>
{{if $.Config "page.results.showLink"}}
<p class="has-text-success">{{$result.Link}}</p>
{{end}}
<div class="columns">
{{if $.Config "page.results.engineTags"}}
<div class="column has-text-left">
{{- range $engine := $result.Engines }}
<span class="tag is-light px-2">{{$engine}}</span>
{{end}}
</div>
{{end}}
{{if $.Config "page.results.cachedLink"}}
<div class="column has-text-right">
<a href="https://web.archive.org/web/{{$result.Link}}">
<span class="iconify" data-icon="ic:baseline-cached" data-inline="true"></span>
Cached
</a>
</div>
{{end}}
</div>
<hr>
</div>
{{end}}
</section>
{{if ne (len .Results) 0}}
<!-- Pagination -->
<section id="pagination" class="section container has-text-centered">
<a class="button is-rounded is-link" {{if eq .Page
0}}disabled{{else}}href="/search?q={{.Keyword}}&page={{sub .Page 1}}" {{end}}>Prev</a>
<a class="button is-link mx-4" style="cursor:default;"><span class="icon">{{.Page}}</span></a>
<a class="button is-rounded is-link" href="/search?q={{.Keyword}}&page={{add .Page 1}}">Next</a>
</section>
{{end}}
{{end}}