1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
{{define "head"}}<head>
<title>{{.Title}}</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--
  prevent favicon request, based on answers in
  https://stackoverflow.com/questions/1321878/how-to-prevent-favicon-ico-requests
  TODO: create favicon
-->
<link rel="icon" href="data:,">
{{.AssetTags}}
<style>
  dl {
    margin: 1em;
    padding: 0.5em 1em;
    border: thin solid;
  }
  progress-player {
    max-width: 400px;
  }
</style>
</head>
{{end}}

{{define "body"}}
{{if .Settings.FreeleechExhausted}}<p>Not using freeleech tokens</p>{{else}}<p>Using freeleech tokens (automatic)</p>{{end}}

<progress-player
  src="/serve/torrent?torrent-id=4854922&amp;file-id=0"
  coverart="/serve/torrent/cover?torrent-id=4854922"
  artist="Kendrick Lamar"
  title="Not Like Us"></progress-player>
<script src="/static/progress-player.js"></script>

<form action="redacted-search">
  <label for="redacted-search-input">Redacted Search</label>
  <input
    id="redacted-search-input"
    type="text"
    name="searchstr"
    value="{{.SearchFieldContent}}" />
  <button type="submit" hx-disabled-elt="this">Search</button>
  <div class="htmx-indicator">Search running!</div>
</form>

<div>
{{.MainContent}}
</div>
{{end}}

{{define "torrent-table"}}
<h2>{{.SectionName}}</h2>
<table class="table">
  <thead>
    <tr>
      <th>Local</th>
      <th>Group ID</th>
      {{if .WithReason}}<th>Reason</th>{{end}}
      <th>Artist</th>
      <th>Name</th>
      <th>Type</th>
      <th>Year</th>
      <th>Weight</th>
      <th>Format</th>
      <th>Torrent</th>
    </tr>
  </thead>
  <tbody>
    {{range .Rows}}
    <tr id="torrent-{{.Torrent.TorrentID}}">
      <td>{{template "local-torrent" .Torrent}}</td>
      <td>{{.Torrent.GroupID}}</td>
      {{if $.WithReason}}<td>{{.ReasonLinks}}</td>{{end}}
      <td>{{.ArtistLinks}}</td>
      <td>
        <a href="{{.GroupLink}}" target="_blank">{{.Torrent.GroupName}}</a>
      </td>
      <td title="{{.ReleaseTypeTooltip}}">{{.Torrent.ReleaseType.StringKey}}</td>
      <td>{{.Torrent.GroupYear}}</td>
      <td>{{.Torrent.SeedingWeight}}</td>
      <td>{{.Torrent.TorrentFormat}}</td>
      <td><details hx-trigger="toggle once" hx-post="snips/redacted/torrentDataJson" hx-vals="{{.TorrentIDVals}}"></details></td>
    </tr>
    {{end}}
  </tbody>
</table>
{{end}}

{{define "local-torrent"}}
{{- if eq .Status 0 -}}
<form method="post">
  <input type="hidden" name="torrent-id" value="{{.TorrentID}}" />
  <button
    formaction="snips/redacted/getTorrentFile"
    hx-post="snips/redacted/getTorrentFile"
    hx-swap="outerHTML"
    hx-vals="{&#34;torrent-id&#34;:{{.TorrentID}}}">Upload Torrent</button>
</form>
{{- else if eq .Status 1 -}}
<button hx-post="snips/redacted/startTorrentFile" hx-swap="outerHTML" hx-vals="{&#34;torrent-id&#34;:{{.TorrentID}}}">Start Torrent</button>
{{- else -}}
{{.PercentDone}}% done
{{- end -}}
{{end}}

{{define "recommendations-form"}}
<form action="populate-recommendations" method="post" style="margin-bottom: 1em;">
  <button type="submit" hx-disabled-elt="this">
    Fetch New Recommendations
  </button>
  <div class="htmx-indicator">Fetching recommendations...</div>
</form>
{{end}}