diff --git a/appview/db/profile.go b/appview/db/profile.go index 894d890b..7de3bfa5 100644 --- a/appview/db/profile.go +++ b/appview/db/profile.go @@ -22,6 +22,20 @@ type ProfileTimeline struct { ByMonth []ByMonth } +func (p *ProfileTimeline) IsEmpty() bool { + if p == nil { + return true + } + + for _, m := range p.ByMonth { + if !m.IsEmpty() { + return false + } + } + + return true +} + type ByMonth struct { RepoEvents []RepoEvent IssueEvents IssueEvents diff --git a/appview/db/punchcard.go b/appview/db/punchcard.go index 62a386ee..91dde121 100644 --- a/appview/db/punchcard.go +++ b/appview/db/punchcard.go @@ -29,8 +29,8 @@ type Punchcard struct { Punches []Punch } -func MakePunchcard(e Execer, filters ...filter) (Punchcard, error) { - punchcard := Punchcard{} +func MakePunchcard(e Execer, filters ...filter) (*Punchcard, error) { + punchcard := &Punchcard{} now := time.Now() startOfYear := time.Date(now.Year(), 1, 1, 0, 0, 0, 0, time.UTC) endOfYear := time.Date(now.Year(), 12, 31, 0, 0, 0, 0, time.UTC) @@ -63,7 +63,7 @@ func MakePunchcard(e Execer, filters ...filter) (Punchcard, error) { rows, err := e.Query(query, args...) if err != nil { - return punchcard, err + return nil, err } defer rows.Close() @@ -72,7 +72,7 @@ func MakePunchcard(e Execer, filters ...filter) (Punchcard, error) { var date string var count sql.NullInt64 if err := rows.Scan(&date, &count); err != nil { - return punchcard, err + return nil, err } punch.Date, err = time.Parse(time.DateOnly, date) diff --git a/appview/pages/pages.go b/appview/pages/pages.go index e9abc83f..f43d007c 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -409,21 +409,40 @@ func (p *Pages) ForkRepo(w io.Writer, params ForkRepoParams) error { return p.execute("repo/fork", w, params) } -type ProfileHomePageParams struct { - LoggedInUser *oauth.User - Repos []db.Repo - CollaboratingRepos []db.Repo - ProfileTimeline *db.ProfileTimeline - Card ProfileCard - Punchcard db.Punchcard -} - type ProfileCard struct { UserDid string UserHandle string FollowStatus db.FollowStatus FollowersCount int FollowingCount int + Punchcard *db.Punchcard + Profile *db.Profile + Active string +} + +func (p *ProfileCard) GetTabs() [][]string { + tabs := [][]string{ + {"overview", "overview", "square-chart-gantt"}, + {"repos", "repos", "book-marked"}, + {"starred", "starred", "star"}, + } + + return tabs +} + +type ProfileOverviewParams struct { + LoggedInUser *oauth.User + Repos []db.Repo + CollaboratingRepos []db.Repo + ProfileTimeline *db.ProfileTimeline + Card *ProfileCard + Active string +} + +func (p *Pages) ProfileOverview(w io.Writer, params ProfileOverviewParams) error { + params.Active = "overview" + return p.executeProfile("user/overview", w, params) +} Profile *db.Profile } diff --git a/appview/pages/templates/user/fragments/editBio.html b/appview/pages/templates/user/fragments/editBio.html index 042acd94..7c2730c6 100644 --- a/appview/pages/templates/user/fragments/editBio.html +++ b/appview/pages/templates/user/fragments/editBio.html @@ -13,7 +13,7 @@ diff --git a/appview/pages/templates/user/fragments/profileCard.html b/appview/pages/templates/user/fragments/profileCard.html index ced8fd1c..eae96f60 100644 --- a/appview/pages/templates/user/fragments/profileCard.html +++ b/appview/pages/templates/user/fragments/profileCard.html @@ -1,6 +1,5 @@ {{ define "user/fragments/profileCard" }} {{ $userIdent := didOrHandle .UserDid .UserHandle }} -
ACTIVITY
+ACTIVITY
This user does not have any activity yet.
+ {{ end }} + {{ with .ProfileTimeline }} {{ range $idx, $byMonth := .ByMonth }} {{ with $byMonth }} -{{$idx}} month{{$s}} ago
- {{ end }} + {{ if not .IsEmpty }} ++ {{ if eq $idx 0 }} + this month + {{ else }} + {{$idx}} month{{if ne $idx 1}}s{{end}} ago + {{ end }} +
- {{ if .IsEmpty }} -This user does not have any activity yet.
{{ end }} {{ end }}This user does not have any repos yet.
+This user does not have any pinned repos.
{{ end }}COLLABORATING ON
+COLLABORATING ON
This user is not collaborating.
{{ end }} @@ -276,43 +256,3 @@ {{ end }} {{ end }} -{{ define "punchcard" }} - {{ $now := now }} -- PUNCHCARD - - {{ .Total | int64 | commaFmt }} commits - -
-