Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

add Revision

aichy12689738b8898b6
diff --git a/cmd/answer/main.go b/cmd/answer/main.go
index 626eb2b2..06f8c47b 100644
--- a/cmd/answer/main.go
+++ b/cmd/answer/main.go
@@ -53,6 +53,7 @@ func runApp() {
panic(err)
}
constant.Version = Version
+ constant.Revision = Revision
schema.AppStartTime = time.Now()
defer cleanup()
diff --git a/docs/docs.go b/docs/docs.go
index 6955ff5f..d1fa0a96 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -7230,6 +7230,9 @@ const docTemplate = `{
"login": {
"$ref": "#/definitions/schema.SiteLoginResp"
},
+ "revision": {
+ "type": "string"
+ },
"site_seo": {
"$ref": "#/definitions/schema.SiteSeoReq"
},
diff --git a/docs/swagger.json b/docs/swagger.json
index 962004ee..1ade7434 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -7218,6 +7218,9 @@
"login": {
"$ref": "#/definitions/schema.SiteLoginResp"
},
+ "revision": {
+ "type": "string"
+ },
"site_seo": {
"$ref": "#/definitions/schema.SiteSeoReq"
},
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 88129421..6c17b0c8 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -1354,6 +1354,8 @@ definitions:
$ref: '#/definitions/schema.SiteInterfaceResp'
login:
$ref: '#/definitions/schema.SiteLoginResp'
+ revision:
+ type: string
site_seo:
$ref: '#/definitions/schema.SiteSeoReq'
theme:
diff --git a/internal/base/constant/constant.go b/internal/base/constant/constant.go
index 40990b93..a71d1a9c 100644
--- a/internal/base/constant/constant.go
+++ b/internal/base/constant/constant.go
@@ -30,7 +30,8 @@ const (
// object TagID AnswerList
// key equal database's table name
var (
- Version string = ""
+ Version string = ""
+ Revision string = ""
PathIgnoreMap map[string]bool
diff --git a/internal/controller/siteinfo_controller.go b/internal/controller/siteinfo_controller.go
index b2a95bdf..b0ec1315 100644
--- a/internal/controller/siteinfo_controller.go
+++ b/internal/controller/siteinfo_controller.go
@@ -31,7 +31,7 @@ func NewSiteinfoController(siteInfoService *siteinfo_common.SiteInfoCommonServic
// @Router /answer/api/v1/siteinfo [get]
func (sc *SiteinfoController) GetSiteInfo(ctx *gin.Context) {
var err error
- resp := &schema.SiteInfoResp{Version: constant.Version}
+ resp := &schema.SiteInfoResp{Version: constant.Version, Revision: constant.Revision}
resp.General, err = sc.siteInfoService.GetSiteGeneral(ctx)
if err != nil {
log.Error(err)
@@ -103,6 +103,7 @@ func (sc *SiteinfoController) GetManifestJson(ctx *gin.Context) {
resp := &schema.GetManifestJsonResp{
ManifestVersion: 3,
Version: constant.Version,
+ Revision: constant.Revision,
ShortName: "Answer",
Name: "Answer.dev",
Icons: map[string]string{
diff --git a/internal/controller/template_controller.go b/internal/controller/template_controller.go
index aa9e702a..b57df849 100644
--- a/internal/controller/template_controller.go
+++ b/internal/controller/template_controller.go
@@ -471,6 +471,7 @@ func (tc *TemplateController) html(ctx *gin.Context, code int, tpl string, siteI
data["HeaderCode"] = siteInfo.CustomCssHtml.CustomHeader
data["FooterCode"] = siteInfo.CustomCssHtml.CustomFooter
data["Version"] = constant.Version
+ data["Revision"] = constant.Revision
_, ok := data["path"]
if !ok {
data["path"] = ""
diff --git a/internal/schema/dashboard_schema.go b/internal/schema/dashboard_schema.go
index 1ed09010..88afed90 100644
--- a/internal/schema/dashboard_schema.go
+++ b/internal/schema/dashboard_schema.go
@@ -27,6 +27,7 @@ type DashboardInfo struct {
type DashboardInfoVersion struct {
Version string `json:"version"`
+ Revision string `json:"revision"`
RemoteVersion string `json:"remote_version"`
}
diff --git a/internal/schema/siteinfo_schema.go b/internal/schema/siteinfo_schema.go
index 19f3d9fb..4f786009 100644
--- a/internal/schema/siteinfo_schema.go
+++ b/internal/schema/siteinfo_schema.go
@@ -170,6 +170,7 @@ type SiteInfoResp struct {
CustomCssHtml *SiteCustomCssHTMLResp `json:"custom_css_html"`
SiteSeo *SiteSeoReq `json:"site_seo"`
Version string `json:"version"`
+ Revision string `json:"revision"`
}
type TemplateSiteInfoResp struct {
General *SiteGeneralResp `json:"general"`
@@ -225,6 +226,7 @@ type GetSMTPConfigResp struct {
type GetManifestJsonResp struct {
ManifestVersion int `json:"manifest_version"`
Version string `json:"version"`
+ Revision string `json:"revision"`
ShortName string `json:"short_name"`
Name string `json:"name"`
Icons map[string]string `json:"icons"`
diff --git a/internal/service/dashboard/dashboard_service.go b/internal/service/dashboard/dashboard_service.go
index e47645fe..d8fcc8cb 100644
--- a/internal/service/dashboard/dashboard_service.go
+++ b/internal/service/dashboard/dashboard_service.go
@@ -90,6 +90,7 @@ func (ds *DashboardService) StatisticalByCache(ctx context.Context) (*schema.Das
startTime := time.Now().Unix() - schema.AppStartTime.Unix()
dashboardInfo.AppStartTime = fmt.Sprintf("%d", startTime)
dashboardInfo.VersionInfo.Version = constant.Version
+ dashboardInfo.VersionInfo.Revision = constant.Revision
return dashboardInfo, nil
}
@@ -194,6 +195,7 @@ func (ds *DashboardService) Statistical(ctx context.Context) (*schema.DashboardI
dashboardInfo.AppStartTime = fmt.Sprintf("%d", startTime)
dashboardInfo.TimeZone = siteInfoInterface.TimeZone
dashboardInfo.VersionInfo.Version = constant.Version
+ dashboardInfo.VersionInfo.Revision = constant.Revision
dashboardInfo.VersionInfo.RemoteVersion = ds.RemoteVersion(ctx)
return dashboardInfo, nil
}
diff --git a/ui/template/header.html b/ui/template/header.html
index 5b654c56..f43213ad 100644
--- a/ui/template/header.html
+++ b/ui/template/header.html
@@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>{{.title}}</title>
<meta name="description" content="{{.description}}" data-rh="true" />
- <meta name="generator" content="Answer {{.Version}} - https://github.com/answerdev/answer">
+ <meta name="generator" content="Answer {{.Version}} - https://github.com/answerdev/answer version {{.Revision}}">
{{if .keywords }}<meta name="keywords" content="{{.keywords}}" data-rh="true" />{{end}}
<link rel="canonical" href="{{.siteinfo.Canonical}}" />