Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ankündigung auch während des Wartungsmodus sichtbar halten, Vorschau-Modus #107

Merged
merged 8 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions assets/css/maintenance-frontend.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
html, body {
height: 100%;
background-color: #f7f7f7;
}
body {
display: flex;
align-items: center;
}
.maintenance-container {
max-width: 500px;
min-width: 300px;
width: 50%;
margin: 0 auto;
color: #999;
font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
font-size: 15px;
line-height: 1.5;
text-align: center;
}
.maintenance-error a {
color: #666;
}
.maintenance-error a:hover {
color: #111;
}
.maintenance-error-title {
margin: 0;
font-size: 40px;
font-weight: 700;
color: #5b98d7;
text-shadow: 0 4px 2px rgba(255, 255, 255, 1);
line-height: 1.2em;
}
.maintenance-error-message {
padding: 0 20px;
}

.maintenance-login a {
color: #666;
}
.maintenance-login a:hover {
color: #111;
}
.maintenance-login-title {
margin: 0;
font-size: 40px;
font-weight: 700;
color: #5b98d7;
text-shadow: 0 4px 2px rgba(255, 255, 255, 1);
line-height: 1.2em;
}
.maintenance-login-message {
padding: 0 20px;
}

.maintenance-pw-input {
margin: 1em 1em 1em 1em;
padding: 1em 2em 1em 1em;
background: rgba(255,255,255,1);
border-radius: 30px;
border: none;
font-size: 1em;
}

.maintenance-pw-btn {
margin: 1em 1em 1em 1em;
padding: 1em 1em 1em 1em;
background: #5b98d7;
border-radius: 10px;
color: #ffffff;
border: none;
font-size: 1em;
cursor: pointer;
}

.maintenance-btn {
display: inline-block;
text-decoration: none;
margin: 1em 1em 1em 1em;
padding: 1em 1em 1em 1em;
background: #5b98d7;
border-radius: 10px;
color: #ffffff;
border: none;
font-size: 1em;
}
12 changes: 12 additions & 0 deletions fragments/maintenance/announcement.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
$announcement = rex_config::get('maintenance', 'announcement', '');

Check warning on line 2 in fragments/maintenance/announcement.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'rex_config'
$start_date = rex_config::get('maintenance', 'announcement_start_date');

Check warning on line 3 in fragments/maintenance/announcement.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'rex_config'
$end_date = rex_config::get('maintenance', 'announcement_end_date');

Check warning on line 4 in fragments/maintenance/announcement.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'rex_config'
$current_date = date('Y-m-d H:i:s');

if ($announcement !== '' && $start_date <= $current_date && $end_date >= $current_date) {
?>
<div class="maintenance-announcement">
<?php echo $announcement; ?>
</div>
<?php } ?>
53 changes: 11 additions & 42 deletions fragments/maintenance/frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,22 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Maintenance</title>
<style type="text/css">
html, body {
height: 100%;
background-color: #f7f7f7;
}
body {
display: flex;
align-items: center;
}
.maintenance-container {
max-width: 500px;
min-width: 300px;
width: 50%;
margin: 0 auto;
color: #999;
font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
font-size: 15px;
line-height: 1.5;
text-align: center;
}
.maintenance-error a {
color: #666;
}
.maintenance-error a:hover {
color: #111;
}
.maintenance-error-title {
margin: 0;
font-size: 40px;
font-weight: 700;
color: #5b98d7;
text-shadow: 0 4px 2px rgba(255, 255, 255, 1);
line-height: 1.2em;
}
.maintenance-error-message {
padding: 0 20px;
}
</style>
<title><?= rex::getServerName() ?> - Maintenance</title>

Check warning on line 6 in fragments/maintenance/frontend.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'rex'
<link rel="stylesheet" href="<?= rex_url::addonAssets('maintenance', 'css/maintenance-frontend.css') ?>" />

Check warning on line 7 in fragments/maintenance/frontend.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'rex_url'
</head>
<body>
<div class="maintenance-container">
<div class="maintenance-error">
<p class="maintenance-error-title">Maintenance<br>Wartung</p>
<p class="maintenance-error-message">This website is temporarily unavailable</p>
<p class="maintenance-error-message">Diese Website ist temporär nicht erreichbar</p>
<p class="maintenance-error-title">Maintenance / <span lang="de">Wartung</span></p>
<p class="maintenance-error-message">This website is temporarily unavailable.</p>
<p class="maintenance-error-message" lang="de">Diese Website ist vorübergehend nicht erreichbar.</p>
</div>
<?php
// Subfragment announcement.php ausgeben
echo $this->subfragment('maintenance/announcement.php');
echo $this->subfragment('maintenance/login.php');
echo $this->subfragment('maintenance/reload.php');
?>
</div>
</body>
</html>
78 changes: 0 additions & 78 deletions fragments/maintenance/frontend_password.php

