Add filesize and dates to page
Cette révision appartient à :
Parent
6e6b34afb7
révision
8a513bcc01
|
@ -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>
|
||||
|
|
18
models.go
18
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,14 +106,14 @@ 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 )
|
||||
rows.Scan(&item.Id, &item.Name, &item.Hash, &item.Timestamp)
|
||||
magnet := "magnet:?xt=urn:btih:" + strings.TrimSpace(item.Hash) + "&dn=" + item.Name + trackers
|
||||
item.Magnet = magnet
|
||||
// memory hog
|
||||
result = append( result, item )
|
||||
result = append(result, item)
|
||||
}
|
||||
rows.Close()
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -163,7 +167,7 @@ func getTorrentsDB(parameters WhereParams) []Torrents {
|
|||
/* Function to get all torrents
|
||||
*/
|
||||
|
||||
func getAllTorrentsOrderBy(orderBy string, limit int, offset int) [] Torrents {
|
||||
func getAllTorrentsOrderBy(orderBy string, limit int, offset int) []Torrents {
|
||||
return getTorrentsOrderBy(nil, orderBy, limit, 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