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: add strategy setting for post slug generation #4551

Merged
merged 21 commits into from
Sep 10, 2023

Conversation

GodlessLiu
Copy link
Contributor

@GodlessLiu GodlessLiu commented Sep 5, 2023

What type of PR is this?

/kind improvement

What this PR does / why we need it:

添加文章别名自动生成策略

Which issue(s) this PR fixes:

Fixes #1790

Special notes for your reviewer:

需要后端提供支持在globalInfo里面添加gSlugMode字段。它的类型为(后续可能会支持更多的模式)
image

Does this PR introduce a user-facing change?

文章支持多别名生成策略。

@f2c-ci-robot f2c-ci-robot bot added kind/improvement Categorizes issue or PR as related to a improvement. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Sep 5, 2023
@GodlessLiu GodlessLiu changed the title Fix/article slug 添加文章别名自动生成策略 Sep 5, 2023
@f2c-ci-robot f2c-ci-robot bot requested review from QuentinHsu and ruibaby September 5, 2023 03:31
@codecov
Copy link

codecov bot commented Sep 5, 2023

Codecov Report

Merging #4551 (bbe99e0) into main (0098654) will decrease coverage by 0.03%.
Report is 1 commits behind head on main.
The diff coverage is 0.00%.

@@             Coverage Diff              @@
##               main    #4551      +/-   ##
============================================
- Coverage     61.07%   61.04%   -0.03%     
  Complexity     2566     2566              
============================================
  Files           374      374              
  Lines         13162    13168       +6     
  Branches        937      938       +1     
============================================
  Hits           8039     8039              
- Misses         4670     4676       +6     
  Partials        453      453              
Files Changed Coverage Δ
...java/run/halo/app/actuator/GlobalInfoEndpoint.java 1.25% <0.00%> (-0.11%) ⬇️

📢 Have feedback on the report? Share it here.

Signed-off-by: guqing <i@guqing.email>
@guqing
Copy link
Member

guqing commented Sep 5, 2023

@GodlessLiu 已在 globalinfo 中添加 postSlugGenerationStrategy 字段

@GodlessLiu
Copy link
Contributor Author

@GodlessLiu 已在 globalinfo 中添加 postSlugGenerationStrategy 字段

是否考虑分类或者标签的生成也可以应用所选策略

@GodlessLiu
Copy link
Contributor Author

@guqing 添加设置在主题路由设置下,而不是文章设置下,还有第一次修改设置需要刷新页面才会生效,初步判断出错的地方可能是use-global-info.ts下面设置了缓存
image

@guqing
Copy link
Member

guqing commented Sep 5, 2023

@guqing 添加设置在主题路由设置下,而不是文章设置下,还有第一次修改设置需要刷新页面才会生效,初步判断出错的地方可能是use-global-info.ts下面设置了缓存

image

@ruibaby 在主题路由设置下?

@guqing
Copy link
Member

guqing commented Sep 5, 2023

@guqing 添加设置在主题路由设置下,而不是文章设置
@ruibaby 在主题路由设置下?

将 slug 生成策略放在路由规则设置下可能会与其它路由相关的设置混淆,并且不够直观。路由规则设置主要关注于定义 URL 的格式和结构,以便访问特定的资源。slug 生成策略应该只是为了更好的填充文章的基本属性而准备的相关性更高

@ruibaby
Copy link
Member

ruibaby commented Sep 5, 2023

@GodlessLiu 已在 globalinfo 中添加 postSlugGenerationStrategy 字段

是否考虑分类或者标签的生成也可以应用所选策略

建议目前仅对文章生效,分类和标签保持以前的逻辑。

@guqing 添加设置在主题路由设置下,而不是文章设置
@ruibaby 在主题路由设置下?

将 slug 生成策略放在路由规则设置下可能会与其它路由相关的设置混淆,并且不够直观。路由规则设置主要关注于定义 URL 的格式和结构,以便访问特定的资源。slug 生成策略应该只是为了更好的填充文章的基本属性而准备的相关性更高

可以放在文章设置下。后续如果对分类和标签也有这样的需求,也可以放在文章设置下,因为分类和标签只是文章的概念。

@GodlessLiu
Copy link
Contributor Author

@guqing 添加设置在主题路由设置下,而不是文章设置
@ruibaby 在主题路由设置下?

将 slug 生成策略放在路由规则设置下可能会与其它路由相关的设置混淆,并且不够直观。路由规则设置主要关注于定义 URL 的格式和结构,以便访问特定的资源。slug 生成策略应该只是为了更好的填充文章的基本属性而准备的相关性更高

但是该设置不应该只作用于文章路由生成,它也应该作用于标签和分类的路由生成(这样可以保证全局的路由生成规则风格一致)。这样放在文章设置下可能有些许不妥。

@ruibaby
Copy link
Member

ruibaby commented Sep 5, 2023

还有第一次修改设置需要刷新页面才会生效

在保存系统设置之后,清理掉 key 为 globalinfo 的 缓存即可。

参考:https://github.com/halo-dev/halo/blob/2baf6aeb31906599e5fee9b833a2801c637434a8/console/src/modules/system/settings/tabs/Setting.vue#L60C4-L60C69

@guqing
Copy link
Member

guqing commented Sep 5, 2023

添加了 postSlugGenerationStrategy 的默认值,console 部分 @GodlessLiu 继续改就好了,我发现文章点保存的之后规则是还是默认的时间戳应该功能不全

@GodlessLiu
Copy link
Contributor Author

添加了 postSlugGenerationStrategy 的默认值,console 部分 @GodlessLiu 继续改就好了,我发现文章点保存的之后规则是还是默认的时间戳应该功能不全

@guqing @ruibaby done

@GodlessLiu GodlessLiu changed the title 添加文章别名自动生成策略 添加文章、标签、分类别名自动生成策略 Sep 6, 2023
@f2c-ci-robot f2c-ci-robot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 7, 2023
@f2c-ci-robot f2c-ci-robot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 7, 2023
@GodlessLiu GodlessLiu changed the title 添加文章、标签、分类别名自动生成策略 添加文章别名自动生成策略 Sep 7, 2023
GodlessLiu and others added 2 commits September 8, 2023 14:52
Refine camel-case

Co-authored-by: guqing <38999863+guqing@users.noreply.github.com>
@guqing
Copy link
Member

guqing commented Sep 8, 2023

image

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 Sep 8, 2023
@ruibaby ruibaby changed the title 添加文章别名自动生成策略 feat: add strategy setting for post slug generation Sep 8, 2023
@ruibaby
Copy link
Member

ruibaby commented Sep 8, 2023

/milestone 2.10.x

@f2c-ci-robot f2c-ci-robot bot added this to the 2.10.x milestone Sep 8, 2023
@ruibaby ruibaby requested review from JohnNiang and LIlGG and removed request for QuentinHsu September 8, 2023 09:01
Copy link
Member

@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.

/approve

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Sep 10, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: guqing

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 Sep 10, 2023
@f2c-ci-robot f2c-ci-robot bot merged commit e13563b into halo-dev:main Sep 10, 2023
@ruibaby ruibaby modified the milestones: 2.10.x, 2.10.0 Sep 13, 2023
@GodlessLiu GodlessLiu deleted the fix/article-slug branch September 29, 2023 05:16
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. kind/improvement Categorizes issue or PR as related to a improvement. 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