tinyrelayfile
tinyrelay/tinyclient/repo.html/

tinyclient/repo.html raw
1{{define "repo"}}{{if .Error}}<section><h1>{{.Query.Get "repo"}}</h1>{{template "alert" .Error}}</section>
2{{else}}{{$repo := asMap .Event}}{{$view := repoView .Query}}{{if eq $view "home"}}<section id="readme">
3{{if .Readme}}{{.Readme}}{{else}}<h1>{{str (index $repo "identifier")}}</h1><p>This repository has no README at its default branch.</p>{{end}}
4</section>
5{{else if or (eq $view "tree") (eq $view "file")}}<table id="split"><tbody><tr><td id="tree"><header><a href="{{repoURL .Query "tree" ""}}">{{str (index $repo "identifier")}}/</a>{{range $index, $crumb := repoBreadcrumbs .Query}}{{if $index}}{{if $crumb.URL}}<a href="{{$crumb.URL}}">{{$crumb.Label}}</a>{{else}}<b>{{$crumb.Label}}</b>{{end}}/{{end}}{{end}}</header>
6{{template "repoTree" .}}</td>
7<td id="preview">{{if eq $view "file"}}<header>{{.Query.Get "path"}} <a fx-ignore href="/repo/raw?owner={{urlquery (.Query.Get "owner")}}&amp;repo={{urlquery (.Query.Get "repo")}}&amp;ref={{urlquery (.Query.Get "ref")}}&amp;path={{urlquery (.Query.Get "path")}}">raw</a></header>
8{{if index $repo "binary"}}<p>This is a binary file. Download it to view its contents.</p>
9{{else if index $repo "content"}}{{sourceHTML .Event}}
10{{else}}<p>This file is empty.</p>
11{{end}}{{else}}<p>select a file to preview</p>{{end}}</td></tr></tbody></table>
12{{else if eq $view "history"}}<section>
13<table id="rows">
14<tbody>
15{{range index $repo "commits"}}{{$commit := asMap .}}<tr><td>{{str (index $commit "author")}}</td><td><a href="{{repoCommitURL $.Query (str (index $commit "oid"))}}">{{str (index $commit "subject")}}</a></td><td>{{shortID (index $commit "oid")}} {{short (index $commit "time")}}</td></tr>
16{{else}}<tr><td colspan="3">No commits.</td></tr>
17{{end}}</tbody>
18</table>
19<p id="pages">{{if .Query.Get "offset"}}<a href="{{repoURL .Query "history" ""}}">first page</a> {{end}}{{if hasNextOffset (index $repo "next_offset")}}<a href="{{browsePageURL "/repo" .Query "offset" (index $repo "next_offset")}}">next page</a>{{end}}</p>
20</section>
21{{else if eq $view "commit"}}<section>
22<h1>Commit <code>{{shortID (index $repo "commit")}}</code></h1>
23<p><a href="{{repoURL .Query "tree" ""}}">browse files at this commit</a> | <a href="{{repoURL .Query "history" ""}}">history</a></p>
24</section>
25{{diffHTML .Event}}
26{{else if eq $view "activity"}}<section>
27{{with index $repo "events"}}<ol id="events">
28{{range .}}<li>{{template "nostrEvent" .}}</li>
29{{end}}</ol>
30{{else}}<p>No repository activity.</p>
31{{end}}</section>
32{{else if or (eq $view "issues") (eq $view "prs") (eq $view "issue") (eq $view "pr")}}{{template "collaboration" .}}
33{{end}}{{end}}{{end}}
34
35{{define "repoTree"}}{{$repo := asMap .Event}}{{$entries := index $repo "entries"}}{{if .Tree}}{{$entries = .Tree}}{{end}}<ul>
36{{range $e := $entries}}{{$entry := asMap $e}}<li>{{if eq (str (index $entry "type")) "tree"}}<a href="{{repoURL $.Query "tree" (str (index $entry "path"))}}">{{str (index $entry "name")}}/</a>{{else if eq (str (index $entry "type")) "commit"}}{{str (index $entry "name")}} <span>(submodule)</span>{{else}}<a href="{{repoURL $.Query "file" (str (index $entry "path"))}}"{{if eq (str (index $entry "path")) ($.Query.Get "path")}} aria-current="page"{{end}}>{{str (index $entry "name")}}</a>{{end}}</li>
37{{else}}<li><span>no published files here</span></li>
38{{end}}</ul>
39<p id="pages">{{if .Query.Get "offset"}}<a href="{{repoURL .Query "tree" (.Query.Get "path")}}">first page</a> {{end}}{{if hasNextOffset (index $repo "next_offset")}}<a href="{{browsePageURL "/repo" .Query "offset" (index $repo "next_offset")}}">more</a>{{end}}</p>
40{{end}}

About

ownerc01503e8035f
visibilitypublic
headd730679639bf

Maintainers

  • c01503e8035f owner
  • ba1b5beed5b5 agent hermes

Clone

  • https://012.run/npub1cq2s86qrtadf36eqq3epm38wmhdynrrcwxf84eldk3f94dkv7ttsrulrz5/tinyrelay.git

Refs