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 final Map<String, String> 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 "<div style=\"max-width: 800px;margin: auto;\">" + s + "</div>";
});
},
"standalone");
});
}
var body = notFoundHtml.getBytes(StandardCharsets.UTF_8);

View file

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

View file

@ -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();

View file

@ -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();

View file

@ -122,12 +122,12 @@ public class AppPrefs {
private final StringProperty lockCrypt =
mapVaultSpecific(new SimpleStringProperty(), "workspaceLock", String.class);
final Property<Integer> httpServerPort = mapVaultSpecific(
final Property<Integer> 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<Integer> 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());
}

View file

@ -19,7 +19,7 @@ import java.util.function.UnaryOperator;
public class MarkdownHelper {
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()
.set(
Parser.EXTENSIONS,
@ -47,7 +47,7 @@ public class MarkdownHelper {
var html = renderer.render(document);
var result = bodyTransformation.apply(html);
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>";
}
}

View file

@ -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%;

View file

@ -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%;

View file

@ -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

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;
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<String> getPossibleNames() {
return List.of("serviceGroup");
return List.of("customServiceGroup");
}
@Override
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,
ScanStoreAction;
provides DataStoreProvider with
FixedServiceGroupStoreProvider,
ServiceGroupStoreProvider,
FixedServiceGroupStoreProvider, CustomServiceGroupStoreProvider,
CustomServiceStoreProvider,
MappedServiceStoreProvider,
FixedServiceStoreProvider,

View file

@ -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

View file

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