152 lines
7.5 KiB
Cheetah
152 lines
7.5 KiB
Cheetah
<table id="repo-files-table" class="ui single line table">
|
|
<thead>
|
|
<tr class="commit-list">
|
|
<th>
|
|
{{if .LatestCommitUser}}
|
|
{{ctx.AvatarUtils .LatestCommitUser 24}}
|
|
{{if .LatestCommitUser.FullName}}
|
|
<a href="{{AppSubUrl}}/{{.LatestCommitUser.Name}}"><strong>{{.LatestCommitUser.FullName}}</strong></a>
|
|
{{else}}
|
|
<a href="{{AppSubUrl}}/{{.LatestCommitUser.Name}}"><strong>{{if .LatestCommit.Author}}{{.LatestCommit.Author.Name}}{{else}}{{.LatestCommitUser.Name}}{{end}}</strong></a>
|
|
{{end}}
|
|
{{else}}
|
|
{{if .LatestCommit.Author}}
|
|
{{ctx.AvatarUtils.AvatarByEmail .LatestCommit.Author.Email .LatestCommit.Author.Name 24}}
|
|
<strong>{{.LatestCommit.Author.Name}}</strong>
|
|
{{end}}
|
|
{{end}}
|
|
|
|
</th>
|
|
<th>{{ $commitLink:= printf "%s/commit/%s" .RepoLink .LatestCommit.ID }}
|
|
{{template "repo/commit_statuses" dict "Status" .LatestCommitStatus "Statuses" .LatestCommitStatuses "root" $}}
|
|
<span class="grey commit-summary" title="{{.LatestCommit.Summary}}"><span
|
|
class="message-wrapper">{{RenderCommitMessageLinkSubject .LatestCommit.Message $.RepoLink $commitLink $.Repository.ComposeMetas}}</span>
|
|
{{if IsMultilineCommitMessage .LatestCommit.Message}}
|
|
<button class="basic compact mini ui icon button commit-button"><i
|
|
class="ellipsis horizontal icon"></i></button>
|
|
<pre class="commit-body"
|
|
style="display: none;">{{RenderCommitBody .LatestCommit.Message $.RepoLink $.Repository.ComposeMetas}}</pre>
|
|
{{end}}
|
|
</span>
|
|
</th>
|
|
<th id="total"></th>
|
|
<th class="text grey right age">{{if .LatestCommit.Author}}{{TimeSince .LatestCommit.Author.When $.Lang}}{{end}}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{{if .HasParentPath}}
|
|
<tr class="has-parent">
|
|
<td colspan="3">{{svg "octicon-reply"}}<a href="{{$.BranchLink}}{{.ParentPath}}">..</a></td>
|
|
</tr>
|
|
{{end}}
|
|
{{range $item := .Files}}
|
|
{{$entry := $item.Entry}}
|
|
{{$commit := $item.Commit}}
|
|
{{$subModuleFile := $item.SubModuleFile}}
|
|
<tr>
|
|
<td class="name four wide">
|
|
<span class="truncate">
|
|
{{if $entry.IsSubModule}}
|
|
{{svg "octicon-file-submodule"}}
|
|
{{$refURL := $subModuleFile.RefURL AppUrl $.Repository.FullName $.SSHDomain}}
|
|
{{if $refURL}}
|
|
<a href="{{$refURL}}">{{$entry.Name}}</a><span class="at">@</span><a
|
|
href="{{$refURL}}/commit/{{$subModuleFile.RefID}}">{{ShortSha $subModuleFile.RefID}}</a>
|
|
{{else}}
|
|
{{$entry.Name}}<span class="at">@</span>{{ShortSha $subModuleFile.RefID}}
|
|
{{end}}
|
|
{{else}}
|
|
{{if $entry.IsDir}}
|
|
{{$subJumpablePathName := $entry.GetSubJumpablePathName}}
|
|
{{svg "octicon-file-directory-fill"}}
|
|
<a class="muted" href="{{$.TreeLink}}/{{PathEscapeSegments $subJumpablePathName}}" title="{{$subJumpablePathName}}">
|
|
{{$subJumpablePathFields := StringUtils.Split $subJumpablePathName "/"}}
|
|
{{$subJumpablePathFieldLast := (Eval (len $subJumpablePathFields) "-" 1)}}
|
|
{{if eq $subJumpablePathFieldLast 0}}
|
|
{{$subJumpablePathName}}
|
|
{{else}}
|
|
{{$subJumpablePathPrefixes := slice $subJumpablePathFields 0 $subJumpablePathFieldLast}}
|
|
<span class="text light-2">{{StringUtils.Join $subJumpablePathPrefixes "/"}}</span>/{{index $subJumpablePathFields $subJumpablePathFieldLast}}
|
|
{{end}}
|
|
</a>
|
|
{{else}}
|
|
{{svg (printf "octicon-%s" (EntryIcon $entry))}}
|
|
<a href="{{$.TreeLink}}/{{$entry.Name}}"
|
|
title="{{$entry.Name}}">{{$entry.Name}}</a>
|
|
{{end}}
|
|
{{end}}
|
|
</span>
|
|
</td>
|
|
<td class="message five wide">
|
|
<span class="truncate">
|
|
<a href="{{$.RepoLink}}/commit/{{$commit.ID}}"
|
|
title="{{$commit.Summary}}">{{$commit.Summary | RenderEmoji}}</a>
|
|
</span>
|
|
</td>
|
|
<td class="message four wide center centered">
|
|
<span style="display: none;" class="ui basic label" id="{{$entry.Name}}">
|
|
</span>
|
|
</td>
|
|
<td class="text right age three wide">{{TimeSince $commit.Committer.When $.Lang}}</td>
|
|
</tr>
|
|
{{end}}
|
|
</tbody>
|
|
</table>
|
|
{{if .ReadmeExist}}
|
|
{{template "repo/view_file" .}}
|
|
{{end}}
|
|
<script>
|
|
if (!("{{.Name}}" === "tutors" || "{{.Name}}" === "template")) {
|
|
fetch(COURSES_URL + "/courses/{{$.Repository.Owner.Name}}/{{$.Repository.Name}}/exercises", {
|
|
referrerPolicy: "origin",
|
|
credentials: "include",
|
|
redirect: 'follow'
|
|
}).then(res => {
|
|
if (!res.ok) {
|
|
if (res.status === 401) {
|
|
const form = document.createElement("form")
|
|
form.action = "/user/logout"
|
|
form.method = "POST"
|
|
document.body.appendChild(form);
|
|
form.submit()
|
|
}
|
|
} else {
|
|
res.text().then(res => {
|
|
let json = JSON.parse(res)
|
|
let total = document.getElementById("total")
|
|
total.innerText = json["total"] + " / " + json["max_total"] + " (" + json["percentage"] + "%)"
|
|
for (let [name, info] of Object.entries(json["exercises"])) {
|
|
let el = document.getElementById(name)
|
|
if (el !== null) {
|
|
if (info["finished"]) {
|
|
if (info["points"] !== null) {
|
|
el.innerText = info["points"].toString() + " / " + info["max_points"].toString()
|
|
el.classList.add("black")
|
|
} else {
|
|
el.innerText = "grading in process"
|
|
el.classList.add("black")
|
|
}
|
|
} else {
|
|
el.innerText = info["message"]
|
|
if (info["important_message"]) {
|
|
el.classList.add("red")
|
|
}
|
|
}
|
|
el.style.removeProperty("display")
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}).catch(_ => {
|
|
{{if .IsAdmin}}
|
|
{{else}}
|
|
const form = document.createElement("form")
|
|
form.action = "/user/logout"
|
|
form.method = "POST"
|
|
document.body.appendChild(form);
|
|
form.submit()
|
|
{{end}}
|
|
})
|
|
}
|
|
</script>
|