Skip to content
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

feat: implement a feature for previewing posts and single pages #3983

Merged
merged 8 commits into from May 25, 2023

Conversation

guqing
Copy link
Member

@guqing guqing commented May 22, 2023

What type of PR is this?

/kind feature
/area core
/area console
/milestone 2.6.x

What this PR does / why we need it:

新增文章和自定义页面预览功能

提供了以下两个路由用于预览,必须登录且是对应文章或自定义页面的 contributors 才能访问,如果不是 contributor 则先得到没有权限访问异常,如果有权限访问但预览文章不存在则得到 404

  • 文章预览 GET /preview/posts/{name}
  • 自定义页面预览 GET /preview/singlepages/{name}

两个路由都可以通过查询参数 snapshotName 来指定需要预览的内容快照,它是可选的,默认为当前正在编辑的内容

Which issue(s) this PR fixes:

Fixes #2349

Does this PR introduce a user-facing change?

新增文章和自定义页面预览功能

@f2c-ci-robot f2c-ci-robot bot added kind/feature Categorizes issue or PR as related to a new feature. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels May 22, 2023
@f2c-ci-robot f2c-ci-robot bot added this to the 2.6.x milestone May 22, 2023
@f2c-ci-robot f2c-ci-robot bot added area/core Issues or PRs related to the Halo Core area/console Issues or PRs related to the Halo Console labels May 22, 2023
@codecov
Copy link

codecov bot commented May 22, 2023

Codecov Report

Merging #3983 (ec09a3d) into main (533f0cf) will decrease coverage by 0.18%.
The diff coverage is 61.11%.

@@             Coverage Diff              @@
##               main    #3983      +/-   ##
============================================
- Coverage     60.52%   60.35%   -0.18%     
- Complexity     2342     2360      +18     
============================================
  Files           353      356       +3     
  Lines         12106    12215     +109     
  Branches        881      889       +8     
============================================
+ Hits           7327     7372      +45     
- Misses         4347     4403      +56     
- Partials        432      440       +8     
Impacted Files Coverage Δ
...pp/theme/dialect/ContentTemplateHeadProcessor.java 82.35% <ø> (ø)
...app/theme/dialect/TemplateGlobalHeadProcessor.java 94.44% <ø> (ø)
...ain/java/run/halo/app/theme/router/ModelConst.java 100.00% <ø> (ø)
...pp/theme/router/factories/ArchiveRouteFactory.java 74.28% <ø> (ø)
...heme/router/factories/AuthorPostsRouteFactory.java 82.60% <ø> (ø)
...theme/router/factories/CategoriesRouteFactory.java 100.00% <ø> (ø)
...eme/router/factories/CategoryPostRouteFactory.java 15.62% <ø> (ø)
.../app/theme/router/factories/IndexRouteFactory.java 100.00% <ø> (ø)
.../halo/app/theme/router/factories/RouteFactory.java 100.00% <ø> (ø)
...o/app/theme/router/factories/TagsRouteFactory.java 62.50% <ø> (ø)
... and 7 more

... and 11 files with indirect coverage changes

@ruibaby
Copy link
Member

ruibaby commented May 23, 2023

测试发现未发布的文章预览时,部分数据没有会导致页面渲染异常,比较常见的是 spec.publishTimestatus.lastModifyTime,但仅限于对其做了特殊处理(比如格式化)会导致异常。是否需要对这些字段设置一个 mock 值?

image

@guqing
Copy link
Member Author

guqing commented May 23, 2023

测试发现未发布的文章预览时,部分数据没有会导致页面渲染异常,比较常见的是 spec.publishTimestatus.lastModifyTime,但仅限于对其做了特殊处理(比如格式化)会导致异常。是否需要对这些字段设置一个 mock 值?

可以

@guqing
Copy link
Member Author

guqing commented May 23, 2023

/hold
wait for console adaptation

@f2c-ci-robot f2c-ci-robot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 23, 2023
Signed-off-by: Ryan Wang <i@ryanc.cc>
Signed-off-by: Ryan Wang <i@ryanc.cc>
@ruibaby
Copy link
Member

ruibaby commented May 23, 2023

/unhold

Console 已经适配,目前有两个入口可进行预览:

image image

@f2c-ci-robot f2c-ci-robot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 23, 2023
Copy link
Member

@ruibaby ruibaby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@f2c-ci-robot f2c-ci-robot bot added the lgtm Indicates that a PR is ready to be merged. label May 24, 2023
@guqing
Copy link
Member Author

guqing commented May 24, 2023

能否在新创建时也显示预览按钮而不是点击了保存之后再显示,反正预览时都会保存内容

Signed-off-by: Ryan Wang <i@ryanc.cc>
@f2c-ci-robot f2c-ci-robot bot removed the lgtm Indicates that a PR is ready to be merged. label May 24, 2023
@ruibaby
Copy link
Member

ruibaby commented May 25, 2023

能否在新创建时也显示预览按钮而不是点击了保存之后再显示,反正预览时都会保存内容

已修改。

Copy link
Member Author

@guqing guqing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented May 25, 2023

@guqing: you cannot LGTM your own PR.

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Member

@JohnNiang JohnNiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@f2c-ci-robot f2c-ci-robot bot added the lgtm Indicates that a PR is ready to be merged. label May 25, 2023
@f2c-ci-robot
Copy link

f2c-ci-robot bot commented May 25, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JohnNiang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@f2c-ci-robot f2c-ci-robot bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 25, 2023
@f2c-ci-robot f2c-ci-robot bot merged commit da5fb1a into halo-dev:main May 25, 2023
4 checks passed
@ruibaby ruibaby modified the milestones: 2.6.x, 2.6.0 May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/console Issues or PRs related to the Halo Console area/core Issues or PRs related to the Halo Core kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

文章预览功能
3 participants