forked from halo-dev/halo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add content extension points for post and single page on theme-…
…side (halo-dev#4080) #### What type of PR is this? /kind feature /milestone 2.7.x /area core #### What this PR does / why we need it: 为主题端的文章和自定义页面内容添加扩展点 插件可以通过实现扩展点来干预文章和自定义页面的内容显示,如修改内容的 html 结构,改变特定样式等 使用方式参考:[docs/extension-points/content.md](halo-dev@9b2b9f1) #### Which issue(s) this PR fixes: Fixes halo-dev#4003 #### Does this PR introduce a user-facing change? ```release-note 为主题端的文章和自定义页面内容添加扩展点 ```
- Loading branch information
Showing
17 changed files
with
571 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
api/src/main/java/run/halo/app/theme/ReactivePostContentHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package run.halo.app.theme; | ||
|
||
import lombok.Builder; | ||
import lombok.Data; | ||
import org.pf4j.ExtensionPoint; | ||
import org.springframework.lang.NonNull; | ||
import reactor.core.publisher.Mono; | ||
import run.halo.app.core.extension.content.Post; | ||
|
||
/** | ||
* <p>{@link ReactivePostContentHandler} provides a way to extend the content to be displayed in | ||
* the theme.</p> | ||
* Plugins can implement this interface to extend the content to be displayed in the theme, | ||
* including but not limited to adding specific styles, JS libraries, inserting specific content, | ||
* and intercepting content. | ||
* | ||
* @author guqing | ||
* @since 2.7.0 | ||
*/ | ||
public interface ReactivePostContentHandler extends ExtensionPoint { | ||
|
||
/** | ||
* <p>Methods for handling {@link run.halo.app.core.extension.content.Post} content.</p> | ||
* <p>For example, you can use this method to change the content for a better display in | ||
* theme-side.</p> | ||
* | ||
* @param postContent content to be handled | ||
* @return handled content | ||
*/ | ||
Mono<PostContentContext> handle(@NonNull PostContentContext postContent); | ||
|
||
@Data | ||
@Builder | ||
class PostContentContext { | ||
private Post post; | ||
private String content; | ||
private String raw; | ||
private String rawType; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
api/src/main/java/run/halo/app/theme/ReactiveSinglePageContentHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package run.halo.app.theme; | ||
|
||
import lombok.Builder; | ||
import lombok.Data; | ||
import org.pf4j.ExtensionPoint; | ||
import org.springframework.lang.NonNull; | ||
import reactor.core.publisher.Mono; | ||
import run.halo.app.core.extension.content.SinglePage; | ||
|
||
/** | ||
* <p>{@link ReactiveSinglePageContentHandler} provides a way to extend the content to be | ||
* displayed in the theme.</p> | ||
* | ||
* @author guqing | ||
* @see ReactivePostContentHandler | ||
* @since 2.7.0 | ||
*/ | ||
public interface ReactiveSinglePageContentHandler extends ExtensionPoint { | ||
|
||
/** | ||
* <p>Methods for handling {@link run.halo.app.core.extension.content.SinglePage} content.</p> | ||
* <p>For example, you can use this method to change the content for a better display in | ||
* theme-side.</p> | ||
* | ||
* @param singlePageContent content to be handled | ||
* @return handled content | ||
*/ | ||
Mono<SinglePageContentContext> handle(@NonNull SinglePageContentContext singlePageContent); | ||
|
||
@Data | ||
@Builder | ||
class SinglePageContentContext { | ||
private SinglePage singlePage; | ||
private String content; | ||
private String raw; | ||
private String rawType; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.