mirror of https://gitee.com/answerdev/answer.git
Merge branch 'feat/0.6.0/seo' into test
This commit is contained in:
commit
a2bcae97ab
5
go.mod
5
go.mod
|
@ -25,7 +25,7 @@ require (
|
|||
github.com/segmentfault/pacman v1.0.1
|
||||
github.com/segmentfault/pacman/contrib/cache/memory v0.0.0-20221018072427-a15dd1434e05
|
||||
github.com/segmentfault/pacman/contrib/conf/viper v0.0.0-20221018072427-a15dd1434e05
|
||||
github.com/segmentfault/pacman/contrib/i18n v0.0.0-20221109042453-26158da67632
|
||||
github.com/segmentfault/pacman/contrib/i18n v0.0.0-20221207032920-3662d1e32068
|
||||
github.com/segmentfault/pacman/contrib/log/zap v0.0.0-20221018072427-a15dd1434e05
|
||||
github.com/segmentfault/pacman/contrib/server/http v0.0.0-20221018072427-a15dd1434e05
|
||||
github.com/spf13/cobra v1.6.1
|
||||
|
@ -45,6 +45,7 @@ require (
|
|||
require (
|
||||
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
|
||||
github.com/KyleBanks/depth v1.2.1 // indirect
|
||||
github.com/LinkinStars/go-i18n/v2 v2.2.2 // indirect
|
||||
github.com/Microsoft/go-winio v0.5.2 // indirect
|
||||
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
|
||||
github.com/andybalholm/brotli v1.0.4 // indirect
|
||||
|
@ -108,7 +109,7 @@ require (
|
|||
golang.org/x/image v0.1.0 // indirect
|
||||
golang.org/x/mod v0.6.0 // indirect
|
||||
golang.org/x/sys v0.1.0 // indirect
|
||||
golang.org/x/text v0.4.0 // indirect
|
||||
golang.org/x/text v0.5.0 // indirect
|
||||
golang.org/x/tools v0.2.0 // indirect
|
||||
google.golang.org/protobuf v1.28.1 // indirect
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||
|
|
6
go.sum
6
go.sum
|
@ -50,6 +50,8 @@ github.com/Chain-Zhang/pinyin v0.1.3/go.mod h1:5iHpt9p4znrnaP59/hfPMnAojajkDxQaP
|
|||
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
||||
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
|
||||
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
|
||||
github.com/LinkinStars/go-i18n/v2 v2.2.2 h1:ZfjpzbW13dv6btv3RALKZkpN9A+7K1JA//2QcNeWaxU=
|
||||
github.com/LinkinStars/go-i18n/v2 v2.2.2/go.mod h1:hLglSJ4/3M0Y7ZVcoEJI+OwqkglHCA32DdjuJJR2LbM=
|
||||
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
|
||||
github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA=
|
||||
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
|
||||
|
@ -599,6 +601,8 @@ github.com/segmentfault/pacman/contrib/conf/viper v0.0.0-20221018072427-a15dd143
|
|||
github.com/segmentfault/pacman/contrib/conf/viper v0.0.0-20221018072427-a15dd1434e05/go.mod h1:prPjFam7MyZ5b3S9dcDOt2tMPz6kf7C9c243s9zSwPY=
|
||||
github.com/segmentfault/pacman/contrib/i18n v0.0.0-20221109042453-26158da67632 h1:so07u8RWXZQ0gz30KXJ9MKtQ5zjgcDlQ/UwFZrwm5b0=
|
||||
github.com/segmentfault/pacman/contrib/i18n v0.0.0-20221109042453-26158da67632/go.mod h1:5Afm+OQdau/HQqSOp/ALlSUp0vZsMMMbv//kJhxuoi8=
|
||||
github.com/segmentfault/pacman/contrib/i18n v0.0.0-20221207032920-3662d1e32068 h1:ln/qgrC62e7/XHGPiikWFV4dyYgCaWeZYkmSGqrHZp4=
|
||||
github.com/segmentfault/pacman/contrib/i18n v0.0.0-20221207032920-3662d1e32068/go.mod h1:7QcRmnV7OYq4hNOOCWXT5HXnN/u756JUsqIW0Bw8n9E=
|
||||
github.com/segmentfault/pacman/contrib/log/zap v0.0.0-20221018072427-a15dd1434e05 h1:jcGZU2juv0L3eFEkuZYV14ESLUlWfGMWnP0mjOfrSZc=
|
||||
github.com/segmentfault/pacman/contrib/log/zap v0.0.0-20221018072427-a15dd1434e05/go.mod h1:L4GqtXLoR73obTYqUQIzfkm8NG8pvZafxFb6KZFSSHk=
|
||||
github.com/segmentfault/pacman/contrib/server/http v0.0.0-20221018072427-a15dd1434e05 h1:91is1nKNbfTOl8CvMYiFgg4c5Vmol+5mVmMV/jDXD+A=
|
||||
|
@ -932,6 +936,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
|
||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=
|
||||
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
|
|
|
@ -51,20 +51,28 @@ func NewTranslator(c *I18n) (tr i18n.Translator, err error) {
|
|||
return nil, fmt.Errorf("read file failed: %s %s", file.Name(), err)
|
||||
}
|
||||
|
||||
// only parse the backend translation
|
||||
//translation := struct {
|
||||
// Content map[string]interface{} `yaml:"backend"`
|
||||
//}{}
|
||||
//if err = yaml.Unmarshal(buf, &translation); err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
//content, err := yaml.Marshal(translation.Content)
|
||||
//if err != nil {
|
||||
// return nil, fmt.Errorf("marshal translation content failed: %s %s", file.Name(), err)
|
||||
//}
|
||||
// parse the backend translation
|
||||
originalTr := struct {
|
||||
Backend map[string]map[string]interface{} `yaml:"backend"`
|
||||
UI map[string]interface{} `yaml:"ui"`
|
||||
}{}
|
||||
if err = yaml.Unmarshal(buf, &originalTr); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
translation := make(map[string]interface{}, 0)
|
||||
for k, v := range originalTr.Backend {
|
||||
translation[k] = v
|
||||
}
|
||||
translation["backend"] = originalTr.Backend
|
||||
translation["ui"] = originalTr.UI
|
||||
|
||||
content, err := yaml.Marshal(translation)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("marshal translation content failed: %s %s", file.Name(), err)
|
||||
}
|
||||
|
||||
// add translator use backend translation
|
||||
if err = myTran.AddTranslator(buf, file.Name()); err != nil {
|
||||
if err = myTran.AddTranslator(content, file.Name()); err != nil {
|
||||
return nil, fmt.Errorf("add translator failed: %s %s", file.Name(), err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -215,12 +215,7 @@ func (tc *TemplateController) TagList(ctx *gin.Context) {
|
|||
}
|
||||
data, err := tc.templateRenderController.TagList(ctx, req)
|
||||
if err != nil {
|
||||
ctx.HTML(http.StatusOK, "404.html", gin.H{
|
||||
"scriptPath": tc.scriptPath,
|
||||
"cssPath": tc.cssPath,
|
||||
"err": err.Error(),
|
||||
"siteinfo": tc.SiteInfo(ctx),
|
||||
})
|
||||
tc.Page404(ctx)
|
||||
return
|
||||
}
|
||||
page := templaterender.Paginator(req.Page, req.PageSize, data.Count)
|
||||
|
@ -238,24 +233,14 @@ func (tc *TemplateController) TagInfo(ctx *gin.Context) {
|
|||
tag := ctx.Param("tag")
|
||||
req := &schema.GetTamplateTagInfoReq{}
|
||||
if handler.BindAndCheck(ctx, req) {
|
||||
ctx.HTML(http.StatusOK, "404.html", gin.H{
|
||||
"scriptPath": tc.scriptPath,
|
||||
"cssPath": tc.cssPath,
|
||||
"err": "",
|
||||
"siteinfo": tc.SiteInfo(ctx),
|
||||
})
|
||||
tc.Page404(ctx)
|
||||
return
|
||||
}
|
||||
nowPage := req.Page
|
||||
req.Name = tag
|
||||
taginifo, questionList, questionCount, err := tc.templateRenderController.TagInfo(ctx, req)
|
||||
if err != nil {
|
||||
ctx.HTML(http.StatusOK, "404.html", gin.H{
|
||||
"scriptPath": tc.scriptPath,
|
||||
"cssPath": tc.cssPath,
|
||||
"err": err.Error(),
|
||||
"siteinfo": tc.SiteInfo(ctx),
|
||||
})
|
||||
tc.Page404(ctx)
|
||||
return
|
||||
}
|
||||
page := templaterender.Paginator(nowPage, req.PageSize, questionCount)
|
||||
|
@ -289,21 +274,11 @@ func (tc *TemplateController) UserInfo(ctx *gin.Context) {
|
|||
req.Username = username
|
||||
userinfo, err := tc.templateRenderController.UserInfo(ctx, req)
|
||||
if !userinfo.Has {
|
||||
ctx.HTML(http.StatusNotFound, "404.html", gin.H{
|
||||
"siteinfo": tc.SiteInfo(ctx),
|
||||
"scriptPath": tc.scriptPath,
|
||||
"cssPath": tc.cssPath,
|
||||
"err": "",
|
||||
})
|
||||
tc.Page404(ctx)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
ctx.HTML(http.StatusNotFound, "404.html", gin.H{
|
||||
"siteinfo": tc.SiteInfo(ctx),
|
||||
"scriptPath": tc.scriptPath,
|
||||
"cssPath": tc.cssPath,
|
||||
"err": err.Error(),
|
||||
})
|
||||
tc.Page404(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -327,11 +302,7 @@ func (tc *TemplateController) UserInfo(ctx *gin.Context) {
|
|||
}
|
||||
|
||||
func (tc *TemplateController) Page404(ctx *gin.Context) {
|
||||
ctx.HTML(http.StatusNotFound, "404.html", gin.H{
|
||||
"siteinfo": tc.SiteInfo(ctx),
|
||||
"scriptPath": tc.scriptPath,
|
||||
"cssPath": tc.cssPath,
|
||||
})
|
||||
tc.html(ctx, http.StatusNotFound, "404.html", tc.SiteInfo(ctx), gin.H{})
|
||||
}
|
||||
|
||||
func (tc *TemplateController) html(ctx *gin.Context, code int, tpl string, siteInfo *schema.TemplateSiteInfoResp, data gin.H) {
|
||||
|
|
|
@ -39,17 +39,17 @@ type ActObjectTimeline struct {
|
|||
ObjectType string `json:"object_type"`
|
||||
Cancelled bool `json:"cancelled"`
|
||||
CancelledAt int64 `json:"cancelled_at"`
|
||||
UserID string `json:"-"`
|
||||
UserID string `json:"id"`
|
||||
}
|
||||
|
||||
// ActObjectInfo act object info
|
||||
type ActObjectInfo struct {
|
||||
Title string `json:"title"`
|
||||
ObjectType string `json:"object_type"`
|
||||
QuestionID string `json:"question_id"`
|
||||
AnswerID string `json:"answer_id"`
|
||||
Username string `json:"username"`
|
||||
DisplayName string `json:"display_name"`
|
||||
Title string `json:"title"`
|
||||
ObjectType string `json:"object_type"`
|
||||
QuestionID string `json:"question_id"`
|
||||
AnswerID string `json:"answer_id"`
|
||||
Username string `json:"username"`
|
||||
DisplayName string `json:"display_name"`
|
||||
MainTagSlugName string `json:"main_tag_slug_name"`
|
||||
}
|
||||
|
||||
|
|
|
@ -368,7 +368,7 @@ type ActionRecordResp struct {
|
|||
}
|
||||
|
||||
type UserBasicInfo struct {
|
||||
ID string `json:"-"` // user_id
|
||||
ID string `json:"id"` // user_id
|
||||
Username string `json:"username" ` // name
|
||||
Rank int `json:"rank" ` // rank
|
||||
DisplayName string `json:"display_name"` // display_name
|
||||
|
|
Loading…
Reference in New Issue