Fixes [stage]

This commit is contained in:
crschnick 2024-06-15 13:52:48 +00:00
parent 368612b70f
commit 7b6d4d4dbf
15 changed files with 58 additions and 49 deletions

View file

@ -45,7 +45,7 @@ public class AppBeaconServer {
private String notFoundHtml; private String notFoundHtml;
private final Map<String, String> resources = new HashMap<>(); private final Map<String, String> resources = new HashMap<>();
static { public static void setupPort() {
int port; int port;
boolean propertyPort; boolean propertyPort;
if (System.getProperty(BeaconConfig.BEACON_PORT_PROP) != null) { if (System.getProperty(BeaconConfig.BEACON_PORT_PROP) != null) {
@ -170,7 +170,8 @@ public class AppBeaconServer {
}, },
s -> { s -> {
return "<div style=\"max-width: 800px;margin: auto;\">" + s + "</div>"; return "<div style=\"max-width: 800px;margin: auto;\">" + s + "</div>";
}); },
"standalone");
}); });
} }
var body = notFoundHtml.getBytes(StandardCharsets.UTF_8); var body = notFoundHtml.getBytes(StandardCharsets.UTF_8);

View file

@ -42,7 +42,7 @@ public class MarkdownComp extends Comp<CompStructure<StackPane>> {
} }
private String getHtml() { private String getHtml() {
return MarkdownHelper.toHtml(markdown.getValue(), s -> s, htmlTransformation); return MarkdownHelper.toHtml(markdown.getValue(), s -> s, htmlTransformation, null);
} }
@SneakyThrows @SneakyThrows

View file

@ -51,7 +51,6 @@ public class BaseMode extends OperationMode {
LocalShell.init(); LocalShell.init();
AppShellCheck.check(); AppShellCheck.check();
XPipeDistributionType.init(); XPipeDistributionType.init();
AppPrefs.setDefaults();
// Initialize beacon server as we should be prepared for git askpass commands // Initialize beacon server as we should be prepared for git askpass commands
AppBeaconServer.init(); AppBeaconServer.init();
GitStorageHandler.getInstance().init(); GitStorageHandler.getInstance().init();

View file

@ -1,5 +1,6 @@
package io.xpipe.app.core.mode; package io.xpipe.app.core.mode;
import io.xpipe.app.beacon.AppBeaconServer;
import io.xpipe.app.core.*; import io.xpipe.app.core.*;
import io.xpipe.app.core.check.AppDebugModeCheck; import io.xpipe.app.core.check.AppDebugModeCheck;
import io.xpipe.app.core.check.AppTempCheck; import io.xpipe.app.core.check.AppTempCheck;
@ -113,6 +114,8 @@ public abstract class OperationMode {
AppExtensionManager.init(true); AppExtensionManager.init(true);
AppI18n.init(); AppI18n.init();
AppPrefs.initLocal(); AppPrefs.initLocal();
AppPrefs.setLocalDefaultsIfNeeded();
AppBeaconServer.setupPort();
TrackEvent.info("Finished initial setup"); TrackEvent.info("Finished initial setup");
} catch (Throwable ex) { } catch (Throwable ex) {
ErrorEvent.fromThrowable(ex).term().handle(); ErrorEvent.fromThrowable(ex).term().handle();

View file

@ -122,12 +122,12 @@ public class AppPrefs {
private final StringProperty lockCrypt = private final StringProperty lockCrypt =
mapVaultSpecific(new SimpleStringProperty(), "workspaceLock", String.class); mapVaultSpecific(new SimpleStringProperty(), "workspaceLock", String.class);
final Property<Integer> httpServerPort = mapVaultSpecific( final Property<Integer> httpServerPort = map(
new SimpleObjectProperty<>(XPipeInstallation.getDefaultBeaconPort()), "httpServerPort", Integer.class); new SimpleObjectProperty<>(XPipeInstallation.getDefaultBeaconPort()), "httpServerPort", Integer.class);
final StringProperty apiKey = final StringProperty apiKey =
mapVaultSpecific(new SimpleStringProperty(UUID.randomUUID().toString()), "apiKey", String.class); mapVaultSpecific(new SimpleStringProperty(UUID.randomUUID().toString()), "apiKey", String.class);
final BooleanProperty disableApiAuthentication = final BooleanProperty disableApiAuthentication =
mapVaultSpecific(new SimpleBooleanProperty(false), "disableApiAuthentication", Boolean.class); map(new SimpleBooleanProperty(false), "disableApiAuthentication", Boolean.class);
public ObservableValue<Integer> httpServerPort() { public ObservableValue<Integer> httpServerPort() {
return httpServerPort; return httpServerPort;
@ -204,7 +204,7 @@ public class AppPrefs {
}); });
} }
public static void setDefaults() { public static void setLocalDefaultsIfNeeded() {
INSTANCE.initDefaultValues(); INSTANCE.initDefaultValues();
PrefsProvider.getAll().forEach(prov -> prov.initDefaultValues()); PrefsProvider.getAll().forEach(prov -> prov.initDefaultValues());
} }

View file

