Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize default theme when Halo starts up for the first time #2704

Merged
merged 4 commits into from Nov 15, 2022

Conversation

JohnNiang
Copy link
Member

@JohnNiang JohnNiang commented Nov 15, 2022

What type of PR is this?

/kind feature
/area core
/milestone 2.0

What this PR does / why we need it:

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

Default theme configuration is as following:

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

Which issue(s) this PR fixes:

Fixes #2700

Special notes for your reviewer:

Steps to test:

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

Does this PR introduce a user-facing change?

在首次启动 Halo 时初始化默认主题

Signed-off-by: John Niang <johnniang@fastmail.com>
@f2c-ci-robot f2c-ci-robot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. labels Nov 15, 2022
@f2c-ci-robot f2c-ci-robot bot added this to the 2.0 milestone Nov 15, 2022
@f2c-ci-robot f2c-ci-robot bot added the area/core Issues or PRs related to the Halo Core label Nov 15, 2022
Signed-off-by: John Niang <johnniang@fastmail.com>
Signed-off-by: John Niang <johnniang@fastmail.com>
Copy link
Member

@ruibaby ruibaby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Nov 15, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ruibaby

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@f2c-ci-robot f2c-ci-robot bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 15, 2022
Signed-off-by: John Niang <johnniang@fastmail.com>
Copy link
Member

@guqing guqing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@f2c-ci-robot f2c-ci-robot bot added the lgtm Indicates that a PR is ready to be merged. label Nov 15, 2022
@f2c-ci-robot f2c-ci-robot bot merged commit 0c8ccec into halo-dev:main Nov 15, 2022
@JohnNiang JohnNiang deleted the feat/initialize-default-theme branch November 15, 2022 14:06
f2c-ci-robot bot pushed a commit that referenced this pull request Nov 18, 2022
#### 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 <#2704>.

#### Special notes for your reviewer:

Steps to test:

1. Upgrade any theme

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

```release-note
None
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/core Issues or PRs related to the Halo Core kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request to initialize default theme when system startup for the first time
3 participants