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
$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);
} else {
// 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");
}
$uid = $_REQUEST['puid'] ?? 0;
$s_colorset = DI::config()->get('duepuntozero', 'colorset');
$colorset = DI::pConfig()->get($uid, 'duepuntozero', 'colorset');
if (empty($colorset)) {
$colorset = $s_colorset;
/*
* This script can be included when the maintenance mode is on, which requires us to avoid any config call
*/
if (DI::mode()->has(\Friendica\App\Mode::MAINTENANCEDISABLED)) {
$s_colorset = DI::config()->get('duepuntozero', 'colorset');
$colorset = DI::pConfig()->get($_REQUEST['puid'] ?? 0, 'duepuntozero', 'colorset', $s_colorset);
}
$setcss = '';

View File

@ -23,27 +23,36 @@ use Friendica\App;
use Friendica\Core\Renderer;
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) {
Renderer::setActiveTemplateEngine('smarty3');
Renderer::setActiveTemplateEngine('smarty3');
$colorset = DI::pConfig()->get( local_user(), 'duepuntozero','colorset');
if (!$colorset)
$colorset = DI::config()->get('duepuntozero', 'colorset'); // user setting have priority, then node settings
if ($colorset) {
if ($colorset == 'greenzero')
DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/greenzero.css" type="text/css" media="screen" />'."\n";
if ($colorset == 'purplezero')
DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/purplezero.css" type="text/css" media="screen" />'."\n";
if ($colorset == 'easterbunny')
DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/easterbunny.css" type="text/css" media="screen" />'."\n";
if ($colorset == 'darkzero')
DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/darkzero.css" type="text/css" media="screen" />'."\n";
if ($colorset == 'comix')
DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/comix.css" type="text/css" media="screen" />'."\n";
if ($colorset == 'slackr')
DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/slackr.css" type="text/css" media="screen" />'."\n";
}
$colorset = null;
if (DI::mode()->has(App\Mode::MAINTENANCEDISABLED)) {
$colorset = DI::pConfig()->get(local_user(), 'duepuntozero', 'colorset');
if (!$colorset)
$colorset = DI::config()->get('duepuntozero', 'colorset'); // user setting have priority, then node settings
}
if ($colorset) {
if ($colorset == 'greenzero')
DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/greenzero.css" type="text/css" media="screen" />' . "\n";
if ($colorset == 'purplezero')
DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/purplezero.css" type="text/css" media="screen" />' . "\n";
if ($colorset == 'easterbunny')
DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/easterbunny.css" type="text/css" media="screen" />' . "\n";
if ($colorset == 'darkzero')
DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/darkzero.css" type="text/css" media="screen" />' . "\n";
if ($colorset == 'comix')
DI::page()['htmlhead'] .= '<link rel="stylesheet" href="view/theme/duepuntozero/deriv/comix.css" type="text/css" media="screen" />' . "\n";
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'] .= <<< EOT
<script>
function cmtBbOpen(comment, id) {

View File

@ -31,45 +31,64 @@ $schemecss = '';
$schemecssfile = false;
$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
$scheme = DI::config()->get('frio', 'scheme', DI::config()->get('frio', 'schema'));
$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 (DI::mode()->has(\Friendica\App\Mode::MAINTENANCEDISABLED)) {
DI::config()->load('frio');
// Default to hard-coded values for empty settings
$scheme = DI::config()->get('frio', 'scheme', DI::config()->get('frio', 'schema'));
$scheme_accent = DI::config()->get('frio', 'scheme_accent') ?: $scheme_accent;
$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.
$uid = $_REQUEST['puid'] ?? 0;
if ($uid) {
DI::pConfig()->load($uid, 'frio');
// Only override display settings that have actually been set
$scheme = DI::pConfig()->get($uid, 'frio', 'scheme', DI::pConfig()->get($uid, 'frio', 'schema')) ?: $scheme;
$scheme_accent = DI::pConfig()->get($uid, 'frio', 'scheme_accent') ?: $scheme_accent;
$nav_bg = DI::pConfig()->get($uid, 'frio', 'nav_bg') ?: $nav_bg;
$nav_icon_color = DI::pConfig()->get($uid, 'frio', 'nav_icon_color') ?: $nav_icon_color;
$link_color = DI::pConfig()->get($uid, 'frio', 'link_color') ?: $link_color;
$background_color = DI::pConfig()->get($uid, 'frio', 'background_color') ?: $background_color;
$contentbg_transp = DI::pConfig()->get($uid, 'frio', 'contentbg_transp') ?? $contentbg_transp;
$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;
$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';
// Get the UID of the profile owner.
$uid = $_REQUEST['puid'] ?? 0;
if ($uid) {
DI::pConfig()->load($uid, 'frio');
// Only override display settings that have actually been set
$scheme = DI::pConfig()->get($uid, 'frio', 'scheme', DI::pConfig()->get($uid, 'frio', 'schema')) ?: $scheme;
$scheme_accent = DI::pConfig()->get($uid, 'frio', 'scheme_accent') ?: $scheme_accent;
$nav_bg = DI::pConfig()->get($uid, 'frio', 'nav_bg') ?: $nav_bg;
$nav_icon_color = DI::pConfig()->get($uid, 'frio', 'nav_icon_color') ?: $nav_icon_color;
$link_color = DI::pConfig()->get($uid, 'frio', 'link_color') ?: $link_color;
$background_color = DI::pConfig()->get($uid, 'frio', 'background_color') ?: $background_color;
$contentbg_transp = DI::pConfig()->get($uid, 'frio', 'contentbg_transp') ?? $contentbg_transp;
$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;
$modified = DI::pConfig()->get($uid, 'frio', 'css_modified') ?: $modified;
}
// 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
// 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 ?? '');
if (($scheme) && ($scheme != '---')) {
if ($scheme && ($scheme != '---')) {
if (file_exists('view/theme/frio/scheme/' . $scheme . '.php')) {
$schemefile = 'view/theme/frio/scheme/' . $scheme . '.php';
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.
// 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_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)
{
global $frio;
@ -191,50 +195,52 @@ function frio_contact_photo_menu(App $a, &$args)
*/
function frio_remote_nav(App $a, array &$nav_info)
{
// get the homelink from $_XSESSION
$homelink = Model\Profile::getMyURL();
if (!$homelink) {
$homelink = Session::get('visitor_home', '');
}
if (DI::mode()->has(App\Mode::MAINTENANCEDISABLED)) {
// get the homelink from $_SESSION
$homelink = Model\Profile::getMyURL();
if (!$homelink) {
$homelink = Session::get('visitor_home', '');
}
// since $userinfo isn't available for the hook we write it to the nav array
// this isn't optimal because the contact query will be done now twice
$fields = ['id', 'url', 'avatar', 'micro', 'name', 'nick', 'baseurl', 'updated'];
if ($a->isLoggedIn()) {
$remoteUser = Contact::selectFirst($fields, ['uid' => $a->getLoggedInUserId(), 'self' => true]);
} elseif (!local_user() && remote_user()) {
$remoteUser = Contact::getById(remote_user(), $fields);
$nav_info['nav']['remote'] = DI::l10n()->t('Guest');
} elseif (Model\Profile::getMyURL()) {
$remoteUser = Contact::getByURL($homelink, null, $fields);
$nav_info['nav']['remote'] = DI::l10n()->t('Visitor');
} else {
$remoteUser = null;
}
// since $userinfo isn't available for the hook we write it to the nav array
// this isn't optimal because the contact query will be done now twice
$fields = ['id', 'url', 'avatar', 'micro', 'name', 'nick', 'baseurl', 'updated'];
if ($a->isLoggedIn()) {
$remoteUser = Contact::selectFirst($fields, ['uid' => $a->getLoggedInUserId(), 'self' => true]);
} elseif (!local_user() && remote_user()) {
$remoteUser = Contact::getById(remote_user(), $fields);
$nav_info['nav']['remote'] = DI::l10n()->t('Guest');
} elseif (Model\Profile::getMyURL()) {
$remoteUser = Contact::getByURL($homelink, null, $fields);
$nav_info['nav']['remote'] = DI::l10n()->t('Visitor');
} else {
$remoteUser = null;
}
if (DBA::isResult($remoteUser)) {
$nav_info['userinfo'] = [
'icon' => Contact::getMicro($remoteUser),
'name' => $remoteUser['name'],
];
$server_url = $remoteUser['baseurl'];
}
if (DBA::isResult($remoteUser)) {
$nav_info['userinfo'] = [
'icon' => Contact::getMicro($remoteUser),
'name' => $remoteUser['name'],
];
$server_url = $remoteUser['baseurl'];
}
if (!local_user() && !empty($server_url) && !is_null($remoteUser)) {
// user menu
$nav_info['nav']['usermenu'][] = [$server_url . '/profile/' . $remoteUser['nick'], DI::l10n()->t('Status'), '', DI::l10n()->t('Your posts and conversations')];
$nav_info['nav']['usermenu'][] = [$server_url . '/profile/' . $remoteUser['nick'] . '/profile', DI::l10n()->t('Profile'), '', DI::l10n()->t('Your profile page')];
$nav_info['nav']['usermenu'][] = [$server_url . '/photos/' . $remoteUser['nick'], DI::l10n()->t('Photos'), '', DI::l10n()->t('Your photos')];
$nav_info['nav']['usermenu'][] = [$server_url . '/profile/' . $remoteUser['nick'] . '/media', DI::l10n()->t('Media'), '', DI::l10n()->t('Your postings with media')];
$nav_info['nav']['usermenu'][] = [$server_url . '/events/', DI::l10n()->t('Events'), '', DI::l10n()->t('Your events')];
if (!local_user() && !empty($server_url) && !is_null($remoteUser)) {
// user menu
$nav_info['nav']['usermenu'][] = [$server_url . '/profile/' . $remoteUser['nick'], DI::l10n()->t('Status'), '', DI::l10n()->t('Your posts and conversations')];
$nav_info['nav']['usermenu'][] = [$server_url . '/profile/' . $remoteUser['nick'] . '/profile', DI::l10n()->t('Profile'), '', DI::l10n()->t('Your profile page')];
$nav_info['nav']['usermenu'][] = [$server_url . '/photos/' . $remoteUser['nick'], DI::l10n()->t('Photos'), '', DI::l10n()->t('Your photos')];
$nav_info['nav']['usermenu'][] = [$server_url . '/profile/' . $remoteUser['nick'] . '/media', DI::l10n()->t('Media'), '', DI::l10n()->t('Your postings with media')];
$nav_info['nav']['usermenu'][] = [$server_url . '/events/', DI::l10n()->t('Events'), '', DI::l10n()->t('Your events')];
// navbar links
$nav_info['nav']['network'] = [$server_url . '/network', DI::l10n()->t('Network'), '', DI::l10n()->t('Conversations from your friends')];
$nav_info['nav']['events'] = [$server_url . '/events', DI::l10n()->t('Events'), '', DI::l10n()->t('Events and Calendar')];
$nav_info['nav']['messages'] = [$server_url . '/message', DI::l10n()->t('Messages'), '', DI::l10n()->t('Private mail')];
$nav_info['nav']['settings'] = [$server_url . '/settings', DI::l10n()->t('Settings'), '', DI::l10n()->t('Account settings')];
$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');
// navbar links
$nav_info['nav']['network'] = [$server_url . '/network', DI::l10n()->t('Network'), '', DI::l10n()->t('Conversations from your friends')];
$nav_info['nav']['events'] = [$server_url . '/events', DI::l10n()->t('Events'), '', DI::l10n()->t('Events and Calendar')];
$nav_info['nav']['messages'] = [$server_url . '/message', DI::l10n()->t('Messages'), '', DI::l10n()->t('Private mail')];
$nav_info['nav']['settings'] = [$server_url . '/settings', DI::l10n()->t('Settings'), '', DI::l10n()->t('Account settings')];
$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');
}
}
}

View File

@ -21,24 +21,27 @@
use Friendica\DI;
$uid = $_REQUEST['puid'] ?? 0;
$color = false;
/*
* 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
*/
$color = 'dark';
$quattro_align = false;
$site_color = DI::config()->get("quattro", "color", "dark");
$site_quattro_align = DI::config()->get("quattro", "align", false);
$textarea_font_size = '20';
$post_font_size = '12';
if ($uid) {
$color = DI::pConfig()->get($uid, "quattro", "color", false);
$quattro_align = DI::pConfig()->get($uid, 'quattro', 'align', false);
}
if (DI::mode()->has(\Friendica\App\Mode::MAINTENANCEDISABLED)) {
$site_color = DI::config()->get("quattro", "color", $color);
$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) {
$color = $site_color;
}
$uid = $_REQUEST['puid'] ?? 0;
if ($quattro_align === false) {
$quattro_align = $site_quattro_align;
$color = DI::pConfig()->get($uid, "quattro", "color", $site_color);
$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);
@ -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 "
textarea { 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\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) {
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>';;

View File

@ -14,6 +14,10 @@ use Friendica\App;
use Friendica\Core\Renderer;
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) {
Renderer::setActiveTemplateEngine('smarty3');

View File

@ -23,16 +23,16 @@ use Friendica\Core\Logger;
use Friendica\DI;
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::config()->get('vier', 'style');
}
if (empty($style)) {
$style = "plus";
$style = DI::pConfig()->get($uid, 'vier', 'style', DI::config()->get('vier', 'style', $style));
}
$stylecss = '';

View File

@ -19,6 +19,10 @@ use Friendica\DI;
use Friendica\Model\Contact;
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)
{
$a->setThemeInfoValue('events_in_profile', false);
@ -27,7 +31,12 @@ function vier_init(App $a)
$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();