feat(api): add plugin information to version endpoint
Some checks failed
Build and Release / Create Release (push) Has been skipped
Build and Release / Unit Tests (push) Successful in 3m22s
Build and Release / Build Binaries (amd64, darwin, macos) (push) Has been cancelled
Build and Release / Build Binaries (amd64, linux, linux-latest) (push) Has been cancelled
Build and Release / Build Binaries (amd64, windows, windows-latest) (push) Has been cancelled
Build and Release / Build Binaries (arm64, darwin, macos) (push) Has been cancelled
Build and Release / Build Binary (linux/arm64) (push) Has been cancelled
Build and Release / Lint (push) Has been cancelled
Build and Release / Integration Tests (PostgreSQL) (push) Has been cancelled
Some checks failed
Build and Release / Create Release (push) Has been skipped
Build and Release / Unit Tests (push) Successful in 3m22s
Build and Release / Build Binaries (amd64, darwin, macos) (push) Has been cancelled
Build and Release / Build Binaries (amd64, linux, linux-latest) (push) Has been cancelled
Build and Release / Build Binaries (amd64, windows, windows-latest) (push) Has been cancelled
Build and Release / Build Binaries (arm64, darwin, macos) (push) Has been cancelled
Build and Release / Build Binary (linux/arm64) (push) Has been cancelled
Build and Release / Lint (push) Has been cancelled
Build and Release / Integration Tests (PostgreSQL) (push) Has been cancelled
Include loaded plugin details (name, version, description) in /api/v2/version response when plugins are enabled. Also add page class to AI learning admin templates for consistent styling.
This commit is contained in:
@@ -6,22 +6,43 @@ package v2
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"code.gitcaddy.com/server/v3/modules/plugins"
|
||||
"code.gitcaddy.com/server/v3/modules/setting"
|
||||
"code.gitcaddy.com/server/v3/services/context"
|
||||
)
|
||||
|
||||
// VersionResponse contains version information
|
||||
type VersionResponse struct {
|
||||
Version string `json:"version"`
|
||||
API string `json:"api"`
|
||||
// VersionPluginInfo is a summary of a loaded plugin.
|
||||
type VersionPluginInfo struct {
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version"`
|
||||
Description string `json:"description"`
|
||||
}
|
||||
|
||||
// Version returns the Gitea version
|
||||
// VersionResponse contains version information
|
||||
type VersionResponse struct {
|
||||
Version string `json:"version"`
|
||||
API string `json:"api"`
|
||||
Plugins []VersionPluginInfo `json:"plugins,omitempty"`
|
||||
}
|
||||
|
||||
// Version returns the server version and loaded plugins
|
||||
func Version(ctx *context.APIContext) {
|
||||
ctx.JSON(http.StatusOK, VersionResponse{
|
||||
resp := VersionResponse{
|
||||
Version: setting.AppVer,
|
||||
API: "v2",
|
||||
})
|
||||
}
|
||||
|
||||
if setting.Plugins.Enabled {
|
||||
for _, p := range plugins.All() {
|
||||
resp.Plugins = append(resp.Plugins, VersionPluginInfo{
|
||||
Name: p.Name(),
|
||||
Version: p.Version(),
|
||||
Description: p.Description(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
ctx.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// GetAuthenticatedUser returns the authenticated user
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{template "admin/layout_head" .}}
|
||||
{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin ai-learning")}}
|
||||
<div class="admin ai-learning">
|
||||
<h4 class="ui top attached header">
|
||||
{{ctx.Locale.Tr "admin.ai_learning"}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{template "admin/layout_head" .}}
|
||||
{{template "admin/layout_head" (dict "ctxData" . "pageClass" "admin ai-learning")}}
|
||||
<div class="admin ai-learning-edit">
|
||||
<h4 class="ui top attached header">
|
||||
{{ctx.Locale.Tr "admin.ai_learning.edit"}} - {{.Pattern.Pattern}}
|
||||
|
||||
Reference in New Issue
Block a user