Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve web UI #20

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions html/assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ h1 {
line-height: 1;
}

h2 {
h2, .tagline {
font-family: "Noto Serif";
font-weight: 400;
font-size: 2.4rem;
Expand Down Expand Up @@ -196,7 +196,7 @@ nav li {

/* UTILITY CLASSES */

.italic-text {
.italic-text, .tagline {
font-style: italic;
}

Expand Down
29 changes: 5 additions & 24 deletions html/index.html
Original file line number Diff line number Diff line change
@@ -1,31 +1,12 @@
{{ template "head" . }}
<header class="header-home">
<a class="header-home_link" href="https://github.com/cblgh/lieu">Lieu</a>
<nav>
<ul class="header-home_navigation" role='list'>
<li><a href="/webring">Webring</a></li>
<li><a href="/about">About</a></li>
</ul>
</nav>
</header>
{{ template "nav" . }}
<main class="grid-items-center">
<article class="translateY-75">
<div class="flow">
<h1>
{{ .SiteName }}
</h1>
<h2 class="italic-text">
{{ .Data.Tagline }}
</h2>
<form class="search">
<label class="visually-hidden" for="search">Search {{ .SiteName }}</label>
<span class="search__input">
<input type="search" required minlength="1" name="q" placeholder="{{ .Data.Placeholder }}" class="flex-grow" id="search" maxlength="6000" >
<button type="submit" class="search__button" aria-label="Search" title="Search">
<svg viewBox="0 0 420 300" xmlns="http://www.w3.org/2000/svg" baseProfile="full" style="background:var(--secondary)" width="42" height="30" fill="none"><path d="M90 135q60-60 120-60 0 0 0 0 60 0 120 60m-120 60a60 60 0 01-60-60 60 60 0 0160-60 60 60 0 0160 60 60 60 0 01-60 60m45-15h0l30 30m-75-15h0v45m-45-60h0l-30 30" stroke-width="81" stroke-linecap="square" stroke-linejoin="round" stroke="var(--primary)"/></svg>
</button>
</span>
</form>
<h1>{{ .SiteName }}</h1>
<p class="tagline">{{ .Data.Tagline }}</p>
<!-- The search form currently is in nav.html -->
{{ template "search-form" . }}
</div>
</article>
</main>
Expand Down
32 changes: 25 additions & 7 deletions html/nav.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
{{ define "nav" }}
<header class="header-home">
<a class="header-home_link" href="/">{{ .SiteName }}</a>
<nav>
<ul class="header-home_navigation" role='list'>
<li><a href="/webring">Webring</a></li>
<li><a href="/about">About</a></li>
</ul>
</nav>
{{ if eq .View "index" }}
<a class="header-home_link" href="https://github.com/cblgh/lieu">Lieu</a>
{{else}}
<a class="header-home_link" href="/">{{ .SiteName }}</a>
{{ end }}
<nav>
<ul class="header-home_navigation">
<li><a href="/webring" title="Webring (external link)">Webring<span aria-hidden="true"> ↗</span></a></li>
<li><a href="/about" {{if eq .View "about"}}aria-current="page"{{end}}>About</a></li>
</ul>
</nav>
</header>
{{ end }}

{{ define "search-form" }}
<form method="GET" class="search">
<span class="search__input">
<input type="search" minlength="1" required name="q" aria-label="Search {{ .SiteName }}" placeholder="Search {{ .SiteName }}" {{ if (eq .View "search") }}value="{{ .Data.Query }}"{{ end }} class="search-box" id="search" maxlength="6000">
{{ if and (eq .View "search") (ne .Data.Site "") }}
<input type="hidden" value="{{ .Data.Site }}" name="site">
{{ end }}
<button type="submit" class="search__button" aria-label="Search" title="Search">
<svg aria-hidden="true" viewBox="0 0 420 300" xmlns="http://www.w3.org/2000/svg" baseProfile="full" width="42" height="30" fill="none"><path d="M90 135q60-60 120-60 0 0 0 0 60 0 120 60m-120 60a60 60 0 01-60-60 60 60 0 0160-60 60 60 0 0160 60 60 60 0 01-60 60m45-15h0l30 30m-75-15h0v45m-45-60h0l-30 30" stroke-width="81" stroke-linecap="square" stroke-linejoin="round" stroke="var(--primary)"/></svg>
</button>
</span>
</form>
{{ end }}
14 changes: 2 additions & 12 deletions html/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,8 @@
<main id="results" class="flow2">
<h1>{{ .Data.Title }} {{ if ne .Data.Site "" }} for {{ .Data.Site }} {{ end }}</h1>

<form method="GET" class="search">
<label for="search">Search {{ .SiteName }} </label>
<span class="search__input">
<input type="search" minlength="1" required name="q" placeholder="Search" value="{{ .Data.Query }}" class="search-box" id="search" maxlength="6000">
{{ if ne .Data.Site "" }}
<input type="hidden" value="{{ .Data.Site }}" name="site">
{{ end }}
<button type="submit" class="search__button" aria-label="Search" title="Search">
<svg viewBox="0 0 420 300" xmlns="http://www.w3.org/2000/svg" baseProfile="full" style="background:var(--secondary)" width="42" height="30" fill="none"><path d="M90 135q60-60 120-60 0 0 0 0 60 0 120 60m-120 60a60 60 0 01-60-60 60 60 0 0160-60 60 60 0 0160 60 60 60 0 01-60 60m45-15h0l30 30m-75-15h0v45m-45-60h0l-30 30" stroke-width="81" stroke-linecap="square" stroke-linejoin="round" stroke="var(--primary)"/></svg>
</button>
</span>
</form>
<!-- The search form currently is in nav.html -->
{{ template "search-form" . }}
{{ if ne .Data.Site "" }}
<!-- add a button to clear the search results if a site:<domain> param has been used -->
<form method="GET" class="search">
Expand Down
2 changes: 2 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type RequestHandler struct {

type TemplateView struct {
SiteName string
View string
Data interface{}
}

Expand Down Expand Up @@ -221,6 +222,7 @@ func (h RequestHandler) webringRoute(res http.ResponseWriter, req *http.Request)

func (h RequestHandler) renderView(res http.ResponseWriter, tmpl string, view *TemplateView) {
view.SiteName = h.config.General.Name
view.View = tmpl
var errTemp error
if _, exists := os.LookupEnv("LIEU_DEV"); exists {
var templates = template.Must(template.ParseFiles(
Expand Down