Commit Graph

2419 Commits (7188464bc1339a5af043bfffecd44210f5168ec0)

Author SHA1 Message Date
guqing 58e98f0fc8
feat: add an API to list uninstalled themes (#2586)
#### What type of PR is this?
/kind feature
/milestone 2.0
/area core
/kind api-change

#### What this PR does / why we need it:
新增 API 用于查询未安装的主题

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

Fixes #2554

#### Special notes for your reviewer:
how to test it?
1. 安装几个主题
2. 直接解压几个主题到 work dir 的 themes 目录
3. 使用以下 endpoint 查询未安装的主题,期望获得所有未安装主题的 themes.yaml 信息
```
/apis/api.console.halo.run/v1alpha1/themes?uninstalled=true
```

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

```release-note
支持扫描主题目录下未安装的主题
```
2022-10-18 04:30:09 +00:00
guqing 3d79484591
feat: head tag supports extension for template (#2574)
#### What type of PR is this?
/kind feature
/milestone 2.0
/area core

#### What this PR does / why we need it:
允许插件通过实现 TemplateHeadProcessor 接口来修改主题模板的 head 标签

#### Which issue(s) this PR fixes:
how to test it?
1. 克隆 https://github.com/halo-sigs/plugin-umami
2. build 一个 jar 包作为插件使用
3. 配置 plugin-umami 后能在主题页的 head 标签看到一个用于 umami 统计的 script 标签

Fixes #

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

```release-note
None
```
2022-10-18 04:18:09 +00:00
guqing 3973768a7a
refactor: get default menu (#2587)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
优化主题端菜单项查询

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

Fixes #2564

#### Special notes for your reviewer:
how to test it?
使用 menuFinder.getDefault() 方法测试多级菜单项的排序及新增

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

```release-note
修复主题端菜单查询数据错误问题
```
2022-10-18 04:14:13 +00:00
guqing a3448adee2
feat: add favicon head processor (#2582)
#### What type of PR is this?
/kind feature
/area core
/milestone 2.0

#### What this PR does / why we need it:
模板渲染自动填充 Favicon 到 head 标签
#### Which issue(s) this PR fixes:

Fixes #2581

#### Special notes for your reviewer:
how to test it?
在 console 系统设置 -> 基础设置 填写 Favicon 后,到主题端能到看它

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

```release-note
支持设置 Favicon
```
2022-10-18 02:22:09 +00:00
John Niang 2527eb42e2
Disable CSRF token check for RESTful APIs (#2580)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.0
/kind api-change

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

1. Disable CSRF token check for RESTful APIs but login and logout APIs.
2. Enable CORS check for login and logout APIs

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

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

#### How to test?

1. Install a valid theme and create a sample post
2. View the post at theme end
3. Check the response of counter API

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

```release-note
禁用对 RESTful API 的 CSRF 检查
```
2022-10-17 08:03:38 +00:00
guqing 2505c7fe4a
refactor: register method for reverse proxy registry (#2567)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
对反向代理规则注册增加重复注册检查

场景:
ReverseProxyRouterFunctionRegistry 中有一个 pluginIdReverseProxyMap 记录了 插件名称和插件的 ReverseProxy 名称对应关系
当重复 fake-plugin -> test-reverse-proxy 时,pluginIdReverseProxyMap 的 value 不会去重,因此需要增加重复注册检查
#### Which issue(s) this PR fixes:

Fixes #

#### Special notes for your reviewer:
how to test it?
本 PR 不需要测试,已经对上述场景添加了单元测试

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

```release-note
None
```
2022-10-17 06:19:38 +00:00
guqing 6cce2202a1
refactor: plugin js bundle file loading and routing rules (#2556)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0
/kind api-change
#### What this PR does / why we need it:
重构插件 JsBundle 文件加载方式及路由规则

- 将插件静态资源的访问路由规则从 /assets/{plugin-name}/** 改为 /plugins/{plugin-name}/assets/** 与主题静态资源规则结构一致
- 默认在 Halo 中提供 /plugins/{plugin-name}/assets/console/** 路由以确保插件都能加载到最基础的 JsBundle 文件
#### Which issue(s) this PR fixes:

Fixes #2555

#### Special notes for your reviewer:
how to test it?
1. 安装并启用一个插件能访问到 `/plugins/{plugin-name}/assets/console/main.js` 和 `/plugins/{plugin-name}/assets/console/style.css` 即为功能正确
2. 在插件的 extensions 目录创建一个 reverse proxy 的自定义模型 yaml 资源,并使用此插件,插件反向代理规则能正确访问到文件即为功能正确

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

```release-note
重构插件 JsBundle 文件加载方式及路由规则
```
2022-10-17 04:19:37 +00:00
guqing 08fe1858cf
feat: add upvote and downvote tracker (#2566)
#### What type of PR is this?
/kind feature
/area core
/milestone 2.0
/kind api-change

#### What this PR does / why we need it:
新增文章和评论等资源的点赞和踩 API

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

Fixes #2565

#### Special notes for your reviewer:
how to test it?
1.  创建并发布一篇文章 替换下面的 `your-post-name` 然后执行它
```curl
curl --location --request POST 'http://localhost:8090/apis/api.halo.run/v1alpha1/trackers/upvote' \
--header 'Content-Type: application/json' \
--data-raw '{
    "group": "content.halo.run",
    "plural": "posts",
    "name": your-post-name
}
```
2. 请求成功并得到 response 为点赞数
3. 踩的 API 为 `http://localhost:8090/apis/api.halo.run/v1alpha1/trackers/downvote` 请求体与步骤1相同的测试方法
4. 重启 Halo 后 Counter 数据应该依然存在并且正确

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

```release-note
新增文章和评论等资源的点赞和踩 API
```
2022-10-15 04:53:34 +00:00
John Niang 83b40b6dad
Update README.md due to 2.0.0-alpha.2 released (#2546)
#### What type of PR is this?

/kind documentation

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

The README.md is out of date due to [2.0.0-alpha.2](https://github.com/halo-dev/halo/releases/tag/v2.0.0-alpha.2) released.

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

```release-note
None
```
2022-10-12 09:10:16 +00:00
Ryan Wang 823acdaaae
docs: remove changelog documentation (#2540)
#### What type of PR is this?

/kind documentation

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

目前 Halo 处于多版本同时并存发行的现状,所以在各个分支(main、release-1.5、release-1.6)维护 CHANGELOG.md 会变得比较麻烦。所以考虑移除掉仓库内的 CHANGELOG.md 文件,后续以 [releases](https://github.com/halo-dev/halo/releases) 页面提供。

Ref https://github.com/halo-dev/halo/issues/2538

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

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

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo 

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

```release-note
None
```
2022-10-12 08:20:15 +00:00
John Niang cc221d31c7
Continue extension updation if modification conflict occurs (#2536)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.0

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

When we initialize default extensions at Halo startup, updation of one extension is very likely to be failed due to modification conflict. Then, remaining extensions won't be updated anymore.

Therefore, this PR resolve this problem by retrying updation with 3 times with interval 100ms and continue extension updation if modification conflict occurs.

#### How to test

1. Fully initialize system(e.g.: Clear `~/halo-next` before starting Halo)
2. Update Role `authenticated` as you wish via Extension API
3. Restart Halo and check it again
4. Retry multiple times

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

```release-note
修复系统默认数据无法正常更新的问题
```
2022-10-12 04:26:15 +00:00
John Niang dbaa087936
Support proxying console in server side (#2535)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.0

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

Support proxying console in server side. We just need to configure the properties as following:

```yaml
halo:
  console:
    proxy:
      endpoint: http://localhost:3000/
      enabled: true
```

Before starting Halo server, please start the console first at port 3000 by checkouting https://github.com/halo-dev/console/pull/638.

Now we can have a try to access console via <http://localhost:8090/console/>.

Please note that this feature should be only for development environment instead of production environment.

#### Todos

- [ ] Proxy WebSocket for hmr of Vite

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

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

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

```release-note
None
```
2022-10-11 15:30:14 +00:00
John Niang af8860ffb6
Refine logic of form login and logout (#2528)
#### What type of PR is this?

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

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

Please see b092b390b7/docs/authentication/README.md

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

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

#### Special notes for your reviewer:

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

```release-note
优化系统登录和登出逻辑
```
2022-10-11 08:04:14 +00:00
Ryan Wang fb6c3755ed
docs: provides Halo 2.0 online demo environment (#2527)
#### What type of PR is this?

/kind documentation
/milestone 2.0

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

更新 README,提供 Halo 2.0 的演示环境信息。

#### Special notes for your reviewer:

/cc @halo-dev/sig-halo 

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

```release-note
None
```
2022-10-11 01:38:13 +00:00
guqing 36e8ae1a15
refactor: system role templates (#2524)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
优化系统角色模板配置
- 认证用户仅具有名为 system-states 的 ConfigMap 查看权限而非所有 ConfigMap查看权限
- 主题和插件的管理权限目前需要单独勾选 ConfigMap 和 Setting 的权限才可以看到表单和值
#### Which issue(s) this PR fixes:

Fixes #2523

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

```release-note
None
```
2022-10-10 08:04:10 +00:00
guqing 04300308fe
refactor: the way of router function register for reverse proxy (#2522)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
重构插件反向代理注册方式
#### Which issue(s) this PR fixes:

Fixes #2520

#### Special notes for your reviewer:
How to test:
1. clone 项目 https://github.com/halo-sigs/plugin-comment-widget 后 build 一个 jar
2. 将该 jar 作为一个插件安装到系统并启用它
3. 访问插件提供的反向代理资源
    ```
    curl --location --request GET 'http://localhost:8090/assets/PluginCommentWidget/static/comment-widget.iife.js'
    ```
    期望得到结果
4. 停用插件,重复 Step 3,期望得到 404
5. 重复数次 Step 3-4 均与期望相同即可 
#### Does this PR introduce a user-facing change?

```release-note
None
```
2022-10-09 03:42:30 +00:00
guqing a4609f68d1
fix: the exception of plugin context has been closed when plugin restart (#2518)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.0

#### What this PR does / why we need it:
BasePlugin 持有了一个当前插件的 PluginApplicationContext 当插件停止后重新启用会获取到旧的 PluginApplicationContext,之前之所以这样写的目的只是插件的这个 BasePlugin 不支持依赖注入,目前已经支持所以不在这样解决问题

日志:

```
Caused by: java.lang.IllegalStateException: run.halo.app.plugin.PluginApplicationContext@6baf2671 has been closed already
	at org.springframework.context.support.AbstractApplicationContext.assertBeanFactoryActive(AbstractApplicationContext.java:1125) ~[spring-context-6.0.0-M5.jar:6.0.0-M5]
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1158) ~[spring-context-6.0.0-M5.jar:6.0.0-M5]
	at run.halo.app.plugin.SpringExtensionFactory.create(SpringExtensionFactory.java:102) ~[classes/:2.0.0-alpha.1]
	at org.pf4j.ExtensionWrapper.getExtension(ExtensionWrapper.java:37) ~[pf4j-3.7.0.jar:3.7.0]
	at org.pf4j.AbstractPluginManager.getExtensions(AbstractPluginManager.java:971) ~[pf4j-3.7.0.jar:3.7.0]
	at run.halo.app.plugin.HaloPluginManager.getExtensions(HaloPluginManager.java:118) ~[classes/:2.0.0-alpha.1]
	at run.halo.app.plugin.ExtensionComponentsFinder.getExtensions(ExtensionComponentsFinder.java:36) ~[classes/:2.0.0-alpha.1]
	at run.halo.app.theme.dialect.CommentElementTagProcessor.doProcess(CommentElementTagProcessor.java:49) ~[classes/:2.0.0-alpha.1]
	at org.thymeleaf.processor.element.AbstractElementTagProcessor.process(AbstractElementTagProcessor.java:95) ~[thymeleaf-3.1.0.M2.jar:3.1.0.M2]
	at org.thymeleaf.util.ProcessorConfigurationUtils$ElementTagProcessorWrapper.process(ProcessorConfigurationUtils.java:633) ~[thymeleaf-3.1.0.M2.jar:3.1.0.M2]
	at org.thymeleaf.engine.ProcessorTemplateHandler.handleStandaloneElement(ProcessorTemplateHandler.java:918) ~[thymeleaf-3.1.0.M2.jar:3.1.0.M2]
	at org.thymeleaf.engine.StandaloneElementTag.beHandled(StandaloneElementTag.java:228) ~[thymeleaf-3.1.0.M2.jar:3.1.0.M2]
	at org.thymeleaf.engine.Model.process(Model.java:282) ~[thymeleaf-3.1.0.M2.jar:3.1.0.M2]
	at org.thymeleaf.engine.ProcessorTemplateHandler.handleStandaloneElement(ProcessorTemplateHandler.java:1204) ~[thymeleaf-3.1.0.M2.jar:3.1.0.M2]
	at org.thymeleaf.engine.StandaloneElementTag.beHandled(StandaloneElementTag.java:228) ~[thymeleaf-3.1.0.M2.jar:3.1.0.M2]
	at org.thymeleaf.engine.Model.process(Model.java:282) ~[thymeleaf-3.1.0.M2.jar:3.1.0.M2]
	at org.thymeleaf.engine.ProcessorTemplateHandler.handleOpenElement(ProcessorTemplateHandler.java:1587) ~[thymeleaf-3.1.0.M2.jar:3.1.0.M2]
	at org.thymeleaf.engine.OpenElementTag.beHandled(OpenElementTag.java:205) ~[thymeleaf-3.1.0.M2.jar:3.1.0.M2]
	at org.thymeleaf.engine.TemplateModel.process(TemplateModel.java:136) ~[thymeleaf-3.1.0.M2.jar:3.1.0.M2]
	at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:592) ~[thymeleaf-3.1.0.M2.jar:3.1.0.M2]
	at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1103) ~[thymeleaf-3.1.0.M2.jar:3.1.0.M2]
	at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1077) ~[thymeleaf-3.1.0.M2.jar:3.1.0.M2]
	at run.halo.app.theme.engine.SpringWebFluxTemplateEngine.lambda$createFullStream$0(SpringWebFluxTemplateEngine.java:202) ~[classes/:2.0.0-alpha.1]
	at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:58) ~[reactor-core-3.5.0-M4.jar:3.5.0-M4]
	at reactor.core.publisher.Mono.subscribe(Mono.java:4321) ~[reactor-core-3.5.0-M4.jar:3.5.0-M4]
	at reactor.core.publisher.MonoSubscribeOn$SubscribeOnSubscriber.run(MonoSubscribeOn.java:126) ~[reactor-core-3.5.0-M4.jar:3.5.0-M4]
	at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:84) ~[reactor-core-3.5.0-M4.jar:3.5.0-M4]
	at reactor.core.scheduler.WorkerTask.call(WorkerTask.java:37) ~[reactor-core-3.5.0-M4.jar:3.5.0-M4]
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source) ~[na:na]
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[na:na]
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[na:na]
	at java.base/java.lang.Thread.run(Unknown Source) ~[na:na]
```

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

Fixes #

#### Special notes for your reviewer:
how to test:
1. 安装一个插件
2. 启用它再停止它,如此反复,没有抛出异常即可

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

```release-note
None
```
2022-10-09 03:36:30 +00:00
Ryan Wang 18a3fc51a5
chore: rename the default location of the plugin's bundle resources to `console` (#2521)
#### What type of PR is this?

/kind api-change
/kind improvement
/milestone 2.0

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

Ref #2519 ,我们已经将 halo-admin 的命名改为了 console,所以相关命名需要同步修改。

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

Fixes #2519 

#### Special notes for your reviewer:

/hold 

等待插件的 PR。

测试方式:

1. 使用 plugin-links 插件的 https://github.com/halo-sigs/plugin-links/pull/3 PR 进行测试,需要 Clone 到本地。
2. 使用 `./graldew build` 的命令编译插件,得到 `build/libs/plugin-link-*.jar`。
3. Halo 的插件运行模式改为 deployment 模式。
4. 启动 Halo 之后,安装第二步得到的插件。
5. 检查浏览器控制台是否正常加载了 `/assets/PluginLinks/console/main.js` 和 `/assets/PluginLinks/admin/style.css`

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

```release-note
None
```
2022-10-09 03:30:30 +00:00
John Niang 543bdc45b5
Support running Halo with MySQL and MariaDB database (#2512)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.0

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

Add MySQL script to support running Halo with MySQL database due to https://github.com/jasync-sql/jasync-sql/issues/311 has been resolved.

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

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

#### Special notes for reviewers

Steps to test:

1. Start up MySQL. e.g.:

    ```yaml
    version: '3.1'
    
    services:
    
      db:
        image: mysql
        # NOTE: use of "mysql_native_password" is not recommended: https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password
        # (this is just an example, not intended to be a production configuration)
        command: --default-authentication-plugin=mysql_native_password
        restart: always
        environment:
          MYSQL_ROOT_PASSWORD: openmysql
        ports:
          - 3306:3306
    
      adminer:
        image: adminer
        restart: always
        ports:
          - 8080:8080
    ```
    
    ```bash
    docker-compose -f mysql.yaml up
    ```

2. Start Halo with `mysql` profile. e.g.:

    ```bash
    ./gradlew bootRun --args="--spring.profiles.active=mysql"
    ```

3. Validate the functionality of Halo

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

```release-note
None
```
2022-10-09 02:32:30 +00:00
guqing 9725d63056
fix: tracker counter api does not need authentication for theme (#2517)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.0

#### What this PR does / why we need it:
修复主题端内容页访问量统计接口角色规则动词配置错误问题
#### Which issue(s) this PR fixes:

Fixes #2507

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

```release-note
None
```
2022-10-08 09:06:28 +00:00
John Niang b23ed2efcc
Bump version of Spring Boot & SpringDoc (#2511)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.0

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

1. Upgrade Spring Boot to 3.0.0-M5. See https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0.0-M5-Release-Notes for more.
2. Upgrade SpringDoc to 2.0.0-M6. The version is compatible to Spring Boot 3.0.0-M5. See https://github.com/springdoc/springdoc-openapi/issues/1865 for more.

#### Special notes for your reviewer:

Please check the API documentation endpoint: <http://localhost:8090/swagger-ui.html>.

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

```release-note
None
```
2022-10-08 02:04:27 +00:00
John Niang e23193cd73
Add Pull Request template for default branch (#2513)
#### What type of PR is this?

/kind documentation

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

See https://github.com/halo-dev/halo/pull/2078 for more.

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

```release-note
None
```
2022-10-06 11:00:25 +00:00
Ryan Wang a89d51e63f
docs: remove readme documentation about running with jar (#2501)
#### What type of PR is this?

/kind documentation
/milestone 2.0

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

因为目前暂时没有提供 JAR 包,所以移除 README 有关使用 JAR 包运行的文档。


#### Special notes for your reviewer:

/cc @halo-dev/sig-halo 

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

```release-note
None
```
2022-10-04 16:22:24 +00:00
John Niang cd2dc99898
Change condition of docker push (#2499) 2022-09-30 19:04:24 +08:00
guqing 708cd12d25
fix: total comment count for page and singlepage (#2498)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
修复文章和自定义页面的总评论数量统计取值错误
#### 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
```
2022-09-30 09:44:19 +00:00
Ryan Wang 3b4703533e
docs: update readme for Halo 2.0 (#2492)
#### What type of PR is this?

/kind documentation
/milestone 2.0

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

更新 README。

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

#### Special notes for your reviewer:

/hold

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

```release-note
None
```
2022-09-30 09:42:24 +00:00
guqing 470696fff1
feat: add retry operation for post and single page when publish and update (#2497)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
发布和更新文章及自定义页面时如果遇到乐观锁错误自动重试
#### 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
```
2022-09-30 09:40:23 +00:00
guqing 3995adba32
feat: add more role templates (#2488)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
补充角色模板
#### Which issue(s) this PR fixes:

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

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

```release-note
None
```
2022-09-30 09:38:23 +00:00
guqing 7de944f61d
chore: degrade springboot version from 3.0.0-M5 to 3.0.0-M4 (#2496)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
将 spring boot 的版本从 3.0.0-M5 降级到 3.0.0-M5 以解决 swragger 无法使用的问题
#### 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
```
2022-09-30 08:52:19 +00:00
John Niang ba41c481bb
Fix the problem of granting role not taking effect (#2495)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.0

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

Fix the problem of granting role not taking effect.

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

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

#### Special notes for your reviewer:

Steps to test:

1. Create an user
2. Grant a role for the user
3. Check the user list

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

```release-note
None
```
2022-09-30 08:04:20 +00:00
guqing eaa18573f0
feat: add post and single page statistics (#2476)
#### What type of PR is this?
/kind feature
/area core
/milestone 2.0
/kind api-change

#### What this PR does / why we need it:
新增文章和自定义页面统计功能:
1. 浏览量统计,通过在指定模板页面插入 tracker js 上报浏览量数据并写日志到文件同时通过 Metrics 暴露数据
2. 浏览量日志异步写文件
3. 文章列表和自定义页面列表数据增加 stats 属性
4. 主题文章列表及详情、自定义页面详情增加 stats 属性
5. 新增仪表盘统计数据展示, endpoint: `/apis/api.console.halo.run/v1alpha1/stats`
```java
private Integer visits;
private Integer comments;
private Integer approvedComments;
private Integer upvotes;
private Integer users;
```

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

Fixes #2430

#### Special notes for your reviewer:
how to test it?
1. 使用一个主题,创建几篇文章和一些自定义页面,访问他们,并在详情页面的 head 总看到一个 `halo-tracker.js` 的 script 标签
![telegram-cloud-document-5-6167924618783885123](https://user-images.githubusercontent.com/38999863/192552428-b5635607-9810-4be3-b1fe-8a54ed3407c5.jpg)
2. 访问10次以上可以看到 halo work下有一个 `logs/visits.log`,里面有访问记录,它是10条为一批异步刷新到磁盘
3. 主题端文章列表及详情和自定义页面的详情可以取到一个stats字段
4.  `/apis/api.console.halo.run/v1alpha1/stats` 此 endpoint 可以得到总的访问量和评论量,这些数据也是异步的会有一分钟延迟

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

```release-note
None
```
2022-09-30 07:58:19 +00:00
guqing a3aba94102
refactor: comment hidden default is false (#2482)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
创建评论时 hidden 字段默认为 false
#### 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
```
2022-09-30 02:22:19 +00:00
John Niang 79bd55424d
Fix the problem of changing password not exist before (#2493)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.0

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

Fix the problem of changing password not exist before.

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

Partial Fixes https://github.com/halo-dev/halo/issues/2427

#### Special notes for your reviewer:

Steps to test:

1. Create an user and change his/her password
2. Login with the user and the password

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

```release-note
None
```
2022-09-30 02:18:20 +00:00
John Niang e8d00e56f4
Support filtering and sorting plugins (#2489)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.0

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

Support filtering and sorting plugins. e.g.:

```bash
http://localhost:8090/api/api.console.halo.run/v1alpha1/plugins?keyword=xyz&enabled=true&sort=creationTimestamp,desc
```

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

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

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

```release-note
None
```
2022-09-30 01:30:19 +00:00
guqing 98829f0a3e
feat: add more query params and sorter for single page (#2481)
#### What type of PR is this?
/kind feature
/milestone 2.0
/area core
/kind api-change

#### What this PR does / why we need it:
自定义页面增加排序和筛选:
筛选:
关键词
状态
可见性
作者

排序:
发布时间
创建时间
#### Which issue(s) this PR fixes:

Fixes #2469

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

```release-note
None
```
2022-09-28 15:50:17 +00:00
guqing 27e151a574
feat: add location for theme (#2484)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
主题支持展示绝对路径位置
#### Which issue(s) this PR fixes:

Fixes #2461

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

```release-note
None
```
2022-09-28 15:46:17 +00:00
guqing fe3860a8b2
refactor: reload theme.yaml when theme reload (#2486)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
主题 reload endpoint 增加对 theme.yaml 的 reload 操作
#### 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
```
2022-09-28 15:28:18 +00:00
guqing 2d87a95193
refactor: do not serialize compact post for tag and category (#2483)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
标签和分类的 status 中的 posts 字段不序列化,只提供文章 postCount 代替
#### 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
```
2022-09-28 14:10:17 +00:00
John Niang 565c8340e9
Fix the problem of not being able to request SinglePage with slug name containing special characters (#2479)
#### What type of PR is this?

/kind bug
/kind api-change
/area core
/milestone 2.0

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

Support setting special characters on slug name of SinglePage.

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

Partial Fixes https://github.com/halo-dev/halo/issues/2473

#### Special notes for your reviewer:

Steps to test:

1. Create single pags with slug name `中文`, `/a/b/c/d` or `a / b`
2. Request it with permalink generated by Halo

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

```release-note
None
```
2022-09-28 07:48:21 +00:00
Ryan Wang e954af88ec
perf: change the default sort order of articles (#2480)
#### What type of PR is this?

/kind improvement
/milestone 2.0
/area core

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

修改文章列表的默认排序规则,之前是按照创建时间(createTime)升序,现在改为降序。即最新创建的文章在前面。

#### Special notes for your reviewer:

测试方式:

连续创建多篇文章,检查前后台的文章排序是否是最新的在最前面。

/cc @halo-dev/sig-halo 

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

```release-note
None
```
2022-09-28 06:52:16 +00:00
Ryan Wang 91793a7e03
perf: refine the extension definition for system setting (#2477)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.0

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

完善系统设置表单的资源定义。

- 副标题的验证改为取消必填
- 优化主题路由规则显示名称
- 移除暂未实现的用户注册相关设置
- 代码注入设置的文案

#### 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
完善系统设置表单的资源定义
```
2022-09-28 03:34:16 +00:00
John Niang 11d91712f6
Fix empty listing of single page (#2474)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.0

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

Fix empty listing of single page while using PostgreSQL.

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

```release-note
None
```
2022-09-27 09:46:15 +00:00
John Niang 1fc37673f7
Support running Halo with PostgreSQL (#2472)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.0

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

Add PostgreSQL script to support running Halo with PostgreSQL database. BTW, there was a weird issue (emty posts even if there are some posts created) while listing Post, and I fixed it in this PR.

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

Partial Fixes https://github.com/halo-dev/halo/issues/2464

#### Special notes for reviewers

Steps to test:

1. Start up PostgreSQL. e.g.:

    ```yaml
    version: '3.1'
    
    services:
    
      db:
        image: postgres
        restart: always
        environment:
          POSTGRES_PASSWORD: openpostgresql
        ports:
          - 5432:5432
    
      adminer:
        image: adminer
        restart: always
        ports:
          - 8080:8080
    ```
    
    ```bash
    docker-compose -f postgresql.yaml up
    ```

2. Start Halo with `postgresql` profile. e.g.:

    ```bash
    ./gradlew bootRun --args="--spring.profiles.active=postgresql"
    ```

3. Validate the functionality of Halo

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

```release-note
None
```
2022-09-27 02:24:15 +00:00
guqing 264a4330c3
feat: add error log when permalink exists (#2460)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
注册 permalink 到 Permalinker 时校验 permalink 是否已经存在,如果存在则记录错误日志且不向 PermalinkIndexer 添加记录

TODO:
- [ ] 后续增加事件功能后检查到 permalink 重复则发送记录事件的 event 来代替日志记录
#### Which issue(s) this PR fixes:

A part of #2454

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

```release-note
None
```
2022-09-27 02:16:15 +00:00
guqing 721cddff5d
fix: post excerptare generated using only published content that is in use (#2457)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
文章自动摘要只从正在使用的已发布版本的内容中取得
#### Which issue(s) this PR fixes:

Fixes #2452

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

```release-note
None
```
2022-09-26 08:28:19 +00:00
guqing ed8dddbafa
feat: add comment list APIs for theme-side (#2433)
#### What type of PR is this?
/kind feature
/milestone 2.0
/area core
/kind api-change

#### What this PR does / why we need it:
- 新增主题端评论列表功能
- 新增 `<halo:comment />` html tag 用于扩展评论组件
- 插件可以实现 `CommentWidget` 扩展点来渲染评论组件 html 块,以替换 `<halo:comment />` 标签
#### Which issue(s) this PR fixes:

Fixes #2432

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

```release-note
新增主题端评论列表功能
```
2022-09-26 08:26:13 +00:00
John Niang 73c66289e0
Bump version of dependencies (#2466)
#### What type of PR is this?

/kind cleanup
/area core
/milestone 2.0

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

This PR mainly upgrades version of dependencies and removes unused dependencies.

See the following references for more:

- https://github.com/spring-projects/spring-boot/releases/tag/v3.0.0-M5
- https://github.com/jhy/jsoup/releases/tag/jsoup-1.15.3
- https://github.com/spring-projects/spring-security/issues/6613

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

```release-note
None
```
2022-09-25 11:22:14 +00:00
John Niang 1da89f04e2
Fix the problem of generating permalink due to special filename (#2462)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.0

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

Encode path of attachment permalink instead of using URI#resolve methods directly.

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

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

#### Special notes for reviewers

Steps to test:

1. Create a file with special name, e.g.: `hello world.txt`
2. Upload the file and see the permalink

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

```release-note
None
```
2022-09-24 04:50:15 +00:00
guqing 02cc2fa7be
feat: add theme setting reload API (#2456)
#### What type of PR is this?
/kind feature
/milestone 2.0
/area core
/kind api-change

#### What this PR does / why we need it:
新增主题设置重载 API,调用此 API 会从主题文件中重新加载 settings.yaml 复盖原有记录,便于主题开发和测试
插件不需要此功能,配置了 `fixedPluginPath` 后每次重启都会加载新的配置项
#### Which issue(s) this PR fixes:

Fixes #2426

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

```release-note
None
```
2022-09-23 09:38:13 +00:00
guqing f0892b2f4d
feat: add theme link expression dialect (#2438)
#### What type of PR is this?
/kind feature
/milestone 2.0
/area core

#### What this PR does / why we need it:
允许主题模板在 HTML 或 JavaScript 片段中使用表达式对象获得链接:
- `${#theme.assets('/js/main.js'))}`
- `${#theme.route('/categories')}`

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

Fixes #2435

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

```release-note
None
```
2022-09-23 03:12:13 +00:00