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

improvements to topbar

some links still need to be stuffed into a dropdown

Changed files
+41 -65
appview
pages
templates
state
knotserver
git
types
+6 -1
appview/pages/pages.go
···
"path/filepath"
"strings"
chromahtml "github.com/alecthomas/chroma/v2/formatters/html"
"github.com/alecthomas/chroma/v2/lexers"
"github.com/alecthomas/chroma/v2/styles"
···
}
func (p *Pages) RepoBlob(w io.Writer, params RepoBlobParams) error {
if params.Lines < 5000 {
c := params.Contents
-
style := styles.Get("bw")
formatter := chromahtml.New(
chromahtml.InlineCode(true),
chromahtml.WithLineNumbers(true),
···
"path/filepath"
"strings"
+
"github.com/alecthomas/chroma/v2"
chromahtml "github.com/alecthomas/chroma/v2/formatters/html"
"github.com/alecthomas/chroma/v2/lexers"
"github.com/alecthomas/chroma/v2/styles"
···
}
func (p *Pages) RepoBlob(w io.Writer, params RepoBlobParams) error {
+
style := styles.Get("bw")
+
b := style.Builder()
+
b.Add(chroma.LiteralString, "noitalic")
+
style, _ = b.Build()
+
if params.Lines < 5000 {
c := params.Contents
formatter := chromahtml.New(
chromahtml.InlineCode(true),
chromahtml.WithLineNumbers(true),
+26 -48
appview/pages/templates/layouts/topbar.html
···
{{ define "layouts/topbar" }}
-
{{ with .LoggedInUser }}
-
<nav
-
class="flex items-center justify-center space-x-4 mb-4 py-2 border-b border-l border-r border-black"
-
>
-
<a
-
href="/"
-
hx-boost="true"
-
class="text-gray-600 hover:text-gray-900 no-underline"
-
>timeline</a
-
>
-
<a
-
href="/settings"
-
hx-boost="true"
-
class="text-gray-600 hover:text-gray-900 no-underline"
-
>settings</a
-
>
-
<a
-
href="/knots"
-
hx-boost="true"
-
class="text-gray-600 hover:text-gray-900 no-underline"
-
>knots</a
-
>
-
<a
-
href="/repo/new"
-
hx-boost="true"
-
class="text-gray-600 hover:text-gray-900 no-underline"
-
>add repos</a
-
>
-
{{ if .Handle }}
-
<a
-
href="/@{{ .Handle }}"
-
hx-boost="true"
-
class="text-gray-600 hover:text-gray-900 no-underline"
-
>my profile</a
-
>
-
{{ else }}
-
<a
-
href="/{{ .Did }}"
-
hx-boost="true"
-
class="text-gray-600 hover:text-gray-900 no-underline"
-
>my profile</a
-
>
-
{{ end }}
-
<button hx-get="/logout" class="btn">logout</a>
-
</nav>
-
{{ else }}
-
<a href="/login" class="btn my-2 no-underline">login</a>
-
{{ end }}
{{ end }}
···
{{ define "layouts/topbar" }}
+
{{ $linkstyle := "text-gray-400 hover:text-gray-900 no-underline" }}
+
<nav class="flex justify-between px-6 space-x-4 mb-4 py-2 border-b border-black">
+
<div id="left-items">
+
<a href="/" hx-boost="true" class="{{ $linkstyle }} flex gap-2">
+
<i class="w-6 h-6" data-lucide="tangent"></i>
+
tangled.sh
+
</a>
+
</div>
+
<div id="right-items" class="flex gap-2">
+
{{ with .LoggedInUser }}
+
<a href="/repo/new" hx-boost="true" class="{{ $linkstyle }}">
+
<i class="w-6 h-6" data-lucide="plus"></i>
+
</a>
+
<a href="/{{ didOrHandle .Did .Handle }}" hx-boost="true" class="{{ $linkstyle }}">
+
{{ didOrHandle .Did .Handle }}
+
</a>
+
<a href="/logout"class="{{ $linkstyle }}">
+
(logout)
+
</a>
+
{{ else }}
+
<a href="/login" hx-boost="true" class="{{ $linkstyle }}">
+
login
+
</a>
+
{{ end }}
+
</div>
+
</nav>
{{ end }}
-1
appview/pages/templates/repo/commit.html
···
<pre class="overflow-auto">
{{- range .TextFragments -}}
<div class="bg-gray-100 text-gray-500 select-none">{{ .Header }}</div>
-
{{- range .Lines -}}
{{- if eq .Op.String "+" -}}
<div class="bg-green-100 text-green-700"><span class="select-none">{{ .Op.String }}</span><span>{{ .Line }}</span></div>
···
<pre class="overflow-auto">
{{- range .TextFragments -}}
<div class="bg-gray-100 text-gray-500 select-none">{{ .Header }}</div>
{{- range .Lines -}}
{{- if eq .Op.String "+" -}}
<div class="bg-green-100 text-green-700"><span class="select-none">{{ .Op.String }}</span><span>{{ .Line }}</span></div>
+4 -2
appview/pages/templates/repo/index.html
···
onchange="window.location.href = '/{{ .RepoInfo.FullName }}/tree/' + this.value"
class="p-1 border border-gray-500 bg-white"
>
-
<optgroup label="branches" class="uppercase bold text-sm">
{{ range .Branches }}
<option
value="{{ .Reference.Name }}"
···
</option>
{{ end }}
</optgroup>
-
<optgroup label="tags" class="uppercase bold text-sm">
{{ range .Tags }}
<option
value="{{ .Reference.Name }}"
···
>
{{ .Reference.Name }}
</option>
{{ end }}
</optgroup>
</select>
···
onchange="window.location.href = '/{{ .RepoInfo.FullName }}/tree/' + this.value"
class="p-1 border border-gray-500 bg-white"
>
+
<optgroup label="branches" class="bold text-sm">
{{ range .Branches }}
<option
value="{{ .Reference.Name }}"
···
</option>
{{ end }}
</optgroup>
+
<optgroup label="tags" class="bold text-sm">
{{ range .Tags }}
<option
value="{{ .Reference.Name }}"
···
>
{{ .Reference.Name }}
</option>
+
{{ else }}
+
<option class="py-1" disabled>no tags found</option>
{{ end }}
</optgroup>
</select>
-1
appview/state/middleware.go
···
start := time.Now()
didOrHandle := chi.URLParam(req, "user")
-
log.Println(didOrHandle)
id, err := s.resolver.ResolveIdent(req.Context(), didOrHandle)
if err != nil {
// invalid did or handle
···
start := time.Now()
didOrHandle := chi.URLParam(req, "user")
id, err := s.resolver.ResolveIdent(req.Context(), didOrHandle)
if err != nil {
// invalid did or handle
-4
appview/state/repo.go
···
return
}
-
log.Println(resp.Status, result)
-
user := s.auth.GetUser(r)
s.pages.RepoIndexPage(w, pages.RepoIndexParams{
LoggedInUser: user,
···
log.Println("failed to parse response:", err)
return
}
-
-
log.Println(result)
user := s.auth.GetUser(r)
s.pages.RepoBranches(w, pages.RepoBranchesParams{
···
return
}
user := s.auth.GetUser(r)
s.pages.RepoIndexPage(w, pages.RepoIndexParams{
LoggedInUser: user,
···
log.Println("failed to parse response:", err)
return
}
user := s.auth.GetUser(r)
s.pages.RepoBranches(w, pages.RepoBranchesParams{
+1 -4
knotserver/git/diff.go
···
ndiff.IsDelete = d.IsDelete
for _, tf := range d.TextFragments {
-
ndiff.TextFragments = append(ndiff.TextFragments, types.TextFragment{
-
Header: tf.Header(),
-
Lines: tf.Lines,
-
})
for _, l := range tf.Lines {
switch l.Op {
case gitdiff.OpAdd:
···
ndiff.IsDelete = d.IsDelete
for _, tf := range d.TextFragments {
+
ndiff.TextFragments = append(ndiff.TextFragments, *tf)
for _, l := range tf.Lines {
switch l.Op {
case gitdiff.OpAdd:
+4 -4
types/diff.go
···
Old string `json:"old"`
New string `json:"new"`
} `json:"name"`
-
TextFragments []TextFragment `json:"text_fragments"`
-
IsBinary bool `json:"is_binary"`
-
IsNew bool `json:"is_new"`
-
IsDelete bool `json:"is_delete"`
}
// A nicer git diff representation.
···
Old string `json:"old"`
New string `json:"new"`
} `json:"name"`
+
TextFragments []gitdiff.TextFragment `json:"text_fragments"`
+
IsBinary bool `json:"is_binary"`
+
IsNew bool `json:"is_new"`
+
IsDelete bool `json:"is_delete"`
}
// A nicer git diff representation.