Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/templates/view.html
Ramon Dantas 8fbdeed9f5 CSS-only tree view. (#753)
* Make tree-view work with CSS only

Changed the file list tree-view to use recursive templating instead of
an external function, and improved it so that it works with only CSS.
Striped lines won't work though.

* Remove inline-block from folder label

It breaks with the text-overflow: ellipsis.

* Rename makeFolderData to makeTreeViewData
2017-05-26 11:53:18 +10:00

139 lignes
7,7 Kio
HTML
Brut Annotations Historique

Ce fichier contient des caractères Unicode ambigus.

Ce fichier contient des caractères Unicode qui peuvent être confondus avec d'autres caractères. Si vous pensez que c'est intentionnel, vous pouvez ignorer cet avertissement. Utilisez le bouton Échappe pour les dévoiler.

{{define "title"}}{{.Torrent.Name}}{{end}}
{{define "contclass"}}cont-view {{if eq .Torrent.Status 2}}remake{{end}} {{if eq .Torrent.Status 3}}trusted{{end}} {{if eq .Torrent.Status 4}}aplus{{end}}{{end}}
{{ define "make_treeview" }}
{{ range $index, $folder := .Folder.Folders }}
{{ $folderId := (print $.IdentifierChain "_" $index) }}
<tr class="tr-filelist tr-folder" style="--nest-level: {{ $.NestLevel }}">
<td><label for="contents_{{$folderId}}">{{$folder.FolderName}}</label></td>
<td>{{ fileSize $folder.TotalSize $.T }}</td>
</tr>
<tr>
<td colspan="2">
<input id="contents_{{$folderId}}" type="checkbox" class="filelist-checkbox">
<table class="table-filelist">
{{ template "make_treeview" (makeTreeViewData $folder (inc $.NestLevel) $.T $folderId) }}
</table>
</td>
</tr>
{{ end }}
{{ range .Folder.Files }}
<tr class="tr-filelist tr-file" style="--nest-level: {{ $.NestLevel }}">
<td>{{.Filename}}</td>
<td>{{fileSize .Filesize $.T}}</td>
</tr>
{{ end }}
{{ end }}
{{define "content"}}
<div style="text-align: left;" class="box">
{{with .Torrent}}
{{ range (index $.FormErrors "errors")}}
<div class="alert alert-danger"><a class="panel-close close" data-dismiss="alert">×</a><i class="glyphicon glyphicon-exclamation-sign"></i> {{ . }}</div>
{{end}}
{{ range (index $.Infos "infos")}}
<div class="alert alert-info"><a class="panel-close close" data-dismiss="alert">×</a><i class="glyphicon glyphicon-info-sign"></i> {{ . }}</div>
{{end}}
<div id="torrent-name" class="{{if eq .Status 2}}remake{{end}}
{{if eq .Status 3}}trusted{{end}}
{{if eq .Status 4}}aplus{{end}}">
<p style="text-align: center;" class="torrent-hr">{{.Name}}</p>
</div>
<br>
<table>
<tr class="torrent-info-row">
<td class="torrent-info-td torrent-info-label">{{ call $.T "category" }}:</td><td class="torrent-info-td torrent-info-data"><a href="{{$.URL.Parse (printf "/search?c=%s_%s" .Category .SubCategory) }}">{{ if Sukebei}}{{ call $.T (CategoryName .Category .SubCategory) }}{{else}}{{ call $.T (CategoryName .Category .SubCategory) }}{{end}}</a> <br></td>
<td class="torrent-info-td torrent-info-label">{{ call $.T "date" }}:</td><td class="torrent-info-td date-full">{{.Date}}</td>
</tr>
<tr class="torrent-info-row">
<td class="torrent-info-td torrent-info-label">{{ call $.T "uploaded_by" }}:</td><td class="torrent-view-td torrent-info-data"><a href="{{ genRoute "user_profile" "id" ( print .UploaderID ) "username" (print .UploaderName) }}">{{.UploaderName}}</a></td>
<td class="torrent-info-td torrent-info-label">{{call $.T "seeders"}}:</td><td class="torrent-info-td">{{if .LastScrape.IsZero}}{{call $.T "unknown"}}{{else}}{{.Seeders}}{{end}}</td>
</tr>
<tr class="torrent-info-row">
<td class="torrent-info-td torrent-info-label">{{ call $.T "website_link" }}:</td><td class="torrent-view-td torrent-info-data">{{if ne .WebsiteLink ""}}<a href="{{.WebsiteLink}}">{{.WebsiteLink}}</a>{{else}}<a href="//nyaa.pantsu.cat">nyaa.pantsu.cat{{end}}</td>
<td class="torrent-info-td torrent-info-label">{{call $.T "leechers"}}:</td><td class="torrent-info-td">{{if .LastScrape.IsZero}}{{call $.T "unknown"}}{{else}}{{.Leechers}}{{end}}</td>
</tr>
<tr class="torrent-info-row">
<td class="torrent-info-td torrent-info-label">{{call $.T "hash"}}:</td><td style="font-size: small;" class="torrent-view-td torrent-info-data">{{.Hash}}</td>
<td class="torrent-info-td torrent-info-label">{{call $.T "completed"}}:</td><td class="torrent-info-td">{{if .LastScrape.IsZero}}{{call $.T "unknown"}}{{else}}{{.Completed}}{{end}}</td>
</tr>
<tr class="torrent-info-row">
<td class="torrent-info-td torrent-info-label">{{call $.T "size"}}:</td><td class="torrent-view-td torrent-info-data">{{ fileSize .Filesize $.T }}</td>
<td class="torrent-info-td torrent-info-label">{{call $.T "last_scraped"}}</td><td class="torrent-info-td">{{if not .LastScrape.IsZero}}{{formatDateRFC .LastScrape}}{{else}}{{call $.T "unknown"}}{{end}}</td>
</tr>
</table>
<div class="torrent-buttons">
<a href="{{.Magnet}}" class="form-input">{{call $.T "magnet_link"}}</a>
<a href="{{.TorrentLink}}" class="form-input">{{call $.T "torrent_file"}}</a>
{{ if gt $.User.ID 0}}
<script>
function reportPopup() {
reportContent = `
<h4>{{ call $.T "report_torrent_number" (print $.Torrent.ID) }}</h4>
<b>{{ call $.T "report_type" }}:</b>
<form method="post" action="/report/{{$.Torrent.ID}}">
<input type="radio" name="report_type" value="illegal" id="illegal" required> <label for="illegal">{{ call $.T "illegal_content" }}</label><br />
<input type="radio" name="report_type" value="spam" id="spam" required> <label for="spam">{{ call $.T "spam_garbage" }}</label><br />
<input type="radio" name="report_type" value="wrongcat" id="wrongcat" required> <label for="wrongcat">{{ call $.T "wrong_category" }}</label><br />
<input type="radio" name="report_type" value="dup" id="dup" required> <label for="dup">{{ call $.T "duplicate_deprecated" }}</label><br />
<button type="submit" class="btn btn-default">{{ call $.T "report_btn" }}</button>
</form> <br />
`
reportWindow = window.open("", 'reportWindow', "width=300,height=300"); // Opens a new window
reportWindow.document.write(reportContent);
}
</script>
<a onclick="reportPopup();" class="form-input">{{ call $.T "report_btn" }}</a>
{{end}}
</div>
<p class="torrent-hr">{{call $.T "description"}}</p>
{{ if ne .Description ""}}
<div style="padding-left: 14px;" class="torrent-info-box">{{.Description}}</div>
{{else}}
<p>No description provided!</p>
{{end}}
<input type="checkbox" id="show-filelist">
<label class="torrent-hr filelist-control" for="show-filelist">{{call $.T "files"}}</label>
{{ if gt (len .FileList) 0 }}
{{/* how do i concat lol */}}
<div class="torrent-info-box" id="filelist">
<table>
<thead>
<th style="width: 70%">{{call $.T "filename"}}</th>
<th>{{call $.T "size"}}</th>
</thead>
<tbody>
{{ template "make_treeview" (makeTreeViewData $.RootFolder 0 $.T "root") }}
</tbody>
</table>
</div>
{{ else }}
<p>No files found? That doesn't even make sense!</p>
{{end}}
<p class="torrent-hr">{{call $.T "comments"}}</p>
{{range $index, $element := .Comments}}
<div class="torrent-info-box comment-box">
<span class="comment-index"><a href="#comment_{{inc $index}}">#{{inc $index}}</a><small style="padding-left: 4px;" class="date-short"> {{.Date}}</small></span>
<p>{{.Username}}</p>
<p>{{.Content}}</p>
</div>
{{end}}
{{end}}
<div style="margin-top: 10px" class="torrent-info-box">
<form method="post">
<div class="comment-form">
<div class="comment-text">
<h3>{{ if gt .User.ID 0}} {{call $.T "submit_a_comment_as_username" .User.Username}} {{else}} {{call $.T "submit_a_comment_as_anonymous"}} {{end}}</h3>
<textarea style="height: 10rem;" placeholder="サンキュー" name="comment" class="form-input up-input"></textarea>
</div>
<div class="comment-captcha">
{{block "captcha" (makeCaptchaData .CaptchaID $.T)}}{{end}}
<button type="submit" class="form-input up-btn">{{call $.T "submit" }}</button>
</div>
</div>
</form>
</div>
</div>
{{end}}