Merge pull request #19 from hcvcastro/master
Application config, set default port 9980
This commit is contained in:
commit
c675eccee9
@ -103,38 +103,47 @@ class DocumentController extends Controller{
|
|||||||
\OC::$server->getNavigationManager()->setActiveEntry( 'richdocuments_index' );
|
\OC::$server->getNavigationManager()->setActiveEntry( 'richdocuments_index' );
|
||||||
$maxUploadFilesize = \OCP\Util::maxUploadFilesize("/");
|
$maxUploadFilesize = \OCP\Util::maxUploadFilesize("/");
|
||||||
$wopiRemote = $this->settings->getAppValue('richdocuments', 'wopi_url');
|
$wopiRemote = $this->settings->getAppValue('richdocuments', 'wopi_url');
|
||||||
|
if (($parts = parse_url($wopiRemote))) {
|
||||||
|
// Provides access to information about the capabilities of a WOPI client
|
||||||
|
// and the mechanisms for invoking those abilities through URIs.
|
||||||
|
// HTTP://server/hosting/discovery
|
||||||
|
$wopiDiscovery = sprintf(
|
||||||
|
"%s%s%s%s",
|
||||||
|
isset($parts['scheme']) ? $parts['scheme'] . "://" : '',
|
||||||
|
isset($parts['host']) ? $parts['host'] : "",
|
||||||
|
isset($parts['port']) ? ":" . $parts['port'] : "",
|
||||||
|
"/hosting/discovery" );
|
||||||
|
$webSocket = sprintf(
|
||||||
|
"%s%s%s",
|
||||||
|
"ws://",
|
||||||
|
isset($parts['host']) ? $parts['host'] : "",
|
||||||
|
isset($parts['port']) ? ":" . $parts['port'] : "");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$wopiRemote = null;
|
||||||
|
}
|
||||||
|
|
||||||
$response = new TemplateResponse('richdocuments', 'documents', [
|
$response = new TemplateResponse('richdocuments', 'documents', [
|
||||||
'enable_previews' => $this->settings->getSystemValue('enable_previews', true),
|
'enable_previews' => $this->settings->getSystemValue('enable_previews', true),
|
||||||
'savePath' => $this->settings->getUserValue($this->uid, 'richdocuments', 'save_path', '/'),
|
'savePath' => $this->settings->getUserValue($this->uid, 'richdocuments', 'save_path', '/'),
|
||||||
'uploadMaxFilesize' => $maxUploadFilesize,
|
'uploadMaxFilesize' => $maxUploadFilesize,
|
||||||
'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize),
|
'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize),
|
||||||
'allowShareWithLink' => $this->settings->getAppValue('core', 'shareapi_allow_links', 'yes'),
|
'allowShareWithLink' => $this->settings->getAppValue('core', 'shareapi_allow_links', 'yes'),
|
||||||
'wopi_url' => $wopiRemote,
|
'wopi_url' => $webSocket,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$policy = new ContentSecurityPolicy();
|
$policy = new ContentSecurityPolicy();
|
||||||
$policy->addAllowedScriptDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\' ' . $wopiRemote);
|
$policy->addAllowedScriptDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\' ' . $wopiRemote);
|
||||||
$policy->addAllowedFrameDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\' ' . $wopiRemote);
|
$policy->addAllowedFrameDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\' ' . $wopiRemote);
|
||||||
$policy->addAllowedConnectDomain('ws://' . $_SERVER['SERVER_NAME'] . ':9980');
|
$policy->addAllowedConnectDomain($webSocket);
|
||||||
$policy->addAllowedImageDomain('*');
|
$policy->addAllowedImageDomain('*');
|
||||||
$policy->allowInlineScript(true);
|
$policy->allowInlineScript(true);
|
||||||
$policy->addAllowedFontDomain('data:');
|
$policy->addAllowedFontDomain('data:');
|
||||||
$response->setContentSecurityPolicy($policy);
|
$response->setContentSecurityPolicy($policy);
|
||||||
$discovery = $this->cache->get('discovery.xml');
|
|
||||||
|
|
||||||
if(is_null($discovery)) {
|
$discovery = $this->cache->get('discovery.xml');
|
||||||
if (($parts = parse_url($wopiRemote))) {
|
if(is_null($discovery) && isset($wopiDiscovery)) {
|
||||||
// Provides access to information about the capabilities of a WOPI client
|
$this->requestDiscovery($wopiDiscovery);
|
||||||
// and the mechanisms for invoking those abilities through URIs.
|
|
||||||
// HTTP://server/hosting/discovery
|
|
||||||
$wopiDiscovery = sprintf(
|
|
||||||
"%s%s%s%s",
|
|
||||||
isset($parts['scheme']) ? $parts['scheme'] . "://" : '',
|
|
||||||
isset($parts['host']) ? $parts['host'] : '',
|
|
||||||
isset($parts['port']) ? ":" . $parts['port'] : '',
|
|
||||||
"/hosting/discovery" );
|
|
||||||
$this->requestDiscovery($wopiDiscovery);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
|
@ -197,8 +197,8 @@ var documentsMain = {
|
|||||||
documentsMain.url = window.location.protocol + '//' + window.location.host + url;
|
documentsMain.url = window.location.protocol + '//' + window.location.host + url;
|
||||||
|
|
||||||
var viewer = urlsrc +
|
var viewer = urlsrc +
|
||||||
'file_path=' + encodeURIComponent(documentsMain.url) +
|
'WOPISrc=' + encodeURIComponent(documentsMain.url) +
|
||||||
'&host=' + 'ws://' + window.location.hostname + ':9980' +
|
'&host=' + $('#wopi-url').val() +
|
||||||
'&permission=' + 'view' +
|
'&permission=' + 'view' +
|
||||||
'×tamp=' + '';
|
'×tamp=' + '';
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ use \OCP\IConfig;
|
|||||||
class AppConfig{
|
class AppConfig{
|
||||||
private $appName = 'richdocuments';
|
private $appName = 'richdocuments';
|
||||||
private $defaults = [
|
private $defaults = [
|
||||||
'wopi_url' => 'http://localhost'
|
'wopi_url' => 'http://localhost:9980'
|
||||||
];
|
];
|
||||||
|
|
||||||
private $config;
|
private $config;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user