Skip to content

Commit

Permalink
移除对已过时的 PluginWrapper 的引用
Browse files Browse the repository at this point in the history
  • Loading branch information
chengzhongxue committed Jul 2, 2024
1 parent e0e7d21 commit 542f326
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/main/java/la/moony/douban/ContactDoubanWidget.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package la.moony.douban;

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
public class ContactDoubanWidget implements TemplateHeadProcessor {
private final PropertyPlaceholderHelper
PROPERTY_PLACEHOLDER_HELPER = new PropertyPlaceholderHelper("${", "}");
private final PluginWrapper pluginWrapper;
private final PluginContext pluginContext;

public Mono<Void> process(ITemplateContext context, IModel model, IElementModelStructureHandler structureHandler) {
return Mono.just(this.contactFormHtml()).doOnNext((html) -> {
Expand All @@ -26,14 +26,14 @@ public Mono<Void> process(ITemplateContext context, IModel model, IElementModelS

private String contactFormHtml() {
Properties properties = new Properties();
properties.setProperty("version", this.pluginWrapper.getDescriptor().getVersion());
properties.setProperty("version", pluginContext.getVersion());
properties.setProperty("pluginStaticPath", "/plugins/plugin-douban/assets/static");
return this.PROPERTY_PLACEHOLDER_HELPER.replacePlaceholders(
"<link href=\"${pluginStaticPath}/style.css?version=${version}\" rel=\"stylesheet\"/>\n "
+ "<script src=\"${pluginStaticPath}/contact-douban.iife.js?version=${version}\"></script>\n ", properties);
}

public ContactDoubanWidget(PluginWrapper pluginWrapper) {
this.pluginWrapper = pluginWrapper;
public ContactDoubanWidget(PluginContext pluginContext) {
this.pluginContext = pluginContext;
}
}

0 comments on commit 542f326

Please sign in to comment.