fix (about): incorrect plugin list

This commit is contained in:
MickaelK 2024-12-10 09:46:53 +11:00
parent 9895842d90
commit aa3f76ebb0

View file

@ -343,12 +343,9 @@ func AboutHandler(ctx *App, res http.ResponseWriter, req *http.Request) {
<tr> <tr>
<td> Plugins </td> <td> Plugins </td>
<td> <td>
{{ $oss := (index .Plugins 0) }}
{{ $enterprise := (index .Plugins 1) }}
{{ $custom := (index .Plugins 2) }}
STANDARD[<span class="small">{{ renderPlugin (index .Plugins 0) .CommitHash }}</span>] STANDARD[<span class="small">{{ renderPlugin (index .Plugins 0) .CommitHash }}</span>]
<br/> <br/>
EXTENDED[<span class="small">{{ renderPlugin (index .Plugins 1) "" }}</span>] ENTERPRISE[<span class="small">{{ renderPlugin (index .Plugins 1) "" }}</span>]
<br/> <br/>
CUSTOM[<span class="small">{{ renderPlugin (index .Plugins 2) "" }}</span>] CUSTOM[<span class="small">{{ renderPlugin (index .Plugins 2) "" }}</span>]
</td> </td>
@ -556,32 +553,22 @@ func ServeIndex(indexPath string) func(*App, http.ResponseWriter, *http.Request)
} }
func InitPluginList(code []byte) { func InitPluginList(code []byte) {
listOfPackages := regexp.MustCompile(`github.com/mickael-kerjean/([^\"]+)`).FindAllString(string(code), -1) listOfPackages := regexp.MustCompile(`\t_?\s*\"(github.com/[^\"]+)`).FindAllStringSubmatch(string(code), -1)
for _, packageName := range listOfPackages { for _, packageNameMatch := range listOfPackages {
if packageName == "github.com/mickael-kerjean/filestash/server/common" { if len(packageNameMatch) != 2 {
continue Log.Error("ctrl::static error=assertion_failed msg=invalid_match_size arg=%d", len(packageNameMatch))
} }
packageName := packageNameMatch[1]
packageShortName := filepath.Base(packageName)
if strings.HasPrefix(packageName, "github.com/mickael-kerjean/filestash/server/plugin/") { if strings.HasPrefix(packageName, "github.com/mickael-kerjean/filestash/server/plugin/") {
listOfPlugins["oss"] = append( listOfPlugins["oss"] = append(listOfPlugins["oss"], packageShortName)
listOfPlugins["oss"],
strings.TrimPrefix(packageName, "github.com/mickael-kerjean/filestash/server/plugin/"),
)
} else if strings.HasPrefix(packageName, "github.com/mickael-kerjean/filestash/filestash-enterprise/plugins/") { } else if strings.HasPrefix(packageName, "github.com/mickael-kerjean/filestash/filestash-enterprise/plugins/") {
listOfPlugins["enterprise"] = append( listOfPlugins["enterprise"] = append(listOfPlugins["enterprise"], packageShortName)
listOfPlugins["enterprise"],
strings.TrimPrefix(packageName, "github.com/mickael-kerjean/filestash/filestash-enterprise/plugins/"),
)
} else if strings.HasPrefix(packageName, "github.com/mickael-kerjean/filestash/filestash-enterprise/customers/") { } else if strings.HasPrefix(packageName, "github.com/mickael-kerjean/filestash/filestash-enterprise/customers/") {
listOfPlugins["custom"] = append( listOfPlugins["custom"] = append(listOfPlugins["custom"], packageShortName)
listOfPlugins["custom"],
strings.TrimPrefix(packageName, "github.com/mickael-kerjean/filestash/filestash-enterprise/customers/"),
)
} else { } else {
listOfPlugins["custom"] = append( listOfPlugins["custom"] = append(listOfPlugins["custom"], packageShortName)
listOfPlugins["custom"],
packageName,
)
} }
} }
} }