@@ -16,6 +16,9 @@ class PageController extends Controller
1616 */
1717 public function index ()
1818 {
19+ // Uncomment to test without using an iframe
20+ // return static::index_embed();
21+
1922 \OC ::$ server ->getNavigationManager ()->setActiveEntry ('snappymail ' );
2023
2124 \OCP \Util::addStyle ('snappymail ' , 'style ' );
@@ -72,5 +75,61 @@ public function appPost()
7275 {
7376 SnappyMailHelper::startApp ();
7477 }
75- }
7678
79+ /**
80+ * Draft code to run without using an iframe
81+ */
82+ private static function index_embed ()
83+ {
84+ \OC ::$ server ->getNavigationManager ()->setActiveEntry ('snappymail ' );
85+
86+ \OCP \Util::addStyle ('snappymail ' , 'style ' );
87+
88+ SnappyMailHelper::startApp (true );
89+ $ webPath = \OC ::$ server ->getAppManager ()->getAppWebPath ('snappymail ' ) . '/app ' ;
90+ $ oConfig = \RainLoop \Api::Config ();
91+ $ oActions = \RainLoop \Api::Actions ();
92+ $ oHttp = \MailSo \Base \Http::SingletonInstance ();
93+ $ oServiceActions = new \RainLoop \ServiceActions ($ oHttp , $ oActions );
94+ $ sAppJsMin = $ oConfig ->Get ('labs ' , 'use_app_debug_js ' , false ) ? '' : '.min ' ;
95+ $ sAppCssMin = $ oConfig ->Get ('labs ' , 'use_app_debug_css ' , false ) ? '' : '.min ' ;
96+ $ sLanguage = $ oActions ->GetLanguage (false );
97+
98+ $ sScriptNonce = \OC ::$ server ->getContentSecurityPolicyNonceManager ()->getNonce ();
99+ // $sScriptNonce = \SnappyMail\UUID::generate();
100+ // \RainLoop\Service::setCSP($sScriptNonce);
101+
102+ $ params = [
103+ 'LoadingDescriptionEsc ' => \htmlspecialchars ($ oConfig ->Get ('webmail ' , 'loading_description ' , 'SnappyMail ' ), ENT_QUOTES |ENT_IGNORE , 'UTF-8 ' ),
104+ 'BaseTemplates ' => \RainLoop \Utils::ClearHtmlOutput ($ oServiceActions ->compileTemplates (false )),
105+ 'BaseAppBootScript ' => \str_replace (
106+ 'loadScript(`./?/ ' ,
107+ 'loadScript(` ' .$ webPath .'/?/ ' ,
108+ \file_get_contents (APP_VERSION_ROOT_PATH .'static/js ' .($ sAppJsMin ? '/min ' : '' ).'/boot ' .$ sAppJsMin .'.js ' )
109+ ),
110+ 'BaseAppBootScriptNonce ' => $ sScriptNonce ,
111+ 'BaseLanguage ' => $ oActions ->compileLanguage ($ sLanguage , false ),
112+ ];
113+
114+ \OCP \Util::addHeader ('style ' , ['id ' =>'app-boot-css ' ], \file_get_contents (APP_VERSION_ROOT_PATH .'static/css/boot ' .$ sAppCssMin .'.css ' ));
115+ \OCP \Util::addHeader ('link ' , ['type ' =>'text/css ' ,'rel ' =>'stylesheet ' ,'href ' =>\RainLoop \Utils::WebStaticPath ('css/app ' .$ sAppCssMin .'.css ' )], '' );
116+ \OCP \Util::addHeader ('style ' , ['id ' =>'app-theme-style ' ,'data-href ' =>$ oActions ->ThemeLink (false )],
117+ \preg_replace (
118+ '/ \\s*([:;{},]+) \\s*/s ' ,
119+ '$1 ' ,
120+ $ oActions ->compileCss ($ oActions ->GetTheme (false ), false )
121+ ));
122+
123+ $ response = new TemplateResponse ('snappymail ' , 'index_embed ' , $ params );
124+
125+ $ csp = new ContentSecurityPolicy ();
126+ $ csp ->addAllowedScriptDomain ("'self' " );
127+ $ csp ->useStrictDynamic (true );
128+ $ csp ->allowEvalScript (true ); // $csp->addAllowedScriptDomain("'unsafe-eval'");
129+ $ csp ->addAllowedStyleDomain ("'self' " );
130+ $ response ->setContentSecurityPolicy ($ csp );
131+
132+ return $ response ;
133+ }
134+
135+ }
0 commit comments