From 7b6d4d4dbf4c03cf371ff721fc635aa5834f2462 Mon Sep 17 00:00:00 2001 From: crschnick Date: Sat, 15 Jun 2024 13:52:48 +0000 Subject: [PATCH] Fixes [stage] --- .../io/xpipe/app/beacon/AppBeaconServer.java | 5 ++-- .../io/xpipe/app/comp/base/MarkdownComp.java | 2 +- .../java/io/xpipe/app/core/mode/BaseMode.java | 1 - .../io/xpipe/app/core/mode/OperationMode.java | 3 ++ .../java/io/xpipe/app/prefs/AppPrefs.java | 6 ++-- .../io/xpipe/app/util/MarkdownHelper.java | 4 +-- .../resources/misc/github-markdown-dark.css | 9 ++++++ .../resources/misc/github-markdown-light.css | 9 ++++++ .../service/AbstractServiceStoreProvider.java | 2 +- .../base/service/CustomServiceGroupStore.java | 16 ++++++++++ ...a => CustomServiceGroupStoreProvider.java} | 10 +++---- .../ext/base/service/ServiceGroupStore.java | 29 ------------------- ext/base/src/main/java/module-info.java | 3 +- lang/base/strings/translations_en.properties | 6 ++-- version | 2 +- 15 files changed, 58 insertions(+), 49 deletions(-) create mode 100644 ext/base/src/main/java/io/xpipe/ext/base/service/CustomServiceGroupStore.java rename ext/base/src/main/java/io/xpipe/ext/base/service/{ServiceGroupStoreProvider.java => CustomServiceGroupStoreProvider.java} (59%) delete mode 100644 ext/base/src/main/java/io/xpipe/ext/base/service/ServiceGroupStore.java diff --git a/app/src/main/java/io/xpipe/app/beacon/AppBeaconServer.java b/app/src/main/java/io/xpipe/app/beacon/AppBeaconServer.java index 2809e023a..57cf25d6b 100644 --- a/app/src/main/java/io/xpipe/app/beacon/AppBeaconServer.java +++ b/app/src/main/java/io/xpipe/app/beacon/AppBeaconServer.java @@ -45,7 +45,7 @@ public class AppBeaconServer { private String notFoundHtml; private final Map resources = new HashMap<>(); - static { + public static void setupPort() { int port; boolean propertyPort; if (System.getProperty(BeaconConfig.BEACON_PORT_PROP) != null) { @@ -170,7 +170,8 @@ public class AppBeaconServer { }, s -> { return "
" + s + "
"; - }); + }, + "standalone"); }); } var body = notFoundHtml.getBytes(StandardCharsets.UTF_8); diff --git a/app/src/main/java/io/xpipe/app/comp/base/MarkdownComp.java b/app/src/main/java/io/xpipe/app/comp/base/MarkdownComp.java index 83e6ac940..dcbe66b02 100644 --- a/app/src/main/java/io/xpipe/app/comp/base/MarkdownComp.java +++ b/app/src/main/java/io/xpipe/app/comp/base/MarkdownComp.java @@ -42,7 +42,7 @@ public class MarkdownComp extends Comp> { } private String getHtml() { - return MarkdownHelper.toHtml(markdown.getValue(), s -> s, htmlTransformation); + return MarkdownHelper.toHtml(markdown.getValue(), s -> s, htmlTransformation, null); } @SneakyThrows diff --git a/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java b/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java index 63f840d94..694efd1c1 100644 --- a/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java +++ b/app/src/main/java/io/xpipe/app/core/mode/BaseMode.java @@ -51,7 +51,6 @@ public class BaseMode extends OperationMode { LocalShell.init(); AppShellCheck.check(); XPipeDistributionType.init(); - AppPrefs.setDefaults(); // Initialize beacon server as we should be prepared for git askpass commands AppBeaconServer.init(); GitStorageHandler.getInstance().init(); diff --git a/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java b/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java index 1b373c615..eee4c3a7d 100644 --- a/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java +++ b/app/src/main/java/io/xpipe/app/core/mode/OperationMode.java @@ -1,5 +1,6 @@ package io.xpipe.app.core.mode; +import io.xpipe.app.beacon.AppBeaconServer; import io.xpipe.app.core.*; import io.xpipe.app.core.check.AppDebugModeCheck; import io.xpipe.app.core.check.AppTempCheck; @@ -113,6 +114,8 @@ public abstract class OperationMode { AppExtensionManager.init(true); AppI18n.init(); AppPrefs.initLocal(); + AppPrefs.setLocalDefaultsIfNeeded(); + AppBeaconServer.setupPort(); TrackEvent.info("Finished initial setup"); } catch (Throwable ex) { ErrorEvent.fromThrowable(ex).term().handle(); diff --git a/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java b/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java index d746ad2f1..41d1d932d 100644 --- a/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java +++ b/app/src/main/java/io/xpipe/app/prefs/AppPrefs.java @@ -122,12 +122,12 @@ public class AppPrefs { private final StringProperty lockCrypt = mapVaultSpecific(new SimpleStringProperty(), "workspaceLock", String.class); - final Property httpServerPort = mapVaultSpecific( + final Property httpServerPort = map( new SimpleObjectProperty<>(XPipeInstallation.getDefaultBeaconPort()), "httpServerPort", Integer.class); final StringProperty apiKey = mapVaultSpecific(new SimpleStringProperty(UUID.randomUUID().toString()), "apiKey", String.class); final BooleanProperty disableApiAuthentication = - mapVaultSpecific(new SimpleBooleanProperty(false), "disableApiAuthentication", Boolean.class); + map(new SimpleBooleanProperty(false), "disableApiAuthentication", Boolean.class); public ObservableValue httpServerPort() { return httpServerPort; @@ -204,7 +204,7 @@ public class AppPrefs { }); } - public static void setDefaults() { + public static void setLocalDefaultsIfNeeded() { INSTANCE.initDefaultValues(); PrefsProvider.getAll().forEach(prov -> prov.initDefaultValues()); } diff --git a/app/src/main/java/io/xpipe/app/util/MarkdownHelper.java b/app/src/main/java/io/xpipe/app/util/MarkdownHelper.java index 5dc8ad378..2d16cac55 100644 --- a/app/src/main/java/io/xpipe/app/util/MarkdownHelper.java +++ b/app/src/main/java/io/xpipe/app/util/MarkdownHelper.java @@ -19,7 +19,7 @@ import java.util.function.UnaryOperator; public class MarkdownHelper { public static String toHtml( - String value, UnaryOperator headTransformation, UnaryOperator bodyTransformation) { + String value, UnaryOperator headTransformation, UnaryOperator bodyTransformation, String bodyStyleClass) { MutableDataSet options = new MutableDataSet() .set( Parser.EXTENSIONS, @@ -47,7 +47,7 @@ public class MarkdownHelper { var html = renderer.render(document); var result = bodyTransformation.apply(html); var headContent = headTransformation.apply(""); - return "" + headContent + "
" + result + return "" + headContent + "
" + result + "
"; } } diff --git a/app/src/main/resources/io/xpipe/app/resources/misc/github-markdown-dark.css b/app/src/main/resources/io/xpipe/app/resources/misc/github-markdown-dark.css index 4fe441894..0c93153a8 100644 --- a/app/src/main/resources/io/xpipe/app/resources/misc/github-markdown-dark.css +++ b/app/src/main/resources/io/xpipe/app/resources/misc/github-markdown-dark.css @@ -2,6 +2,15 @@ html { font-family: Roboto; } +body { + margin: 0; + padding: 0; +} + +body.standalone { + background-color: #0d1117; +} + .markdown-body { color-scheme: dark; -ms-text-size-adjust: 100%; diff --git a/app/src/main/resources/io/xpipe/app/resources/misc/github-markdown-light.css b/app/src/main/resources/io/xpipe/app/resources/misc/github-markdown-light.css index c69cdde9c..c5c9edf0e 100644 --- a/app/src/main/resources/io/xpipe/app/resources/misc/github-markdown-light.css +++ b/app/src/main/resources/io/xpipe/app/resources/misc/github-markdown-light.css @@ -3,6 +3,15 @@ html { font-family: Roboto; } +body { + margin: 0; + padding: 0; +} + +body.standalone { + background-color: #ffffff; +} + .markdown-body { -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; diff --git a/ext/base/src/main/java/io/xpipe/ext/base/service/AbstractServiceStoreProvider.java b/ext/base/src/main/java/io/xpipe/ext/base/service/AbstractServiceStoreProvider.java index 6c2577785..979f0875a 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/service/AbstractServiceStoreProvider.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/service/AbstractServiceStoreProvider.java @@ -39,7 +39,7 @@ public abstract class AbstractServiceStoreProvider implements SingletonSessionSt .getOrCreateNewSyntheticEntry( s.getHost().get(), "Services", - ServiceGroupStore.builder().parent(s.getHost()).build()); + CustomServiceGroupStore.builder().parent(s.getHost()).build()); } @Override diff --git a/ext/base/src/main/java/io/xpipe/ext/base/service/CustomServiceGroupStore.java b/ext/base/src/main/java/io/xpipe/ext/base/service/CustomServiceGroupStore.java new file mode 100644 index 000000000..1436df3ae --- /dev/null +++ b/ext/base/src/main/java/io/xpipe/ext/base/service/CustomServiceGroupStore.java @@ -0,0 +1,16 @@ +package io.xpipe.ext.base.service; + +import com.fasterxml.jackson.annotation.JsonTypeName; +import io.xpipe.core.store.NetworkTunnelStore; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.experimental.FieldDefaults; +import lombok.experimental.SuperBuilder; +import lombok.extern.jackson.Jacksonized; + +@Getter +@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) +@SuperBuilder +@Jacksonized +@JsonTypeName("customServiceGroup") +public class CustomServiceGroupStore extends AbstractServiceGroupStore {} diff --git a/ext/base/src/main/java/io/xpipe/ext/base/service/ServiceGroupStoreProvider.java b/ext/base/src/main/java/io/xpipe/ext/base/service/CustomServiceGroupStoreProvider.java similarity index 59% rename from ext/base/src/main/java/io/xpipe/ext/base/service/ServiceGroupStoreProvider.java rename to ext/base/src/main/java/io/xpipe/ext/base/service/CustomServiceGroupStoreProvider.java index c6df32da1..b52ee75e5 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/service/ServiceGroupStoreProvider.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/service/CustomServiceGroupStoreProvider.java @@ -5,26 +5,26 @@ import io.xpipe.core.store.DataStore; import java.util.List; -public class ServiceGroupStoreProvider extends AbstractServiceGroupStoreProvider { +public class CustomServiceGroupStoreProvider extends AbstractServiceGroupStoreProvider { @Override public DataStore defaultStore() { - return ServiceGroupStore.builder().build(); + return CustomServiceGroupStore.builder().build(); } @Override public DataStoreEntry getDisplayParent(DataStoreEntry store) { - ServiceGroupStore s = store.getStore().asNeeded(); + CustomServiceGroupStore s = store.getStore().asNeeded(); return s.getParent().get(); } @Override public List getPossibleNames() { - return List.of("serviceGroup"); + return List.of("customServiceGroup"); } @Override public List> getStoreClasses() { - return List.of(ServiceGroupStore.class); + return List.of(CustomServiceGroupStore.class); } } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/service/ServiceGroupStore.java b/ext/base/src/main/java/io/xpipe/ext/base/service/ServiceGroupStore.java deleted file mode 100644 index 6b244f283..000000000 --- a/ext/base/src/main/java/io/xpipe/ext/base/service/ServiceGroupStore.java +++ /dev/null @@ -1,29 +0,0 @@ -package io.xpipe.ext.base.service; - -import io.xpipe.app.storage.DataStoreEntryRef; -import io.xpipe.app.util.Validators; -import io.xpipe.core.store.DataStore; -import io.xpipe.core.util.JacksonizedValue; -import io.xpipe.ext.base.GroupStore; - -import com.fasterxml.jackson.annotation.JsonTypeName; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.experimental.FieldDefaults; -import lombok.experimental.SuperBuilder; -import lombok.extern.jackson.Jacksonized; - -@Getter -@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) -@SuperBuilder -@Jacksonized -@JsonTypeName("serviceGroup") -public class ServiceGroupStore extends JacksonizedValue implements DataStore, GroupStore { - - DataStoreEntryRef parent; - - @Override - public void checkComplete() throws Throwable { - Validators.nonNull(parent); - } -} diff --git a/ext/base/src/main/java/module-info.java b/ext/base/src/main/java/module-info.java index 64ffe6cb5..6123c6a09 100644 --- a/ext/base/src/main/java/module-info.java +++ b/ext/base/src/main/java/module-info.java @@ -71,8 +71,7 @@ open module io.xpipe.ext.base { BrowseStoreAction, ScanStoreAction; provides DataStoreProvider with - FixedServiceGroupStoreProvider, - ServiceGroupStoreProvider, + FixedServiceGroupStoreProvider, CustomServiceGroupStoreProvider, CustomServiceStoreProvider, MappedServiceStoreProvider, FixedServiceStoreProvider, diff --git a/lang/base/strings/translations_en.properties b/lang/base/strings/translations_en.properties index 2c3fbfc63..7089c151b 100644 --- a/lang/base/strings/translations_en.properties +++ b/lang/base/strings/translations_en.properties @@ -141,8 +141,8 @@ serviceRemotePortDescription=The port on which the service is running on serviceHost=Service host serviceHostDescription=The host the service is running on openWebsite=Open website -serviceGroup.displayName=Service group -serviceGroup.displayDescription=Group multiple services into one category +customServiceGroup.displayName=Service group +customServiceGroup.displayDescription=Group multiple services into one category initScript=Run on shell init shellScript=Make script available during shell session fileScript=Allow script to be called with file arguments in the file browser @@ -152,5 +152,7 @@ fixedServiceGroup.displayName=Service group fixedServiceGroup.displayDescription=List the available services on a system mappedService.displayName=Service mappedService.displayDescription=Interact with a service exposed by a container +customService.displayName=Service +customService.displayDescription=Add a custom service to tunnel and open diff --git a/version b/version index a3a9b449c..322f1c737 100644 --- a/version +++ b/version @@ -1 +1 @@ -10.0-1 +10.0-2