Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Cette révision appartient à :
Eliot Whalan 2017-05-27 11:56:28 +10:00
révision 5041bd1de1
Aucune clé n'a été trouvée pour cette signature dans la base de données
ID de la clé GPG: C0A42175139840D6
13 fichiers modifiés avec 55 ajouts et 37 suppressions

Voir le fichier

@ -165,7 +165,7 @@ func (p *TorrentParam) Find(client *elastic.Client) (int64, []model.Torrent, err
// INFO We are not using Hits.Id because the id in the index might not
// correspond to the id in the database later on.
type TId struct {
Id string
Id uint
}
var tid TId
var torrents []model.Torrent
@ -175,11 +175,11 @@ func (p *TorrentParam) Find(client *elastic.Client) (int64, []model.Torrent, err
// Building a string of the form {id1,id2,id3}
source, _ := hits[0].Source.MarshalJSON()
json.Unmarshal(source, &tid)
idsToString := "{" + tid.Id
idsToString := "{" + strconv.FormatUint(uint64(tid.Id), 10)
for _, t := range hits[1:] {
source, _ = t.Source.MarshalJSON()
json.Unmarshal(source, &tid)
idsToString += "," + tid.Id
idsToString += "," + strconv.FormatUint(uint64(tid.Id), 10)
}
idsToString += "}"
db.ORM.Raw("SELECT * FROM " + config.TorrentsTableName +

Voir le fichier

@ -24,8 +24,7 @@ mappings:
properties:
# TODO Consistent ID's type in TorrentJSON
id:
type: text
fielddata: true # Use to sort by id because it is currently a text field
type: long
name:
type: text
analyzer: nyaapantsu_analyzer

Voir le fichier

@ -32,9 +32,8 @@ fetches = cur.fetchmany(CHUNK_SIZE)
while fetches:
actions = list()
for torrent_id, torrent_name, category, sub_category, status, torrent_hash, date, uploader, downloads, filesize, seeders, leechers, completed in fetches:
# TODO Consistent ID representation on the codebase
doc = {
'id': str(torrent_id),
'id': torrent_id,
'name': torrent_name.decode('utf-8'),
'category': str(category),
'sub_category': str(sub_category),

Voir le fichier

@ -126,7 +126,7 @@ func (t Torrent) AddToESIndex(client *elastic.Client) error {
_, err := client.Index().
Index(config.DefaultElasticsearchIndex).
Type(config.DefaultElasticsearchType).
Id(torrentJSON.ID).
Id(strconv.FormatUint(uint64(torrentJSON.ID), 10)).
BodyJson(torrentJSON).
Refresh("true").
Do(ctx)
@ -203,7 +203,7 @@ type FileJSON struct {
// TorrentJSON for torrent model in json for api
type TorrentJSON struct {
ID string `json:"id"`
ID uint `json:"id"`
Name string `json:"name"`
Status int `json:"status"`
Hash string `json:"hash"`
@ -281,7 +281,7 @@ func (t *Torrent) ToJSON() TorrentJSON {
torrentlink = fmt.Sprintf(config.TorrentStorageLink, t.Hash)
}
res := TorrentJSON{
ID: strconv.FormatUint(uint64(t.ID), 10),
ID: t.ID,
Name: t.Name,
Status: t.Status,
Hash: t.Hash,

Voir le fichier

@ -407,9 +407,10 @@ td { border-color: #ccc !important; }
td.tr-se { color: #22A243; }
td.tr-le { color: #E84C4C; }
.aplus { background: hsla(200, 100%, 70%, 0.2); }
.trusted { background: hsla(100, 100%, 70%, 0.2); }
.remake { background: hsla(30, 100%, 70%, 0.2); }
/* Original Nyaa colors, do NOT change! */
.aplus { background: #60B0F0; }
.trusted { background: #98D9A8; }
.remake { background: #F0B080; }
.pagination .active { background: #d5d5d5; color: #222; }
.pagination .disabled { color: #d5d5d5; cursor: unset; }

Voir le fichier

@ -73,7 +73,7 @@ func init() {
Router.HandleFunc("/user/{id}/{username}/follow", UserFollowHandler).Name("user_follow").Methods("GET")
Router.Handle("/user/{id}/{username}/edit", wrapHandler(gzipUserDetailsHandler)).Name("user_profile_details").Methods("GET")
Router.Handle("/user/{id}/{username}/edit", wrapHandler(gzipUserProfileFormHandler)).Name("user_profile_edit").Methods("POST")
Router.Handle("/user/{id}/{username}/apireset", wrapHandler(gzipUserAPIKeyResetHandler)).Name("user_profile_apireset").Methods("POST")
Router.Handle("/user/{id}/{username}/apireset", wrapHandler(gzipUserAPIKeyResetHandler)).Name("user_profile_apireset").Methods("GET")
Router.Handle("/user/notifications", wrapHandler(gzipUserNotificationsHandler)).Name("user_notifications")
Router.HandleFunc("/user/{id}/{username}/feed", RSSHandler).Name("feed_user")
Router.HandleFunc("/user/{id}/{username}/feed/{page}", RSSHandler).Name("feed_user_page")

Voir le fichier

@ -75,7 +75,7 @@ func RSSHandler(w http.ResponseWriter, r *http.Request) {
for i, torrent := range torrents {
torrentJSON := torrent.ToJSON()
feed.Items[i] = &feeds.Item{
ID: "https://" + config.WebAddress + "/view/" + torrentJSON.ID,
ID: "https://" + config.WebAddress + "/view/" + strconv.FormatUint(uint64(torrentJSON.ID), 10),
Title: torrent.Name,
Link: &feeds.Link{Href: string(torrentJSON.Magnet)},
Description: string(torrentJSON.Description),

Voir le fichier

@ -357,11 +357,11 @@ func UserAPIKeyResetHandler(w http.ResponseWriter, r *http.Request) {
}
userProfile.APIToken, _ = crypto.GenerateRandomToken32()
userProfile.APITokenExpiry = time.Unix(0, 0)
_, errorUser = userService.UpdateUserCore(&userProfile)
_, errorUser = userService.UpdateRawUser(&userProfile)
if errorUser != nil {
messages.ImportFromError("errors", errorUser)
} else {
messages.AddInfo("infos", Ts("profile_updated"))
}
UserProfileHandler(w, r)
}

Voir le fichier

@ -178,6 +178,17 @@ func UpdateUserCore(user *model.User) (int, error) {
return http.StatusOK, nil
}
// UpdateRawUser : Function to update a user without updating his associations model
func UpdateRawUser(user *model.User) (int, error) {
user.UpdatedAt = time.Now()
err := db.ORM.Model(&user).UpdateColumn(&user).Error
if err != nil {
return http.StatusInternalServerError, err
}
return http.StatusOK, nil
}
// UpdateUser updates a user.
func UpdateUser(w http.ResponseWriter, form *formStruct.UserForm, formSet *formStruct.UserSettingsForm, currentUser *model.User, id string) (model.User, int, error) {
var user model.User

Voir le fichier

@ -27,7 +27,7 @@
</a>
</td>
<td class="tr-name">
<a href="{{genRoute "view_torrent" "id" .ID }}">
<a href="{{genRoute "view_torrent" "id" ( print .ID ) }}">
{{.Name}}
</a>
</td>

Voir le fichier

@ -52,7 +52,7 @@ Your browser does not support the audio element.
</a>
</td>
<td class="tr-name home-td">
<a href="{{genRoute "view_torrent" "id" .ID }}">
<a href="{{genRoute "view_torrent" "id" ( print .ID ) }}">
{{.Name}}
</a>
</td>

Voir le fichier

@ -42,7 +42,7 @@
<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 "category" }}:</td><td class="torrent-info-td torrent-info-data" style="padding:0"><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-short">{{.Date}}</td>
</tr>
<tr class="torrent-info-row">
@ -54,7 +54,7 @@
<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 "hash"}}:</td><td style="font-family: monospace;" 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">
@ -90,26 +90,26 @@
{{ if ne .Description ""}}
<div id="description-box" class="torrent-info-box">{{.Description}}</div>
{{else}}
<p>No description provided!</p>
<p>{{ call $.T "no_description" }}</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>
<div class="torrent-info-box" id="filelist">
{{ if gt (len .FileList) 0 }}
{{/* how do i concat lol */}}
<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>
{{ else }}
<p>No files found? That doesn't even make sense!</p>
{{end}}
<p>{{ call $.T "no_files" }}</p>
{{ end }}
</div>
<p class="torrent-hr">{{call $.T "comments"}}</p>
{{range $index, $element := .Comments}}

Voir le fichier

@ -543,6 +543,10 @@
"id": "description",
"translation": "Description"
},
{
"id": "no_description",
"translation": "No description provided!"
},
{
"id": "comments",
"translation": "Comments"
@ -691,6 +695,10 @@
"id": "files",
"translation": "Files"
},
{
"id": "no_files",
"translation": "No files found? That doesn't even make sense!"
},
{
"id": "filename",
"translation": "Filename"