Commit Graph

2445 Commits (9dee9b0409de1357da5bfa0b185a1469d032975f)

Author SHA1 Message Date
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
John Niang d40626b07b
Support configuring console location to access console (#2453)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.0

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

Support configuring console location to access console. By default, `classpath:/console/` location will be used. If anyone want to debug locally, you can configure the console properties as following:

```yaml
halo:
  console:
    location: file:/home/xxx/path/to/halo-admin/dist/ # The trailing slash is required or it will be treated with a file instead of a folder.
```

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

```release-note
None
```
2022-09-22 14:22:13 +00:00
guqing 95b7a273f8
feat: create a configmap based on the setting definition when installing a theme (#2440)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0
#### What this PR does / why we need it:
- 安装主题后通过读取主题 Setting 模型中的默认值初始化一个 ConfigMap
- 修改了 Setting 模型的 spec  结构(多了一层 forms 嵌套),配置示例如下:
```yaml
apiVersion: v1alpha1
kind: Setting
metadata:
  name: theme-anatole-setting
spec:
  forms:
    - group: basic
      label: 基本设置
      formSchema:
        - $formkit: select
          name: sidebar_width
          label: 侧边栏宽度
          options:
            "20%": 20%
            "30%": 30%
            "40%": 40%
            "50%": 50%
          value: "40%"
```

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

Fixes #2414

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

```release-note
None
```
2022-09-22 08:26:13 +00:00
guqing cda6402780
feat: any user who accesses the system has the anonymous role (#2443)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
- 未认证用户在系统中被定义为匿名用户(username=anonymousUser),它在授权系统中具有 principle=anonymousUser 且 role=anonymous,key=[secure randomly generated key]
- 未认证用户和已认证用户都将被赋予一个匿名用户角色

参考:
- [Spring security#ServerHttpSecurity.AnonymousSpec](70460ca009/config/src/main/java/org/springframework/security/config/web/server/ServerHttpSecurity.java (L4387))
- [Spring security reactive AnonymousAuthenticationWebFilter](70460ca009/web/src/main/java/org/springframework/security/web/server/authentication/AnonymousAuthenticationWebFilter.java (L46))


#### 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-22 06:58:12 +00:00
guqing bfbc4ec70a
feat: add more query predicates for post list (#2436)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
文章列表新增更过的查询条件
- publishPhase 状态
- visible 可见性
- keyword 关键词
新增排序(sort)(可逆序 sortOrder)
- 创建时间(默认创建时间逆序)
- 发布时间

关键词过滤暂不管文章内容,否则需要查询所有文章内容判断是否包含字符串
排序暂无法支持评论数量和阅读量,这两个属性属于文章统计需要 #2430 的支撑
#### Which issue(s) this PR fixes:

Fixes #2424

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

```release-note
None
```
2022-09-22 06:14:12 +00:00
guqing eee81e78f1
fix: category and tag query parameters in post query (#2441)
#### What type of PR is this?
/kind api-change
/kind improvement
/area core
/milestone 2.0
#### What this PR does / why we need it:
修复文章列表的分类、标签查询参数方法名和取值不一致导致无效问题
#### Which issue(s) this PR fixes:

Fixes #2439

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

```release-note
None
```
2022-09-21 13:58:12 +00:00
guqing ac8dd74211
feat: the ConfigMap named system to store user-defined configurations (#2415)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
将原来系统默认的系统配置 system 改名为 system-default, 并使用名为 system 的 ConfigMap 来存储用户自定义的系统配置。系统最终配置为用户自定义系统配置 Merge Patch 系统默认配置的结果。
see also #2304
#### Which issue(s) this PR fixes:

Fixes #2304

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

```release-note
None
```
2022-09-21 04:06:10 +00:00
John Niang 1714f8edb2
Refactor CustomEndpoint for customizing GroupVersion (#2429)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.0.0

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

Refactor CustomEndpoint for customizing GroupVersion.

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

```release-note
None
```
2022-09-20 06:38:09 +00:00
guqing a39cf2645e
refactor: rename api group for custom api (#2419)
#### What type of PR is this?
/kind improvement
/kind api-change
/area core
/milestone 2.0

#### What this PR does / why we need it:
- 修改管理后台使用的自定义 API 的 group 为 `api.console.halo.run`
- 面向三方应用的自定义 API 的 group 为 `api.halo.run`
- 插件的自定义 API 的 group 为 `api.plugin.halo.run`

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

Fixes #2418

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

```release-note
None
```
2022-09-19 16:24:35 +00:00
guqing 9fdc9c1bb7
feat: add comment custom endpoint for list view (#2412)
#### 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,支持过滤和排序条件
- 新增评论 Reconciler 以支持:
  -  是否有新回复
  - 最新回复时间
  - 上次查看回复时间
  - 未读回复数量
- 新增评论主体信息获取扩展点 `CommentSubject` 用于获取评论的 subject 信息 ,默认实现 `Post` 模型和 `SinglePage`
#### Which issue(s) this PR fixes:
Fixes #2409

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?
```release-note
新增评论列表自定义 API (包括回复)并支持过滤和排序条件
新增发表评论和回复的自定义 API
支持是否有新回复及未读回复数量
```
2022-09-19 08:38:13 +00:00
guqing 510f155e05
feat: count the number of posts under categories and tags (#2402)
#### 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 #2401

#### Special notes for your reviewer:
how to test it?
1. 创建一个多层级的分类及若干文章,查看分类的 status.posts 是否包含当前及其子分类下的文章
2. 创建标签,并将其分配给若干文章,查看标签的 status.posts 是否正确
3. 在主题端查看分类和标签包含的文章数量是否正确,需要注意的是主题端显示的文章数量只包含已发布且 visiable 为 public 且未删除的

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

```release-note
None
```
2022-09-19 02:22:12 +00:00
guqing a0d55c58f6
feat: theme side provides variables for theme and some system settings (#2406)
#### What type of PR is this?
/kind feature
/milestone 2.0
/area core

#### What this PR does / why we need it:
提供当前使用主题(预览或激活)的 configMap 变量和部分系统设置等变量。

提供了以下变量:
- `${theme}` 当前主题的信息,theme.yaml 
- `${theme.config}` 获取当前主题的设置项
- ~`${siteSetting}`~ `${site}` 提供必要系统变量

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

#### Special notes for your reviewer:
how to test it?
再任意主题模板上使用表达式获取例如:`${theme}`,`${theme.config.sns?.email}`

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

```release-note
None
```
2022-09-15 06:52:13 +00:00
guqing 069ff04c84
refactor: theme route pattern and permalink indexer (#2397)
#### What type of PR is this?
/kind improvement
/milestone 2.0
/area core

#### What this PR does / why we need it:
使用正则细化主题端路由并优化

如何测试:
1. 在 admin 系统设置中修改文章文章详情页访问规则
2. 根据规则访问文章详情页,如规则为:`/{year:\d{4}}/{month:\d{2}}/{slug}` 而存在文章 slug 为 fake-slug 且发布日期为 2022-09-08 则 /2022/09/fake-slug 能访问, /2022/9/fake-slug 则不能访问
使用规则 `/{year:\d{4}}/{month:\d{2}}/{day:\d{2}}/{slug}`时 /2022/09/08/fake-slug 能访问 /2022/09/8/fake-slug ,则不能访问
#### Which issue(s) this PR fixes:
Fixes #2396

#### Special notes for your reviewer:
/cc @halo-dev/sig-halo 
#### Does this PR introduce a user-facing change?
```release-note
None
```
2022-09-13 03:58:10 +00:00
guqing 9dc7bc1729
refactor: the structure of finders vo (#2400)
#### What type of PR is this?
/kind improvement
/area core
/milestone 2.0

#### What this PR does / why we need it:
统一主题端 VO 的结构 
#### Which issue(s) this PR fixes:
Fixes #2394

#### Special notes for your reviewer:
how to test it?
通过主题端调用 finder 方法来验证

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

```release-note
None
```
2022-09-09 09:44:11 +00:00
guqing 1d73228b1f
feat: theme template route filling necessary data to request model (#2393)
* feat: add archives data

* refactor: route strategy to populate necessary data

* refactor: next page url does not exceed the total number of pages
2022-09-09 14:43:02 +08:00
John Niang 9331f31d58
Fix stackoverflow error when installing big theme (#2399)
#### What type of PR is this?

/kind bug
/area core
/milestone 2.0

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

We will encounter a stackoverflow error when installing theme with large size. Please see the following screenshot:

![a8a3fadd7b06a071e80d4dd1899a244](https://user-images.githubusercontent.com/16865714/189171274-1940634e-a984-4ca6-857f-f8232f6a6ad3.jpg)

#### Special notes for your reviewer:

How to test?

1. Create a big theme installation package
2. Install it and see the result

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

```release-note
None
```
2022-09-08 17:04:11 +00:00
John Niang d1902ef50f
Reconcile SinglePage reference of MenuItem (#2395)
#### What type of PR is this?

/kind feature

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

Synchronize premalink and display name from SinglePage every 1 minute if only `spec.pageRef` is set.

#### Special notes for your reviewer:

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

How to test?

1. Checkout https://github.com/halo-dev/halo-admin/pull/608 and run it.
2. Create a custom page
3. Select the custom page you created just now when creating menu item
4. Check the permalink of the menu item
5. Change slug name of the custom page and check the permalink of it
6. Wait for 1 minute and check the permalink of of the menu item

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

```release-note
支持绑定自定义页面至菜单项
```
2022-09-08 10:12:10 +00:00
John Niang a2ee2e492e
Support pushing to Docker Hub (#2392)
Signed-off-by: johnniang <johnniang@fastmail.com>

Signed-off-by: johnniang <johnniang@fastmail.com>
2022-09-07 22:39:04 +08:00
guqing e25a3d2232
fix: permalink update when slug changed (#2382)
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->

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

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

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

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

#### What this PR does / why we need it:
修复文章 分类 标签的 slug 改变时,没有重新生成 permalink 的问题
#### Which issue(s) this PR fixes:

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

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

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

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

```release-note
None
```
2022-09-07 08:28:11 +00:00
guqing 969fcde641
feat: add single page extension module (#2381)
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->

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

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

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

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

#### What this PR does / why we need it:
新增自定义页面模块

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

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

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

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

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

```release-note
None
```
2022-09-07 07:48:12 +00:00
guqing 53ee2ea547
feat: support code snippet injection for theme template (#2377)
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->

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

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

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

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

#### What this PR does / why we need it:
主题模板渲染时支持代码片段自动注入

如何测试:
<img width="644" alt="image" src="https://user-images.githubusercontent.com/38999863/188456203-e43c56b0-a886-4feb-bc87-ed17b97ecc4d.png">

1. 文章页 head 注入
 对于文章当spec.htmlMetas字段存在数据时访问文章页面 post.html 会自动在该页面的 head 中插入 meta tag
例如
htmlMetas = [{"name":"keywords", "content": "Halo,Blog"}, {"property":"org:name", "content": "fake-name"}]
则在 post.html返回结果的 `<head></head>`中能看到
```
<meta name="keywords" content="Halo,Blog" />
<meta property="org:name" content="fake-name" />
```
2. 内容页注入
当在后台设置->代码注入的`内容页 head`中填写了内容则访问 post.html 和 page.html 时会自动注入到 head 标签中(需要主题的是 page.html 为自定义页面,该功能在另一个 PR 中还未合并,因此内容页注入目前只适用 post.html)
3. 全局 head
当在后台设置->代码注入的`全局 head` 中填写的内容,访问任意模板页面时都会自动注入到 head 标签中
4. 页脚
页脚自定注入不适合,一般由主题开发者选择位置注入,因此提供了一个`<halo:footer></halo:footer>`标签,当在模板页面使用了此标签则 后台设置->代码注入的`页脚`处填写的内容在渲染后会替换此标签

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

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

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

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

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

```release-note
None
```
2022-09-07 06:12:11 +00:00
John Niang de40a108e2
Allow configuration of external access url (#2385)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.0

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

Many permanent links will be generated in the system, in order to ensure accessiblity, we will allow users to configure external access links instead of internal url.

#### Special notes for your reviewer:

Before starting the application, we need to modify the following configuration into the configuration file(application.yaml):

```yaml
halo:
  external-url: https://halo.run
```

Then, after booting the application, check for permalinks of attachments.

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

```release-note
支持在配置文件中修改博客访问链接
```
2022-09-07 03:54:11 +00:00
John Niang 5118434db2
Refine menu item reconciler to sync permalinks of other refs (#2380)
#### What type of PR is this?

/kind improvement
/area core
/milestone 2.0

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

1. Synchronize permalink and display name of category every 1min
2. Synchronize permalink and display name of tag every 1min
3. Synchronize permalink and display name of post every 1min

Please note that we don't handle the synchronization of `Page` because we don't have the extension yet.

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

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

#### Special notes for your reviewer:

**How to test?**

1. Create a Category/Tag/Post and check the permalink
2. Create a menu and a menu item
3. Set `spec.categoryRef.name` of menu item with the extension name we just created
5. Update the menu item and check the permalink
6. Update slug name of Category/Tag/Post and check the permalink
7. Wait for 1min and check the permalink of menu item

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

```release-note
None
```
2022-09-06 02:50:11 +00:00
John Niang 703f697bc3
Provide an ability of managing attachments (#2354)
#### What type of PR is this?

/kind feature
/area core
/milestone 2.0

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

This PR provides an ability of manging attachments.
- Upload an attachment
- Delete an attachment
- Manage attachment with group
- Manage Policy

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

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

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

```release-note
新增附件管理功能
```
2022-09-05 01:48:12 +00:00
guqing 693b6cc344
feat: improve the site setting config (#2375)
<!--  Thanks for sending a pull request!  Here are some tips for you:
1. 如果这是你的第一次,请阅读我们的贡献指南:<https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>。
1. If this is your first time, please read our contributor guidelines: <https://github.com/halo-dev/halo/blob/master/CONTRIBUTING.md>.
2. 请根据你解决问题的类型为 Pull Request 添加合适的标签。
2. Please label this pull request according to what type of issue you are addressing, especially if this is a release targeted pull request.
3. 请确保你已经添加并运行了适当的测试。
3. Ensure you have added or ran the appropriate tests for your PR.
-->

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

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

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

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

#### What this PR does / why we need it:
新增系统设置默认资源 yaml
#### Which issue(s) this PR fixes:

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

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

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

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

```release-note
None
```
2022-09-04 13:18:10 +00:00