Improved Nextcloud integration for #96

This commit is contained in:
the-djmaze 2022-10-13 10:24:35 +02:00
parent dc241ded1b
commit 5c597c4c1d
10 changed files with 123 additions and 35 deletions

View file

@ -21,8 +21,8 @@ foreach ($files as $file) {
$nc_tar->addFile('data/.htaccess'); $nc_tar->addFile('data/.htaccess');
$nc_tar->addFromString('data/VERSION', $package->version); $nc_tar->addFromString('data/VERSION', $package->version);
$nc_tar->addFile('data/README.md'); $nc_tar->addFile('data/README.md');
*/
$nc_tar->addFile('_include.php', 'snappymail/app/_include.php'); $nc_tar->addFile('_include.php', 'snappymail/app/_include.php');
*/
$nc_tar->addFile('.htaccess', 'snappymail/app/.htaccess'); $nc_tar->addFile('.htaccess', 'snappymail/app/.htaccess');
$index = file_get_contents('index.php'); $index = file_get_contents('index.php');

View file

@ -283,7 +283,7 @@ class SquireUI
this.wysiwyg = wysiwyg; this.wysiwyg = wysiwyg;
toolbar.className = 'squire-toolbar btn-toolbar'; toolbar.className = 'squire-toolbar btn-toolbar';
let group, action, touchTap; let group, action/*, touchTap*/;
for (group in actions) { for (group in actions) {
/* /*
if ('bidi' == group && !rl.settings.app('allowHtmlEditorBitiButtons')) { if ('bidi' == group && !rl.settings.app('allowHtmlEditorBitiButtons')) {
@ -328,16 +328,18 @@ class SquireUI
input.className = 'btn'; input.className = 'btn';
input.innerHTML = cfg.html; input.innerHTML = cfg.html;
input.action_cmd = cfg.cmd; input.action_cmd = cfg.cmd;
input.addEventListener('touchstart', () => touchTap = input, {passive:true}); /*
input.addEventListener('touchmove', () => touchTap = null, {passive:true}); input.addEventListener('pointerdown', () => touchTap = input, {passive:true});
input.addEventListener('touchcancel', () => touchTap = null); input.addEventListener('pointermove', () => touchTap = null, {passive:true});
input.addEventListener('touchend', e => { input.addEventListener('pointercancel', () => touchTap = null);
input.addEventListener('pointerup', e => {
if (touchTap === input) { if (touchTap === input) {
e.preventDefault(); e.preventDefault();
cfg.cmd(input); cfg.cmd(input);
} }
touchTap = null; touchTap = null;
}); });
*/
} }
input.addEventListener(ev, () => cfg.cmd(input)); input.addEventListener(ev, () => cfg.cmd(input));
if (cfg.hint) { if (cfg.hint) {

View file

@ -69,9 +69,9 @@ To fill in the default email address and password to use, each Nextcloud user sh
## How to Activate SnappyMail Logging and then Find Logs ## How to Activate SnappyMail Logging and then Find Logs
You can activate SnappyMail logging here: `/path/to/nextcloud/data/snappymail-storage/_data_/_default_/configs/application.ini` You can activate SnappyMail logging here: `/path/to/nextcloud/data/appdata_snappymail/_data_/_default_/configs/application.ini`
``` ```
[logs] [logs]
enable = On enable = On
``` ```
Logs are then available in `/path/to/nextcloud/data/snappymail-storage/_data_/_default_/logs/` Logs are then available in `/path/to/nextcloud/data/appdata_snappymail/_data_/_default_/logs/`

View file

@ -0,0 +1,44 @@
<?php
// Name this file as "include.php" to enable it.
//header('Strict-Transport-Security: max-age=31536000');
/**
* Uncomment to use gzip compressed output
*/
//define('USE_GZIP', 1);
/**
* Uncomment to use brotli compressed output
*/
//define('USE_BROTLI', 1);
/**
* Uncomment to enable multiple domain installation.
*/
//define('MULTIDOMAIN', 1);
/**
* Uncomment to disable APCU.
*/
//define('APP_USE_APCU_CACHE', false);
/**
* Custom 'data' folder path
*/
if (!empty($_ENV['SNAPPYMAIL_NEXTCLOUD'])) {
define('APP_DATA_FOLDER_PATH', \rtrim(\trim(\OC::$server->getSystemConfig()->getValue('datadirectory', '')), '\\/').'/appdata_snappymail/');
} else {
http_response_code(400);
header($_SERVER['SERVER_PROTOCOL'].' 400 Bad Request', true, 400);
error_log("SnappyMail outside Nextcloud {$_SERVER['REQUEST_URI']}");
exit('Not inside Nextcloud');
// define('APP_DATA_FOLDER_PATH', dirname(__DIR__) . '/snappymail-data/');
// define('APP_DATA_FOLDER_PATH', '/var/external-snappymail-data-folder/');
}
/**
* Additional configuration file name
*/
//define('APP_CONFIGURATION_NAME', $_SERVER['HTTP_HOST'].'.ini');

View file

@ -7,6 +7,11 @@ return [
'url' => '/', 'url' => '/',
'verb' => 'GET' 'verb' => 'GET'
], ],
[
'name' => 'page#indexPost',
'url' => '/',
'verb' => 'POST'
],
[ [
'name' => 'page#appGet', 'name' => 'page#appGet',
'url' => '/run/', 'url' => '/run/',

View file

@ -0,0 +1,40 @@
/*
SnappyMail runs in an iframe, so this style sheet is not used there.
Only needed to give you the opportunity to theme the nextcloud part of this app.
However, there is hidden code in the PageController to embed instead of using an iframe.
Then the below #rl-app can be used to style it.
*/
#rl-app {
position: relative;
min-width: 100%;
min-height: 100%;
}
#content[class*="app-"] #rl-app * {
box-sizing: content-box;
}
#content[class*="app-"] #rl-app #V-Settings-Domains .domain-name,
#content[class*="app-"] #rl-app #V-Settings-Domains .domain-alias
#content[class*="app-"] #rl-app #rl-settings-subscreen,
#content[class*="app-"] #rl-app .e-checkbox.material-design > div > div,
#content[class*="app-"] #rl-app .attachmentItem .iconMain,
#content[class*="app-"] #rl-app .attachmentItem .iconPreview,
#content[class*="app-"] #rl-app #V-PopupsCompose .textAreaParent,
#content[class*="app-"] #rl-app #V-PopupsCompose .attachmentAreaParent,
#content[class*="app-"] #rl-app .emailaddresses,
#content[class*="app-"] #rl-app .squire-wysiwyg,
#content[class*="app-"] #rl-app .squire-plain,
/* bootstrap */
#content[class*="app-"] #rl-app .btn-block,
#content[class*="app-"] #rl-app select,
#content[class*="app-"] #rl-app .select,
#content[class*="app-"] #rl-app textarea,
#content[class*="app-"] #rl-app input,
#content[class*="app-"] #rl-app .input-block-level
{
box-sizing: border-box;
}
.squire-wysiwyg {
min-width: 100%;
min-height: 100%;
}

View file

@ -26,13 +26,12 @@ class Application extends App implements IBootstrap
$this->getContainer()->query('SnappyMailHelper')->registerHooks(); $this->getContainer()->query('SnappyMailHelper')->registerHooks();
} }
public function __construct(array $urlParams = []) // public function __construct(string $appName, array $urlParams = [])
public function __construct()
{ {
parent::__construct('snappymail', $urlParams); parent::__construct('snappymail', $urlParams);
$container = $this->getContainer(); $container = $this->getContainer();
// $server = $container->getServer();
// $config = $server->getConfig();
/** /**
* Controllers * Controllers

View file

@ -76,17 +76,30 @@ class PageController extends Controller
SnappyMailHelper::startApp(); SnappyMailHelper::startApp();
} }
/**
* @NoAdminRequired
* @NoCSRFRequired
*/
public function indexPost()
{
SnappyMailHelper::startApp();
}
/** /**
* Draft code to run without using an iframe * Draft code to run without using an iframe
*/ */
private static function index_embed() private static function index_embed()
{ {
if (!empty($_SERVER['QUERY_STRING'])) {
SnappyMailHelper::startApp();
return;
}
\OC::$server->getNavigationManager()->setActiveEntry('snappymail'); \OC::$server->getNavigationManager()->setActiveEntry('snappymail');
\OCP\Util::addStyle('snappymail', 'style'); \OCP\Util::addStyle('snappymail', 'embed');
SnappyMailHelper::startApp(true); SnappyMailHelper::startApp(true);
$webPath = \OC::$server->getAppManager()->getAppWebPath('snappymail') . '/app';
$oConfig = \RainLoop\Api::Config(); $oConfig = \RainLoop\Api::Config();
$oActions = \RainLoop\Api::Actions(); $oActions = \RainLoop\Api::Actions();
$oHttp = \MailSo\Base\Http::SingletonInstance(); $oHttp = \MailSo\Base\Http::SingletonInstance();
@ -102,11 +115,7 @@ class PageController extends Controller
$params = [ $params = [
'LoadingDescriptionEsc' => \htmlspecialchars($oConfig->Get('webmail', 'loading_description', 'SnappyMail'), ENT_QUOTES|ENT_IGNORE, 'UTF-8'), 'LoadingDescriptionEsc' => \htmlspecialchars($oConfig->Get('webmail', 'loading_description', 'SnappyMail'), ENT_QUOTES|ENT_IGNORE, 'UTF-8'),
'BaseTemplates' => \RainLoop\Utils::ClearHtmlOutput($oServiceActions->compileTemplates(false)), 'BaseTemplates' => \RainLoop\Utils::ClearHtmlOutput($oServiceActions->compileTemplates(false)),
'BaseAppBootScript' => \str_replace( 'BaseAppBootScript' => \file_get_contents(APP_VERSION_ROOT_PATH.'static/js'.($sAppJsMin ? '/min' : '').'/boot'.$sAppJsMin.'.js'),
'loadScript(`./?/',
'loadScript(`'.$webPath.'/?/',
\file_get_contents(APP_VERSION_ROOT_PATH.'static/js'.($sAppJsMin ? '/min' : '').'/boot'.$sAppJsMin.'.js')
),
'BaseAppBootScriptNonce' => $sScriptNonce, 'BaseAppBootScriptNonce' => $sScriptNonce,
'BaseLanguage' => $oActions->compileLanguage($sLanguage, false), 'BaseLanguage' => $oActions->compileLanguage($sLanguage, false),
]; ];

View file

@ -44,39 +44,29 @@ class SnappyMailHelper
} }
}); });
$path = \OC::$server->getAppManager()->getAppPath('snappymail') . '/app/';
$sData = \rtrim(\trim(\OC::$server->getSystemConfig()->getValue('datadirectory', '')), '\\/').'/appdata_snappymail/';
if (!\is_file("{$path}include.php")) {
\file_put_contents("{$path}include.php",
\file_get_contents("{$path}_include.php")
. "define('APP_DATA_FOLDER_PATH', '{$sData}');\n"
);
}
// \define('APP_DATA_FOLDER_PATH', $sData);
if ($api) { if ($api) {
$_ENV['SNAPPYMAIL_INCLUDE_AS_API'] = true; $_ENV['SNAPPYMAIL_INCLUDE_AS_API'] = true;
} }
require_once "{$path}index.php"; require_once \dirname(\dirname(__DIR__)) . '/app/index.php';
if ($api) { if ($api) {
$oConfig = \RainLoop\Api::Config(); $oConfig = \RainLoop\Api::Config();
$bSave = false;
if (!$oConfig->Get('webmail', 'app_path')) { if (!$oConfig->Get('webmail', 'app_path')) {
$oConfig->Set('webmail', 'app_path', \OC::$server->getAppManager()->getAppWebPath('snappymail') . '/app/'); $oConfig->Set('webmail', 'app_path', \OC::$server->getAppManager()->getAppWebPath('snappymail') . '/app/');
$oConfig->Save(); $bSave = true;
} }
/*
if (!\is_dir(APP_PLUGINS_PATH . 'nextcloud')) { if (!\is_dir(APP_PLUGINS_PATH . 'nextcloud')) {
\SnappyMail\Repository::installPackage('plugin', 'nextcloud'); \SnappyMail\Repository::installPackage('plugin', 'nextcloud');
$oConfig->Set('plugins', 'enable', true); $oConfig->Set('plugins', 'enable', true);
$aList = \SnappyMail\Repository::getEnabledPackagesNames(); $aList = \SnappyMail\Repository::getEnabledPackagesNames();
$aList[] = 'nextcloud'; $aList[] = 'nextcloud';
$oConfig->Set('plugins', 'enabled_list', \implode(',', \array_unique($aList))); $oConfig->Set('plugins', 'enabled_list', \implode(',', \array_unique($aList)));
$oConfig->Save(); $oConfig->Set('webmail', 'theme', 'Nextcloud@custom');
$bSave = true;
} }
*/ $bSave && $oConfig->Save();
} }
} }
} }

View file

@ -41,7 +41,6 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
/* /*
\OC::$server->getCalendarManager(); \OC::$server->getCalendarManager();
\OC::$server->getLDAPProvider(); \OC::$server->getLDAPProvider();
\OC::$server->getAppDataDir('snappymail'); ??
$oFiles = \OCP\Files::getStorage('files'); $oFiles = \OCP\Files::getStorage('files');
if ($oFiles and $oFiles->is_dir('/')) { if ($oFiles and $oFiles->is_dir('/')) {