Allow customizing companion commands

This commit is contained in:
2026-05-08 21:25:41 +02:00
parent 7209aebc62
commit 30b5e36cd7
11 changed files with 317 additions and 59 deletions
+63
View File
@@ -49,6 +49,17 @@
margin-top: 1.25rem;
}
button:hover { background: var(--primary-hover); }
.btn-small {
padding: 0.4rem 0.75rem;
font-size: 0.8rem;
margin-top: 0;
}
.input-row {
display: flex;
gap: 0.5rem;
align-items: stretch;
}
.input-row input { flex: 1; }
.notice {
background: var(--bg-panel);
border-left: 3px solid var(--secondary);
@@ -58,6 +69,23 @@
.meta { margin-top: 2rem; font-size: 0.8rem; color: var(--text-muted); border-top: 1px dashed var(--secondary); padding-top: 0.75rem; }
.meta div { margin: 0.2rem 0; }
code { color: var(--link); word-break: break-all; }
.log {
margin-top: 2rem;
border-top: 1px dashed var(--secondary);
padding-top: 0.75rem;
}
.log h2 { font-size: 0.95rem; margin: 0 0 0.5rem; }
.log pre {
background: var(--bg-panel);
border: 1px solid var(--secondary);
margin: 0;
padding: 0.5rem 0.75rem;
max-height: 20rem;
overflow: auto;
font-size: 0.8rem;
white-space: pre-wrap;
word-break: break-all;
}
</style>
</head>
<body>
@@ -78,13 +106,48 @@
<textarea id="allowedOrigins" name="allowedOrigins" placeholder="https://wiki.example.lan&#10;http://192.168.1.10:8080">{{.AllowedOrigins}}</textarea>
<div class="help">One origin per line (scheme + host + optional port, no trailing slash). Only browser tabs from these origins can ask the companion to open files.</div>
<label for="openFileCommand">Open-file command</label>
<div class="input-row">
<input id="openFileCommand" name="openFileCommand" type="text" value="{{.OpenFileCommand}}" placeholder="{{.DefaultOpenFileCommand}}">
<button type="button" class="btn-small" data-reset="openFileCommand" data-default="{{.DefaultOpenFileCommand}}">RESET</button>
</div>
<div class="help">Run when the wiki asks to open a file. Use <code>{{`{path}`}}</code> for the resolved file path. Leave blank to use the default. Default: <code>{{.DefaultOpenFileCommand}}</code></div>
<label for="openFolderCommand">Open-folder command</label>
<div class="input-row">
<input id="openFolderCommand" name="openFolderCommand" type="text" value="{{.OpenFolderCommand}}" placeholder="{{.DefaultOpenFolderCommand}}">
<button type="button" class="btn-small" data-reset="openFolderCommand" data-default="{{.DefaultOpenFolderCommand}}">RESET</button>
</div>
<div class="help">Run when the wiki asks to reveal a folder. Default: <code>{{.DefaultOpenFolderCommand}}</code></div>
<button type="submit">SAVE</button>
</form>
<script>
document.querySelectorAll('button[data-reset]').forEach(function (btn) {
btn.addEventListener('click', function () {
var input = document.getElementById(btn.dataset.reset);
if (input) input.value = btn.dataset.default;
});
});
</script>
<div class="meta">
<div>Config file: <code>{{.ConfigPath}}</code></div>
<div>Log file: <code>{{.LogPath}}</code></div>
<div>Port is set in the config file only; restart after editing.</div>
</div>
<div class="log">
<h2>Log (last 50 lines)</h2>
{{if .LogError}}
<div class="muted">Could not read log: {{.LogError}}</div>
{{else if .LogTail}}
<pre>{{.LogTail}}</pre>
{{else}}
<div class="muted">Log is empty.</div>
{{end}}
</div>
</main>
</body>
</html>