1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-06-24 03:55:23 -04:00

plugins: enhance browser and CLI with new votes and labels

This commit is contained in:
bbedward
2026-06-23 14:48:43 -04:00
parent 28f40afccf
commit bed11feaa4
26 changed files with 2353 additions and 599 deletions
+49
View File
@@ -0,0 +1,49 @@
package plugins
import (
"encoding/json"
"net/http"
"time"
)
const feedbackURL = "https://api.danklinux.com/plugins"
type Feedback struct {
Upvotes int
Status []string
IssueURL string
}
// FetchFeedback retrieves community upvotes and moderator status from the directory API.
// Best-effort: any failure returns a nil map.
func FetchFeedback() map[string]Feedback {
client := &http.Client{Timeout: 5 * time.Second}
resp, err := client.Get(feedbackURL)
if err != nil {
return nil
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil
}
var payload struct {
Plugins []struct {
ID string `json:"id"`
Upvotes int `json:"upvotes"`
Status []string `json:"status"`
IssueURL string `json:"issueUrl"`
} `json:"plugins"`
}
if err := json.NewDecoder(resp.Body).Decode(&payload); err != nil {
return nil
}
feedback := make(map[string]Feedback, len(payload.Plugins))
for _, p := range payload.Plugins {
feedback[p.ID] = Feedback{Upvotes: p.Upvotes, Status: p.Status, IssueURL: p.IssueURL}
}
return feedback
}
+6
View File
@@ -28,9 +28,12 @@ func HandleList(conn net.Conn, req models.Request) {
return
}
feedback := plugins.FetchFeedback()
result := make([]PluginInfo, len(pluginList))
for i, p := range pluginList {
installed, _ := manager.IsInstalled(p)
fb := feedback[p.ID]
result[i] = PluginInfo{
ID: p.ID,
Name: p.Name,
@@ -46,6 +49,9 @@ func HandleList(conn net.Conn, req models.Request) {
FirstParty: strings.HasPrefix(p.Repo, "https://github.com/AvengeMedia"),
Featured: p.Featured,
RequiresDMS: p.RequiresDMS,
Upvotes: fb.Upvotes,
Status: fb.Status,
IssueURL: fb.IssueURL,
}
}
+3
View File
@@ -17,6 +17,9 @@ type PluginInfo struct {
Note string `json:"note,omitempty"`
HasUpdate bool `json:"hasUpdate,omitempty"`
RequiresDMS string `json:"requires_dms,omitempty"`
Upvotes int `json:"upvotes,omitempty"`
Status []string `json:"status,omitempty"`
IssueURL string `json:"issueUrl,omitempty"`
}
type SuccessResult struct {