MCPcopy Create free account
hub / github.com/TruthHun/DocHub / GetByPage

Method GetByPage

models/SeoModel.go:67–95  ·  view source on GitHub ↗

获取SEO @param page 页面 @param defaultTitle 默认标题 @param defaultKeywords 默认关键字 @param defaultDescription 默认摘要 @param Sitename 站点名称 @return seo SEO数据

(page string, defaultTitle, defaultKeywords, defaultDescription, Sitename string)

Source from the content-addressed store, hash-verified

65//@param Sitename 站点名称
66//@return seo SEO数据
67func (this *Seo) GetByPage(page string, defaultTitle, defaultKeywords, defaultDescription, Sitename string) (seo map[string]string) {
68 var seoStruct Seo
69 seo = make(map[string]string)
70 defSeo := map[string]string{
71 "Title": defaultTitle,
72 "Keywords": defaultKeywords,
73 "Description": defaultDescription,
74 "Sitename": Sitename,
75 }
76 replace := map[string]string{
77 "Title": "{title}",
78 "Keywords": "{keywords}",
79 "Description": "{description}",
80 "Sitename": "{sitename}",
81 }
82 replaceFunc := func(item string, defSeo map[string]string) string {
83 for k, v := range replace {
84 item = strings.Replace(item, v, defSeo[k], -1)
85 }
86 return item
87 }
88 orm.NewOrm().QueryTable(GetTableSeo()).Filter("Page", page).One(&seoStruct)
89 if seoStruct.Id > 0 {
90 seo["Title"] = replaceFunc(seoStruct.Title, defSeo)
91 seo["Keywords"] = replaceFunc(seoStruct.Keywords, defSeo)
92 seo["Description"] = replaceFunc(seoStruct.Description, defSeo)
93 }
94 return seo
95}
96
97//baseUrl := this.Ctx.Input.Scheme() + "://" + this.Ctx.Request.Host
98//if host := beego.AppConfig.String("sitemap_host"); len(host) > 0 {

Callers 12

GetMethod · 0.80
CoinMethod · 0.80
CollectMethod · 0.80
LoginMethod · 0.80
RegMethod · 0.80
FindPwdMethod · 0.80
GetMethod · 0.80
PagesMethod · 0.80
GetMethod · 0.80
GetMethod · 0.80
GetMethod · 0.80
GetMethod · 0.80

Calls 2

GetTableSeoFunction · 0.85
OneMethod · 0.80

Tested by

no test coverage detected