8000 Feat seo view by ZLValien · Pull Request #972 · qor5/admin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Feat seo view #972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/docsrc/examples/examples_admin/seo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestSEOExampleBasic(t *testing.T) {
BuildEventFuncRequest()
return req
},
ExpectPortalUpdate0ContainsInOrder: []string{`<v-img :src=`},
ExpectPortalUpdate0ContainsInOrder: []string{`http://www.text.jpg`},
},
{
Name: "SEO Detail Without OpenGraphImageURL",
Expand All @@ -76,7 +76,7 @@ func TestSEOExampleBasic(t *testing.T) {
BuildEventFuncRequest()
return req
},
ExpectPortalUpdate0NotContains: []string{`<v-img :src=`},
ExpectPortalUpdate0NotContains: []string{`http://www.text.jpg`},
},
}

Expand Down
58 changes: 28 additions & 30 deletions seo/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,42 +369,24 @@ func (b *Builder) vSeoReadonly(obj interface{}, fieldPrefix, locale string, seo
}
keywordsComps = append(keywordsComps, h.Span(keyword))
}
var openGraphInformationComp h.HTMLComponent
if setting.OpenGraphURL == "" && setting.OpenGraphTitle == "" && setting.OpenGraphType == "" && setting.OpenGraphDescription == "" && setting.OpenGraphImageURL == "" {
openGraphInformationComp = h.Text(msgr.BlankOpenGraphInformationTips)
} else {
openGraphInformationComp = h.Components(
h.If(
strings.HasPrefix(setting.OpenGraphImageURL, "http://") ||
strings.HasPrefix(setting.OpenGraphImageURL, "https://"),
VImg().Src(setting.OpenGraphImageURL).Width(300)),
h.Div(h.Span(setting.OpenGraphTitle)).Class("text-subtitle-1 mt-2"),
h.Div(h.Span(setting.OpenGraphDescription)).Class("text-body-2 mt-2"),
h.Div(h.A().Text(setting.OpenGraphURL).Href(setting.OpenGraphURL)).Class("text-body-2 mt-2"))
}

return h.Components(
h.Div(
h.Span(msgr.SEOPreview).Class("text-subtitle-1 px-2 py-1 rounded", "bg-"+ColorGreyLighten3),
h.Span(msgr.Basic).Class("text-subtitle-1 px-2 py-1 rounded", "bg-"+ColorGreyLighten3),
),
VCard(
VCardText(
h.Span(setting.Title).Class("text-subtitle-1").Class(fmt.Sprintf(`text-%s`, ColorPrimary)),
h.Div(keywordsComps...).Class("mt-2").Class(fmt.Sprintf(`text-%s`, ColorPrimary)),
h.Div(h.Span(setting.Description)).Class("text-body-2 mt-2"),
).Class("pa-0"),
).Class("pa-6", "mt-2").Color(ColorPrimaryLighten2),
seoFieldPortal(msgr.Title, setting.Title),
seoFieldPortal(msgr.Description, setting.Description),
seoFieldPortal(msgr.Keywords, setting.Keywords),
h.Div(
h.Span(msgr.OpenGraphInformation).Class("text-subtitle-1 px-2 py-1 rounded", "bg-"+ColorGreyLighten3),
).Class("mt-7"),
VCard(
VCardText(
openGraphInformationComp,
).Class("pa-0"),
).Class("pa-6 mt-2").Color(ColorPrimaryLighten2),
).Class("mt-10"),
seoFieldPortal(msgr.OpenGraphTitle, setting.OpenGraphTitle),
seoFieldPortal(msgr.OpenGraphDescription, setting.OpenGraphDescription),
seoFieldPortal(msgr.OpenGraphURL, setting.OpenGraphURL),
seoFieldPortal(msgr.OpenGraphImageURL, setting.OpenGraphImageURL),
h.Div(
h.Span(msgr.OpenGraphImage).Class("text-subtitle-1 px-2 py-1 rounded", "bg-"+ColorGreyLighten3),
).Class("mt-7"),
).Class("mt-10 mb-2"),
VContainer(
VRow(
VCol(media.QMediaBox(db).
Expand Down Expand Up @@ -432,8 +414,12 @@ func (b *Builder) vSeoReadonly(obj interface{}, fieldPrefix, locale string, seo
).Class("pl-0 pt-2"),
h.Div(
h.Span(msgr.OpenGraphMetadata).Class("text-subtitle-1 px-2 py-1 rounded", "bg-"+ColorGreyLighten3),
).Class("mt-7"),
h.Text(GetOpenGraphMetadataString(setting.OpenGraphMetadata)),
).Class("mt-1"),
h.Div(
h.Pre(
GetOpenGraphMetadataString(setting.OpenGraphMetadata),
).Style("margin: 0; font-family: inherit;"),
).Class("mt-4 px-3"),
)
}

Expand Down Expand Up @@ -492,3 +478,15 @@ func (b *Builder) detailSaver(obj interface{}, ctx *web.EventContext) (err error
}
return
}

func seoFieldPortal(label string, value string) h.HTMLComponent {
return h.Div(
VXLabel(
h.Span(label).
Style("line-height:20px; font-size:14px; font-weight:500;"),
),
h.Div(
h.Span(value),
).Class("pa-2 px-3 d-flex align-center gap-1"),
).Class("mt-4")
}
3 changes: 0 additions & 3 deletions seo/messages.go
7C0D
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ type Messages struct {
OpenGraphMetadata string
Seo string
Customize string
SEOPreview string
BlankOpenGraphInformationTips string
}

Expand All @@ -37,7 +36,6 @@ var Messages_en_US = &Messages{
OpenGraphMetadata: "Open Graph Metadata",
Seo: "SEO",
Customize: "Customize",
SEOPreview: "SEO Preview",
BlankOpenGraphInformationTips: `The "Open Graph Information" are blank. The default values will be used on the page.`,
}

Expand All @@ -57,6 +55,5 @@ var Messages_zh_CN = &Messages{
OpenGraphMetadata: "OG 元数据",
Seo: "搜索引擎优化",
Customize: "自定义",
SEOPreview: "SEO 预览",
BlankOpenGraphInformationTips: `"OG 信息"w为空。页面将使用默认值。`,
}
Loading
0