+8
-7
appview/pages/pages.go
+8
-7
appview/pages/pages.go
···
69
69
}
70
70
71
71
func (p *Pages) Login(w io.Writer, params LoginParams) error {
72
-
return p.t["user/login"].ExecuteTemplate(w, "layouts/base", params)
72
+
return p.execute("user/login", w, params)
73
73
}
74
74
75
75
type TimelineParams struct {
76
-
User *auth.User
76
+
LoggedInUser *auth.User
77
77
}
78
78
79
79
func (p *Pages) Timeline(w io.Writer, params TimelineParams) error {
···
81
81
}
82
82
83
83
type SettingsParams struct {
84
-
User *auth.User
85
-
PubKeys []db.PublicKey
84
+
LoggedInUser *auth.User
85
+
PubKeys []db.PublicKey
86
86
}
87
87
88
88
func (p *Pages) Settings(w io.Writer, params SettingsParams) error {
···
90
90
}
91
91
92
92
type KnotsParams struct {
93
-
User *auth.User
93
+
LoggedInUser *auth.User
94
94
Registrations []db.Registration
95
95
}
96
96
···
99
99
}
100
100
101
101
type KnotParams struct {
102
-
User *auth.User
102
+
LoggedInUser *auth.User
103
103
Registration *db.Registration
104
104
Members []string
105
105
IsOwner bool
···
110
110
}
111
111
112
112
type NewRepoParams struct {
113
-
User *auth.User
113
+
LoggedInUser *auth.User
114
114
}
115
115
116
116
func (p *Pages) NewRepo(w io.Writer, params NewRepoParams) error {
···
153
153
}
154
154
155
155
func (p *Pages) RepoIndexPage(w io.Writer, params RepoIndexParams) error {
156
+
156
157
return p.execute("repo/index", w, params)
157
158
}
158
159
+1
-3
appview/pages/templates/knot.html
+1
-3
appview/pages/templates/knot.html
···
1
1
{{define "title"}}{{ .Registration.Domain }}{{end}}
2
2
3
3
{{define "content"}}
4
-
<a href="/">back to timeline</a>
5
-
<a href="/knots">back to all knots</a>
6
4
<h1>{{.Registration.Domain}}</h1>
7
5
<p>
8
6
<code>
9
7
opened by: {{.Registration.ByDid}}
10
-
{{ if eq $.User.Did $.Registration.ByDid }}
8
+
{{ if eq $.LoggedInUser.Did $.Registration.ByDid }}
11
9
(you)
12
10
{{ end }}
13
11
</code><br>
-1
appview/pages/templates/knots.html
-1
appview/pages/templates/knots.html
+5
appview/pages/templates/layouts/base.html
+5
appview/pages/templates/layouts/base.html
+18
appview/pages/templates/layouts/topbar.html
+18
appview/pages/templates/layouts/topbar.html
···
1
+
{{ define "layouts/topbar" }}
2
+
3
+
{{ with .LoggedInUser }}
4
+
<nav>
5
+
<a href="/settings">settings</a> ·
6
+
<a href="/knots">knots</a> ·
7
+
<a href="/repo/new">add repos</a> ·
8
+
{{ if .Handle }}
9
+
<a href="/@{{ .Handle }}">my profile</a>
10
+
{{ else }}
11
+
<a href="/{{ .Did }}">my profile</a>
12
+
{{ end }}
13
+
</nav>
14
+
{{ else }}
15
+
<button onclick="window.location.href='/login'">login</button>
16
+
{{ end }}
17
+
18
+
{{ end }}
+1
-2
appview/pages/templates/repo/branches.html
+1
-2
appview/pages/templates/repo/branches.html
+1
-1
appview/pages/templates/repo/index.html
+1
-1
appview/pages/templates/repo/index.html
+2
-2
appview/pages/templates/repo/log.html
+2
-2
appview/pages/templates/repo/log.html
···
1
-
{{define "title"}} log | {{ .RepoInfo.OwnerWithAt }} / {{ .RepoInfo.Name }} {{end}}
1
+
{{define "title"}} log | {{ .RepoInfo.FullName }} {{end}}
2
2
3
3
{{define "content"}}
4
4
5
5
<h1>
6
-
log | {{ .RepoInfo.OwnerWithAt }} / {{ .RepoInfo.Name }}
6
+
log | {{ .RepoInfo.FullName }}
7
7
</h1>
8
8
<main>
9
9
<div class="log">
+3
-4
appview/pages/templates/settings/keys.html
+3
-4
appview/pages/templates/settings/keys.html
···
1
1
{{define "title"}}settings{{end}}
2
2
3
3
{{define "content"}}
4
-
<a href="/">back to timeline</a>
5
4
<h1>settings</h1>
6
5
7
6
<h2>profile</h2>
8
-
<p><strong>handle:</strong> {{.User.Handle}}</p>
9
-
<p><strong>did:</strong> {{.User.Did}}</p>
10
-
<p><strong>pds:</strong> {{.User.Pds}}</p>
7
+
<p><strong>handle:</strong> {{.LoggedInUser.Handle}}</p>
8
+
<p><strong>did:</strong> {{.LoggedInUser.Did}}</p>
9
+
<p><strong>pds:</strong> {{.LoggedInUser.Pds}}</p>
11
10
12
11
<h2>ssh keys</h2>
13
12
<form hx-put="/settings/keys">
-11
appview/pages/templates/timeline.html
-11
appview/pages/templates/timeline.html
···
2
2
3
3
{{define "content"}}
4
4
<h1>timeline</h1>
5
-
6
-
{{ if .User }}
7
-
<p>logged in as {{ .User.Handle }}</p>
8
-
<a href="/settings">settings</a>
9
-
<a href="/knots">knots</a>
10
-
<a href="/repo/new">add repos</a>
11
-
<a href="/@{{ .User.Handle }}">my profile</a>
12
-
{{ else }}
13
-
<p>not logged in</p>
14
-
<a href="/login">login</a>
15
-
{{ end }}
16
5
{{end}}
+3
-1
appview/pages/templates/user/login.html
+3
-1
appview/pages/templates/user/login.html
-1
appview/pages/templates/user/profile.html
-1
appview/pages/templates/user/profile.html
+6
-6
appview/state/state.go
+6
-6
appview/state/state.go
···
113
113
func (s *State) Timeline(w http.ResponseWriter, r *http.Request) {
114
114
user := s.auth.GetUser(r)
115
115
s.pages.Timeline(w, pages.TimelineParams{
116
-
User: user,
116
+
LoggedInUser: user,
117
117
})
118
118
return
119
119
}
···
163
163
}
164
164
165
165
s.pages.Settings(w, pages.SettingsParams{
166
-
User: user,
167
-
PubKeys: pubKeys,
166
+
LoggedInUser: user,
167
+
PubKeys: pubKeys,
168
168
})
169
169
}
170
170
···
366
366
isOwner := err == nil && ok
367
367
368
368
p := pages.KnotParams{
369
-
User: user,
369
+
LoggedInUser: user,
370
370
Registration: reg,
371
371
Members: members,
372
372
IsOwner: isOwner,
···
385
385
}
386
386
387
387
s.pages.Knots(w, pages.KnotsParams{
388
-
User: user,
388
+
LoggedInUser: user,
389
389
Registrations: registrations,
390
390
})
391
391
}
···
490
490
switch r.Method {
491
491
case http.MethodGet:
492
492
s.pages.NewRepo(w, pages.NewRepoParams{
493
-
User: s.auth.GetUser(r),
493
+
LoggedInUser: s.auth.GetUser(r),
494
494
})
495
495
case http.MethodPost:
496
496
user := s.auth.GetUser(r)