Enable the view module in maintenance mode

- This allows to load the default theme CSS
- Theme scripts have been updated to reflect the possibility they will be included in maintenance mode
This commit is contained in:
Hypolite Petovan 2022-07-12 19:48:36 -04:00
parent ac56dcd50f
commit 1d94e2866a
10 changed files with 177 additions and 141 deletions

View File

@ -705,7 +705,8 @@ class App
// Initialize module that can set the current theme in the init() method, either directly or via App->setProfileOwner // Initialize module that can set the current theme in the init() method, either directly or via App->setProfileOwner
$page['page_title'] = $moduleName; $page['page_title'] = $moduleName;
if (!$this->mode->isInstall() && !$this->mode->has(App\Mode::MAINTENANCEDISABLED)) { // The "view" module is required to show the theme CSS
if (!$this->mode->isInstall() && !$this->mode->has(App\Mode::MAINTENANCEDISABLED) && $moduleName !== 'view') {
$module = $router->getModule(Maintenance::class); $module = $router->getModule(Maintenance::class);
} else { } else {
// determine the module class and save it to the module instance // determine the module class and save it to the module instance

View File

@ -25,13 +25,12 @@ if (file_exists("$THEMEPATH/style.css")) {
echo file_get_contents("$THEMEPATH/style.css"); echo file_get_contents("$THEMEPATH/style.css");
} }
$uid = $_REQUEST['puid'] ?? 0; /*
* This script can be included when the maintenance mode is on, which requires us to avoid any config call
$s_colorset = DI::config()->get('duepuntozero', 'colorset'); */
$colorset = DI::pConfig()->get($uid, 'duepuntozero', 'colorset'); if (DI::mode()->has(\Friendica\App\Mode::MAINTENANCEDISABLED)) {
$s_colorset = DI::config()->get('duepuntozero', 'colorset');
if (empty($colorset)) { $colorset = DI::pConfig()->get($_REQUEST['puid'] ?? 0, 'duepuntozero', 'colorset', $s_colorset);
$colorset = $s_colorset;
} }
$setcss = ''; $setcss = '';

View File

@ -23,26 +23,35 @@ use Friendica\App;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
/*
* This script can be included even when the app is in maintenance mode which requires us to avoid any config call
*/
function duepuntozero_init(App $a) { function duepuntozero_init(App $a) {
Renderer::setActiveTemplateEngine('smarty3'); Renderer::setActiveTemplateEngine('smarty3');
$colorset = DI::pConfig()->get( local_user(), 'duepuntozero','colorset'); $colorset = null;
if (DI::mode()->has(App\Mode::MAINTENANCEDISABLED)) {
$colorset = DI::pConfig()->get(local_user(), 'duepuntozero', 'colorset');
if (!$colorset) if (!$colorset)
$colorset = DI::config()->get('duepuntozero', 'colorset'); // user setting have priority, then node settings $colorset = DI::config()->get('duepuntozero', 'colorset'); // user setting have priority, then node settings
}
if ($colorset) { if ($colorset) {
if ($colorset == 'greenzero') if ($colorset == 'greenzero')
DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/greenzero.css" type="text/css" media="screen" />'."\n"; DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/greenzero.css" type="text/css" media="screen" />' . "\n";
if ($colorset == 'purplezero') if ($colorset == 'purplezero')
DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/purplezero.css" type="text/css" media="screen" />'."\n"; DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/purplezero.css" type="text/css" media="screen" />' . "\n";
if ($colorset == 'easterbunny') if ($colorset == 'easterbunny')
DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/easterbunny.css" type="text/css" media="screen" />'."\n"; DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/easterbunny.css" type="text/css" media="screen" />' . "\n";
if ($colorset == 'darkzero') if ($colorset == 'darkzero')
DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/darkzero.css" type="text/css" media="screen" />'."\n"; DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/darkzero.css" type="text/css" media="screen" />' . "\n";
if ($colorset == 'comix') if ($colorset == 'comix')
DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/comix.css" type="text/css" media="screen" />'."\n"; DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/comix.css" type="text/css" media="screen" />' . "\n";
if ($colorset == 'slackr') if ($colorset == 'slackr')
DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/slackr.css" type="text/css" media="screen" />'."\n"; DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/slackr.css" type="text/css" media="screen" />' . "\n";
} }
DI::page()['htmlhead'] .= <<< EOT DI::page()['htmlhead'] .= <<< EOT
<script> <script>

View File

@ -31,30 +31,43 @@ $schemecss = '';
$schemecssfile = false; $schemecssfile = false;
$scheme_modified = 0; $scheme_modified = 0;
DI::config()->load('frio'); /*
* This script can be included when the maintenance mode is on, which requires us to avoid any config call and
* use the following hardcoded defaults
*/
$scheme = null;
$scheme_accent = FRIO_SCHEME_ACCENT_BLUE;
$nav_bg = '#708fa0';
$nav_icon_color = '#ffffff';
$link_color = '#6fdbe8';
$background_color = '#ededed';
$contentbg_transp = 100;
$background_image = 'img/none.png';
$bg_image_option = '';
$login_bg_image = '';
$login_bg_color = '';
$modified = time();
// Default to hard-coded values for empty settings if (DI::mode()->has(\Friendica\App\Mode::MAINTENANCEDISABLED)) {
$scheme = DI::config()->get('frio', 'scheme', DI::config()->get('frio', 'schema')); DI::config()->load('frio');
$scheme_accent = DI::config()->get('frio', 'scheme_accent') ?: FRIO_SCHEME_ACCENT_BLUE;
$nav_bg = DI::config()->get('frio', 'nav_bg') ?: '#708fa0';
$nav_icon_color = DI::config()->get('frio', 'nav_icon_color') ?: '#ffffff';
$link_color = DI::config()->get('frio', 'link_color') ?: '#6fdbe8';
$background_color = DI::config()->get('frio', 'background_color') ?: '#ededed';
$contentbg_transp = DI::config()->get('frio', 'contentbg_transp') ?? 100;
$background_image = DI::config()->get('frio', 'background_image') ?: 'img/none.png';
$bg_image_option = DI::config()->get('frio', 'bg_image_option') ?: '';
$login_bg_image = DI::config()->get('frio', 'login_bg_image') ?: '';
$login_bg_color = DI::config()->get('frio', 'login_bg_color') ?: '';
$modified = DI::config()->get('frio', 'css_modified') ?: time();
if (!$login_bg_image && !$login_bg_color) { // Default to hard-coded values for empty settings
$login_bg_image = 'img/login_bg.jpg'; $scheme = DI::config()->get('frio', 'scheme', DI::config()->get('frio', 'schema'));
} $scheme_accent = DI::config()->get('frio', 'scheme_accent') ?: $scheme_accent;
$login_bg_color = $login_bg_color ?: '#ededed'; $nav_bg = DI::config()->get('frio', 'nav_bg') ?: $nav_bg;
$nav_icon_color = DI::config()->get('frio', 'nav_icon_color') ?: $nav_icon_color;
$link_color = DI::config()->get('frio', 'link_color') ?: $link_color;
$background_color = DI::config()->get('frio', 'background_color') ?: $background_color;
$contentbg_transp = DI::config()->get('frio', 'contentbg_transp') ?? $contentbg_transp;
$background_image = DI::config()->get('frio', 'background_image') ?: $background_image;
$bg_image_option = DI::config()->get('frio', 'bg_image_option') ?: $bg_image_option;
$login_bg_image = DI::config()->get('frio', 'login_bg_image') ?: $login_bg_image;
$login_bg_color = DI::config()->get('frio', 'login_bg_color') ?: $login_bg_color;
$modified = DI::config()->get('frio', 'css_modified') ?: $modified;
// Get the UID of the profile owner. // Get the UID of the profile owner.
$uid = $_REQUEST['puid'] ?? 0; $uid = $_REQUEST['puid'] ?? 0;
if ($uid) { if ($uid) {
DI::pConfig()->load($uid, 'frio'); DI::pConfig()->load($uid, 'frio');
// Only override display settings that have actually been set // Only override display settings that have actually been set
@ -68,8 +81,14 @@ if ($uid) {
$background_image = DI::pConfig()->get($uid, 'frio', 'background_image') ?: $background_image; $background_image = DI::pConfig()->get($uid, 'frio', 'background_image') ?: $background_image;
$bg_image_option = DI::pConfig()->get($uid, 'frio', 'bg_image_option') ?: $bg_image_option; $bg_image_option = DI::pConfig()->get($uid, 'frio', 'bg_image_option') ?: $bg_image_option;
$modified = DI::pConfig()->get($uid, 'frio', 'css_modified') ?: $modified; $modified = DI::pConfig()->get($uid, 'frio', 'css_modified') ?: $modified;
}
} }
if (!$login_bg_image && !$login_bg_color) {
$login_bg_image = 'img/login_bg.jpg';
}
$login_bg_color = $login_bg_color ?: '#ededed';
// Now load the scheme. If a value is changed above, we'll keep the settings // Now load the scheme. If a value is changed above, we'll keep the settings
// If not, we'll keep those defined by the scheme // If not, we'll keep those defined by the scheme
// Setting $scheme to '' wasn't working for some reason, so we'll check it's // Setting $scheme to '' wasn't working for some reason, so we'll check it's
@ -81,7 +100,7 @@ if (!empty($_REQUEST['scheme'])) {
$scheme = Strings::sanitizeFilePathItem($scheme ?? ''); $scheme = Strings::sanitizeFilePathItem($scheme ?? '');
if (($scheme) && ($scheme != '---')) { if ($scheme && ($scheme != '---')) {
if (file_exists('view/theme/frio/scheme/' . $scheme . '.php')) { if (file_exists('view/theme/frio/scheme/' . $scheme . '.php')) {
$schemefile = 'view/theme/frio/scheme/' . $scheme . '.php'; $schemefile = 'view/theme/frio/scheme/' . $scheme . '.php';
require_once $schemefile; require_once $schemefile;
@ -104,7 +123,7 @@ if (!$scheme) {
} }
} }
$contentbg_transp = ((isset($contentbg_transp) && $contentbg_transp != '') ? $contentbg_transp : 100); $contentbg_transp = $contentbg_transp ?? 0 ?: 100;
// Calculate some colors in dependance of existing colors. // Calculate some colors in dependance of existing colors.
// Some colors are calculated to don't have too many selection // Some colors are calculated to don't have too many selection

View File

@ -27,6 +27,10 @@ const FRIO_SCHEME_ACCENT_PURPLE = '#a54bad';
const FRIO_SCHEME_ACCENT_GREEN = '#218f39'; const FRIO_SCHEME_ACCENT_GREEN = '#218f39';
const FRIO_SCHEME_ACCENT_PINK = '#d900a9'; const FRIO_SCHEME_ACCENT_PINK = '#d900a9';
/*
* This script can be included even when the app is in maintenance mode which requires us to avoid any config call
*/
function frio_init(App $a) function frio_init(App $a)
{ {
global $frio; global $frio;
@ -191,7 +195,8 @@ function frio_contact_photo_menu(App $a, &$args)
*/ */
function frio_remote_nav(App $a, array &$nav_info) function frio_remote_nav(App $a, array &$nav_info)
{ {
// get the homelink from $_XSESSION if (DI::mode()->has(App\Mode::MAINTENANCEDISABLED)) {
// get the homelink from $_SESSION
$homelink = Model\Profile::getMyURL(); $homelink = Model\Profile::getMyURL();
if (!$homelink) { if (!$homelink) {
$homelink = Session::get('visitor_home', ''); $homelink = Session::get('visitor_home', '');
@ -236,6 +241,7 @@ function frio_remote_nav(App $a, array &$nav_info)
$nav_info['nav']['contacts'] = [$server_url . '/contact', DI::l10n()->t('Contacts'), '', DI::l10n()->t('Manage/edit friends and contacts')]; $nav_info['nav']['contacts'] = [$server_url . '/contact', DI::l10n()->t('Contacts'), '', DI::l10n()->t('Manage/edit friends and contacts')];
$nav_info['nav']['sitename'] = DI::config()->get('config', 'sitename'); $nav_info['nav']['sitename'] = DI::config()->get('config', 'sitename');
} }
}
} }
function frio_display_item(App $a, &$arr) function frio_display_item(App $a, &$arr)

View File

@ -21,24 +21,27 @@
use Friendica\DI; use Friendica\DI;
$uid = $_REQUEST['puid'] ?? 0; /*
* This script can be included when the maintenance mode is on, which requires us to avoid any config call and
$color = false; * use the following hardcoded defaults
*/
$color = 'dark';
$quattro_align = false; $quattro_align = false;
$site_color = DI::config()->get("quattro", "color", "dark"); $textarea_font_size = '20';
$site_quattro_align = DI::config()->get("quattro", "align", false); $post_font_size = '12';
if ($uid) { if (DI::mode()->has(\Friendica\App\Mode::MAINTENANCEDISABLED)) {
$color = DI::pConfig()->get($uid, "quattro", "color", false); $site_color = DI::config()->get("quattro", "color", $color);
$quattro_align = DI::pConfig()->get($uid, 'quattro', 'align', false); $site_quattro_align = DI::config()->get("quattro", "align", $quattro_align);
} $site_textarea_font_size = DI::config()->get("quattro", "tfs", $textarea_font_size);
$site_post_font_size = DI::config()->get("quattro", "pfs", $post_font_size);
if ($color === false) { $uid = $_REQUEST['puid'] ?? 0;
$color = $site_color;
}
if ($quattro_align === false) { $color = DI::pConfig()->get($uid, "quattro", "color", $site_color);
$quattro_align = $site_quattro_align; $quattro_align = DI::pConfig()->get($uid, 'quattro', 'align', $site_quattro_align);
$textarea_font_size = DI::pConfig()->get($uid, "quattro", "tfs", $site_textarea_font_size);
$post_font_size = DI::pConfig()->get($uid, "quattro", "pfs", $site_post_font_size);
} }
$color = \Friendica\Util\Strings::sanitizeFilePathItem($color); $color = \Friendica\Util\Strings::sanitizeFilePathItem($color);
@ -59,24 +62,6 @@ if ($quattro_align == "center") {
} }
$textarea_font_size = false;
$post_font_size = false;
$site_textarea_font_size = DI::config()->get("quattro", "tfs", "20");
$site_post_font_size = DI::config()->get("quattro", "pfs", "12");
if ($uid) {
$textarea_font_size = DI::pConfig()->get($uid, "quattro", "tfs", false);
$post_font_size = DI::pConfig()->get($uid, "quattro", "pfs", false);
}
if ($textarea_font_size === false) {
$textarea_font_size = $site_textarea_font_size;
}
if ($post_font_size === false) {
$post_font_size = $site_post_font_size;
}
echo " echo "
textarea { font-size: ${textarea_font_size}px; } textarea { font-size: ${textarea_font_size}px; }
.wall-item-comment-wrapper .comment-edit-text-full { font-size: ${textarea_font_size}px; } .wall-item-comment-wrapper .comment-edit-text-full { font-size: ${textarea_font_size}px; }

View File

@ -10,6 +10,10 @@
use Friendica\App; use Friendica\App;
use Friendica\DI; use Friendica\DI;
/*
* This script can be included even when the app is in maintenance mode which requires us to avoid any config call
*/
function quattro_init(App $a) { function quattro_init(App $a) {
DI::page()['htmlhead'] .= '<script src="'.DI::baseUrl().'/view/theme/quattro/tinycon.min.js"></script>'; DI::page()['htmlhead'] .= '<script src="'.DI::baseUrl().'/view/theme/quattro/tinycon.min.js"></script>';
DI::page()['htmlhead'] .= '<script src="'.DI::baseUrl().'/view/theme/quattro/js/quattro.js"></script>';; DI::page()['htmlhead'] .= '<script src="'.DI::baseUrl().'/view/theme/quattro/js/quattro.js"></script>';;

View File

@ -14,6 +14,10 @@ use Friendica\App;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\DI; use Friendica\DI;
/*
* This script can be included even when the app is in maintenance mode which requires us to avoid any config call
*/
function smoothly_init(App $a) { function smoothly_init(App $a) {
Renderer::setActiveTemplateEngine('smarty3'); Renderer::setActiveTemplateEngine('smarty3');

View File

@ -23,16 +23,16 @@ use Friendica\Core\Logger;
use Friendica\DI; use Friendica\DI;
use Friendica\Network\HTTPException\NotModifiedException; use Friendica\Network\HTTPException\NotModifiedException;
$uid = $_REQUEST['puid'] ?? 0; /*
* This script can be included when the maintenance mode is on, which requires us to avoid any config call and
* use the following hardcoded default
*/
$style = 'plus';
$style = DI::pConfig()->get($uid, 'vier', 'style'); if (DI::mode()->has(\Friendica\App\Mode::MAINTENANCEDISABLED)) {
$uid = $_REQUEST['puid'] ?? 0;
if (empty($style)) { $style = DI::pConfig()->get($uid, 'vier', 'style', DI::config()->get('vier', 'style', $style));
$style = DI::config()->get('vier', 'style');
}
if (empty($style)) {
$style = "plus";
} }
$stylecss = ''; $stylecss = '';

View File

@ -19,6 +19,10 @@ use Friendica\DI;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Util\Strings; use Friendica\Util\Strings;
/*
* This script can be included even when the app is in maintenance mode which requires us to avoid any config call
*/
function vier_init(App $a) function vier_init(App $a)
{ {
$a->setThemeInfoValue('events_in_profile', false); $a->setThemeInfoValue('events_in_profile', false);
@ -27,7 +31,12 @@ function vier_init(App $a)
$args = DI::args(); $args = DI::args();
if ($args->get(0) === 'profile' && $args->get(1) === ($a->getLoggedInUserNickname() ?? '') || $args->get(0) === 'network' && local_user() if (
DI::mode()->has(App\Mode::MAINTENANCEDISABLED)
&& (
$args->get(0) === 'profile' && $args->get(1) === ($a->getLoggedInUserNickname() ?? '')
|| $args->get(0) === 'network' && local_user()
)
) { ) {
vier_community_info(); vier_community_info();