This commit is contained in:
YouROK
2020-11-19 15:19:26 +03:00
parent 835ce5c12a
commit f5827b8424
4 changed files with 8 additions and 38 deletions

View File

@@ -28,6 +28,7 @@ func GetTorrentDB(hash metainfo.Hash) *Torrent {
torr.TorrentSpec = db.TorrentSpec
torr.Title = db.Title
torr.Poster = db.Poster
torr.Timestamp = db.Timestamp
torr.Stat = state.TorrentInDB
return torr
}
@@ -47,6 +48,7 @@ func ListTorrentsDB() map[metainfo.Hash]*Torrent {
torr.TorrentSpec = db.TorrentSpec
torr.Title = db.Title
torr.Poster = db.Poster
torr.Timestamp = db.Timestamp
torr.Stat = state.TorrentInDB
ret[torr.TorrentSpec.InfoHash] = torr
}

View File

@@ -12,6 +12,6 @@ func SetupRoute(route *gin.Engine) {
temp = template.InitTemplate(route)
route.GET("/", mainPage)
route.GET("/api.js", apijsPage)
route.GET("/main.js", mainjsPage)
// route.GET("/api.js", apijsPage)
// route.GET("/main.js", mainjsPage)
}

View File

@@ -12,22 +12,8 @@ const mainPage = `
<!DOCTYPE html>
<html lang="en">
` + header + `
<body ng-app="app">
<script src="/api.js"></script>
<script src="/main.js"></script>
<nav class="navbar navbar-expand-lg navbar-light bg-light {{active}}" ng-click="$event.preventDefault()">
<div class="navbar-nav">
<a href="#" class="nav-item nav-link torrents" ng-click="active='torrents'">Torrents</a>
<a href="#" class="nav-item nav-link settings" ng-click="active='settings'">Settings</a>
<a href="#" class="nav-item nav-link cache" ng-click="active='cache'">Cache</a>
<a href="#" class="nav-item nav-link about" ng-click="active='about'">About</a>
</div>
</nav>
<p ng-hide="active">Please click a menu item</p>
<p ng-show="active">You chose <b>{{active}}</b></p>
<body>
<p> TorrServer ` + version.Version + `</p>
</body>
</html>

View File

@@ -8,24 +8,6 @@ import (
var ctx *gin.Engine
//
// func InitTemplate(route *gin.Engine) {
// ctx = route
//
// tmpl := getTemplate("favicon", faviconB64)
// tmpl = getTemplate("header", header)
//
// route.SetHTMLTemplate(tmpl)
// }
//
// func getTemplate(name, body string) *template.Template {
// tmpl, err := template.New(name).ParseFiles(body)
// if err != nil {
// log.TLogln("error parse template", err)
// }
// return tmpl
// }
type Template struct {
templates *template.Template
}
@@ -34,8 +16,8 @@ func InitTemplate(c *gin.Engine) *Template {
temp := new(Template)
temp.parsePage("mainPage", mainPage)
temp.parsePage("apijsPage", apiJS)
temp.parsePage("mainjsPage", mainJS)
// temp.parsePage("apijsPage", apiJS)
// temp.parsePage("mainjsPage", mainJS)
c.SetHTMLTemplate(temp.templates)
return temp