~bigbes/sr-ht-compare

04b591cd0be655f51284c69022c8854effaf9c7e — bigbes 11 days ago 981e4f7
web: git.sr.ht-style dashboard and unified nav brand

Adopt the family look the dolt service already has. The nav brand
becomes circle icon + site name + red service label (dropping the
hub-origin variant), matching every other service on the instance. The
logged-in index turns into the two-column dashboard: a sidebar with the
service blurb and the jump form, and the repositories as shared-theme
event-list cards — name, visibility as small muted text (non-public
only, lowercase), description underneath. The big in-page h2 lives on
only for anonymous visitors, where the nav has no user context yet.
3 files changed, 38 insertions(+), 23 deletions(-)

M web/templates/index.html
M web/templates/layout.html
M web/web_test.go
M web/templates/index.html => web/templates/index.html +35 -15
@@ 1,28 1,43 @@
{{define "content"}}
{{if .Data.LoggedIn}}
<div class="row">
  <div class="col-md-12">
    <h2>{{.SiteName}} <span class="text-danger">compare</span></h2>
  <div class="col-md-4">
    <p>
      Compare two references — branches, tags or commits — of any git repository
      on this instance, and review the diff file by file.
    </p>
    <form method="GET" action="/jump">
      <div class="form-group">
        <label class="sr-only" for="owner">Owner</label>
        <input class="form-control" type="text" id="owner" name="owner"
               placeholder="~owner" autocomplete="off">
      </div>
      <div class="form-group">
        <label class="sr-only" for="repo">Repository</label>
        <input class="form-control" type="text" id="repo" name="repo"
               placeholder="repo" autocomplete="off">
      </div>
      <button class="btn btn-primary btn-block" type="submit">Compare</button>
    </form>
  </div>
</div>

{{if .Data.LoggedIn}}
<div class="row">
  <div class="col-md-12">
    <h3>Your repositories</h3>
  <div class="col-md-8">
    <hr class="d-md-none" />
    {{if .Data.Repos}}
    <ul class="list-unstyled">
    <div class="event-list">
      {{range .Data.Repos}}
      <li>
        <a href="/~{{$.Username}}/{{.Name}}"><strong>~{{$.Username}}/{{.Name}}</strong></a>
        <span class="badge badge-secondary">{{.Visibility}}</span>
        {{if .Description}}<span class="text-muted"> — {{.Description}}</span>{{end}}
      </li>
      <div class="event">
        <h4>
          <a href="/~{{$.Username}}/{{.Name}}">~{{$.Username}}/{{.Name}}</a>
          {{if ne .Visibility "PUBLIC"}}
          <small class="pull-right">{{if eq .Visibility "UNLISTED"}}unlisted{{else}}private{{end}}</small>
          {{end}}
        </h4>
        {{if .Description}}
        <p>{{.Description}}</p>
        {{end}}
      </div>
      {{end}}
    </ul>
    </div>
    {{else}}
    <p class="text-muted">You have no repositories yet.</p>
    {{end}}


@@ 31,6 46,11 @@
{{else}}
<div class="row">
  <div class="col-md-12">
    <h2>{{.SiteName}} <span class="text-danger">compare</span></h2>
    <p>
      Compare two references — branches, tags or commits — of any git repository
      on this instance, and review the diff file by file.
    </p>
    <p>
      <a href="{{.LoginURL}}" rel="nofollow">Log in</a> to list your own
      repositories, or jump directly to any repository below.

M web/templates/layout.html => web/templates/layout.html +1 -6
@@ 43,18 43,13 @@
    </div>
    {{end}}
    <nav class="container navbar navbar-light navbar-expand-sm">
      {{if .HubOrigin}}
      <span class="navbar-brand">
        <a href="{{.HubOrigin}}">{{.SiteName}}</a>
      </span>
      {{else}}
      <span class="navbar-brand">
        <span class="icon icon-circle" aria-hidden="true"><svg width="22" height="22" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm0 448c-110.5 0-200-89.5-200-200S145.5 56 256 56s200 89.5 200 200-89.5 200-200 200z"/></svg></span>
        <a class="navbar-brand" href="/">
          {{.SiteName}}
          <span class="text-danger">compare</span>
        </a>
      </span>
      {{end}}
      <ul class="navbar-nav">
        {{if .Username}}
        {{range .Nav}}

M web/web_test.go => web/web_test.go +2 -2
@@ 381,8 381,8 @@ func TestIndexLoggedIn(t *testing.T) {
	if !strings.Contains(body, "/~bigbes/demo") {
		t.Fatal("logged-in index missing repo link from MyRepos")
	}
	if !strings.Contains(body, "PRIVATE") {
		t.Fatal("logged-in index missing visibility badge")
	if !strings.Contains(body, `<small class="pull-right">private</small>`) {
		t.Fatal("logged-in index missing visibility label on the event card")
	}
}