This file was deleted.

10 changes: 10 additions & 0 deletions fragments/maintenance/login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
if(rex_config::get('maintenance', 'authentification_mode', '') === 'password') { ?>

Check warning on line 2 in fragments/maintenance/login.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'rex_config'
<div class="maintenance-login">
<form action="<?= rex_url::base(); ?>" method="post">

Check warning on line 4 in fragments/maintenance/login.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'rex_url'
<label for="maintenance_secret">Access-Code</label>
<input name="maintenance_secret" class="maintenance-pw-input" type="password" placeholder=""/>
<button type="submit" class="maintenance-pw-btn">Login</button>
</form>
</div>
<?php } ?>
6 changes: 6 additions & 0 deletions fragments/maintenance/reload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
// reload current frontend page html button
?>
<div class="maintenance-reload">
<a href="<?= $_SERVER['REQUEST_URI']; ?>" class="maintenance-btn">Reload</a>
</div>
3 changes: 3 additions & 0 deletions lang/de_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,6 @@ maintenance_allowed_yrewrite_domains_label = Liste erlaubter YRewrite-Domains
maintenance_allowed_yrewrite_domains_notice = YRewrite-Domains eintragen, die nicht gesperrt werden sollen.

maintenance_copy_url_title = URL kopieren

maintenance_preview_title = Vorschau
maintenance_preview = Vorschau in neuem Fenster anzeigen
4 changes: 1 addition & 3 deletions lib/Maintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,7 @@ public static function checkFrontend(): void
$responsecode = strval($addon->getConfig('http_response_code')); // @phpstan-ignore-line

$mpage = new rex_fragment();
if (strval($addon->getConfig('authentification_mode')) === 'password') { // @phpstan-ignore-line
exit($mpage->parse('maintenance/frontend_password.php'));
} elseif ($redirect_url !== '') {
if ($redirect_url !== '') {
rex_response::setStatus(rex_response::HTTP_MOVED_TEMPORARILY);
rex_response::sendRedirect($redirect_url);
}
Expand Down
4 changes: 4 additions & 0 deletions package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ page:
backend:
title: translate:maintenance_backend_title
icon: rex-icon fa-user-gear
preview:
title: translate:maintenance_preview_title
icon: rex-icon fa-eye
hidden: true
help:
title: translate:maintenance_docs_title
subPath: README.md
Expand Down
10 changes: 10 additions & 0 deletions pages/frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,16 @@


<?php
/* Vorschau des Wartungsmodus */
$preview = '<a target="_blank" href="' . rex_url::backendPage('maintenance/preview') . '" class="btn btn-primary">' . rex_i18n::msg('maintenance_preview') . '</a>';

Check warning on line 140 in pages/frontend.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'rex_url'

Check warning on line 140 in pages/frontend.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'rex_i18n'

$fragment = new rex_fragment();
$fragment->setVar('class', 'info', false);
$fragment->setVar('title', rex_i18n::msg('maintenance_preview_title'), false);

Check warning on line 144 in pages/frontend.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'rex_i18n'
$fragment->setVar('body', $preview, false);
echo $fragment->parse('core/page/section.php');

/* Kopieren der URL für den Wartungsmodus */
$copy = '<ul class="list-group">';
$url = '' . rex::getServer() . '?maintenance_secret=' . rex_config::get('maintenance', 'maintenance_secret');
$copy .= '<li class="list-group-item"><label for="maintenance-mode-url">REDAXO config.yml</label>
Expand Down Expand Up @@ -172,6 +181,7 @@
$fragment->setVar('title', rex_i18n::msg('maintenance_copy_url_title'), false);
$fragment->setVar('body', $copy, false);
echo $fragment->parse('core/page/section.php');

?>
</div>
</div>
7 changes: 7 additions & 0 deletions pages/preview.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

ob_clean();

$fragment = new rex_fragment();

Check warning on line 5 in pages/preview.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'rex_fragment'
echo $fragment->parse('maintenance/frontend.php');
exit;
Loading