forked from tangled.org/core
this repo has no description

improve settings page a bit

Changed files
+81 -71
appview
pages
+1 -1
appview/pages/funcmap.go
···
"sequence": func(n int) []struct{} {
return make([]struct{}, n)
},
-
"subslice": func(slice interface{}, start, end int) interface{} {
v := reflect.ValueOf(slice)
if v.Kind() != reflect.Slice && v.Kind() != reflect.Array {
return nil
···
"sequence": func(n int) []struct{} {
return make([]struct{}, n)
},
+
"subslice": func(slice any, start, end int) any {
v := reflect.ValueOf(slice)
if v.Kind() != reflect.Slice && v.Kind() != reflect.Array {
return nil
+1 -1
appview/pages/pages.go
···
}
func (p *Pages) Settings(w io.Writer, params SettingsParams) error {
-
return p.execute("settings/keys", w, params)
}
type KnotsParams struct {
···
}
func (p *Pages) Settings(w io.Writer, params SettingsParams) error {
+
return p.execute("settings", w, params)
}
type KnotsParams struct {
+5 -3
appview/pages/templates/repo/log.html
···
{{ $commit := index .Commits 0 }}
{{ $messageParts := splitN $commit.Message "\n\n" 2 }}
<div>
<p class="pb-5">{{ index $messageParts 0 }}</p>
{{ if gt (len $messageParts) 1 }}
-
<p class="mt-1 text-sm cursor-text pb-5">
-
{{ nl2br (unwrapText (index $messageParts 1)) }}
-
</p>
{{ end }}
</div>
<div class="text-sm text-gray-500">
···
{{ $commit := index .Commits 0 }}
{{ $messageParts := splitN $commit.Message "\n\n" 2 }}
<div>
+
<a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}">
<p class="pb-5">{{ index $messageParts 0 }}</p>
{{ if gt (len $messageParts) 1 }}
+
<p class="mt-1 text-sm cursor-text pb-5">
+
{{ nl2br (unwrapText (index $messageParts 1)) }}
+
</p>
{{ end }}
+
</a>
</div>
<div class="text-sm text-gray-500">
+72
appview/pages/templates/settings.html
···
···
+
{{ define "title" }}settings{{ end }}
+
+
{{ define "content" }}
+
<div class="p-6">
+
<p class="text-xl font-bold">Settings</p>
+
</div>
+
<div class="flex flex-col">
+
{{ block "profile" . }} {{ end }}
+
{{ block "keys" . }} {{ end }}
+
{{ block "knots" . }} {{ end }}
+
</div>
+
{{ end }}
+
+
{{ define "profile" }}
+
<header class="text-sm font-bold py-2 px-6 uppercase">profile</header>
+
<section class="rounded bg-white drop-shadow-sm px-6 py-4 mb-6 w-fit">
+
<dl class="grid grid-cols-[auto_1fr] gap-x-4">
+
{{ if .LoggedInUser.Handle }}
+
<dt class="font-bold">handle</dt>
+
<dd>@{{ .LoggedInUser.Handle }}</dd>
+
{{ end }}
+
<dt class="font-bold">did</dt>
+
<dd>{{ .LoggedInUser.Did }}</dd>
+
<dt class="font-bold">pds</dt>
+
<dd>{{ .LoggedInUser.Pds }}</dd>
+
</dl>
+
</section>
+
{{ end }}
+
+
{{ define "keys" }}
+
<header class="text-sm font-bold py-2 px-6 uppercase">ssh keys</header>
+
<section class="rounded bg-white drop-shadow-sm px-6 py-4 mb-6 w-fit">
+
<div id="key-list" class="flex flex-col gap-6 mb-8">
+
{{ range .PubKeys }}
+
<div>
+
<div class="inline-flex items-center gap-4">
+
<i class="w-3 h-3" data-lucide="key"></i>
+
<p class="font-bold">{{ .Name }} </p>
+
<p class="text-sm text-gray-500">added {{ .Created | timeFmt }}</p>
+
</div>
+
<code class="block text-sm break-all text-gray-500">{{ .Key }}</code>
+
</div>
+
{{ end }}
+
</div>
+
<hr class="mb-4" />
+
<p class="mb-2">add an ssh key</p>
+
<form
+
hx-put="/settings/keys"
+
hx-swap="none"
+
class="max-w-2xl mb-8 space-y-4"
+
>
+
<input
+
type="text"
+
id="name"
+
name="name"
+
placeholder="key name"
+
required
+
class="w-full"/>
+
+
<input
+
id="key"
+
name="key"
+
placeholder="ssh-rsa AAAAAA..."
+
required
+
class="w-full"/>
+
+
<button class="btn w-full" type="submit">add key</button>
+
+
<div id="settings-keys" class="error"></div>
+
</form>
+
</section>
+
{{ end }}
-64
appview/pages/templates/settings/keys.html
···
-
{{ define "title" }}settings{{ end }}
-
-
{{ define "content" }}
-
<h1>settings</h1>
-
-
<section class="mb-8">
-
<h2 class="text-xl mb-4">profile</h2>
-
<dl class="grid grid-cols-[auto_1fr] gap-x-4">
-
<dt>handle</dt>
-
<dd>{{ .LoggedInUser.Handle }}</dd>
-
<dt>did</dt>
-
<dd>{{ .LoggedInUser.Did }}</dd>
-
<dt>pds</dt>
-
<dd>{{ .LoggedInUser.Pds }}</dd>
-
</dl>
-
</section>
-
-
<section>
-
<h2 class="text-xl mb-4">ssh keys</h2>
-
<form
-
hx-put="/settings/keys"
-
hx-swap="none"
-
class="max-w-2xl space-y-4 mb-8"
-
>
-
<div>
-
<label for="name" class="block mb-1">key name</label>
-
<input
-
type="text"
-
id="name"
-
name="name"
-
required
-
class="w-full"
-
/>
-
</div>
-
-
<div>
-
<label for="key" class="block mb-1">pub key</label>
-
<textarea
-
id="key"
-
name="key"
-
placeholder="ssh-rsa AAAAAA..."
-
required
-
class="w-full h-24"
-
></textarea>
-
</div>
-
-
<button class="btn" type="submit">add key</button>
-
-
<div id="settings-keys" class="error"></div>
-
</form>
-
-
<h3 class="text-lg mb-2">existing keys</h3>
-
<ul id="key-list" class="space-y-4">
-
{{ range .PubKeys }}
-
<li class="p-4 bg-gray-50 rounded">
-
<h4 class="font-bold mb-2">{{ .Name }}</h4>
-
<code class="block text-sm break-all">{{ .Key }}</code>
-
</li>
-
{{ else }}
-
<p class="text-gray-600">no ssh keys added yet</p>
-
{{ end }}
-
</ul>
-
</section>
-
{{ end }}
···
+2 -2
input.css
···
@apply block text-sm text-black;
}
input {
-
@apply bg-white border border-black rounded-sm focus:ring-black p-2;
}
textarea {
-
@apply bg-white border border-black rounded-sm focus:ring-black p-2;
}
details summary::-webkit-details-marker {
display: none;
···
@apply block text-sm text-black;
}
input {
+
@apply bg-white border border-gray-400 rounded-sm focus:ring-black p-2;
}
textarea {
+
@apply bg-white border border-gray-400 rounded-sm focus:ring-black p-2;
}
details summary::-webkit-details-marker {
display: none;