Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Updated search

When in a user page and clicked on more torrents, show a list navigable
of the user torrent
On that list, we can make advance search (categories, order, ...)

Moderation search reimplemented
Clicking on user (id) in the torrent list redirect to the list of the
user torrents
Ability to search within the user torrents
Cette révision appartient à :
akuma06 2017-05-11 03:52:36 +02:00
Parent 4111c56970
révision e8774abf21
6 fichiers modifiés avec 18 ajouts et 2 suppressions

Voir le fichier

@ -42,6 +42,7 @@ type SearchParam struct {
Sort SortMode
Category Category
Page int
UserID uint
Max uint
Query string
}

Voir le fichier

@ -31,6 +31,7 @@
<option value="2" {{if eq .Search.Status 2}}selected{{end}}>{{T "trusted"}}</option>
<option value="3" {{if eq .Search.Status 3}}selected{{end}}>A+</option>
</select>
<input type="hidden" name="userID" value="{{ .Search.UserID }}">
{{end}}
{{define "search_advanced"}}
<select name="sort" class="form-control input-sm">

Voir le fichier

@ -8,7 +8,7 @@
<th class="col-xs-1">Action</th>
</tr>
{{ range .Torrents}}
<tr><td><a href="{{ genRoute "mod_tedit" }}?id={{.ID}}">{{ .Name }}</a></td><td><a href="{{ genRoute "mod_tlist" }}?userid={{.UploaderID}}">{{ .UploaderID }}</a></td>
<tr><td><a href="{{ genRoute "mod_tedit" }}?id={{.ID}}">{{ .Name }}</a></td><td><a href="{{ genRoute "mod_tlist" }}?userID={{.UploaderID}}">{{ .UploaderID }}</a></td>
<td><a href="{{ genRoute "mod_tdelete" }}?id={{ .ID }}" class="btn btn-danger btn-lg" onclick="if (!confirm('Are you sure?')) return false;"><i class="glyphicon glyphicon-trash"></i>{{ T "delete" }}</a></td></tr>
{{end}}
</table>

Voir le fichier

@ -11,7 +11,7 @@
{{ range .Torrents}}
<tr><td><a href="{{ genRoute "mod_tedit" }}?id={{.ID}}">{{ .Name }}</a></td><td><a href="{{ genRoute "mod_tlist" }}?userid={{.UploaderID}}">{{ .UploaderID }}</a></td>
<tr><td><a href="{{ genRoute "mod_tedit" }}?id={{.ID}}">{{ .Name }}</a></td><td><a href="{{ genRoute "mod_tlist" }}?userID={{.UploaderID}}">{{ .UploaderID }}</a></td>
<td><a href="{{ genRoute "mod_tdelete" }}?id={{ .ID }}" class="btn btn-danger btn-lg" onclick="if (!confirm('Are you sure?')) return false;"><i class="glyphicon glyphicon-trash"></i>{{ T "delete" }}</a></td></tr>
{{end}}
</table>

Voir le fichier

@ -57,6 +57,14 @@
<div style="padding-top: 10rem"></div>
<div class="container" id="container">
<form class="navbar-form navbar-right" role="search" action="{{ genRoute "mod_tlist" }}" method="get">
<div class="form-group">
{{block "search_common" .}}{{end}}
</div>
<div class="form-group">
{{block "search_button" .}}{{end}}
</div>
</form>
{{block "content" .}}{{end}}
</div>
<footer style="text-align: center; padding-bottom: 2rem;font-size: 2rem;font-family: cursive; color: #616161;text-shadow: -1px -1px #999999;">

Voir le fichier

@ -39,6 +39,8 @@ func searchByQuery(r *http.Request, pagenum int, countAll bool) (
search.Page = pagenum
search.Query = r.URL.Query().Get("q")
userID, _ := strconv.Atoi(r.URL.Query().Get("userID"))
search.UserID = uint(userID)
switch s := r.URL.Query().Get("s"); s {
case "1":
@ -111,6 +113,10 @@ func searchByQuery(r *http.Request, pagenum int, countAll bool) (
conditions = append(conditions, "category = ?")
parameters.Params = append(parameters.Params, string(catString[0]))
}
if search.UserID != 0 {
conditions = append(conditions, "uploader = ?")
parameters.Params = append(parameters.Params, search.UserID)
}
if search.Category.Sub != 0 {
conditions = append(conditions, "sub_category = ?")
parameters.Params = append(parameters.Params, string(catString[2]))