Albirew/nyaa-pantsu
Albirew
/
nyaa-pantsu
Archivé
1
0
Bifurcation 0

Report modal fix (#935)

* fix uploaderid when torrent is hidden

Added a new function template to generate a link for uploaders name
In the view we have the actual uploaderID and uploaderName now

* fix template.HTML to string conversion

* Add a modal for reporting

Replace the popup
Use of Modal.js
Include Captcha

* forgot a div end tag

* Moved modal at the end

* Updated translation missing %s

* Added an information message

New translation string

* Forgot %s

* wrong id check
Cette révision appartient à :
akuma06 2017-06-06 00:06:52 +02:00 révisé par GitHub
Parent 01a3143a08
révision 23210b0250
6 fichiers modifiés avec 52 ajouts et 26 suppressions

Voir le fichier

@ -236,17 +236,19 @@ var FuncMap = template.FuncMap{
}
return string(T(d))
},
"genUploaderLink": func(uploaderID uint, uploaderName string, torrentHidden bool) template.HTML {
"genUploaderLink": func(uploaderID uint, uploaderName template.HTML, torrentHidden bool) template.HTML {
if torrentHidden {
return template.HTML("れんちょん")
}
if uploaderID == 0 {
return template.HTML("れんちょん")
}
url, err := Router.Get("user_profile").URL("id", strconv.Itoa(int(uploaderID)), "username", uploaderName)
url, err := Router.Get("user_profile").URL("id", strconv.Itoa(int(uploaderID)), "username", string(uploaderName))
if err != nil {
return "error"
}
return template.HTML("<a href=\"" + url.String() + "\">" + uploaderName + "</a>")
return template.HTML("<a href=\"" + url.String() + "\">" + string(uploaderName) + "</a>")
},
}

Voir le fichier

@ -158,6 +158,7 @@ func ReportTorrentHandler(w http.ResponseWriter, r *http.Request) {
}
err = db.ORM.Create(&report).Error
messages.AddInfoTf("infos", "report_msg", id)
if err != nil {
messages.ImportFromError("errors", err)
}

Voir le fichier

@ -68,26 +68,7 @@
<a href="{{.TorrentLink}}" class="form-input">{{call $.T "torrent_file"}}</a>
{{end}}
{{ if gt $.User.ID 0}}
<script>
function reportPopup() {
var reportContent = `
<h4>{{ call $.T "report_torrent_number" (print $.Torrent.ID) }}</h4>
<b>{{ call $.T "report_type" }}:</b>
<form method="post" action="/report/{{$.Torrent.ID}}">
{{ block "csrf_field" $ }}{{end}}
<input type="radio" name="report_type" value="illegal_content" id="illegal" required> <label for="illegal">{{ call $.T "illegal_content" }}</label><br />
<input type="radio" name="report_type" value="spam_garbage" id="spam" required> <label for="spam">{{ call $.T "spam_garbage" }}</label><br />
<input type="radio" name="report_type" value="wrong_category" id="wrongcat" required> <label for="wrongcat">{{ call $.T "wrong_category" }}</label><br />
<input type="radio" name="report_type" value="duplicate_deprecated" 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 />
`;
var 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}}
<a id="reportPopup" href="#" class="form-input">{{ call $.T "report_btn" }}</a>
{{ if HasAdmin $.User}}
<a href="{{ genRoute "mod_tdelete" }}?id={{ .ID }}" class="form-input" onclick="if (!confirm('{{ call $.T "are_you_sure" }}')) return false;">{{ call $.T "delete" }}</a>
<a href="{{ genRoute "mod_tedit" }}?id={{ .ID }}" class="form-input">{{ call $.T "edit" }}</a>
@ -95,6 +76,7 @@
<a href="{{ genRoute "user_torrent_delete" }}?id={{ .ID }}" class="form-input" onclick="if (!confirm('{{ call $.T "are_you_sure" }}')) return false;">{{ call $.T "delete" }}</a>
<a href="{{ genRoute "user_torrent_edit" }}?id={{ .ID }}" class="form-input">{{ call $.T "edit" }}</a>
{{end}}
{{end}}
</div>
<p class="torrent-hr">{{call $.T "description"}}</p>
{{ if ne .Description ""}}
@ -146,5 +128,42 @@
</form>
</div>
</div>
{{ if gt $.User.ID 0 }}
<!-- Modal -->
<div id="modal_mod_tools" class="modal">
<!-- Modal content -->
<div class="modal-content">
<form method="post" action="/report/{{$.Torrent.ID}}">
<div class="modal-header">
<span class="close">&times;</span>
<h2>{{ call $.T "report_torrent_number" (print $.Torrent.ID) }}</h2>
</div>
<div class="modal-body">
<h4>{{ call $.T "report_type" }}</h4>
{{ template "csrf_field" $ }}
<input type="radio" name="report_type" value="illegal_content" id="illegal" required> <label for="illegal">{{ call $.T "illegal_content" }}</label><br />
<input type="radio" name="report_type" value="spam_garbage" id="spam" required> <label for="spam">{{ call $.T "spam_garbage" }}</label><br />
<input type="radio" name="report_type" value="wrong_category" id="wrongcat" required> <label for="wrongcat">{{ call $.T "wrong_category" }}</label><br />
<input type="radio" name="report_type" value="duplicate_deprecated" id="dup" required> <label for="dup">{{ call $.T "duplicate_deprecated" }}</label><br />
{{template "captcha" (makeCaptchaData $.CaptchaID $.T)}}
</div>
<div class="modal-footer">
<span><button id="confirm_changes" type="submit">{{ call $.T "yes"}}</button>
<button class="close" onclick="Modal.CloseActive();">{{ call $.T "no"}}</button></span>
<h3>{{ call $.T "are_you_sure" }} </h3>
</div>
</form>
</div>
</div>
{{end}}
{{end}}
{{ define "footer_js"}}
<script type="text/javascript" src="{{ $.URL.Parse "/js/modal.js" }}"></script>
<script type="text/javascript">
// Modal initialization
Modal.Init({
elements: document.getElementsByClassName("modal"),
button: "#reportPopup"
});
</script>
{{end}}

Voir le fichier

@ -1218,5 +1218,9 @@
{
"id": "user_id",
"translation": "User ID"
},
{
"id": "report_msg",
"translation": "The torrent #%s has been reported!"
}
]

Voir le fichier

@ -509,7 +509,7 @@
},
{
"id": "report_torrent_number",
"translation": "Signaler le torrent n° "
"translation": "Signaler le torrent n°%s"
},
{
"id": "report_type",

Voir le fichier

@ -705,7 +705,7 @@
},
{
"id": "report_torrent_number",
"translation": "举报种子 #"
"translation": "举报种子 #%s"
},
{
"id": "report_type",