x
This commit is contained in:
@@ -35,6 +35,7 @@ type Function struct {
|
|||||||
Running bool `json:"-"`
|
Running bool `json:"-"`
|
||||||
Http *Http `json:"-"`
|
Http *Http `json:"-"`
|
||||||
Reply *Reply `json:"-"`
|
Reply *Reply `json:"-"`
|
||||||
|
Downloads int `json:"downloads"`
|
||||||
}
|
}
|
||||||
type Filter struct {
|
type Filter struct {
|
||||||
BlackMode bool
|
BlackMode bool
|
||||||
|
|||||||
@@ -105,6 +105,8 @@ func initPluginList() {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var plugin_downloads = MakeBucket("plugin_downloads")
|
||||||
|
|
||||||
func initWebPluginList() {
|
func initWebPluginList() {
|
||||||
storage.Watch(sillyGirl, "plugin_subcribe_addresses", func(old, new, key string) *storage.Final {
|
storage.Watch(sillyGirl, "plugin_subcribe_addresses", func(old, new, key string) *storage.Final {
|
||||||
plugin_subcribe_addresses = new
|
plugin_subcribe_addresses = new
|
||||||
@@ -187,6 +189,7 @@ func GetPublicResponse() *RequestPluginResult {
|
|||||||
for _, f := range Functions {
|
for _, f := range Functions {
|
||||||
if f.Public {
|
if f.Public {
|
||||||
fs = append(fs, f)
|
fs = append(fs, f)
|
||||||
|
f.Downloads = plugin_downloads.GetInt(f.UUID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rr.Total = len(fs)
|
rr.Total = len(fs)
|
||||||
|
|||||||
@@ -66,10 +66,12 @@ func init() {
|
|||||||
Server.Use(gzip.Gzip(gzip.DefaultCompression))
|
Server.Use(gzip.Gzip(gzip.DefaultCompression))
|
||||||
Server.GET("/api/file/:filename", FindFile)
|
Server.GET("/api/file/:filename", FindFile)
|
||||||
Server.GET("/api/decode/:random", Base642Binary)
|
Server.GET("/api/decode/:random", Base642Binary)
|
||||||
|
|
||||||
Server.GET("/api/plugins/download", func(c *gin.Context) {
|
Server.GET("/api/plugins/download", func(c *gin.Context) {
|
||||||
uuid := c.Query("uuid")
|
uuid := c.Query("uuid")
|
||||||
for _, f := range Functions {
|
for _, f := range Functions {
|
||||||
if f.UUID == uuid && f.Public {
|
if f.UUID == uuid && f.Public {
|
||||||
|
plugin_downloads.Set(f.UUID, plugin_downloads.GetInt(f.UUID)+1)
|
||||||
c.String(200, publicScript(plugins.GetString(f.UUID)))
|
c.String(200, publicScript(plugins.GetString(f.UUID)))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -79,6 +81,7 @@ func init() {
|
|||||||
uuid := c.Param("uuid")
|
uuid := c.Param("uuid")
|
||||||
for _, f := range Functions {
|
for _, f := range Functions {
|
||||||
if f.UUID == uuid && f.Public {
|
if f.UUID == uuid && f.Public {
|
||||||
|
plugin_downloads.Set(f.UUID, plugin_downloads.GetInt(f.UUID)+1)
|
||||||
c.String(200, publicScript(plugins.GetString(f.UUID)))
|
c.String(200, publicScript(plugins.GetString(f.UUID)))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user