1
1
package run .halo .comment .widget ;
2
2
3
+ import java .util .Properties ;
3
4
import lombok .RequiredArgsConstructor ;
4
- import org .pf4j .PluginWrapper ;
5
5
import org .springframework .stereotype .Component ;
6
6
import org .springframework .util .PropertyPlaceholderHelper ;
7
7
import org .thymeleaf .context .ITemplateContext ;
8
8
import org .thymeleaf .model .IModel ;
9
9
import org .thymeleaf .model .IModelFactory ;
10
10
import org .thymeleaf .processor .element .IElementModelStructureHandler ;
11
11
import reactor .core .publisher .Mono ;
12
+ import run .halo .app .plugin .PluginContext ;
12
13
import run .halo .app .theme .dialect .TemplateHeadProcessor ;
13
14
14
- import java .util .Properties ;
15
-
16
15
@ Component
17
16
@ RequiredArgsConstructor
18
17
public class CommentWidgetHeadProcessor implements TemplateHeadProcessor {
19
18
20
19
static final PropertyPlaceholderHelper PROPERTY_PLACEHOLDER_HELPER = new PropertyPlaceholderHelper ("${" , "}" );
21
20
22
- private final PluginWrapper pluginWrapper ;
21
+ private final PluginContext pluginContext ;
23
22
24
23
@ Override
25
24
public Mono <Void > process (ITemplateContext context , IModel model ,
@@ -32,13 +31,13 @@ public Mono<Void> process(ITemplateContext context, IModel model,
32
31
private String commentWidgetScript () {
33
32
34
33
final Properties properties = new Properties ();
35
- properties .setProperty ("version" , pluginWrapper . getDescriptor () .getVersion ());
34
+ properties .setProperty ("version" , pluginContext .getVersion ());
36
35
37
36
return PROPERTY_PLACEHOLDER_HELPER .replacePlaceholders ("""
38
- <!-- plugin-comment-widget start -->
39
- <script src="/plugins/PluginCommentWidget/assets/static/comment-widget.iife.js?version=${version}"></script>
40
- <link rel="stylesheet" href="/plugins/PluginCommentWidget/assets/static/style.css?version=${version}" />
41
- <!-- plugin-comment-widget end -->
42
- """ , properties );
37
+ <!-- plugin-comment-widget start -->
38
+ <script src="/plugins/PluginCommentWidget/assets/static/comment-widget.iife.js?version=${version}"></script>
39
+ <link rel="stylesheet" href="/plugins/PluginCommentWidget/assets/static/style.css?version=${version}" />
40
+ <!-- plugin-comment-widget end -->
41
+ """ , properties );
43
42
}
44
43
}
0 commit comments