{{ define "title" }}{{ or .UserHandle .UserDid }}{{ end }} {{ define "content" }}
{{ block "profileCard" . }}{{ end }}
{{ block "ownRepos" . }}{{ end }} {{ block "collaboratingRepos" . }}{{ end }}
{{ block "profileTimeline2" . }}{{ end }}
{{ end }} {{ define "profileTimeline2" }}

ACTIVITY

{{ with .ProfileTimeline }} {{ range $idx, $byMonth := .ByMonth }} {{ with $byMonth }}
{{ if eq $idx 0 }}

This month

{{ else }} {{ $s := "s" }} {{ if eq $idx 1 }} {{ $s = "" }} {{ end }}

{{$idx}} month{{$s}} ago

{{ end }}
{{ block "repoEvents" (list .RepoEvents $.DidHandleMap) }} {{ end }} {{ block "issueEvents" (list .IssueEvents $.DidHandleMap) }} {{ end }} {{ block "pullEvents" (list .PullEvents $.DidHandleMap) }} {{ end }}
{{ end }} {{ else }}

This user does not have any activity yet.

{{ end }} {{ end }}
{{ end }} {{ define "repoEvents" }} {{ $items := index . 0 }} {{ $handleMap := index . 1 }} {{ if gt (len $items) 0 }}
{{ i "unfold-vertical" "w-4 h-4" }} created {{ len $items }} repositories
{{ range $items }}
{{ if .Source }} {{ i "git-fork" "w-4 h-4" }} {{ else }} {{ i "book-plus" "w-4 h-4" }} {{ end }} {{- .Repo.Name -}}
{{ end }}
{{ end }} {{ end }} {{ define "issueEvents" }} {{ $i := index . 0 }} {{ $items := $i.Items }} {{ $stats := $i.Stats }} {{ $handleMap := index . 1 }} {{ if gt (len $items) 0 }}
{{ i "unfold-vertical" "w-4 h-4" }} created {{ len $items }} issues {{$stats.Open}} open {{$stats.Closed}} closed
{{ range $items }} {{ $repoOwner := index $handleMap .Metadata.Repo.Did }} {{ $repoName := .Metadata.Repo.Name }} {{ $repoUrl := printf "%s/%s" $repoOwner $repoName }}
{{ if .Open }} {{ i "circle-dot" "w-4 h-4" }} {{ else }} {{ i "ban" "w-4 h-4" }} {{ end }} #{{ .IssueId }} {{ .Title -}} on {{$repoUrl}}

{{ end }}
{{ end }} {{ end }} {{ define "pullEvents" }} {{ $i := index . 0 }} {{ $items := $i.Items }} {{ $stats := $i.Stats }} {{ $handleMap := index . 1 }} {{ if gt (len $items) 0 }}
{{ i "unfold-vertical" "w-4 h-4" }} created {{ len $items }} pull requests {{$stats.Open}} open {{$stats.Merged}} merged {{$stats.Closed}} closed
{{ range $items }} {{ $repoOwner := index $handleMap .Repo.Did }} {{ $repoName := .Repo.Name }} {{ $repoUrl := printf "%s/%s" $repoOwner $repoName }}
{{ if .State.IsOpen }} {{ i "git-pull-request" "w-4 h-4" }} {{ else if .State.IsMerged }} {{ i "git-merge" "w-4 h-4" }} {{ else }} {{ i "git-pull-request-closed" "w-4 h-4" }} {{ end }} #{{ .PullId }} {{ .Title -}} on {{$repoUrl}}

{{ end }}
{{ end }} {{ end }} {{ define "profileTimeline" }}

ACTIVITY

{{ range .ProfileTimeline }} {{ if eq .Type "issue" }}
{{ $textColor := "text-gray-800 dark:text-gray-400" }} {{ $icon := "ban" }} {{ if .Issue.Open }} {{ $textColor = "text-green-600 dark:text-green-500" }} {{ $icon = "circle-dot" }} {{ end }}
{{ i $icon "w-5 h-5" }}

{{ .Issue.Title }} #{{ .Issue.IssueId }} on {{ index $.DidHandleMap .Repo.Did }}/{{ .Repo.Name }}

{{ else if eq .Type "pull" }}
{{ $textColor := "text-gray-800 dark:text-gray-400" }} {{ $icon := "git-pull-request-closed" }} {{ if .Pull.State.IsOpen }} {{ $textColor = "text-green-600 dark:text-green-500" }} {{ $icon = "git-pull-request" }} {{ else if .Pull.State.IsMerged }} {{ $textColor = "text-purple-600 dark:text-purple-500" }} {{ $icon = "git-merge" }} {{ end }}
{{ i $icon "w-5 h-5" }}

{{ .Pull.Title }} #{{ .Pull.PullId }} on {{ index $.DidHandleMap .Repo.Did }}/{{ .Repo.Name }}

{{ else if eq .Type "repo" }}
{{ if .Source }}
{{ i "git-fork" "w-5 h-5" }}
{{ else }}
{{ i "book-plus" "w-5 h-5" }}
{{ end }}

{{ if .Source }} forked {{ index $.DidHandleMap .Source.Did }}/{{ .Source.Name }} to {{ .Repo.Name }} {{ else }} created {{ .Repo.Name }} {{ end }}

{{ end }} {{ else }}

This user does not have any activity yet.

{{ end }}
{{ end }} {{ define "profileCard" }}
{{ if .AvatarUri }} {{ end }}

{{ didOrHandle .UserDid .UserHandle }}

{{ .ProfileStats.Followers }} followers
{{ .ProfileStats.Following }} following
{{ if ne .FollowStatus.String "IsSelf" }} {{ template "fragments/follow" . }} {{ end }}
{{ end }} {{ define "ownRepos" }}

REPOS

{{ range .Repos }}
{{ if .Description }}
{{ .Description }}
{{ end }}
{{ if .RepoStats.StarCount }}
{{ i "star" "w-3 h-3 fill-current" }} {{ .RepoStats.StarCount }}
{{ end }}
{{ else }}

This user does not have any repos yet.

{{ end }}

COLLABORATING ON

{{ range .CollaboratingRepos }}
{{ if .Description }}
{{ .Description }}
{{ end }}
{{ if .RepoStats.StarCount }}
{{ i "star" "w-3 h-3 fill-current" }} {{ .RepoStats.StarCount }}
{{ end }}
{{ else }}

This user is not collaborating.

{{ end }}
{{ end }}