Commit Graph

2474 Commits (3146589d25a1b51a520fb0234405e20b703c32a1)

Author SHA1 Message Date
guqing 3146589d25
fix: theme status phase is always FAILED even if version of Halo is satisfied (#3390)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.3.x

#### What this PR does / why we need it:
修复主题 requires 版本匹配后依然显示 FAILED 状态的问题

how to test it?
1. 安装一个主题后更新主题的 requires 为不匹配系统版本号,此时主题 status 会提示版本号不匹配的错误
2. 再更新 requires 为正确的,phase 会从 FAILED 变为 READY

#### Which issue(s) this PR fixes:
Fixes #3326
#### Does this PR introduce a user-facing change?
```release-note
修复主题状态显示不正确的问题
```
2023-02-28 14:10:18 +00:00
guqing 166a440df1
chore: disable the visit log writer (#3421)
#### What type of PR is this?
/kind cleanup
/area core
/milestone 2.3.x

#### What this PR does / why we need it:
移除 VisitLogWriter 的使用,不再记录访问日志,后续由 httptrace 去暴露指标

#### Does this PR introduce a user-facing change?
```release-note
None
```
2023-02-28 13:18:18 +00:00
Li 1a9e2f046a
feat: add stats to the user-sdie comments api (#3366)
#### What type of PR is this?
/milestone 2.3.x
/kind feature

#### What this PR does / why we need it:
为访客端的评论和回复接口 聚合点赞数

#### Which issue(s) this PR fixes:
Fixes #3347 

#### Special notes for your reviewer:
同步修改了 finder API 及 console 位置的接口

如何测试:
1. 调用接口 `/apis/api.halo.run/v1alpha1/trackers/upvote` 增加点赞数。
2. 使用 console 接口 `/apis/api.halo.run/v1alpha1/comments/{name}` 查看目标评论是否增加点赞数。

#### Does this PR introduce a user-facing change?

```release-note
访客端评论及回复列表支持返回点赞数据
```
2023-02-28 10:48:17 +00:00
John Niang 848857fbfd
Provide an endpoint to get plugin presets (#3394)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.3.x

#### What this PR does / why we need it:

This PR provide a new endpoint to get plugins presets. Please see the result:

```bash
❯ curl -s -u admin:admin 'http://127.0.0.1:8090/apis/api.console.halo.run/v1alpha1/plugin-presets'
```
```json
[
  {
    "spec": {
      "displayName": "评论组件",
      "version": "1.2.0",
      "author": {
        "name": "Halo OSS Team",
        "website": "https://github.com/halo-dev"
      },
      "logo": "https://halo.run/logo",
      "pluginDependencies": {},
      "homepage": "https://github.com/halo-sigs/plugin-comment-widget",
      "description": "为用户前台提供完整的评论解决方案",
      "license": [
        {
          "name": "MIT"
        }
      ],
      "requires": ">=2.2.0",
      "enabled": true
    },
    "status": {
      "phase": "RESOLVED"
    },
    "apiVersion": "plugin.halo.run/v1alpha1",
    "kind": "Plugin",
    "metadata": {
      "name": "PluginCommentWidget"
    }
  },
  {
    "spec": {
      "displayName": "搜索组件",
      "version": "1.0.0",
      "author": {
        "name": "Halo OSS Team",
        "website": "https://github.com/halo-dev"
      },
      "logo": "https://halo.run/logo",
      "pluginDependencies": {},
      "homepage": "https://github.com/halo-sigs/plugin-search-widget",
      "description": "为 Halo 2.0 提供统一的搜索组件,方便主题端使用。",
      "license": [
        {
          "name": "MIT"
        }
      ],
      "requires": ">=2.0.0",
      "enabled": true
    },
    "status": {
      "phase": "RESOLVED"
    },
    "apiVersion": "plugin.halo.run/v1alpha1",
    "kind": "Plugin",
    "metadata": {
      "name": "PluginSearchWidget"
    }
  }
]
```

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/3120

#### Special notes for your reviewer:

1. Try to download some plugins from <https://github.com/halo-sigs/awesome-halo>.
2. Put those jars into folder `src/main/resources/presets/plugins/`.
3. Get all plugins presets using the command below:
    
    ```bash
    # You might change your own username and password by yourself.
    curl -s -u admin:admin 'http://127.0.0.1:8090/apis/api.console.halo.run/v1alpha1/plugin-presets'
    ```

#### Does this PR introduce a user-facing change?

```release-note
提供预设插件功能
```
2023-02-28 10:26:18 +00:00
guqing 039d3f508d
fix: post page size configuration not work (#3413)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.3.x
#### What this PR does / why we need it:
修复文章列表分页配置取值错误的问题
此问题为 #3300 PR 引入,由于改动较大遗漏了这点没测试到。

how to test it?
修改文章设置中的大小,查看主题端分页是否符合预期:
包括首页,归档页,标签文章页,分类文章页。
<img width="575" alt="image" src="https://user-images.githubusercontent.com/38999863/221574440-eeec9c27-57ab-46d1-823f-7cc076fb2b54.png">

#### Which issue(s) this PR fixes:
Fixes #3411

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
None
```
2023-02-28 09:30:16 +00:00
guqing 79e705123e
fix: template rendering missing template_id model data (#3414)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.3.x

#### What this PR does / why we need it:
修复文章模板渲染丢失 template_id 参数导致无法代码注入的问题

how to test it?
测试 [plugin-highlightjs](https://github.com/halo-sigs/plugin-highlightjs) 插件功能是否正常,期望在 html head 插入 `/plugins/PluginHighlightJS/assets/static/highlight.min.js`

#### Which issue(s) this PR fixes:
Fixes #3403

#### Does this PR introduce a user-facing change?
```release-note
None
```
2023-02-28 03:34:16 +00:00
Ryan Wang cbd2f8b2ed
docs: fix command of docker run (#3415)
#### What type of PR is this?

/kind documentation

#### What this PR does / why we need it:

修复 Docker 快速运行的 `halo.security.initializer.superadminusername` 参数。

#### Does this PR introduce a user-facing change?


```release-note
None
```
2023-02-27 14:46:15 +00:00
171d4761e6
fix: exclude ghost and anonymous user when counting users (#3370)
#### What type of PR is this?

/kind bug

#### What this PR does / why we need it:
后台进行用户数量统计时,排除ghost和anonymousUser

#### Which issue(s) this PR fixes:

Fixes #3349 

#### Does this PR introduce a user-facing change?

```release-note
修复仪表盘用户数显示错误问题
```
2023-02-25 22:18:16 +08:00
guqing adff2a7194
refactor: default is approved to reply to comments on the console-side (#3363)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.3.x

#### What this PR does / why we need it:
Console 端创建回复不再需要审核
但需要注意的是目前无法区分是否为管理员,所以如果具有评论管理权限的用户在主题端登录回复还是需要审核。

#### Which issue(s) this PR fixes:
Fixes #3353

#### Special notes for your reviewer:
how to test it?
1. 在主题端创建评论和回复都需要审核
2. 在 console 端回复不需要审核

/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
Console 端创建回复不再需要审核
```
2023-02-24 18:09:57 +08:00
guqing f1ec6ceeab
chore: add finalizer for ghost and anonymous users (#3386)
#### What type of PR is this?
/kind improvement
/area core

#### What this PR does / why we need it:
为系统默认用户添加系统保护 finalizer,避免被删除

how to test it?
```shell
curl -u username:password --basic 'http://localhost:8090/api/v1alpha1/users/ghost'
curl -u username:password --basic 'http://localhost:8090/api/v1alpha1/users/anonymousUser'
```
将看到 
```json
"finalizers": [
  "...",
  "system-protection"
]
```
#### Which issue(s) this PR fixes:

Fixes #

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
None
```
2023-02-24 10:04:17 +00:00
Li 3330ff8c3d
refactor: add version flag to plugin static assets (#3381)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.3.x

#### What this PR does / why we need it:
对插件的静态资源(js, css) 增加 version 版本号,用于解决插件静态资源缓存的问题。另外同时也对插件 Logo 增加了版本号标识。

#### Which issue(s) this PR fixes:
Fixes #3205 

#### Special notes for your reviewer:
验证 Console 端插件静态资源链接是否携带 `version={pluginVersion}` 。

特别的,对于 logo只会增加相对路径下的地址,绝对路径的地址将直接返回原始路径/值。

#### Does this PR introduce a user-facing change?

```release-note
为插件静态资源路径增加版本标识以解决缓存更新不及时的问题
```
2023-02-24 18:02:38 +08:00
guqing c8f3229cd6
feat: add role information for user-related custom endpoint (#3372)
#### What type of PR is this?
/kind feature
/kind api-change
/area core
/milestone 2.3.x

#### What this PR does / why we need it:
获取用户信息的 API 响应体包含关联角色信息

- 新增 API `/apis/api.console.halo.run/v1alpha1/users/{name}`
- 修改了 API 的返回值类型 `/apis/api.console.halo.run/v1alpha1/users/-`

由于 API 响应体结构的改变,需要 Console 适配
#### Which issue(s) this PR fixes:

Fixes #3342

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
获取用户信息的 API 响应体包含关联角色信息
```
2023-02-24 17:39:34 +08:00
guqing 9fff768134
perf: cannot be accessed for a long time during startup (#3300)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.3.x
#### What this PR does / why we need it:
能通过注册 pattern 作为路由的就直接注册 pattern 以避免 Reconciler 还没结束而无法注册路由导致的访问问题。
1. 文章、标签、分类的 permalink 规则会记录在对应 extension  的 annotations 中为  `content.halo.run/permalink-pattern: some-pattern` ,当系统设置中路由规则改变时会刷一遍这些资源的 `content.halo.run/permalink-pattern` annotation。
3. 自定义页面的访问是通过 SinglePageRoute 控制,它会在 single page 添加、更新、删除时维护 quickRouteMap 的集合,在路由到它时直接通过 request path 查找 map key,找到则直接返回 HandleFunction。
4. 除了自定义页面外其他都是通过 ThemeCompositeRouterFunction 作为路由管理器,系统启动时文章等的 RouterFunction 会被生成并缓存到 cachedRouters 的一个 List 集合中,当路由规则改变会清理它重新赋值。

#### Which issue(s) this PR fixes:

Fixes #3254 

#### Special notes for your reviewer:
how  to test it?
1.  测试首页、文章、标签、分类、归档页、自定义页面和作者页等的访问。
6. 测试添加、删除资源和修改系统路由规则后上述资源的访问。
7. 测试分页路径如 /tags/slug/page/1 的访问。

/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
 优化启动时页面长时间无法访问的问题
```
2023-02-24 17:38:44 +08:00
guqing ce80ed4283
fix: i18n unit test (#3388)
#### What type of PR is this?
/kind improvement
/area core

#### What this PR does / why we need it:
修复 i18n 的单元测试,在中文或其他除了英语之外的系统语言的环境下断言无法通过
<img width="883" alt="image" src="https://user-images.githubusercontent.com/38999863/221122828-b3cb2139-21ff-4e44-8ee8-62326aa249bc.png">

可以将系统语言设置为其他来测试此 PR 不会出现上述问题即可

#### Does this PR introduce a user-facing change?
```release-note
None
```
2023-02-24 08:40:13 +00:00
John Niang 0d9ec4f197
Report test result using Jacoco plugin (#3385) 2023-02-24 15:51:21 +08:00
guqing 7a0ba922af
refactor: APIs returns ghost users when user is deleted (#3373)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.3.x

#### What this PR does / why we need it:
用户被删除时关联到的用户返回 ghost 用户信息

#### Which issue(s) this PR fixes:

Fixes #3356

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?
```release-note
用户被删除时关联到的用户返回 ghost 用户信息
```
2023-02-24 06:24:12 +00:00
John Niang 937573e6b2
Upgrade to Spring Boot 3.0.3 (#3379)
#### What type of PR is this?

/kind cleanup
/area core

#### What this PR does / why we need it:

Upgrade to Spring Boot 3.0.3. See https://github.com/spring-projects/spring-boot/releases/tag/v3.0.3 for more.

#### Does this PR introduce a user-facing change?

```release-note
Upgrade to Spring Boot 3.0.3.
```
2023-02-24 03:20:12 +00:00
John Niang ce85b98539
Discard watch when extension status is changed only (#3362)
#### What type of PR is this?

/kind improvement
/area core

#### What this PR does / why we need it:

This PR mainly creates two things:

1. Create JsonExtension to represent any extension and make extension modification more convenient
2. Discard watch when we detect that the extension status is changed only. It's useful to prevent infinite loop of reconciler.

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/3273

#### Special notes for your reviewer:

Try to install test plugin from [plugin-comment-widget.zip](https://github.com/halo-dev/halo/files/10799875/plugin-comment-widget.zip) before checking out this PR. You will get a infinite reconciliation loop.

Then, stop the process and checkout this PR and see the result.

#### Does this PR introduce a user-facing change?

```release-note
None
```
2023-02-23 10:24:12 +00:00
guqing 3a1587bab5
refactor: add creationTime field for comment extension to resolve migration issue (#3341)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.3.x
/kind api-change

#### What this PR does / why we need it:
1. spec 中新增 creationTime
2. 旧数据的 spec.creationTime 默认等于 approvedTime
3. 按照 metadata.creationTimestamp 排序的使用 spec.creationTime 代替

how to test it?
1. 使用迁移插件迁移看评论和回复的排序是否正确
2. 使用评论插件创建评论和回复看顺序是否正确
#### Which issue(s) this PR fixes:
Fixes #3330

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
评论和回复新增创建时间以兼容迁移数据的排序
```
2023-02-23 10:06:12 +00:00
guqing 6c2064f1e0
feat: plugin supports configuration when not started (#3355)
#### What type of PR is this?
/kind feature
/milestone 2.3.x
/area core
/area plugin

#### What this PR does / why we need it:
顺便重构了一下插件 Reconciler ,否则经常容易出 bug,刚好一起测试一下免得反复整体测试这一块。
1. 插件 status 里的 message 和 reason 之前是直接放在 status 里的,现在改为一个 ConditionList, 最新的始终在 ConditionList 的第一个,这可以避免插件启动成功时还能在 message 上看到错误信息会很奇怪
2. 插件的 Setting 只会在卸载时删除,停止时不进行删除
3. 插件启动和停止状态的调和能从 CREATED、DISABLED、RESOLVED、STARTED、STOPPED、FAILED 这些状态之间进行循环过渡,如插件当前状态为 CREATED 期望达到 STARTED 则可能会经历 CREATED -> RESOLVED -> STARTED( -> FAILED) 这些过渡, 逻辑更清晰

Console 需要适配:
1. 需要去掉插件启动时才加载 Setting 的判断,让其在插件停用时也能加载
2. 需要修改发生错误时的字段取值,显示 conditons[0] 
#### Which issue(s) this PR fixes:

Fixes #3352

#### Special notes for your reviewer:
how to test it?
1. 测试在开发模式和生产模式下插件启用/设置/配置是否正常
2. 测试开发模式下插件启动失败后修复问题重启 halo 后能否正常启用
3. 测试插件卸载后 setting 是否被正确删除
4. 测试插件 logo 相对路径和 url 是否都能正常显示
5. 测试评论插件启动成功后主题端是否能显示评论列表(验证扩展点加载是否正常)
6. 测试插件配置了 settingName 但没有对应的 Setting 时的情况看 Reconciler 重试时间是否增长

/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
允许插件在未启动时更改设置
```
2023-02-23 09:26:12 +00:00
John Niang 03ec23f90f
Bump up checkout and setup-java actions (#3368) 2023-02-22 23:03:48 +08:00
2139244a62
fix: initializes a ghost user by default to replace that the users that has been deleted (#3344)
#### What type of PR is this?

/kind bug

#### What this PR does / why we need it:

系统默认初始化一个 ghost 用户,用于表示用户已删除。

#### Which issue(s) this PR fixes:

Fixes #3317

```release-note
NONE
```
2023-02-21 09:14:11 +00:00
Li e49baa1cf8
feat: add database endpoint for actuator (#3351)
#### What type of PR is this?
/kind feature

/milestone 2.3.x

#### What this PR does / why we need it:

#### Which issue(s) this PR fixes:

Fixes #3263

#### Special notes for your reviewer:
测试方法:
1. 使用超级管理员登录
2. 查看接口 /actuator/info 查看是否存在 database 字段。
#### Does this PR introduce a user-facing change?


```release-note
NONE
```
2023-02-21 03:06:10 +00:00
John Niang 7e09cdcbf0
Refine problem detail when plugin is already installed (#3350)
#### What type of PR is this?

/kind improvement
/area core

#### What this PR does / why we need it:

This PR refines problem detail of PluginAlreadyExistsException. Please note the new type `https://halo.run/probs/plugin-alreay-exists` and additional property `pluginName` of problem detail.

Meanwhile 

- Before

    ```json
    {
      "type": "about:blank",
      "title": "Plugin Already Exists Error",
      "status": 400,
      "detail": "Plugin PluginCommentWidget already exists.",
      "instance": "/apis/api.console.halo.run/v1alpha1/plugins/install",
      "requestId": "880fe8cd-5",
      "timestamp": "2023-02-20T10:17:21.541104Z"
    }
    ```

- After

    ```json
    {
      "type": "https://halo.run/probs/plugin-alreay-exists",
      "title": "Plugin Already Exists Error",
      "status": 400,
      "detail": "Plugin PluginCommentWidget already exists.",
      "instance": "/apis/api.console.halo.run/v1alpha1/plugins/install",
      "pluginName": "PluginCommentWidget",
      "requestId": "880fe8cd-5",
      "timestamp": "2023-02-20T10:17:21.541104Z"
    }
    ```
#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/3164

#### Special notes for your reviewer:

#### Does this PR introduce a user-facing change?

```release-note
优化插件重复安装错误提示。
```
2023-02-21 02:28:11 +00:00
Li db4142787e
feat: open actuator logfile endpoint for prod (#3345)
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->

#### What type of PR is this?
/kind feature
<!--
添加其中一个类别:
Add one of the following kinds:

/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind improvement

适当添加其中一个或多个类别(可选):
Optionally add one or more of the following kinds if applicable:

/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->

#### What this PR does / why we need it:

#### Which issue(s) this PR fixes:

<!--
PR 合并时自动关闭 issue。
Automatically closes linked issue when PR is merged.

用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)`
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->

Fixes #3188 

#### Special notes for your reviewer:
测试方式:
1. 使用 prod 模式启动项目,使用超级管理员登陆
2. 访问 /actuator/logfile 查看是否有日志显示。

#### Does this PR introduce a user-facing change?

<!--
如果当前 Pull Request 的修改不会造成用户侧的任何变更,在 `release-note` 代码块儿中填写 `NONE`。
否则请填写用户侧能够理解的 Release Note。如果当前 Pull Request 包含破坏性更新(Break Change),
Release Note 需要以 `action required` 开头。
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
-->

```release-note
NONE
```
2023-02-20 07:34:18 +00:00
7c075dc5d7
Add custom endpoint for listing user conditionally (#3320)
#### What type of PR is this?

/kind bug

#### What this PR does / why we need it:

为后端用户管理提供更多筛选接口,包括关键词、角色、创建时间排序

#### Which issue(s) this PR fixes:

Fixes #3290

```release-note
NONE
```
2023-02-20 04:18:18 +00:00
guqing 3cde340b71
fix: route for the tag is not registered when halo starts (#3322)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.3.x

#### What this PR does / why we need it:
1. 去掉原 TagReconciler 的 requeue 逻辑,来临时解决大量 tag 时 reconciler 空转导致 cpu 下不来的问题,参考: https://github.com/halo-dev/halo/issues/3311
2. 增加 TagRouteReconciler 在启动时注册路由

#### Which issue(s) this PR fixes:
Fixes #3321

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?
```release-note
修复 #3316 引入的 tags 标签的路由没有注册的问题
```
2023-02-15 13:52:12 +00:00
Ryan Wang dd161eec19
perf: disable syncAllOnStart for tag reconciler (#3316)
#### What type of PR is this?

/kind improvement

#### What this PR does / why we need it:

暂时禁用 Tag Reconciler 在启动的时候同步。(临时解决方案)

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/3312

#### Does this PR introduce a user-facing change?


```release-note
禁用系统启动时同步标签文章数的功能
```
2023-02-15 10:16:12 +00:00
guqing e71b79b1cf
refactor: status update when setting not found (#3314)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.3.x
#### What this PR does / why we need it:
状态更新时检查是否与之前状态相同,目前先这样解决后续等 status 的 update 出来以后再重构一下 plugin 的 status 结构。

测试:
测试插件在开发模式和生产模式下填写 settingName 后有/无对应 settingName 资源的插件启动情况,看 PluginReconciler 出错时是否很快
步骤:
1. 开发模式下,插件的 plugin.yaml 配置了 settingName 但没有创建名称为 settingName 对应的 Setting 资源看插件启动时控制台是否出现很快的错误日志,期望出现错误的时间间隔会逐渐变长。
2. 与步骤一相同,但 settingName 对应有 Setting 模型的 yaml,期望插件正常启动且能保存配置
3. 生产模式启动插件重复步骤 1 和 2

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?
```release-note
None
```
2023-02-15 07:30:20 +00:00
longjuan 9dee9b0409
fix: incorrect number of comments (#3295)
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->

#### What type of PR is this?
/kind bug
/area core
<!--
添加其中一个类别:
Add one of the following kinds:

/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind improvement

适当添加其中一个或多个类别(可选):
Optionally add one or more of the following kinds if applicable:

/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->

#### What this PR does / why we need it:
Fixed incorrect number of comments after comment deletion.
#### Which issue(s) this PR fixes:

<!--
PR 合并时自动关闭 issue。
Automatically closes linked issue when PR is merged.

用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)`
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes https://github.com/halo-dev/halo/issues/3287

#### Special notes for your reviewer:
为一篇文章添加多个评论,期望评论数量正确。
删除评论,期望评论数量正常减少。
删除全部评论,期望评论数量归零。
#### Does this PR introduce a user-facing change?

<!--
如果当前 Pull Request 的修改不会造成用户侧的任何变更,在 `release-note` 代码块儿中填写 `NONE`。
否则请填写用户侧能够理解的 Release Note。如果当前 Pull Request 包含破坏性更新(Break Change),
Release Note 需要以 `action required` 开头。
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
-->

```release-note
修复删除评论后Console端文章和单页评论数量不正确
```
2023-02-15 06:52:12 +00:00
John Niang 5f7ea18f7c
Auto rename attachment if it exists (#3305)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.3.x

#### What this PR does / why we need it:

Before this PR, halo will throw an FileAlreadyExists exception if users upload file which already exists.

But now, we will rename the attachment automatically on filename conflict. e.g.:

```bash
halo.run -> halo-xyz.run
.run -> xyz.run
halo -> halo-xyz
```

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/3218

#### Special notes for your reviewer:

![image](https://user-images.githubusercontent.com/16865714/218670068-87389289-1248-48e8-82a4-1bcf939e64e3.png)

#### Does this PR introduce a user-facing change?

```release-note
附件已存在时自动重命名
```
2023-02-15 05:38:12 +00:00
e485acef66
perf: associate ghost user with posts on user deletion. (#3293)
#### What type of PR is this?

/kind bug

#### What this PR does / why we need it:

文章发布用户被删除后,设置这篇文章的发布人为Ghost

#### Which issue(s) this PR fixes:

Fixes #3265

```release-note
NONE
```
2023-02-15 05:36:14 +00:00
Ryan Wang 26f29b20c7
chore: add @LIlGG to reviewers list (#3292)
#### What type of PR is this?

/kind improvement

#### What this PR does / why we need it:

将 @LIlGG 添加到 Reviewer 列表。

#### Does this PR introduce a user-facing change?

```release-note
None
```
2023-02-13 01:48:18 +00:00
Ryan Wang 3de9f7f80e
perf: refine display name of system default role (#3280)
#### What type of PR is this?

/kind improvement

#### What this PR does / why we need it:

为系统初始化的角色添加显示名称

#### Which issue(s) this PR fixes:


Fixes https://github.com/halo-dev/halo/issues/3257

#### Screenshots:

<img width="1668" alt="image" src="https://user-images.githubusercontent.com/21301288/218020794-696420c4-69bb-4422-9409-482bb2aff708.png">


#### Special notes for your reviewer:

see 

#### Does this PR introduce a user-facing change?

```release-note
为系统初始化的角色添加显示名称
```
2023-02-10 08:38:16 +00:00
guqing e9389ac1d8
refactor: lru cache key for template engine manager (#3243)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.3.x

#### What this PR does / why we need it:
修改 TemplateEngineManager 中 LRU cache 的缓存 key
see #3242 for more details.

#### Which issue(s) this PR fixes:
Fixes #3242

#### Special notes for your reviewer:
how to test it?
1. 安装几个主题测试预览功能是否正常
2. 特别关注激活主题的预览,激活主题的预览和激活主题直接访问使用的不同的 TemplateEngine

/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?
```release-note
None
```
2023-02-10 07:40:15 +00:00
Ryan Wang 2aa80cfffd
docs: update readme (#3256)
#### What type of PR is this?

/kind documentation

#### What this PR does / why we need it:

更新产品的一句话定位。

```release-note
None
```
2023-02-10 02:46:14 +00:00
findwinds 56aa7de85a
Fix random list problem of tags and categories (#3261)
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->

#### What type of PR is this?
/kind bug

<!--
添加其中一个类别:
Add one of the following kinds:

/kind bug
/kind cleanup
/kind documentation
/kind feature
/kind improvement

适当添加其中一个或多个类别(可选):
Optionally add one or more of the following kinds if applicable:

/kind api-change
/kind deprecation
/kind failing-test
/kind flake
/kind regression
-->

#### What this PR does / why we need it:
replaced flatMap with flatMapSequential to ensure that the list of tags and categories shown in console post order is not random

#### Which issue(s) this PR fixes:

<!--
PR 合并时自动关闭 issue。
Automatically closes linked issue when PR is merged.

用法:`Fixes #<issue 号>`,或者 `Fixes (粘贴 issue 完整链接)`
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #3139

#### Special notes for your reviewer:
/cherrypick release-2.0
/cherrypick release-2.1

#### Does this PR introduce a user-facing change?

<!--
如果当前 Pull Request 的修改不会造成用户侧的任何变更,在 `release-note` 代码块儿中填写 `NONE`。
否则请填写用户侧能够理解的 Release Note。如果当前 Pull Request 包含破坏性更新(Break Change),
Release Note 需要以 `action required` 开头。
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required".
-->

```release-note
修复控制台文章列表中,标签和分类顺序随机的问题
```
2023-02-09 04:24:13 +00:00
guqing 7453b93b1d
fix: default value cannot be read when the setting is not created because of asynchrony (#3236)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.2.x
/cherry-pick release-2.2
#### What this PR does / why we need it:
修复插件安装时有几率出现设置没有默认值导致无法保存的问题

see https://github.com/halo-dev/halo/issues/3224#issuecomment-1418825809 for more details

#### Which issue(s) this PR fixes:

Fixes #3224

#### Special notes for your reviewer:
how to test it?
1. 安装 https://github.com/halo-sigs/plugin-feed 插件并立即启用(或以开发模式)
2. 到此插件设置**始终**能查询到默认值并且能保存

/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
修复插件安装时有几率出现设置没有默认值导致无法保存的问题
```
2023-02-08 07:16:13 +00:00
guqing 6809dbb251
fix: plugin status check to prevent inconsistent status (#3235)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.3.x
#### What this PR does / why we need it:
当开发模式启动时上传 JAR 运行插件会出现插件不存在的异常,但由于 PluginReconciler 中检查状态不一致后 return 在 optional 语句中只是让当前 optional 后面的代码停止执行,还会继续执行 optional 外面的代码导致 status 的异常信息不一致,进而 object equals 始终为 false 而无法让 reconciler 终止运行导致循环。

此 PR 调整了一下代码位置,进入 reconciler 时先进行检查,如果不满足则不执行后面的代码同时将信息写入 plugin.status 让用户知晓。

此问题是修改了 Reconciler 判断逻辑后出现的 https://github.com/halo-dev/halo/pull/3210 ,因此不影响之前的代码只针对当前 2.3.x

#### Special notes for your reviewer:
how to test it?
1. 模拟一个插件找不到的错误场景例如以生产模式启动插件但配置 fixed-plugin 指定为插件项目目录
2. 启动 Halo 看 Reconciler 是否会一直在控制台输出日志
3. 卸载它能成功

/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?

```release-note
None
```
2023-02-07 07:10:14 +00:00
John Niang df9b04c4d5
Reduce the number of queries to resolve theme (#3238)
#### What type of PR is this?

/kind improvement
/area core

#### What this PR does / why we need it:

Save ThemeContext into ServerWebExchange to reduce the number of queries to resolve theme from 2(or 3) to 1.

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/3162

#### Does this PR introduce a user-facing change?

```release-note
优化查询主题的查询次数
```
2023-02-07 06:40:12 +00:00
John Niang df97ee8629
Refine exception message of duplicate key (#3219)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.3.x

#### What this PR does / why we need it:

I create another exception `DuplicateNameException` to map `org.springframework.dao.DuplicateKeyException` when creating extensions.

See https://github.com/halo-dev/halo/issues/3180 for more.

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/3180

#### Special notes for your reviewer:

1. Try to create an user which name has already exist
2. See the error

#### Does this PR introduce a user-facing change?

```release-note
优化名称重复的错误提示
```
2023-02-03 09:50:11 +00:00
John Niang 4636990d5c
Fix the problem that publishing post always fails (#3210)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.3.x

#### What this PR does / why we need it:

1. Refactor Queue in Controller. I add dirty set of request to avoid lost of new request from other places instead of reconciler.
2. Enhance equals and hashcode methods to ensure we can ignore updates of same extensions.

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/2860

#### Special notes for your reviewer:

Please take some time to test publishing posts.

#### Does this PR introduce a user-facing change?

```release-note
修复发布文章时经常出现错误的问题
```
2023-02-02 12:16:10 +00:00
guqing 0fd023b8f6
fix: plugin disappeared after plugin with same name reinstalled (#3198)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.2.x

#### What this PR does / why we need it:
修复重复安装插件时 JAR 文件被删除的问题

需要注意的场景:
prod 模式下,假如安装一个 sitemap 插件,版本为 1.0.0 ,而此时 plugins 目录已经存在同名文件 sitemap-1.0.0.jar 文件但 sitemap 的 plugin.yaml 没有被持久化过,则能正常安装,旧的 JAR 文件被覆盖。

see #3159 for more details
#### Which issue(s) this PR fixes:

Fixes #3159

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo
#### Does this PR introduce a user-facing change?

```release-note
修复重复安装插件时 JAR 文件被删除的问题
```
2023-02-02 02:44:11 +00:00
John Niang 764b664fd8
Bump Halo version to 2.3.0-SNAPSHOT for main branch (#3201)
#### What type of PR is this?

/kind cleanup
/area core

#### What this PR does / why we need it:

Bump Halo version to 2.3.0-SNAPSHOT and update README.md

#### Does this PR introduce a user-facing change?

```release-note
None
```
2023-02-01 08:04:09 +00:00
John Niang 0c18fb3ec4
Fix the problem of not initializing default theme correctly (#3194)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.2.x

#### What this PR does / why we need it:

Make requires field of Theme not required.

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/3177

#### Special notes for your reviewer:

1. Clear Halo working directory
2. Start Halo freshly

#### Does this PR introduce a user-facing change?

```release-note
None
```
2023-01-31 14:18:10 +00:00
John Niang c079762f65
Upgrade Lucene to 9.5.0 (#3190)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.2.x

#### What this PR does / why we need it:

See https://lucene.apache.org/core/9_5_0/MIGRATE.html for more.

#### Special notes for your reviewer:

Please confirm that the search widget is working fine.

#### Does this PR introduce a user-facing change?

```release-note
升级依赖 Lucene 至 9.5.0
```
2023-01-31 07:14:09 +00:00
John Niang f851b1ba53
Upgrade pf4j to 3.9.0 (#3191)
#### What type of PR is this?

/kind imporvement
/area core
/milestone 2.2.x

#### What this PR does / why we need it:

See 2d3cf24fed/CHANGELOG.md (390---2023-01-30) for more.

#### Special notes for your reviewer:

Please confirm that the plugin module is working fine.

#### Does this PR introduce a user-facing change?

```release-note
升级依赖 PF4J 至 3.9.0
```
2023-01-31 06:10:10 +00:00
John Niang b0be55cfad
Upgrade jasync-sql to 2.1.23 (#3192)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.2.x

#### What this PR does / why we need it:

See https://github.com/jasync-sql/jasync-sql/releases/tag/2.1.23 for more.

#### Does this PR introduce a user-facing change?

```release-note
升级依赖 jasync-sql 至 2.1.13
```
2023-01-31 05:54:09 +00:00
John Niang ef45f396d8
Upgrade SpringDoc to 2.0.2 (#3186)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.2.x

#### What this PR does / why we need it:

See <https://github.com/springdoc/springdoc-openapi/releases/tag/v2.0.2> and <https://github.com/springdoc/springdoc-openapi/releases/tag/v2.0.1> for more.

#### Does this PR introduce a user-facing change?

```release-note
升级依赖 SpringDoc 至 2.0.2
```
2023-01-31 03:04:09 +00:00
John Niang bb7fe81343
Add spring-context-indexer to speed up startup (#3185)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.2.x

#### What this PR does / why we need it:

See https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#beans-scanning-index for more.

#### Special notes for your reviewer:

This might help a little, bu we have to.

#### Does this PR introduce a user-facing change?

```release-note
None
```
2023-01-31 02:58:09 +00:00