Skip to content

Commit

Permalink
chore: remove deprecated plugin wrapper (#34)
Browse files Browse the repository at this point in the history
### What this PR does?
移除对已过时的 PluginWrapper 的引用

see also halo-dev/halo#6243

```release-note
None
```
  • Loading branch information
guqing authored Jul 3, 2024
1 parent 050777c commit 2f792aa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repositories {
}

dependencies {
implementation platform('run.halo.tools.platform:plugin:2.5.0-SNAPSHOT')
implementation platform('run.halo.tools.platform:plugin:2.10.0-SNAPSHOT')
compileOnly 'run.halo.app:api'

testImplementation 'run.halo.app:api'
Expand All @@ -42,4 +42,4 @@ build {

halo {
version = "2.12.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
package run.halo.search.widget;

import java.util.Properties;
import lombok.RequiredArgsConstructor;
import org.pf4j.PluginWrapper;
import org.springframework.stereotype.Component;
import org.springframework.util.PropertyPlaceholderHelper;
import org.thymeleaf.context.ITemplateContext;
import org.thymeleaf.model.IModel;
import org.thymeleaf.model.IModelFactory;
import org.thymeleaf.processor.element.IElementModelStructureHandler;
import reactor.core.publisher.Mono;
import run.halo.app.plugin.PluginContext;
import run.halo.app.theme.dialect.TemplateHeadProcessor;

import java.util.Properties;

@Component
@RequiredArgsConstructor
public class SearchWidgetHeadProcessor implements TemplateHeadProcessor {

static final PropertyPlaceholderHelper PROPERTY_PLACEHOLDER_HELPER = new PropertyPlaceholderHelper("${", "}");

private final PluginWrapper pluginWrapper;
private final PluginContext pluginContext;

@Override
public Mono<Void> process(ITemplateContext context, IModel model,
Expand All @@ -32,13 +31,13 @@ public Mono<Void> process(ITemplateContext context, IModel model,
private String searchWidgetScript() {

final Properties properties = new Properties();
properties.setProperty("version", pluginWrapper.getDescriptor().getVersion());
properties.setProperty("version", pluginContext.getVersion());

return PROPERTY_PLACEHOLDER_HELPER.replacePlaceholders("""
<!-- PluginSearchWidget start -->
<script src="/plugins/PluginSearchWidget/assets/static/search-widget.iife.js?version=${version}" async></script>
<link rel="stylesheet" href="/plugins/PluginSearchWidget/assets/static/style.css?version=${version}" />
<!-- PluginSearchWidget end -->
""", properties);
<!-- PluginSearchWidget start -->
<script src="/plugins/PluginSearchWidget/assets/static/search-widget.iife.js?version=${version}" async></script>
<link rel="stylesheet" href="/plugins/PluginSearchWidget/assets/static/style.css?version=${version}" />
<!-- PluginSearchWidget end -->
""", properties);
}
}
6 changes: 3 additions & 3 deletions src/main/java/run/halo/search/widget/SearchWidgetPlugin.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package run.halo.search.widget;

import org.pf4j.PluginWrapper;
import org.springframework.stereotype.Component;
import run.halo.app.plugin.BasePlugin;
import run.halo.app.plugin.PluginContext;

/**
* @author ryanwang
*/
@Component
public class SearchWidgetPlugin extends BasePlugin {

public SearchWidgetPlugin(PluginWrapper wrapper) {
super(wrapper);
public SearchWidgetPlugin(PluginContext pluginContext) {
super(pluginContext);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ metadata:
"store.halo.run/app-id": "app-DlacW"
spec:
enabled: true
requires: ">=2.5.0"
requires: ">=2.10.0"
author:
name: Halo
website: https://github.com/halo-dev
Expand Down

0 comments on commit 2f792aa

Please sign in to comment.