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

chore: remove deprecated plugin wrapper #34

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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