Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into feat/support-search…
Browse files Browse the repository at this point in the history
…-view
  • Loading branch information
JohnNiang committed Jul 3, 2024
2 parents 56e7a7b + ead248b commit 5688b34
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 146 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CD

on:
release:
types:
- published

jobs:
cd:
uses: halo-sigs/reusable-workflows/.github/workflows/plugin-cd.yaml@v1
secrets:
halo-username: ${{ secrets.HALO_USERNAME }}
halo-password: ${{ secrets.HALO_PASSWORD }}
permissions:
contents: write
with:
app-id: app-DlacW
ui-path: "."
15 changes: 15 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
ci:
uses: halo-sigs/reusable-workflows/.github/workflows/plugin-ci.yaml@v1
with:
ui-path: "."
128 changes: 0 additions & 128 deletions .github/workflows/workflow.yaml

This file was deleted.

19 changes: 14 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,24 @@ node {
nodeProjectDir = file("${project.projectDir}")
}

task buildFrontend(type: PnpmTask) {
tasks.register('installDepsForUI', PnpmTask) {
args = ['install']
}

tasks.register('buildFrontend', PnpmTask) {
args = ['build:packages']
dependsOn('installDepsForUI')
}

build {
// build frontend before build
tasks.getByName('compileJava').dependsOn('buildFrontend')
tasks.named('build').configure {
dependsOn('buildFrontend')
}

halo {
<<<<<<< HEAD
version = "2.17.0"
}
}
=======
version = "2.12.0"
}
>>>>>>> upstream/main
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

0 comments on commit 5688b34

Please sign in to comment.