From 937e766294b9e552221c8f914ae74b5b2d709af0 Mon Sep 17 00:00:00 2001 From: xing Date: Mon, 12 Jun 2023 23:08:46 +0800 Subject: [PATCH] =?UTF-8?q?tweentysevent=20=E9=A1=B5=E7=9C=89=E5=AA=92?= =?UTF-8?q?=E4=BD=93=E6=94=AF=E6=8C=81=E8=A7=86=E9=A2=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- app/pkg/dao/posts.go | 1 + app/pkg/models/wp_postmeta.go | 11 ++ app/pkg/models/wp_posts.go | 1 + app/theme/twentyfifteen/customheader.go | 6 +- app/theme/twentyseventeen/layout/base.gohtml | 4 +- app/theme/twentyseventeen/twentyseventeen.go | 29 ++++- app/theme/wp/customheader.go | 126 ++++++++++++++++++- app/theme/wp/ext.go | 121 ++++++++++++++++++ helper/strings/strings.go | 12 ++ readme_en.md | 14 +-- 11 files changed, 310 insertions(+), 17 deletions(-) create mode 100644 app/theme/wp/ext.go diff --git a/README.md b/README.md index b6add44..a83f316 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ |---------------|-----------------| | 站点身份 | 站点身份 | | 颜色 | 颜色 | -| 页眉图片 | 页眉媒体 (暂不支持视频) | +| 页眉图片 | 页眉媒体 | | 背景图片 | 额外css | | 额外css | | diff --git a/app/pkg/dao/posts.go b/app/pkg/dao/posts.go index 6846d9c..6338fef 100644 --- a/app/pkg/dao/posts.go +++ b/app/pkg/dao/posts.go @@ -66,6 +66,7 @@ func GetPostsByIds(a ...any) (m map[uint64]models.Posts, err error) { } mm, ok := meta[pp.Id] if ok { + pp.Metas = mm attMeta, ok := mm["_wp_attachment_metadata"] if ok { att, ok := attMeta.(models.WpAttachmentMetadata) diff --git a/app/pkg/models/wp_postmeta.go b/app/pkg/models/wp_postmeta.go index b31bb72..fc61b24 100644 --- a/app/pkg/models/wp_postmeta.go +++ b/app/pkg/models/wp_postmeta.go @@ -22,6 +22,7 @@ type WpAttachmentMetadata struct { FileSize int `json:"filesize,omitempty"` Sizes map[string]MetaDataFileSize `json:"sizes,omitempty"` ImageMeta ImageMeta `json:"image_meta"` + VideoMeta } type ImageMeta struct { @@ -39,6 +40,16 @@ type ImageMeta struct { Keywords []string `json:"keywords,omitempty"` } +type VideoMeta struct { + Bitrate int `json:"bitrate,omitempty"` + MimeType string `json:"mime_type,omitempty"` + Length int `json:"length,omitempty"` + LengthFormatted string `json:"length_formatted,omitempty"` + FileFormat string `json:"fileformat,omitempty"` + DataFormat string `json:"dataformat,omitempty"` + CreatedTimestamp int64 `json:"created_timestamp"` +} + type MetaDataFileSize struct { File string `json:"file,omitempty"` Width int `json:"width,omitempty"` diff --git a/app/pkg/models/wp_posts.go b/app/pkg/models/wp_posts.go index 34d6e41..fd9bbdc 100644 --- a/app/pkg/models/wp_posts.go +++ b/app/pkg/models/wp_posts.go @@ -40,6 +40,7 @@ type Posts struct { IsSticky bool Thumbnail PostThumbnail AttachmentMetadata WpAttachmentMetadata + Metas map[string]any Author *Users } diff --git a/app/theme/twentyfifteen/customheader.go b/app/theme/twentyfifteen/customheader.go index 35169b5..838623c 100644 --- a/app/theme/twentyfifteen/customheader.go +++ b/app/theme/twentyfifteen/customheader.go @@ -83,8 +83,8 @@ var imgStyle = `.site-header { var header = reload.Vars(constraints.Defaults) -func calCustomHeader(h *wp.Handle) (r string, rand bool) { - img, rand := h.GetCustomHeader() +func calCustomHeaderImg(h *wp.Handle) (r string, rand bool) { + img, rand := h.GetCustomHeaderImg() if img.Path == "" && h.DisplayHeaderText() { return } @@ -112,7 +112,7 @@ func customHeader(h *wp.Handle) func() string { return func() string { headers := header.Load() if headers == constraints.Defaults { - headerss, rand := calCustomHeader(h) + headerss, rand := calCustomHeaderImg(h) headers = headerss if !rand { header.Store(headers) diff --git a/app/theme/twentyseventeen/layout/base.gohtml b/app/theme/twentyseventeen/layout/base.gohtml index a6048ee..55d2410 100644 --- a/app/theme/twentyseventeen/layout/base.gohtml +++ b/app/theme/twentyseventeen/layout/base.gohtml @@ -11,7 +11,7 @@