2024-01-17 03:37:25 +00:00
|
|
|
package html
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
import "github.com/dustin/go-humanize"
|
|
|
|
import "go.jolheiser.com/ugit/internal/git"
|
|
|
|
|
|
|
|
type RepoCommitContext struct{
|
|
|
|
BaseContext
|
|
|
|
RepoHeaderComponentContext
|
|
|
|
Commit git.Commit
|
|
|
|
}
|
|
|
|
|
|
|
|
templ RepoCommit(rcc RepoCommitContext) {
|
|
|
|
@base(rcc.BaseContext) {
|
|
|
|
@repoHeaderComponent(rcc.RepoHeaderComponentContext)
|
|
|
|
<div class="text-text mt-5"><a class="underline decoration-text/50 decoration-dashed hover:decoration-solid" href={ templ.SafeURL(fmt.Sprintf("/%s/tree/%s/", rcc.RepoHeaderComponentContext.Name, rcc.Commit.SHA)) }>tree</a>{ " " }<a class="underline decoration-text/50 decoration-dashed hover:decoration-solid" href={ templ.SafeURL(fmt.Sprintf("/%s/log/%s", rcc.RepoHeaderComponentContext.Name, rcc.Commit.SHA)) }>log</a>{ " " }<a class="underline decoration-text/50 decoration-dashed hover:decoration-solid" href={ templ.SafeURL(fmt.Sprintf("/%s/commit/%s.patch", rcc.RepoHeaderComponentContext.Name, rcc.Commit.SHA)) }>patch</a></div>
|
2024-03-01 21:34:50 +00:00
|
|
|
<div class="text-text whitespace-pre mt-5 p-3 bg-base rounded">{ rcc.Commit.Message }</div>
|
2024-01-17 03:37:25 +00:00
|
|
|
<div class="text-text mt-3">
|
|
|
|
<div>{ rcc.Commit.Author }{ " " }<a class="underline decoration-text/50 decoration-dashed hover:decoration-solid" href={ templ.SafeURL(fmt.Sprintf("mailto:%s", rcc.Commit.Email)) }>{ fmt.Sprintf("<%s>", rcc.Commit.Email) }</a></div>
|
|
|
|
<div title={ rcc.Commit.When.Format("01/02/2006 03:04:05 PM") }>{ humanize.Time(rcc.Commit.When) }</div>
|
|
|
|
</div>
|
|
|
|
<div class="text-text mt-5">{ fmt.Sprintf("%d changed files, %d additions(+), %d deletions(-)", rcc.Commit.Stats.Changed, rcc.Commit.Stats.Additions, rcc.Commit.Stats.Deletions) }</div>
|
|
|
|
for _, file := range rcc.Commit.Files {
|
2024-01-18 04:34:18 +00:00
|
|
|
<div class="text-text mt-5">
|
|
|
|
<span class="text-text/80" title={ file.Action }>{ string(file.Action[0]) }</span>
|
|
|
|
{ " " }
|
|
|
|
if file.From.Path != "" {
|
|
|
|
<a class="underline decoration-text/50 decoration-dashed hover:decoration-solid" href={ templ.SafeURL(fmt.Sprintf("/%s/tree/%s/%s", rcc.RepoHeaderComponentContext.Name, file.From.Commit, file.From.Path)) }>{ file.From.Path }</a>
|
|
|
|
}
|
|
|
|
if file.From.Path != "" && file.To.Path != "" {
|
|
|
|
{ " -> " }
|
|
|
|
}
|
|
|
|
if file.To.Path != "" {
|
|
|
|
<a class="underline decoration-text/50 decoration-dashed hover:decoration-solid" href={ templ.SafeURL(fmt.Sprintf("/%s/tree/%s/%s", rcc.RepoHeaderComponentContext.Name, file.To.Commit, file.To.Path)) }>{ file.To.Path }</a>
|
|
|
|
}
|
|
|
|
</div>
|
2024-03-01 17:58:05 +00:00
|
|
|
<div class="whitespace-pre code">@templ.Raw(file.Patch)</div>
|
2024-01-17 03:37:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|