@ -19,7 +19,7 @@ import java.util.function.UnaryOperator;
public class MarkdownHelper { public class MarkdownHelper {
public static String toHtml( public static String toHtml(
String value, UnaryOperator<String> headTransformation, UnaryOperator<String> bodyTransformation) { String value, UnaryOperator<String> headTransformation, UnaryOperator<String> bodyTransformation, String bodyStyleClass) {
MutableDataSet options = new MutableDataSet() MutableDataSet options = new MutableDataSet()
.set( .set(
Parser.EXTENSIONS, Parser.EXTENSIONS,
@ -47,7 +47,7 @@ public class MarkdownHelper {
var html = renderer.render(document); var html = renderer.render(document);
var result = bodyTransformation.apply(html); var result = bodyTransformation.apply(html);
var headContent = headTransformation.apply("<meta charset=\"utf-8\"/>"); var headContent = headTransformation.apply("<meta charset=\"utf-8\"/>");
return "<html><head>" + headContent + "</head><body><article class=\"markdown-body\">" + result return "<html><head>" + headContent + "</head><body" + (bodyStyleClass != null ? " class=\"" + bodyStyleClass + "\"" : "") + "><article class=\"markdown-body\">" + result
+ "</article></body></html>"; + "</article></body></html>";
} }
} }

View file

@ -2,6 +2,15 @@ html {
font-family: Roboto; font-family: Roboto;
} }
body {
margin: 0;
padding: 0;
}
body.standalone {
background-color: #0d1117;
}
.markdown-body { .markdown-body {
color-scheme: dark; color-scheme: dark;
-ms-text-size-adjust: 100%; -ms-text-size-adjust: 100%;

View file

@ -3,6 +3,15 @@ html {
font-family: Roboto; font-family: Roboto;
} }
body {
margin: 0;
padding: 0;
}
body.standalone {
background-color: #ffffff;
}
.markdown-body { .markdown-body {
-ms-text-size-adjust: 100%; -ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;

View file

@ -39,7 +39,7 @@ public abstract class AbstractServiceStoreProvider implements SingletonSessionSt
.getOrCreateNewSyntheticEntry( .getOrCreateNewSyntheticEntry(
s.getHost().get(), s.getHost().get(),
"Services", "Services",
ServiceGroupStore.builder().parent(s.getHost()).build()); CustomServiceGroupStore.builder().parent(s.getHost()).build());
} }
@Override @Override

View file

@ -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<NetworkTunnelStore> {}

View file

@ -5,26 +5,26 @@ import io.xpipe.core.store.DataStore;
import java.util.List; import java.util.List;
public class ServiceGroupStoreProvider extends AbstractServiceGroupStoreProvider { public class CustomServiceGroupStoreProvider extends AbstractServiceGroupStoreProvider {
@Override @Override
public DataStore defaultStore() { public DataStore defaultStore() {
return ServiceGroupStore.builder().build(); return CustomServiceGroupStore.builder().build();
} }
@Override @Override
public DataStoreEntry getDisplayParent(DataStoreEntry store) { public DataStoreEntry getDisplayParent(DataStoreEntry store) {
ServiceGroupStore s = store.getStore().asNeeded(); CustomServiceGroupStore s = store.getStore().asNeeded();
return s.getParent().get(); return s.getParent().get();
} }
@Override @Override
public List<String> getPossibleNames() { public List<String> getPossibleNames() {
return List.of("serviceGroup"); return List.of("customServiceGroup");
} }
@Override @Override
public List<Class<?>> getStoreClasses() { public List<Class<?>> getStoreClasses() {
return List.of(ServiceGroupStore.class); return List.of(CustomServiceGroupStore.class);
} }
} }

View file

@ -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<DataStore> {
DataStoreEntryRef<? extends DataStore> parent;
@Override
public void checkComplete() throws Throwable {
Validators.nonNull(parent);
}
}

View file

@ -71,8 +71,7 @@ open module io.xpipe.ext.base {
BrowseStoreAction, BrowseStoreAction,
ScanStoreAction; ScanStoreAction;
provides DataStoreProvider with provides DataStoreProvider with
FixedServiceGroupStoreProvider, FixedServiceGroupStoreProvider, CustomServiceGroupStoreProvider,
ServiceGroupStoreProvider,
CustomServiceStoreProvider, CustomServiceStoreProvider,
MappedServiceStoreProvider, MappedServiceStoreProvider,
FixedServiceStoreProvider, FixedServiceStoreProvider,

View file

@ -141,8 +141,8 @@ serviceRemotePortDescription=The port on which the service is running on
serviceHost=Service host serviceHost=Service host
serviceHostDescription=The host the service is running on serviceHostDescription=The host the service is running on
openWebsite=Open website openWebsite=Open website
serviceGroup.displayName=Service group customServiceGroup.displayName=Service group
serviceGroup.displayDescription=Group multiple services into one category customServiceGroup.displayDescription=Group multiple services into one category
initScript=Run on shell init initScript=Run on shell init
shellScript=Make script available during shell session shellScript=Make script available during shell session
fileScript=Allow script to be called with file arguments in the file browser 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 fixedServiceGroup.displayDescription=List the available services on a system
mappedService.displayName=Service mappedService.displayName=Service
mappedService.displayDescription=Interact with a service exposed by a container mappedService.displayDescription=Interact with a service exposed by a container
customService.displayName=Service
customService.displayDescription=Add a custom service to tunnel and open

View file

@ -1 +1 @@
10.0-1 10.0-2