Skip to content

Commit

Permalink
Merge pull request #6 from guqing/chore/plugin-wrapper
Browse files Browse the repository at this point in the history
chore: remove deprecated plugin wrapper
  • Loading branch information
carolcoral authored Jul 2, 2024
2 parents 9a73991 + f6fb8a8 commit 6dc724c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 39 deletions.
13 changes: 13 additions & 0 deletions src/main/java/site/xindu/afdian/AfdianPlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package site.xindu.afdian;

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

@Component
public class AfdianPlugin extends BasePlugin {

public AfdianPlugin(PluginContext pluginContext) {
super(pluginContext);
}
}
31 changes: 0 additions & 31 deletions src/main/java/site/xindu/afdian/StarterPlugin.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
package site.xindu.afdian.component;

import org.pf4j.PluginWrapper;
import java.util.Properties;
import lombok.RequiredArgsConstructor;
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 CustomHeadProcessor implements TemplateHeadProcessor {

private 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 @@ -29,12 +31,8 @@ public Mono<Void> process(ITemplateContext context, IModel model,

private String contactFormHtml() {
Properties properties = new Properties();
properties.setProperty("version", this.pluginWrapper.getDescriptor().getVersion());
properties.setProperty("version", this.pluginContext.getVersion());
properties.setProperty("pluginStaticPath", "/plugins/plugin-afdian/assets/static");
return this.PROPERTY_PLACEHOLDER_HELPER.replacePlaceholders("", properties);
}

public CustomHeadProcessor(PluginWrapper pluginWrapper) {
this.pluginWrapper = pluginWrapper;
}
}

0 comments on commit 6dc724c

Please sign in to comment.