Commit Graph

2450 Commits (release-2.2)

Author SHA1 Message Date
Ryan Wang 63bf99b308
chore: update default theme package (#2805)
#### What type of PR is this?

/kind improvement
/milestone 2.0

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

更新默认主题的安装包。 https://github.com/halo-dev/theme-earth/releases/tag/v1.0.0

#### Special notes for your reviewer:

测试方式:

1. 使用全新的环境启动此 PR。
2. 插件默认主题是否正确初始化。

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

```release-note
None
```
2022-11-30 10:51:46 +00:00
guqing bd02d9bb3b
chore: temporarily disable JWT authentication function (#2804)
#### What type of PR is this?
/kind improvement
/area core
/kind api-change

#### What this PR does / why we need it:
- 暂时关闭 JWT 认证功能,`POST /api/auth/token` API 将失效。
- 移除  `halo.security.oauth2.jwt` 配置,公私钥放在 classpath 只是之前还没有 halo work dir 时的临时方案
- Disable  JWT 相关的单元测试

后续会 Revert 此 PR。

#### Special notes for your reviewer:
how to test it?
1. 期望 `/api/auth/token` 失效
2. 期望 Console 登录功能没问题

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

```release-note
None
```
2022-11-30 10:21:47 +00:00
John Niang 5aff60d5b4
Fix an optimistic lock error always appearing when restarting Halo (#2795)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.0.x

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

This PR only do one improvement for reconciling Role. I always fetch the latest data and compare the difference between the latest and current, and then decide whether to update based on the result.

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

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

#### Special notes for your reviewer:

Steps to test:

1. Restart Halo multiple times and see the log

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

```release-note
None
```
2022-11-30 03:51:47 +00:00
guqing 9d60b8ae06
feat: theme templates support global seo settings (#2801)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0.0-rc.2

#### What this PR does / why we need it:
适配 SEO 系统设置,此功能之前遗漏

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

Fixes #2797

#### Special notes for your reviewer:
how to test it?
1. seo 设置禁用搜索引擎,会在所有页面的 head 添加 `<meta name="robots" content="noindex" />`
2. seo 设置填写`关键词`和`描述`会在所有页面的 head 标签填充 `<meta name="xxx> content="xxx" />` 

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

```release-note
支持 SEO 全局系统设置
```
2022-11-30 02:31:46 +00:00
John Niang eefdd27c44
Simplify references in Attachment (#2800)
#### What type of PR is this?

/kind improvement
/kind api-change
/area core
/milestone 2.0.x

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

This PR replace refs in Attachment extension with simple name.

> **Warning** Please @halo-dev/sig-halo-console be aware of that this PR contains break changes, so that we can not use Attachment feature in the console directly. The console has to adapt the break changes.

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

```release-note
None
```
2022-11-30 02:23:46 +00:00
John Niang 5be038834e
Fix the problem that lucene crashes when searching for posts (#2791)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.0.0-rc.2

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

This PR mainly refactor PostEventListener into PostEventReconciler to reconcile post events synchronously. After that, the concurrent issue will be gone.

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

Fixes https://github.com/halo-dev/halo/issues/2756
Fixes https://github.com/halo-dev/halo/issues/2757

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

```release-note
None
```
2022-11-28 11:28:19 +00:00
BugKing 569cea4ab8
Refine configuration for dev profile (#2753)
#### What type of PR is this?

/kind improvement

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

1. 增加console代理配置,默认代理到`http://localhost:3000/`。
2. 增加用户名密码初始化配置。
3. 增加win profile,指定与dev profile中不同的r2dbc url,windows环境下调试时可以使用 `dev,win` profile。

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

```release-note
None
```
2022-11-28 06:26:16 +00:00
guqing de983a2e46
refactor: cannot reload when settingName is not configured before (#2745)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0.0-rc.1
/kind api-change

#### What this PR does / why we need it:
- 修复 theme.yaml 之前没有配置过 settingName 会无法 reload 的问题
- 将 `/themes/{name}/reload-setting` 的 API 修改为 `/themes/{name}/reload`

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

Fixes #2735

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

```release-note
修复 theme.yaml 之前没有配置过 settingName 会无法 reload 的问题
```
2022-11-28 03:00:17 +00:00
Ryan Wang 4f4f35c67f
chore: update issue templates for Halo 2.0 (#2788)
#### What type of PR is this?

/kind improvement

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

为 Halo 2.0 更新 issue 模板。

#### Special notes for your reviewer:

效果可以查看:

- https://github.com/ruibaby/halo/issues/new?assignees=&labels=bug&template=bug_report.zh.yml
- https://github.com/ruibaby/halo/issues/new?assignees=&labels=&template=feature_request.zh.yml

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

```release-note
None
```
2022-11-28 01:36:17 +00:00
John Niang 145cfb88b7
Delegate ReactiveExtensionClient for default implementation of ExtensionClient (#2774)
#### What type of PR is this?

/kind bug
/kind cleanup
/area core

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

This PR fully delegates ReactiveExtensionClient for default implementation of ExtensionClient and remove old implementation, including its tests. The main reason I delegate is for keeping consistent about implementation of ExtensionClient.

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

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

#### Special notes for your reviewer:

You can test full functions after starting Halo with current changes.

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

```release-note
None
```
2022-11-25 13:41:25 +00:00
guqing 21c18d4b9a
feat: add approvedTime for comment and reply (#2746)
#### What type of PR is this?
/kind feature
/milestone 2.0.0-rc.1
/kind api-change
/area core

#### What this PR does / why we need it:
评论和回复新增 approvedTime 属性
1. 此属性在创建时如果是不需要审核就公开的则会填充当前时间
2. 目前没有审核功能,审核是 Console 端去更新的 approved 字段,因此需要更新 approved 时判断有没有设置 approvedTime 没有则填充当前时间,后续有审核功能后则再由后端处理

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

Fixes #2738

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

```release-note
评论和回复新增 approvedTime 属性
```
2022-11-25 13:33:25 +00:00
John Niang 0df7857ef8
Refactor reconcilers registration (#2737)
#### What type of PR is this?

/kind cleanup
/kind improvement
/area core
/milestone 2.0.0

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

This PR mainly refactors registration of reconcilers to register reconciler more convinient. After that, it is possible to reigster and start reconciler in plugin.

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

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

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

```release-note
None
```
2022-11-25 11:13:09 +00:00
guqing 98db7c6aff
chore: upgrade to PF4J 3.8.0 (#2772)
#### What type of PR is this?
/kind improvement
/area core

#### What this PR does / why we need it:
see also https://github.com/pf4j/pf4j/compare/release-3.7.0...release-3.8.0

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

Fixes #2771

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

```release-note
升级依赖 PF4J 至 3.8.0
```
2022-11-25 11:05:07 +00:00
John Niang 1b888dfb3e
Upgrade to Spring Boot 3.0.0 (#2768)
#### What type of PR is this?

/kind improvement
/area core

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

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

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

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

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

```release-note
升级依赖 Spring Boot 至 3.0.0
```
2022-11-25 02:33:06 +00:00
John Niang 368d8f4ef4
Upgrade to SpringDoc OpenAPI 2.0.0 (#2769)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.0.0-rc.2

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

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

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

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

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

```release-note
升级依赖 SpringDoc OpenAPI 至 2.0.0
```
2022-11-25 02:31:07 +00:00
Ryan Wang 5bf7851a1a
docs: update readme for Halo 2.0.0-rc.1 and new slogan (#2763)
#### What type of PR is this?

/kind documentation

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

为 Halo 2.0.0-rc.1 更新 README。

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo 

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

```release-note
None
```
2022-11-24 15:51:06 +00:00
guqing 16e4e46e40
fix: cannot be published successfully after post or single page unpublished (#2762)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.0.0-rc.1

#### What this PR does / why we need it:
修复文章和自定义页面取消发布后无法再继续发布的问题

#### Special notes for yourd reviewer:
how to test it?
1. create a post and publsih it
2. unpublish it then republish
3. excepted to b published successfully

/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?
```release-note
None
```
2022-11-24 14:53:06 +00:00
John Niang 12fd77f61f
Set mode of frame options to SAMEORIGIN (#2761)
#### What type of PR is this?

/kind bug
/area core

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

The problem https://github.com/halo-dev/halo/issues/2743 was introduced by https://github.com/halo-dev/halo/pull/2729. This Pr mainly resolves it by setting SAMEORIGIN mode for frame options.

![image](https://user-images.githubusercontent.com/16865714/203795956-6efec450-da5f-4222-884d-5a67cb113173.png)

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

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

#### Special notes for your reviewer:

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

```release-note
None
```
2022-11-24 13:39:06 +00:00
guqing 61c7459ccf
refactor: check whether plugin has been loaded when startup (#2759)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0.0-rc.1

#### What this PR does / why we need it:
插件以开发模式启动时加载插件需判断是否已经加载过

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

Fixes #2758

#### Special notes for your reviewer:
how to test it?
1. 配置 `halo.plugin.fixed-plugin-path`
2. 以开发模式启动后重启几次不会出现  #2758 中描述的异常

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

```release-note
修复插件以开发模式启动时会出现插件已经加载过的异常
```
2022-11-24 13:37:06 +00:00
guqing a76ade8aa8
feat: add global error web exception handler (#2741)
#### What type of PR is this?
/kind feature
/milestone 2.0.0-rc.1
/area core

#### What this PR does / why we need it:
新增全局异常处理
参考文档:
- [web.reactive.webflux.error-handling](https://docs.spring.io/spring-boot/docs/3.0.0-RC2/reference/htmlsingle/#web.reactive.webflux.error-handling)
- [webflux-ann-rest-exceptions](https://docs.spring.io/spring-framework/docs/6.0.0-RC4/reference/html/web-reactive.html#webflux-ann-rest-exceptions)

发生异常时返回形如以下结构
```json
{
    "type": "about:blank",
    "title": "Not Found",
    "status": 404,
    "detail": "Hello not found test.",
    "instance": "/hello"
}
```
此结构遵循 [RFC 7807 Problem Details](https://www.rfc-editor.org/rfc/rfc7807.html)

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

Fixes #2732

#### Special notes for your reviewer:
how to test it?
更新文章前把 title 字段删除,会出现校验异常 BadRequest

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

```release-note
新增全局异常处理
```
2022-11-24 12:45:07 +00:00
John Niang edfc9ac1e1
Ignore websocket protocol while proxying console (#2760)
#### What type of PR is this?

/kind feature
/area core

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

Ignore websocket protocol while proxying console. If we don't do this, console dev environment will crash with following error:

```bash
  VITE v3.2.4  ready in 1672 ms

  ➜  Local:   http://localhost:3000/console/                                                                           16:12:21
  ➜  Network: http://172.23.176.1:3000/console/                                                                        16:12:21
  ➜  Network: http://172.18.96.1:3000/console/                                                                         16:12:21
  ➜  Network: http://192.168.31.106:3000/console/                                                                      16:12:21
[vite-plugin-static-copy] Collected 8 items.                                                                           16:12:21
node:events:491
      throw er; // Unhandled 'error' event
      ^

RangeError: Invalid WebSocket frame: RSV1 must be clear
    at Receiver$1.getInfo (file:///C:/Users/johnn/workspaces/halo-dev/console/node_modules/.pnpm/vite@3.2.4_ajklay5k626t46b6fyghkbup3i/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:54186:14)
    at Receiver$1.startLoop (file:///C:/Users/johnn/workspaces/halo-dev/console/node_modules/.pnpm/vite@3.2.4_ajklay5k626t46b6fyghkbup3i/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:54133:22)
    at Receiver$1._write (file:///C:/Users/johnn/workspaces/halo-dev/console/node_modules/.pnpm/vite@3.2.4_ajklay5k626t46b6fyghkbup3i/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:54080:10)
    at writeOrBuffer (node:internal/streams/writable:392:12)
    at _write (node:internal/streams/writable:333:10)
    at Writable.write (node:internal/streams/writable:337:10)
    at Socket.socketOnData (file:///C:/Users/johnn/workspaces/halo-dev/console/node_modules/.pnpm/vite@3.2.4_ajklay5k626t46b6fyghkbup3i/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:56826:37)
    at Socket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Readable.push (node:internal/streams/readable:234:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
Emitted 'error' event on WebSocket$1 instance at:
    at Receiver$1.receiverOnError (file:///C:/Users/johnn/workspaces/halo-dev/console/node_modules/.pnpm/vite@3.2.4_ajklay5k626t46b6fyghkbup3i/node_modules/vite/dist/node/chunks/dep-67e7f8ab.js:56712:13)
    at Receiver$1.emit (node:events:513:28)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'WS_ERR_UNEXPECTED_RSV_1',
  [Symbol(status-code)]: 1002
}

Node.js v18.12.1
 ELIFECYCLE  Command failed with exit code 1.
```

#### Special notes for your reviewer:

Steps to test:

1. Edit your application.yaml with console proxy configuration
2. Start Halo
3. Use non-Chromelike browser to request <http://localhost:8090>.
4. See the result

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

```release-note
None
```
2022-11-24 11:31:06 +00:00
John Niang f96ef7f1b3
Provide ungrouped query param to filter ungrouped attachments (#2752)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.0.0-rc.1

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

Provide `ungrouped` query param to filter ungrouped attachments. Please note that we will ignore `group` query param when `ungropued` is `true`.

```bash
curl -X 'GET' \
  'http://localhost:8090/apis/api.console.halo.run/v1alpha1/attachments?ungrouped=true' \
  -H 'accept: */*'
```

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

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

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

```release-note
None
```
2022-11-24 07:43:02 +00:00
guqing b0c461b5f6
fix: inconsistent order of post for theme-side (#2742)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0.0-rc.1

#### What this PR does / why we need it:
修复主题端文章列表排序不固定问题
#### Which issue(s) this PR fixes:

Fixes #2734

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

```release-note
修复主题端文章列表排序不固定问题
```
2022-11-23 09:21:30 +00:00
guqing 180548161a
feat: provides authentication and authorization expression dialects (#2729)
#### What type of PR is this?
/kind feature
/milestone 2.0.0-rc.1
/area core

#### What this PR does / why we need it:
主题端支持使用表达式方言获取登录状态和判断权限,例如:

获取当前登录用户名
```html
<div th:text="${#authentication.name}">
  The value of the "name" property of the authentication object should appear here.
</div>
```
关于判断登录状态我们并不推荐调用表达式 `${#authentication.isAuthenticated()}`,因为始终返回 `true`,使用以下几种属性表达式代替:
```html
<div sec:authorize="isAuthenticated()">
如果不是匿名用户你会看到我
</div>

<div sec:authorize="isFullyAuthenticated()">
如果不是匿名用户且不是 rememberMe 你会看到我
</div>
```
其他
```html
<div sec:authorize="isAnonymous()">
如果是匿名用户你会看到我
</div>
```
```html
<div sec:authorize="isRememberMe()">
如果是 rememberMe  你会看到我
</div>
```
更多请参考:
https://github.com/thymeleaf/thymeleaf-extras-springsecurity

Console 端判断是否登录需要改一下,目前所有未登录状态都属于一个叫 anonymousUser 的用户
#### Which issue(s) this PR fixes:

Fixes #2676

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?
```release-note
主题端支持使用表达式方言获取登录状态和判断权限
```
2022-11-23 03:00:19 +00:00
John Niang 4c8a890c36
Change working directory to .halo2 (#2728)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.0.0

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

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

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

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

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

```release-note
None
```
2022-11-21 07:14:28 +00:00
John Niang 87ccd61ae5
Bump up springdoc-openapi (#2726)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.0.0

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

springdoc-openapi 2.0.0-RC2 fully supports Spring Boot 3.0.0-RC2 currently, please see https://github.com/springdoc/springdoc-openapi/releases/tag/v2.0.0-RC2 for more.

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

```release-note
升级依赖 SpringDoc OpenAPI 至 2.0.0-RC2
```
2022-11-21 05:44:27 +00:00
guqing cca95cbfab
refactor: snapshot attributes and post publish (#2709)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0
 
#### What this PR does / why we need it:
1. 简化 Snapshot 的指责,去除 Snapshot 中关于 version,publishTime 等与发布相关的东西,Snapshot本身没有发布概念
2. 对应修改文章和自定义页面,将版本的概念转移到拥有 Snapshot 的模型上,如 Post 和 SinglePage

⚠️此 PR 为破坏性更新,对旧数据不兼容,可能导致旧数据文章内容无法显示问题

Console 端需要做出一些修改:
- 将文章发布前调用保存内容的 API 修改为 `/posts/{name}/content`
- 将自定义页面发布前调用保存内容的 API 修改为 `/singlepages/{name}/content`

发布接口提供了一个 `async` 参数,默认值为 `false`此时发布API需要等待发布成功后才返回结果,如果等待超时则提示`Publishing wait timeout.`, 如果传递 `async=true` 表示异步发布,更新完数据就成功,reconciler 在后台慢慢执行。

#### Special notes for your reviewer:
how to test it?
1. 新创建一篇文章,测试点击保存是否成功
2. 新创建一篇文章,测试编辑内容后直接发布是否成功
3. 测试发布过的文章的取消发布状态是否显示未发布状态
4. 对于 Snapshot,新建文章点保存会创建一个snapshot,点击发布则是更新之前点保存创建的一条,所以记录数不会多,发布之后进入编辑随便写点内容直接点发布后查询snapshot则会多一条记录。
5. 文章的 status 里的 conditions 最新添加的都在第一个即头插入,如果连续两次发布则不会在增加 condition,长度超过20条会把旧的 condition 删除掉
6. 自定义页面上同

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

```release-note
Action Required: 简化 Snapshot 模型的职责,去除版本相关属性
```
2022-11-18 13:32:23 +00:00
John Niang e48c228fc3
Fix the problem of upgrading theme due to pipe closed (#2720)
#### What type of PR is this?

/kind bug
/kind regression
/area core
/milestone 2.0

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

When we try to upgrade a theme, error will appear like below:

```java
2022-11-18T15:45:35.130+08:00 ERROR 18136 --- [oundedElastic-1] a.w.r.e.AbstractErrorWebExceptionHandler : [26de12d5-51]  500 Server Error for HTTP POST "/apis/api.console.halo.run/v1alpha1/themes/theme-earth/upgrade"

java.io.IOException: Pipe closed
	at java.base/java.io.PipedInputStream.read(PipedInputStream.java:307) ~[na:na]
	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Assembly trace from producer [reactor.core.publisher.MonoFlatMap] :
	reactor.core.publisher.Mono.flatMap(Mono.java:3080)
	run.halo.app.core.extension.theme.ThemeServiceImpl.upgrade(ThemeServiceImpl.java:72)
Error has been observed at the following site(s):
	*____________Mono.flatMap ⇢ at run.halo.app.core.extension.theme.ThemeServiceImpl.upgrade(ThemeServiceImpl.java:72)
	|_          Mono.doOnNext ⇢ at run.halo.app.core.extension.theme.ThemeServiceImpl.upgrade(ThemeServiceImpl.java:82)
	|_               Mono.map ⇢ at run.halo.app.core.extension.theme.ThemeServiceImpl.upgrade(ThemeServiceImpl.java:88)
	|_          Mono.doOnNext ⇢ at run.halo.app.core.extension.theme.ThemeServiceImpl.upgrade(ThemeServiceImpl.java:89)
	|_           Mono.flatMap ⇢ at run.halo.app.core.extension.theme.ThemeServiceImpl.upgrade(ThemeServiceImpl.java:98)
	|_          Mono.doOnNext ⇢ at run.halo.app.core.extension.theme.ThemeServiceImpl.upgrade(ThemeServiceImpl.java:103)
	|_           Mono.flatMap ⇢ at run.halo.app.core.extension.theme.ThemeServiceImpl.upgrade(ThemeServiceImpl.java:112)
	|_         Mono.doFinally ⇢ at run.halo.app.core.extension.theme.ThemeServiceImpl.upgrade(ThemeServiceImpl.java:113)
	*____________Mono.flatMap ⇢ at run.halo.app.core.extension.theme.ThemeEndpoint.upgrade(ThemeEndpoint.java:180)
	|_           Mono.flatMap ⇢ at run.halo.app.core.extension.theme.ThemeEndpoint.upgrade(ThemeEndpoint.java:187)
```

This might be caused by PR <https://github.com/halo-dev/halo/pull/2704>.

#### Special notes for your reviewer:

Steps to test:

1. Upgrade any theme

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

```release-note
None
```
2022-11-18 10:24:23 +00:00
John Niang e87067eb60
Enable adding more workers for controller (#2718)
#### What type of PR is this?

/kind feature
/kind improvement
/area core
/milestone 2.0

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

This PR enables adding more workers for controller to speed up reconciliations. Default woker count is 1 for one controller.

**What's next?**

- [ ] Enable configuring worker count for every controller in configuration properties.

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

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

#### Special notes for reviewers

You can see there are more threads for post controller in the following screenshot:

![image](https://user-images.githubusercontent.com/16865714/202608470-8763826a-a69c-47b5-8f41-f0612919d681.png)

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

```release-note
None
```
2022-11-18 08:08:22 +00:00
guqing c8bc96ffc3
refactor: support chaining calls for flux and mono in javascript inline tag (#2715)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
支持在 JavaScript 中对 Flux 或 Mono 的泛型类型属性链式调用
测试参考:
7e9bdec492/src/test/java/run/halo/app/theme/ReactiveFinderExpressionParserTests.java (L131-L147)
期望
7e9bdec492/src/test/java/run/halo/app/theme/ReactiveFinderExpressionParserTests.java (L64-L79)

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

```release-note
支持在 JavaScript 中对 Flux 或 Mono 的泛型类型属性链式调用
```
2022-11-18 06:32:22 +00:00
guqing eeb9c4dc7a
feat: support obtaining the configuration of halo.external-url for themes and plugins (#2714)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
主题和插件支持获取 `halo.external-url` 配置信息

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

Fixes #2711
#### Special notes for your reviewer:
how to test it?
1. 在主题中使用`<p th:text="${site.url}"></p>` 可以正确显示
2. 在插件中可以依赖注入 ExternalUrlSupplier

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

```release-note
主题和插件支持获取外部访问地址配置
```
2022-11-18 06:30:27 +00:00
guqing 9e5c6a45c9
fix: failed to build due to wrong type (#2712)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.0

#### What this PR does / why we need it:
修复上一个 PR 没有拉取最新代码合并后导致无法构建的问题

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

```release-note
None
```
2022-11-17 08:04:21 +00:00
guqing 9f53cd1123
feat: theme finders supports the reactive API (#2695)
#### What type of PR is this?
/kind feature
/area core
/milestone 2.0

#### What this PR does / why we need it:
将所有 Finder 的返回值都修改为 Mono 或 Flux

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

Fixes #2671

#### Special notes for your reviewer:
how to test it?
切换几个主题都点一下,没有报错即为正常

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

```release-note
主题端 Finder 支持 Reactive API
```
2022-11-17 02:48:22 +00:00
John Niang cc984b2bb3
Prevent H2 from closing on exit to allow destruction (#2707)
#### What type of PR is this?

/kind bug
/area core

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

Before this, `CounterMeterHandler#stop` will encounter an error when Halo is graceful shutdown due to database closed before.

```java
2022-11-16T15:52:17.904+08:00 DEBUG 21324 --- [ionShutdownHook] r.halo.app.metrics.CounterMeterHandler   : Persist counter meters to database before destroy...
2022-11-16T15:52:17.910+08:00 ERROR 21324 --- [ionShutdownHook] r.halo.app.metrics.CounterMeterHandler   : Persist counter meters to database failed.

org.springframework.dao.DataAccessResourceFailureException: Failed to obtain R2DBC Connection
	at org.springframework.r2dbc.connection.ConnectionFactoryUtils.lambda$getConnection$0(ConnectionFactoryUtils.java:88) ~[spring-r2dbc-6.0.0-RC4.jar:6.0.0-RC4]
	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
```

#### Special notes for your reviewer:

Steps to test:

1. Start Halo and then stop it
2. See the log detail

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

```release-note
None
```
2022-11-16 10:56:20 +00:00
John Niang f1ac4e3740
Provide sort query param for sorting attachment (#2705)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.0

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

Provide sort query param for sorting attachment. By default, we use creationTimestamp(desc) to sort the attachments.

Below is an example to sort with creationTimestamp(desc) and size(asc):

```bash
curl -X 'GET' \
  'http://localhost:8090/apis/api.console.halo.run/v1alpha1/attachments?sort=creationTimestamp%2Cdesc&sort=size%2Casc' \
  -H 'accept: */*'
```

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

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

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

```release-note
附件列表支持排序
```
2022-11-16 10:10:19 +00:00
John Niang 0c8ccecdf3
Initialize default theme when Halo starts up for the first time (#2704)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.0

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

1. Initialize default theme when we detect the theme root has no themes here. This process won't stop Halo starting up if error occurs.
2. Refactor ThemeEndpoint with ThemeService to make it reusable.

Default theme configuration is as following:

```yaml
halo:
  theme:
    initializer:
      disabled: false
      location: classpath:themes/theme-earth.zip
```

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

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

#### Special notes for your reviewer:

Steps to test:

1. Delete all themes at console if installed
2. Restart Halo and check the log
4. Check the theme root folder `~/halo-next/themes`
5. Try to access index page and you will see the default theme

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

```release-note
在首次启动 Halo 时初始化默认主题
```
2022-11-15 10:50:18 +00:00
John Niang 04a7b67fe9
Fix the problem of unpublishing and recycling posts by member of post manager (#2701)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.0

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

This PR refines the role template of posts to allow post managers to unpublish and recycle a specific post.

Before that, post managers will be forbidden to unpublishing and recycling posts. You can see the screenshot below:

![image](https://user-images.githubusercontent.com/16865714/201571476-4bbe6007-94a2-45c1-99fd-1e6c76918eae.png)

After that, we can unpublish and recycle posts successfully. You can see the screenshot below:

![image](https://user-images.githubusercontent.com/16865714/201571537-6179fab4-aecf-46a3-8c5b-bafe0c0accee.png)

#### Special notes for your reviewer:

Steps to test manually:

1. Create a `Role` with `Posts Management` permission
2. Create an `User` with the role bound
3. Login with the `User`
4. Create a `Post` and publish it
5. Unpublish the post and Recycle it

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

```release-note
修复无法“取消发布”和“删除”文章的错误
```
2022-11-14 14:30:15 +00:00
Ryan Wang c86e8df267
docs: update readme for Halo 2.0.0-beta.1 and new slogan (#2698)
#### What type of PR is this?

/kind documentation

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

1. 更新 2.0.0 的版本号。
2. 更新文档的版本号描述。
3. 更新标语。

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo 

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

```release-note
None
```
2022-11-12 16:52:13 +00:00
John Niang dac4eecea6
Implement full-text search of posts with Lucene default (#2675)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.0

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

This PR mainly implement full-text search of posts and provide extension point for other search engine.

Meanwhile, I implement ExtensionGetter to get implemention(s) of extension point from system ConfigMap.

But there still are something to do here:

- [x] Udpate documents when posts are published or posts are becoming unpublic.
- [x] Delete documents when posts are unpublished or deleted.

Because I'm waiting for https://github.com/halo-dev/halo/pull/2659 got merged.

I create two endpoints:

1. For full-text search of post

    ```bash
    curl -X 'GET' \
      'http://localhost:8090/apis/api.halo.run/v1alpha1/indices/post?keyword=halo&limit=10000&highlightPreTag=%3CB%3E&highlightPostTag=%3C%2FB%3E' \
      -H 'accept: */*'
    ```

1. For refreshing indices

    ```bash
    curl -X 'POST' \
      'http://localhost:8090/apis/api.console.halo.run/v1alpha1/indices/post' \
      -H 'accept: */*' \
      -d ''
    ```

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

Fixes #https://github.com/halo-dev/halo/issues/2637

#### Special notes for your reviewer:

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

```release-note
提供文章全文搜索功能并支持搜索引擎扩展
```
2022-11-11 16:12:13 +00:00
John Niang 8b9ea1d301
Fix test issues on Windows (#2693)
#### What type of PR is this?

/kind cleanup

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

Fix failing tests on Windows.

```bash
╰─$ ./gradlew check

> Task :checkstyleTest
Checkstyle rule violations were found. See the report at: file:///C:/Users/johnn/workspaces/halo-dev/halo/build/reports/checkstyle/test.html
Checkstyle files with violations: 8
Checkstyle violations by severity: [warning:20]


> Task :test
2022-11-11T14:19:41.265+08:00 DEBUG 5948 --- [ionShutdownHook] r.halo.app.metrics.CounterMeterHandler   : Persist counter meters to database before destroy...
2022-11-11T14:19:41.277+08:00 DEBUG 5948 --- [ionShutdownHook] r.halo.app.metrics.CounterMeterHandler   : Persist counter meters to database before destroy...
2022-11-11T14:19:41.281+08:00 DEBUG 5948 --- [ionShutdownHook] r.halo.app.metrics.CounterMeterHandler   : Persist counter meters to database before destroy...
2022-11-11T14:19:41.285+08:00 DEBUG 5948 --- [ionShutdownHook] r.halo.app.metrics.CounterMeterHandler   : Persist counter meters to database before destroy...
2022-11-11T14:19:41.289+08:00 DEBUG 5948 --- [ionShutdownHook] r.halo.app.metrics.CounterMeterHandler   : Persist counter meters to database before destroy...
2022-11-11T14:19:41.298+08:00 DEBUG 5948 --- [ionShutdownHook] r.halo.app.metrics.CounterMeterHandler   : Persist counter meters to database before destroy...
2022-11-11T14:19:41.301+08:00 DEBUG 5948 --- [ionShutdownHook] r.halo.app.metrics.CounterMeterHandler   : Persist counter meters to database before destroy...
2022-11-11T14:19:41.304+08:00 DEBUG 5948 --- [ionShutdownHook] r.halo.app.metrics.CounterMeterHandler   : Persist counter meters to database before destroy...
2022-11-11T14:19:41.306+08:00 DEBUG 5948 --- [ionShutdownHook] r.halo.app.metrics.CounterMeterHandler   : Persist counter meters to database before destroy...
2022-11-11T14:19:41.309+08:00 DEBUG 5948 --- [ionShutdownHook] r.halo.app.metrics.CounterMeterHandler   : Persist counter meters to database before destroy...
2022-11-11T14:19:41.311+08:00 DEBUG 5948 --- [ionShutdownHook] r.halo.app.metrics.CounterMeterHandler   : Persist counter meters to database before destroy...

BUILD SUCCESSFUL in 47s
7 actionable tasks: 2 executed, 5 up-to-date

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

```release-note
None
```
2022-11-11 10:52:11 +00:00
John Niang 2cd501955f
Bump Spring Boot to 3.0.0-RC2 (#2692)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.0

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

Bump Spring Boot to 3.0.0-RC2. 

See https://github.com/spring-projects/spring-boot/releases/tag/v3.0.0-RC2 for more.

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

```release-note
升级 Spring Boot 至 3.0.0-RC2
```
2022-11-11 10:50:15 +00:00
guqing 7e592a3835
feat: add plugin finder for theme-side (#2683)
#### What type of PR is this?
/kind feature
/milestone 2.0
/area core
#### What this PR does / why we need it:
主题端提供判断插件是否已经启用的方法

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

#### Special notes for your reviewer:
how to test it?
在主题端使用 `${pluginFinder.available(your-plugin-name)}`  来查看某个插件是否已经启用,如果是则得到 true ,否则 false,如果插件没有安装也得到 false

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

```release-note
主题端支持获取插件启用状态
```
2022-11-11 02:26:11 +00:00
guqing 3adf5b8a95
refactor: change from manual publishing to automatic publishing (#2659)
#### What type of PR is this?
/kind improvement
/milestone 2.0
/area core
/kind api-change

#### What this PR does / why we need it:
- 通过修改 `spec.publish=true` 且 `spec.releasedSnapshot = spec.headSnapshot` 来实现通过 reconciler 异步发布
- Snapshot 中的 subjectRef 类型改为了 Ref 类型,因为之前的 Snapshot.SubjectRef 只包含了 kind 和 name 可能会冲突

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

Fixes #2650

#### Special notes for your reviewer:
how to test it?
1. 通过 `POST /apis/console.halo.run/v1alpha1/posts` 创建文章并将 `spec.publish=true`,创建后查询可以看到 `spec.baseSnapshot`、`spec.headSnapshot`、`spec.releasedSnapshot` 三个值都相等,且 `status.phase=PUBLISHED`(此过程相当于创建即发布没有保存过程)
2. 先通过 `POST /apis/console.halo.run/v1alpha1/posts` 创建一篇草稿(`spec.publish=false`),在获取它并设置 `spec.publish=true` ,更新后期望文章为发布状态 `spec.headSnapshot`, `spec.releasedSnapshot` 都不等于空且等于 `spec.baseSnapshot`),且 `spec.version=1`(此过程相当于先保存后发布且之前从未发布过)
3. 在步骤2的基础上修改`spec.releasedSnapshot=spec.headSnapshot`并更新,期望 `spec.version=2`且`spec.releasedSnapshot` 对应的 Snapshot 数据具有 publishTime(此过程相当于发布后编辑内容在发布的场景)
4. 自定义页面亦如是

/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?
```release-note
重构文章发布以解决创建与发布 API 几乎同时调用时无法成功发布文章的问题
```
2022-11-10 14:44:10 +00:00
guqing 5c05554bd8
feat: total pages returned from paging results (#2669) 2022-11-10 14:31:33 +08:00
guqing a2bb3d4a00
feat: add setting item for primary menu selector (#2667) 2022-11-09 16:01:44 +08:00
guqing 8d6838a956
refactor: add page size configuration for post (#2660) 2022-11-08 10:01:50 +08:00
guqing 36613c0442
refactor: ThemeLinkBuilder needs to rely on external url (#2661) 2022-11-08 09:33:38 +08:00
John Niang 84b28cec16
Build console with release tag when releasing (#2665) 2022-11-07 16:03:15 +08:00
guqing f22a401092
fix: while cycles cause high cpu usage (#2663)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.0
#### What this PR does / why we need it:
修复日志 while 循环导致 cpu 占用高的问题

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

```release-note
None
```
2022-11-07 03:54:11 +00:00
guqing 9b4ed96e2a
fix: cannot stop thread when system is interrupted (#2639)
#### What type of PR is this?
/kind bug
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
修复 Halo 异常停止时日志服务线程无法中断的问题

#### Special notes for your reviewer:
how to test it?
使用 mysql 启动 halo 但不启动 mysql,此时 halo 会无法链接 mysql
期望现象:Halo 服务终止,异常现象:Halo 抛异常但 Netty 服务器不会停止

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

```release-note
修复 Halo 异常停止时日志服务线程无法中断的问题
```
2022-11-03 06:32:19 +00:00