Commit Graph

2372 Commits (3033ceb1ecd72efa83107077139b329a9cd2d5f3)

Author SHA1 Message Date
John Niang 3033ceb1ec
Support configuring Halo in working directory (#2935)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.1.x

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

Force to add environment variables `HALO_WORK_DIR` and `SPRING_CONFIG_LOCATION` into Dockerfile. After that, we can configure `application.yaml` in working directory as we want.

Please note that we can not configure Halo working directory in `/root/.halo2/application.yaml` directly. Use environment variable `HALO_WORK_DIR` instead.

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

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

#### Special notes for your reviewer:

Steps to test:

1. Prepare custom configuration

    ```bash
    mkdir -p halo2

    cat <<EOF > halo2/application.yaml
    server:
      port: 12345
    EOF
    ```

2. Start up Halo using Docker
    
    ```bash
    docker run -it --rm -p12345:12345 -v `pwd`/halo2:/root/.halo2  johnniang/halo:configure-halo-in-work-dir
    ```

3. Request http://localhost:12345

    ```bash
    curl -v localhost:12345
    ```

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

```release-note
支持在工作目录添加自定义配置
```
2022-12-14 09:16:18 +00:00
guqing 925dec476f
fix: plugin logo cannot be loaded when it is not enabled (#2940)
#### What type of PR is this?
/kind bug
/area core

#### What this PR does / why we need it:
修复插件 logo 为相对路径时先启用再停后就无法加载 logo  的问题

原因是 reverse proxy reconciler 资源被删除要取消注册路由时没有确切指定名称,logo 这样的 ReverseProxy 是插件安装时初始化的这条初始化的规则要跟随插件的生命周期,只有插件卸载时才会被删除,而在此之前插件被停止时就被误取消注册了

see #2937 for more detail
#### Which issue(s) this PR fixes:

Fixes #2937

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

```release-note
修复插件 logo 为相对路径时先启用再停后就无法加载 logo  的问题
```
2022-12-14 08:51:24 +00:00
guqing 07f5b0dbcd
fix: failed to load plugin when add fixedPluginPath dynamically in development mode (#2941)
#### What type of PR is this?
/kind bug
/area core

#### What this PR does / why we need it:
修复插件开发模式下后续增加的 fixedPluginPath 项无法被加载的问题
- 目前启动时会加载 pluginRepository 的所有 path,fixedPluginPath 被 DefaultDevelopmentPluginRepository 管理,所以在遍历 fixedPluginPath 加载时可能已经被加载过,需要判断是否被加载过,但即使被加载过也不能跳过而要继续执行创建/更新 plugin.yaml 资源的逻辑
- 创建/更新 plugin.yaml 时需要使用重试机制防止因为乐观锁冲突导致 Halo 无法启动

see #2939 for more detail
#### Which issue(s) this PR fixes:

Fixes #2939

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

```release-note
修复插件开发模式下后续增加的 fixedPluginPath 项无法被加载的问题
```
2022-12-14 07:49:23 +00:00
Ryan Wang df0e6cff49
perf: change the maximum limit of request body to 10MB (#2936)
#### What type of PR is this?

/kind improvement

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

将 http 请求体的最大字节数改为 10m。

Ref https://github.com/halo-dev/halo/issues/2861#issuecomment-1339526589

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

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

#### Special notes for your reviewer:

测试方式:

1. 在 Console 端新建文章,保存大量文本内容(最快方式是截图或者复制图片到编辑器,这时候因为会转为 base64,所以内容会很大)
2. 保存文章,检查是否成功。

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

```release-note
修改 HTTP 请求体最大字节数的限制,修复保存大内容文章异常的问题。
```
2022-12-13 15:38:48 +00:00
guqing a9a65dd408
refactor: metrics to fix post visits cannot be migrated (#2870)
#### What type of PR is this?
/kind improvement
/area core

#### What this PR does / why we need it:
重构访问量统计逻辑
1. 去掉了访问量总数存储在 Meter Counter 中的逻辑,因为迁移时是直接像 Counter 自定义模型创建数据,而文章被访问时是存储在 Meter Counter 后定时同步到数据库,这就存在双向同步问题且都有新数据无法知道该如何合并数据。
2. 目前访问时会发送一个事件,当得到事件后会缓存在队列中,每隔一分钟将增量更新到数据库中
3. 评论统计也去掉了 Meter Counter 改为事件队列处理
4. 如果后续要暴露 Metrics 应该使用 Gauge 监控 Counter 自定义模型
5. Counter 自定义模型的查询优化后续可以使用 Indexer 或者加缓存来实现而非将 Meter Counter 当作缓存
#### Which issue(s) this PR fixes:

Fixes #2820

#### Special notes for your reviewer:
1. 测试迁移导入看文章访问量是否正确
2. 创建评论及回复观察未读回复数量、评论回复数、最新回复时间是否正确
3. 多创建一些回复然后删除评论,看是否正确删除

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

```release-note
重构访问量统计逻辑,修复文章visits无法迁移的问题
```
2022-12-13 03:42:44 +00:00
John Niang cfb66b0faa
Fix the problem of getting stuck on VM exit (#2919)
#### What type of PR is this?

/kind bug
/area core

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

Shutdown AsyncLogWriter on VM exit.

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

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

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

```release-note
None
```
2022-12-12 08:06:42 +00:00
guqing 52906f21c1
fix: single page does not count visits (#2918)
#### What type of PR is this?
/kind bug
/area core

#### What this PR does / why we need it:
修复自定义页面没有统计访问量的问题
#### Which issue(s) this PR fixes:

Fixes #2912

#### Special notes for your reviewer:
how to test it?
创建自定义页面并到主题端访问,可以看到访问量增加

/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?
```release-note
修复自定义页面没有统计访问量的问题
```
2022-12-12 03:48:22 +00:00
will d06078893e
Silent prompt when plugins fail to load in development mode (#2907)
#### What type of PR is this?
/kind improvement
/area core

#### What this PR does / why we need it:
在插件开发模式下加载插件失败时不抛出异常改为静默提示

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

A part of #2901

#### Special notes for your reviewer:
how to test it?
1. 配置 `halo.plugin.fixed-plugin-path` 为一些不合法的插件项目路径不影响 Halo 正常启动,且有错误提示
2. 配置合法路径,插件能正确启动

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

```release-note
插件开发模式下无法被加载时改为静默提示不抛出异常
```
2022-12-12 02:24:22 +00:00
Ryan Wang 86e5366797
feat: improve the quick start section of the readme (#2899)
#### What type of PR is this?

/kind documentation

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

更新 Readme 中快速开始的命令,提供初始管理员账号和外部访问链接的环境变量设置。

```release-note
None
```
2022-12-09 03:28:15 +00:00
John Niang 8f21880683
Enable CI on release branches (#2876) 2022-12-08 10:46:26 +08:00
John Niang f40ba48aa3
Update Halo version to 2.0.1 (#2879) 2022-12-08 10:45:51 +08:00
John Niang cd5cc74714
Set docker image name properly when releasing (#2872) 2022-12-07 15:56:03 +08:00
John Niang 3abc930150
Bump halo version to 2.1.0-SNAPSHOT for next release (#2871)
#### What type of PR is this?

/kind improvement
/area core

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

Bump halo version to 2.1.0-SNAPSHOT for next release.

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

```release-note
None
```
2022-12-07 06:56:55 +00:00
John Niang 5f0539d67f
Add forgotten label for system-reserved roles (#2865)
#### What type of PR is this?

/kind bug
/area core

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

Add forgotten label `rbac.authorization.halo.run/system-reserved` for system-reserved roles. See the screenshot below:

![image](https://user-images.githubusercontent.com/16865714/205936031-8a49d4ef-9d10-4c72-a125-973cd361771e.png)

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

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

#### Special notes for your reviewer:

For @halo-dev/sig-halo-console : We have to determine whether the role is system-reserved by checking if label `rbac.authorization.halo.run/system-reserved` is equal to `true`.

#### 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
修复每个角色都显示系统保留标签的问题
```
2022-12-07 02:49:00 +00:00
guqing 14b210e223
fix: compartor exception in post list (#2854)
#### What type of PR is this?
/kind bugfix
/area core

#### What this PR does / why we need it:
修复文章列表查询时的类型转换错误

文章列表查询将 collectList 错写为 collectSortedList 导致此 `Contributor cannot be cast to class java.lang.Comparable`,
collectSortedList 会使用  `Arrays.sort(a, (Comparator) c)`,这需要目标类实现 Comparable 才行,而此处并不需要自然排序。

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

Fixes #2830

#### Special notes for your reviewer:
此 bug 的复现方式为:
编辑一篇文章保存后,在使用另一个用户账户编辑此文章并发布就会出现,而使用此 PR 后问题消失,此问题只对 Contributor 这个类型有效它不是自定义模型类,而 Tag 和 Category 都是自定义模型 继承了 AbstractExtension 而它 实现了 Comparable 接口。

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

```release-note
修复文章列表查询时的类型转换错误
```
2022-12-06 06:52:14 +00:00
John Niang f5ed34d8a6
Bump Halo version in gradle.properties (#2835)
#### What type of PR is this?

/kind improvement
/area core

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

Bump Halo version in gradle.properties for next release.

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

```release-note
None
```
2022-12-06 03:06:13 +00:00
BugKing 5811261880
docs: remove the downloads badge in README (#2840)
#### What type of PR is this?

/kind documentation

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

鉴于目前已不在 Release 中提供 Jar 包下载,Releases 下载数量的展示已经没有太大意思,所以去掉了 README 中的 Releases 下载数量徽章。

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

```release-note
None
```
2022-12-05 09:06:12 +00:00
John Niang 5980b5b4be
Fix the problem that MySQL complains "Data too long for column 'data' at row 1" (#2833)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.0.1

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

See https://github.com/halo-dev/halo/issues/2832 and https://github.com/halo-dev/halo/issues/2832#issuecomment-1336616901 for more.

For a workaround, please refer to:
- https://github.com/halo-dev/halo/issues/2832#issuecomment-1336610679

But, there are still limitations here:
- For MySQL: ~4GB
- For PosgreSQL: ~1GB

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

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

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

```release-note
修复因文章过长导致无法保存数据的问题
```
2022-12-05 03:32:11 +00:00
Ryan Wang 0072363dee
docs: update readme for Halo 2.0.0 (#2808)
#### What type of PR is this?

/kind documentation

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

为 Halo 2.0 正式版本更新 README。

#### Special notes for your reviewer:

/hold

等待创建 2.0 的 release。

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

```release-note
None
```
2022-12-01 01:31:59 +00:00
John Niang 540cafcdbf
Allow migrating attachments from other places (#2807)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.0.0

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

This PR provides an ability to migrate attachments from other places, like Halo 1.x or Wordpress.

We could simply configure resource mappings to support attachments migration:

```yaml
halo:
  attachment:
    resource-mappings:
      - pathPattern: /upload/**
        locations:
          - upload
          - migrate-from-1.x
      - pathPattern: /wp-content/uploads/**
        locations:
          - migrate-from-wp
```

Meanwhile, I refactored LocalAttachmentUploadHandler for managing attachments from migration in the future.

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

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

#### Special notes for your reviewer:

**Steps to test:**
1. Try to configure the resource mappings
2. Put some static resources into the corresponding location
3. Access it from Browser

At last, please make sure the functionalities of attachment are ok as before.

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

```release-note
None
```
2022-11-30 17:03:51 +00:00
guqing 68ccbb098b
refactor: plugin author to an object (#2806)
#### What type of PR is this?
/kind improvement
/area core
/kind api-change

#### What this PR does / why we need it:
将 Plugin 的 author 改为 Author 对象与主题保持一致。
移除了测试类中使用的 jar 文件,改为使用时压缩

⚠️ 此为破坏性更新,需要修改 Console 插件列表的展示,以及所有官方插件的 plugin.yaml

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

```release-note
Require-user-change:将 Plugin 的 author 类型从 String 为 Author
```
2022-11-30 15:45:50 +00:00
John Niang 9f3c7ae378
Simplify MenuItem with targetRef instead of multi refs (#2799)
#### 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:

Two things this PR does:

1. **Simplify MenuItem with targetRef instead of multi refs**
2. Organize extensions with group `content.halo.run` into content folder

> **Warning** The first thing has some break changes about structure of MenuItem, please @halo-dev/sig-halo-console be aware of that.

Before:

```java
        @Schema(description = "Category reference.")
        private Ref categoryRef;

        @Schema(description = "Tag reference.")
        private Ref tagRef;

        @Schema(description = "Post reference.")
        private Ref postRef;

        @Schema(description = "SinglePage reference.")
        private Ref singlePageRef;
```

After:

```java
        @Schema(description = "Target reference. Like Category, Tag, Post or SinglePage")
        private Ref targetRef;
```

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

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

#### Special notes for your reviewer:

Because this PR contains break changes, we cannot test it in console directly.

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

```release-note
None
```
2022-11-30 13:43:49 +00:00
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