Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ruibaby authored Dec 6, 2024
2 parents 34ca42c + 348e7c9 commit 0f9f25a
Show file tree
Hide file tree
Showing 375 changed files with 1,153 additions and 885 deletions.
2 changes: 1 addition & 1 deletion api-docs/openapi/v3_0/aggregated.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"openapi": "3.0.1",
"info": {
"title": "Halo",
"version": "2.20.10-SNAPSHOT"
"version": "2.20.11-SNAPSHOT"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion api-docs/openapi/v3_0/apis_console.api_v1alpha1.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"openapi": "3.0.1",
"info": {
"title": "Halo",
"version": "2.20.10-SNAPSHOT"
"version": "2.20.11-SNAPSHOT"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion api-docs/openapi/v3_0/apis_extension.api_v1alpha1.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"openapi": "3.0.1",
"info": {
"title": "Halo",
"version": "2.20.10-SNAPSHOT"
"version": "2.20.11-SNAPSHOT"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion api-docs/openapi/v3_0/apis_public.api_v1alpha1.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"openapi": "3.0.1",
"info": {
"title": "Halo",
"version": "2.20.10-SNAPSHOT"
"version": "2.20.11-SNAPSHOT"
},
"servers": [
{
Expand Down
2 changes: 1 addition & 1 deletion api-docs/openapi/v3_0/apis_uc.api_v1alpha1.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"openapi": "3.0.1",
"info": {
"title": "Halo",
"version": "2.20.10-SNAPSHOT"
"version": "2.20.11-SNAPSHOT"
},
"servers": [
{
Expand Down
10 changes: 10 additions & 0 deletions api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ java {
withJavadocJar()
}

publishing {
publications.named('mavenJava', MavenPublication) {
from components.java
pom {
name = 'API library'
description = "$project.description"
}
}
}

tasks.named('test') {
useJUnitPlatform()
finalizedBy jacocoTestReport
Expand Down
40 changes: 40 additions & 0 deletions api/src/main/java/run/halo/app/infra/SystemInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package run.halo.app.infra;

import com.github.zafarkhaja.semver.Version;
import java.net.URL;
import java.util.Locale;
import java.util.TimeZone;
import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
public class SystemInfo {
private String title;

private String subtitle;

private String logo;

private String favicon;

private URL url;

private Version version;

private SeoProp seo;

private Locale locale;

private TimeZone timeZone;

private String activatedThemeName;

@Data
@Accessors(chain = true)
public static class SeoProp {
private boolean blockSpiders;
private String keywords;
private String description;
}
}
7 changes: 7 additions & 0 deletions api/src/main/java/run/halo/app/infra/SystemInfoGetter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package run.halo.app.infra;

import java.util.function.Supplier;
import reactor.core.publisher.Mono;

public interface SystemInfoGetter extends Supplier<Mono<SystemInfo>> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public RouterFunction<ServerResponse> endpoint() {
private Mono<ServerResponse> updateConfigByGroup(ServerRequest request) {
final var group = request.pathVariable("group");
return request.bodyToMono(ObjectNode.class)
.flatMap(objectNode -> configurableEnvironmentFetcher.getConfigMap()
.flatMap(objectNode -> configurableEnvironmentFetcher.loadConfigMap()
.flatMap(configMap -> {
var data = configMap.getData();
data.put(group, JsonUtils.objectToJson(objectNode));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.function.Supplier;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.pf4j.PluginDependency;
import org.pf4j.PluginState;
import org.pf4j.PluginWrapper;
import org.pf4j.RuntimeMode;
Expand All @@ -48,6 +47,7 @@
import run.halo.app.extension.ExtensionClient;
import run.halo.app.extension.ExtensionUtil;
import run.halo.app.extension.Metadata;
import run.halo.app.extension.MetadataUtil;
import run.halo.app.extension.Unstructured;
import run.halo.app.extension.controller.Controller;
import run.halo.app.extension.controller.ControllerBuilder;
Expand All @@ -60,8 +60,10 @@
import run.halo.app.infra.utils.PathUtils;
import run.halo.app.infra.utils.SettingUtils;
import run.halo.app.infra.utils.YamlUnstructuredLoader;
import run.halo.app.plugin.OptionalDependentResolver;
import run.halo.app.plugin.PluginConst;
import run.halo.app.plugin.PluginProperties;
import run.halo.app.plugin.PluginService;
import run.halo.app.plugin.SpringPluginManager;

/**
Expand All @@ -85,13 +87,16 @@ public class PluginReconciler implements Reconciler<Request> {

private final PluginProperties pluginProperties;

private final PluginService pluginService;

private Clock clock;

public PluginReconciler(ExtensionClient client, SpringPluginManager pluginManager,
PluginProperties pluginProperties) {
PluginProperties pluginProperties, PluginService pluginService) {
this.client = client;
this.pluginManager = pluginManager;
this.pluginProperties = pluginProperties;
this.pluginService = pluginService;
this.clock = Clock.systemUTC();
}

Expand Down Expand Up @@ -280,18 +285,9 @@ private Result enablePlugin(Plugin plugin) {
status.setPhase(Plugin.Phase.STARTING);

// check if the parent plugin is started
var pw = pluginManager.getPlugin(pluginName);
var unstartedDependencies = pw.getDescriptor().getDependencies()
.stream()
.filter(pd -> {
if (pd.isOptional()) {
return false;
}
var parent = pluginManager.getPlugin(pd.getPluginId());
return parent == null || !PluginState.STARTED.equals(parent.getPluginState());
})
.map(PluginDependency::getPluginId)
.toList();
var unstartedDependencies = pluginService.getRequiredDependencies(plugin, pw ->
pw == null || !PluginState.STARTED.equals(pw.getPluginState())
);
var conditions = status.getConditions();
if (!CollectionUtils.isEmpty(unstartedDependencies)) {
removeConditionBy(conditions, ConditionType.READY);
Expand Down Expand Up @@ -337,9 +333,31 @@ private Result enablePlugin(Plugin plugin) {
status.setPhase(Plugin.Phase.STARTED);

log.info("Started plugin {}", pluginName);

requestToReloadPluginsOptionallyDependentOn(pluginName);

return null;
}

void requestToReloadPluginsOptionallyDependentOn(String pluginName) {
var startedPlugins = pluginManager.getStartedPlugins()
.stream()
.map(PluginWrapper::getDescriptor)
.toList();
var resolver = new OptionalDependentResolver(startedPlugins);
var dependents = resolver.getOptionalDependents(pluginName);
for (String dependentName : dependents) {
client.fetch(Plugin.class, dependentName)
.ifPresent(childPlugin -> {
var annotations = MetadataUtil.nullSafeAnnotations(childPlugin);
// loadLocation never be null for started plugins
annotations.put(RELOAD_ANNO,
childPlugin.getStatus().getLoadLocation().toString());
client.update(childPlugin);
});
}
}

private Result disablePlugin(Plugin plugin) {
var pluginName = plugin.getMetadata().getName();
var status = plugin.getStatus();
Expand Down Expand Up @@ -515,15 +533,9 @@ private Result loadOrReload(Plugin plugin) {
}

// check dependencies before loading
var unresolvedParentPlugins = plugin.getSpec().getPluginDependencies().keySet()
.stream()
.filter(dependency -> {
var parentPlugin = pluginManager.getPlugin(dependency);
return parentPlugin == null
|| pluginManager.getUnresolvedPlugins().contains(parentPlugin);
})
.sorted()
.toList();
var unresolvedParentPlugins = pluginService.getRequiredDependencies(plugin,
pw -> pw == null || pluginManager.getUnresolvedPlugins().contains(pw)
);
if (!unresolvedParentPlugins.isEmpty()) {
// requeue if the parent plugin is not loaded yet.
removeConditionBy(conditions, ConditionType.INITIALIZED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,6 @@ public boolean isSystemSetting(String name) {
}

private Optional<ConfigMap> getConfigMap(String name) {
return environmentFetcher.getConfigMapBlocking();
return environmentFetcher.loadConfigMapBlocking();
}
}
Loading

0 comments on commit 0f9f25a

Please sign in to comment.