forked from tangled.org/core
Monorepo for Tangled — https://tangled.org

improve commit page styles

Changed files
+57 -45
appview
jetstream
+4 -2
appview/pages/pages.go
···
"splitN": func(s, sep string, n int) []string {
return strings.SplitN(s, sep, n)
},
-
"unescapeHtml": func(s string) template.HTML {
-
return template.HTML(s)
+
"escapeHtml": func(s string) string {
+
return template.HTMLEscapeString(s)
},
"nl2br": func(text string) template.HTML {
return template.HTML(strings.Replace(template.HTMLEscapeString(text), "\n", "<br>", -1))
···
type RepoCommitParams struct {
LoggedInUser *auth.User
RepoInfo RepoInfo
+
Active string
types.RepoCommitResponse
}
func (p *Pages) RepoCommit(w io.Writer, params RepoCommitParams) error {
+
params.Active = "overview"
return p.executeRepo("repo/commit", w, params)
}
+5 -5
appview/pages/templates/layouts/base.html
···
<title>{{ block "title" . }}tangled{{ end }}</title>
</head>
<body class="container mx-auto px-10">
-
<header>
-
{{ block "topbar" . }}
-
{{ template "layouts/topbar" . }}
-
{{ end }}
-
</header>
+
<header>
+
{{ block "topbar" . }}
+
{{ template "layouts/topbar" . }}
+
{{ end }}
+
</header>
<main class="content">{{ block "content" . }}{{ end }}</main>
<script src="/static/lucide.min.js"></script>
<script>
+5 -2
appview/pages/templates/layouts/repobase.html
···
{{ define "content" }}
<section id="repo-header" class="mb-4">
-
<span class="text-xl">{{ .RepoInfo.FullName }}</span>
-
<br/>
+
<p class="text-xl">
+
<a href="/{{ .RepoInfo.OwnerWithAt }}" class="no-underline hover:underline">{{ .RepoInfo.OwnerWithAt }}</a>
+
/
+
<a href="/{{ .RepoInfo.FullName }}" class="no-underline hover:underline">{{ .RepoInfo.Name }}</a>
+
</p>
<span>
{{ if .RepoInfo.Description }}
{{ .RepoInfo.Description }}
+1 -1
appview/pages/templates/repo/blob.html
···
{{ if .IsBinary }}<p class="text-center text-gray-400">This is a binary file and will not be displayed.</p>{{ else }}
<pre class="font-mono text-sm overflow-auto relative text-ellipsis"><code>{{ range $idx, $line := $lines }}<span class="flex">
<span class="{{ $code_number_style }}" style="min-width: {{$tot_chars}}ch;">{{ add $idx 1 }}</span>
-
<span class="whitespace-pre">{{ unescapeHtml $line }}</span></span>{{ else }}<em class="text-gray-400">this file is empty</em>{{ end }}</code></pre>{{ end}}
+
<span class="whitespace-pre">{{ escapeHtml $line }}</span></span>{{ else }}<em class="text-gray-400">this file is empty</em>{{ end }}</code></pre>{{ end}}
{{ end }}
+33 -33
appview/pages/templates/repo/commit.html
···
{{ $diff := .Diff.Diff }}
<section class="commit">
-
<pre>{{- $commit.Message -}}</pre>
-
<div class="commit-info">
-
{{ $commit.Author.Name }} <a href="mailto:{{ $commit.Author.Email }}" class="commit-email">{{ $commit.Author.Email}}</a>
-
<div>{{ $commit.Author.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}</div>
+
<div id="commit-message">
+
{{ $messageParts := splitN $commit.Message "\n\n" 2 }}
+
<div>
+
{{ index $messageParts 0 }}
+
{{ if gt (len $messageParts) 1 }}
+
<p class="mt-1 cursor-text pb-2">{{ nl2br (unwrapText (index $messageParts 1)) }}</p>
+
{{ end }}
+
</div>
</div>
-
<div>
-
<strong>commit</strong>
-
<p><a href="/{{ $repo }}/commit/{{ $commit.This }}" class="commit-hash">
-
{{ slice $commit.This 0 8 }}
-
</a>
+
<p class="text-sm text-gray-500">
+
<a href="mailto:{{ $commit.Author.Email }}" class="no-underline hover:underline text-gray-500">
+
{{ $commit.Author.Name }}
+
</a>
+
&nbsp;·&nbsp;
+
{{ timeFmt $commit.Author.When }}
+
&nbsp;·&nbsp;
+
<span class="font-mono">{{ $stat.FilesChanged }}</span> files <span class="font-mono">(+{{ $stat.Insertions }}, -{{ $stat.Deletions }})</span>
+
&nbsp;·&nbsp;
+
<a href="/{{ $repo }}/commit/{{ $commit.This }}" class="no-underline hover:underline text-gray-500">
+
{{ slice $commit.This 0 8 }}
+
</a>
+
{{ if $commit.Parent }}
+
&lt;--
+
<a href="/{{ $repo }}/commit/{{ $commit.Parent }}" class="no-underline hover:underline text-gray-500">
+
{{ slice $commit.Parent 0 8 }}
+
</a>
+
{{ end }}
</p>
-
</div>
-
{{ if $commit.Parent }}
-
<div>
-
<strong>parent</strong>
-
<p><a href="/{{ $repo }}/commit/{{ $commit.Parent }}" class="commit-hash">
-
{{ slice $commit.Parent 0 8 }}
-
</a></p>
-
</div>
-
-
{{ end }}
<div class="diff-stat">
-
<div>
-
{{ $stat.FilesChanged }} files changed,
-
{{ $stat.Insertions }} insertions(+),
-
{{ $stat.Deletions }} deletions(-)
-
</div>
-
<div>
-
<br>
-
<strong>jump to</strong>
-
{{ range $diff }}
-
<ul>
+
<br>
+
<strong>jump to</strong>
+
{{ range $diff }}
+
<ul>
<li><a href="#{{ .Name.New }}">{{ .Name.New }}</a></li>
-
</ul>
-
{{ end }}
-
</div>
+
</ul>
+
{{ end }}
</div>
</section>
<section>
···
{{ if .IsBinary }}
<p>Not showing binary file.</p>
{{ else }}
-
<pre>
+
<pre class="overflow-auto">
{{- range .TextFragments -}}
<p>{{- .Header -}}</p>
{{- range .Lines -}}
+1 -1
appview/pages/templates/repo/index.html
···
<div class="text-base cursor-pointer">
<div>
<div class="flex items-center gap-1">
-
<a href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}" class="inline no-underline hover:underline hover:text-sky-400">{{ index $messageParts 0 }}</a>
+
<a href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}" class="inline no-underline hover:underline">{{ index $messageParts 0 }}</a>
{{ if gt (len $messageParts) 1 }}
<button class="text-sm inline rounded-sm bg-gray-300 text-gray-700 px-1 w-fit hover:bg-gray-400"
hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')">&hellip;</button>
+8 -1
jetstream/jetstream.go
···
}
func (j *JetstreamClient) AddDid(did string) {
+
if did == "" {
+
return
+
}
j.mu.Lock()
j.cfg.WantedDids = append(j.cfg.WantedDids, did)
j.mu.Unlock()
···
func (j *JetstreamClient) UpdateDids(dids []string) {
j.mu.Lock()
-
j.cfg.WantedDids = dids
+
for _, did := range dids {
+
if did != "" {
+
}
+
j.cfg.WantedDids = append(j.cfg.WantedDids, did)
+
}
j.mu.Unlock()
j.reconnectCh <- struct{}{}
}