Add filesize and dates to page
Cette révision appartient à :
Parent
6e6b34afb7
révision
8a513bcc01
2 fichiers modifiés avec 52 ajouts et 42 suppressions
|
@ -98,6 +98,8 @@
|
|||
<th>Id</th>
|
||||
<th>Name</th>
|
||||
<th>Hash</th>
|
||||
<th>Date</th>
|
||||
<th>Size</th>
|
||||
<th>Links</th>
|
||||
</tr>
|
||||
{{ range .ListTorrents}}
|
||||
|
@ -107,6 +109,8 @@
|
|||
<td>{{.Id}}</td>
|
||||
<td>{{.Name}}</td>
|
||||
<td>{{.Hash}}</td>
|
||||
<td>{{.Date}}</td>
|
||||
<td>{{.Filesize}}</td>
|
||||
|
||||
|
||||
<td><a href="{{.Magnet}}" title="Magnet link" ><span class="glyphicon glyphicon-magnet" aria-hidden="true"></span></a>
|
||||
|
|
12
models.go
12
models.go
|
@ -71,6 +71,8 @@ type TorrentsJson struct {
|
|||
Name string `json: "name"`
|
||||
Status int `json: "status"`
|
||||
Hash string `json: "hash"`
|
||||
Date int `json: "date"`
|
||||
Filesize string `json: "filesize"`
|
||||
Magnet template.URL `json: "magnet"`
|
||||
}
|
||||
|
||||
|
@ -104,7 +106,7 @@ func getFeeds() []Feed {
|
|||
Query(
|
||||
"SELECT `torrent_id` AS `id`, `torrent_name` AS `name`, `torrent_hash` AS `hash`, `timestamp` FROM `torrents` " +
|
||||
"ORDER BY `timestamp` desc LIMIT 50")
|
||||
if ( err == nil ) {
|
||||
if err == nil {
|
||||
for rows.Next() {
|
||||
item := Feed{}
|
||||
rows.Scan(&item.Id, &item.Name, &item.Hash, &item.Timestamp)
|
||||
|
@ -132,13 +134,15 @@ func getTorrentsOrderBy(parameters *WhereParams, orderBy string, limit int, offs
|
|||
var torrents []Torrents
|
||||
var dbQuery *gorm.DB
|
||||
|
||||
if (parameters != nil) { // if there is where parameters
|
||||
if parameters != nil { // if there is where parameters
|
||||
dbQuery = db.Model(&torrents).Where(parameters.conditions, parameters.params...)
|
||||
} else {
|
||||
dbQuery = db.Model(&torrents)
|
||||
}
|
||||
|
||||
if (orderBy == "") { orderBy = "torrent_id DESC" } // Default OrderBy
|
||||
if orderBy == "" {
|
||||
orderBy = "torrent_id DESC"
|
||||
} // Default OrderBy
|
||||
if limit != 0 || offset != 0 { // if limits provided
|
||||
dbQuery = dbQuery.Limit(limit).Offset(offset)
|
||||
}
|
||||
|
@ -194,6 +198,8 @@ func (t *Torrents) toJson() TorrentsJson {
|
|||
Name: html.UnescapeString(t.Name),
|
||||
Status: t.Status_id,
|
||||
Hash: t.Hash,
|
||||
Date: t.Date,
|
||||
Filesize: t.Filesize,
|
||||
Magnet: safe(magnet)}
|
||||
return res
|
||||
}
|
||||
|
|
Référencer dans un nouveau ticket