Skip to content

Commit 73cd042

Browse files
committed
'xterm fixes for uxcandy'
1 parent a1156e9 commit 73cd042

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

plugins/xterm/api.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,25 @@
33
require_once __DIR__."/../../server/api.php";
44

55
FileApi::extend('xterm_open',function($self) {
6+
67
$path = $self->_pathFromUrl(@$_REQUEST['path']);
78
if (!$path) { echo "ERROR: Invalid path"; die(); }
89

910
$reflection = new \ReflectionClass(get_class($self));
1011
$apiFile = $reflection->getFileName();
11-
exec("/usr/bin/php ".__DIR__."/server.php ".escapeshellarg($apiFile));
12-
$port = file_get_contents(__DIR__."/cache/".get_current_user().".port");
12+
$serverStartOutput = shell_exec("/usr/bin/php ".__DIR__."/server.php ".escapeshellarg($apiFile));
13+
14+
$current_user = posix_getpwuid(posix_getuid())['name'];
15+
$port = file_get_contents(__DIR__."/cache/".$current_user.".port");
16+
17+
$plugin_root = !empty($_REQUEST['dayside_url']) ? $_REQUEST['dayside_url']."/plugins/xterm/" : "";
1318

1419
?>
1520
<!doctype html>
1621
<html>
1722
<head>
18-
<link rel="stylesheet" href="assets/xterm.css" />
19-
<script src="assets/xterm.js"></script>
23+
<link rel="stylesheet" href="<?=$plugin_root?>assets/xterm.css" />
24+
<script src="<?=$plugin_root?>assets/xterm.js"></script>
2025
<style>
2126
* { margin: 0; padding: 0; box-sizing: border-box; }
2227
html, body, #terminal { width: 100%; height: 100%; background: #000; }
@@ -26,6 +31,8 @@
2631
<body>
2732
<div id="terminal" />
2833
<script>
34+
console.debug(<?=json_encode($serverStartOutput)?>);
35+
2936
var terminal = new Terminal({cols:130,rows:50});
3037
var terminalEl = document.getElementById('terminal');
3138
terminal.open(terminalEl);

plugins/xterm/server.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ static function createWorker() {
133133
$connection->process = null;
134134

135135
if (count($worker->connections)==1) {
136+
echo "dying since last...\n";
136137
\posix_kill(\file_get_contents(static::$pidFile), \SIGINT);
137138
}
138139
}
@@ -147,8 +148,9 @@ static function createWorker() {
147148
}
148149
}
149150

150-
Worker::$pidFile = __DIR__."/cache/".get_current_user().".pid";
151-
Worker::$portFile = __DIR__."/cache/".get_current_user().".port";
152-
Worker::$logFile = __DIR__."/cache/".get_current_user().".log";
151+
$current_user = posix_getpwuid(posix_getuid())['name'];
152+
Worker::$pidFile = __DIR__."/cache/".$current_user.".pid";
153+
Worker::$portFile = __DIR__."/cache/".$current_user.".port";
154+
Worker::$logFile = __DIR__."/cache/".$current_user.".log";
153155
Worker::createWorker();
154156
Worker::runAll();

plugins/xterm/xterm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dayside.plugins.xterm = () => dayside.ready(()=>{
2525
consoleTab.tabPanel.selectTab(consoleTab);
2626

2727
frame[0].path = path;
28-
FileApi.request('xterm_open', {_type:"xterm_open",path:path}, false, function(answer) {
28+
FileApi.request('xterm_open', {_type:"xterm_open",path:path,dayside_url:dayside.url}, false, function(answer) {
2929
frame[0].contentDocument.open();
3030
frame[0].contentDocument.write(answer.data);
3131
frame[0].contentDocument.close();

0 commit comments

Comments
 (0)