templating: Move actions into template
This commit is contained in:
parent
313af2b9e3
commit
202599aaeb
23 changed files with 153 additions and 105 deletions
|
|
@ -10,6 +10,7 @@ import (
|
|||
"github.com/FAU-CDI/wdresolve"
|
||||
"github.com/FAU-CDI/wdresolve/resolvers"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/auth"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/control/static"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/control/static/custom"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component/instances"
|
||||
|
|
@ -25,6 +26,7 @@ type Resolver struct {
|
|||
Dependencies struct {
|
||||
Instances *instances.Instances
|
||||
Custom *custom.Custom
|
||||
Auth *auth.Auth
|
||||
}
|
||||
|
||||
prefixes lazy.Lazy[map[string]string] // cached prefixes (from the server)
|
||||
|
|
@ -58,8 +60,10 @@ type resolverContext struct {
|
|||
|
||||
func (resolver *Resolver) HandleRoute(ctx context.Context, route string) (http.Handler, error) {
|
||||
resolverTemplate := resolver.Dependencies.Custom.Template(resolverTemplate)
|
||||
crumbs := []component.MenuItem{
|
||||
{Title: "Resolver", Path: "/wisski/get/"},
|
||||
gaps := custom.BaseContextGaps{
|
||||
Crumbs: []component.MenuItem{
|
||||
{Title: "Resolver", Path: "/wisski/get/"},
|
||||
},
|
||||
}
|
||||
|
||||
logger := zerolog.Ctx(ctx)
|
||||
|
|
@ -71,7 +75,11 @@ func (resolver *Resolver) HandleRoute(ctx context.Context, route string) (http.H
|
|||
ctx := resolverContext{
|
||||
IndexContext: context,
|
||||
}
|
||||
resolver.Dependencies.Custom.Update(&ctx, r, crumbs)
|
||||
resolver.Dependencies.Custom.Update(&ctx, r, gaps)
|
||||
|
||||
if !resolver.Dependencies.Auth.Has(auth.User, r) {
|
||||
ctx.IndexContext.Prefixes = nil
|
||||
}
|
||||
|
||||
httpx.WriteHTML(ctx, nil, resolverTemplate, "", w, r)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,14 @@
|
|||
{{ template "_base.html" . }}
|
||||
{{ define "title" }}WissKI Resolver{{ end }}
|
||||
{{ define "title" }}Resolver{{ end }}
|
||||
|
||||
{{ define "content" }}
|
||||
<div class="pure-u-1">
|
||||
<h1>wdresolve</h1>
|
||||
<p>
|
||||
This page implements a resolver for the WissKI Distillery.
|
||||
This page contains the global distillery resolver.
|
||||
It takes a <b>RDF / Triplestore URI</b> that refers to a <b>WissKI Entity</b> and redirects to the page that displays the entity.
|
||||
</p>
|
||||
</div>
|
||||
<div class="pure-u-1">
|
||||
<h2>Resolve URI</h2>
|
||||
<form action="." method="GET" class="pure-form" autocomplete="off">
|
||||
<label for="uri">Enter A URI To Resolve:</label>
|
||||
<input type="text" id="uri" name="uri" value="">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue