Skip to content

Commit

Permalink
Improved: update page (FreshRSS#5420)
Browse files Browse the repository at this point in the history
* prependTitle()

* do not need the "damn" in the alert

* update page layout improved

* release channel

* i18n labels

* add log messages while updating

* Delete updatee.php

* Update updateController.php

* Update updateController.php

* Update updateController.php

* Update updateController.php

* add getCurrentGitBranch()

* Update updateController.php

* state2 buttons

* i18n

* loading

* Update feedback.php

* Update feedback.php

* Update feedback.php

* Update extra.js

* Apply suggestions from code review

Co-authored-by: Luc SANCHEZ <4697568+ColonelMoutarde@users.noreply.github.com>

* Update updateController.php

* Update terminology

* update button is now armed

---------

Co-authored-by: Luc SANCHEZ <4697568+ColonelMoutarde@users.noreply.github.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
  • Loading branch information
3 people committed Jul 4, 2023
1 parent cfb30d2 commit 6ec544e
Show file tree
Hide file tree
Showing 36 changed files with 346 additions and 47 deletions.
34 changes: 29 additions & 5 deletions app/Controllers/updateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ public static function migrateToGitEdge(): bool {
return true;
}

public static function getCurrentGitBranch(): string {
$output = [];
exec('git branch --show-current', $output, $return);
if ($return === 0) {
return 'git branch: ' . $output[0];
} else {
return 'git';
}
}

public static function hasGitUpdate(): bool {
$cwd = getcwd();
if ($cwd === false) {
Expand Down Expand Up @@ -72,6 +82,7 @@ public static function hasGitUpdate(): bool {

/** @return string|true */
public static function gitPull() {
Minz_Log::notice(_t('admin.update.viaGit'));
$cwd = getcwd();
if ($cwd === false) {
Minz_Log::warning('getcwd() failed');
Expand Down Expand Up @@ -110,6 +121,8 @@ public function firstAction(): void {

invalidateHttpCache();

$this->view->is_release_channel_stable = $this->is_release_channel_stable(FRESHRSS_VERSION);

$this->view->update_to_apply = false;
$this->view->last_update_time = 'unknown';
$timestamp = @filemtime(join_path(DATA_PATH, self::LASTUPDATEFILE));
Expand Down Expand Up @@ -144,7 +157,17 @@ public function indexAction(): void {
}
}

private function is_release_channel_stable(string $currentVersion): bool {
return strpos($currentVersion, 'dev') === false &&
strpos($currentVersion, 'edge') === false;
}

/* Check installation if there is a newer version.
via Git, if available.
Else via system configuration auto_update_url
*/
public function checkAction(): void {
FreshRSS_View::prependTitle(_t('admin.update.title') . ' · ');
$this->view->_path('update/index.phtml');

if (file_exists(UPDATE_FILENAME)) {
Expand All @@ -160,11 +183,10 @@ public function checkAction(): void {

if (self::isGit()) {
if (self::hasGitUpdate()) {
$version = 'git';
$version = self::getCurrentGitBranch();
} else {
$this->view->message = array(
'status' => 'latest',
'title' => _t('gen.short.damn'),
'body' => _t('feedback.update.none')
);
@touch(join_path(DATA_PATH, self::LASTUPDATEFILE));
Expand Down Expand Up @@ -199,7 +221,6 @@ public function checkAction(): void {

$this->view->message = array(
'status' => 'bad',
'title' => _t('gen.short.damn'),
'body' => _t('feedback.update.server_not_found', $auto_update_url)
);
return;
Expand All @@ -210,7 +231,6 @@ public function checkAction(): void {
if (strpos($status, 'UPDATE') !== 0) {
$this->view->message = array(
'status' => 'latest',
'title' => _t('gen.short.damn'),
'body' => _t('feedback.update.none')
);
@touch(join_path(DATA_PATH, self::LASTUPDATEFILE));
Expand All @@ -220,6 +240,8 @@ public function checkAction(): void {
$script = $res_array[1];
$version = explode(' ', $status, 2);
$version = $version[1];

Minz_Log::notice(_t('admin.update.copiedFromURL', $auto_update_url));
}

if (file_put_contents(UPDATE_FILENAME, $script) !== false) {
Expand All @@ -228,7 +250,6 @@ public function checkAction(): void {
} else {
$this->view->message = array(
'status' => 'bad',
'title' => _t('gen.short.damn'),
'body' => _t('feedback.update.error', 'Cannot save the update script')
);
}
Expand All @@ -253,8 +274,10 @@ public function applyAction(): void {
if ($res === true) {
@unlink(UPDATE_FILENAME);
@file_put_contents(join_path(DATA_PATH, self::LASTUPDATEFILE), '');
Minz_Log::notice(_t('feedback.update.finished'));
Minz_Request::good(_t('feedback.update.finished'));
} else {
Minz_Log::error(_t('feedback.update.error', $res));
Minz_Request::bad(_t('feedback.update.error', $res), [ 'c' => 'update', 'a' => 'index' ]);
}
} else {
Expand Down Expand Up @@ -288,6 +311,7 @@ public function applyAction(): void {
'params' => array('post_conf' => '1')
), true);
} else {
Minz_Log::error(_t('feedback.update.error', $res));
Minz_Request::bad(_t('feedback.update.error', $res), [ 'c' => 'update', 'a' => 'index' ]);
}
}
Expand Down
2 changes: 2 additions & 0 deletions app/Models/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class FreshRSS_View extends Minz_View {
public $update_to_apply;
/** @var array<string,bool> */
public $status_database;
/** @var bool */
public $is_release_channel_stable;

// Archiving
/** @var int */
Expand Down
9 changes: 9 additions & 0 deletions app/i18n/cz/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,20 @@
'update' => array(
'_' => 'Aktualizace systému',
'apply' => 'Použít',
'changelog' => 'Changelog', // TODO
'check' => 'Zkontrolovat aktualizace',
'copiedFromURL' => 'update.php copied from %s to ./data', // TODO
'current_version' => 'Vaše aktuální verze FreshRSS je %s.',
'last' => 'Poslední kontrola: %s',
'loading' => 'Updating…', // TODO
'none' => 'Žádné nové aktualizace',
'releaseChannel' => array(
'_' => 'Release channel', // TODO
'edge' => 'Rolling release (“edge”)', // TODO
'latest' => 'Stable release (“latest”)', // TODO
),
'title' => 'Aktualizovat systém',
'viaGit' => 'Update via git and Github.com started', // TODO
),
'user' => array(
'admin' => 'Administrátor',
Expand Down
9 changes: 9 additions & 0 deletions app/i18n/de/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,20 @@
'update' => array(
'_' => 'System aktualisieren',
'apply' => 'Anwenden',
'changelog' => 'Changelog', // TODO
'check' => 'Auf neue Aktualisierungen prüfen',
'copiedFromURL' => 'update.php copied from %s to ./data', // TODO
'current_version' => 'Ihre aktuelle Version von FreshRSS ist %s.',
'last' => 'Letzte Überprüfung: %s',
'loading' => 'Updating…', // TODO
'none' => 'Keine ausstehende Aktualisierung',
'releaseChannel' => array(
'_' => 'Release channel', // TODO
'edge' => 'Rolling release (“edge”)', // TODO
'latest' => 'Stable release (“latest”)', // TODO
),
'title' => 'System aktualisieren',
'viaGit' => 'Update via git and Github.com started', // TODO
),
'user' => array(
'admin' => 'Administrator', // IGNORE
Expand Down
9 changes: 9 additions & 0 deletions app/i18n/el/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,20 @@
'update' => array(
'_' => 'Ενημέρωση συστήματος',
'apply' => 'Εφαρμογή',
'changelog' => 'Changelog', // TODO
'check' => 'Έλεγχος για νέες ενημερώσεις',
'copiedFromURL' => 'update.php copied from %s to ./data', // TODO
'current_version' => 'Η τρέχουσα έκδοση του FreshRSS είναι %s.',
'last' => 'Τελευταία επαλήθευση: %s',
'loading' => 'Updating…', // TODO
'none' => 'Δεν υπάρχουν ενημερώσεις',
'releaseChannel' => array(
'_' => 'Release channel', // TODO
'edge' => 'Rolling release (“edge”)', // TODO
'latest' => 'Stable release (“latest”)', // TODO
),
'title' => 'Ενημέρωση συστήματος',
'viaGit' => 'Update via git and Github.com started', // TODO
),
'user' => array(
'admin' => 'Διαχειριστής',
Expand Down
6 changes: 3 additions & 3 deletions app/i18n/el/feedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@
'renamed' => 'Label “%s” has been renamed to “%s”.', // TODO
),
'update' => array(
'can_apply' => 'FreshRSS will now be updated to the <strong>version %s</strong>.', // TODO
'can_apply' => 'FreshRSS will now be updated to the <strong>version %s</strong>.', // DIRTY
'error' => 'The update process has encountered an error: %s', // TODO
'file_is_nok' => 'New <strong>version %s</strong> available, but check permissions on <em>%s</em> directory. HTTP server must have have write permission', // TODO
'file_is_nok' => 'New <strong>version %s</strong> available, but check permissions on <em>%s</em> directory. HTTP server must have have write permission', // DIRTY
'finished' => 'Update complete!', // TODO
'none' => 'No update to apply', // TODO
'none' => 'No update to apply', // DIRTY
'server_not_found' => 'Update server cannot be found. [%s]', // TODO
),
'user' => array(
Expand Down
9 changes: 9 additions & 0 deletions app/i18n/en-us/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,20 @@
'update' => array(
'_' => 'Update system', // IGNORE
'apply' => 'Apply', // IGNORE
'changelog' => 'Changelog', // IGNORE
'check' => 'Check for new updates', // IGNORE
'copiedFromURL' => 'update.php copied from %s to ./data', // IGNORE
'current_version' => 'Your current version of FreshRSS is %s.', // IGNORE
'last' => 'Last verification: %s', // IGNORE
'loading' => 'Updating…', // IGNORE
'none' => 'No update to apply', // IGNORE
'releaseChannel' => array(
'_' => 'Release channel', // IGNORE
'edge' => 'Rolling release (“edge”)', // IGNORE
'latest' => 'Stable release (“latest”)', // IGNORE
),
'title' => 'Update system', // IGNORE
'viaGit' => 'Update via git and Github.com started', // IGNORE
),
'user' => array(
'admin' => 'Administrator', // IGNORE
Expand Down
2 changes: 1 addition & 1 deletion app/i18n/en-us/gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
'clipboard' => 'Clipboard', // IGNORE
'diaspora' => 'Diaspora*', // IGNORE
'email' => 'Email', // IGNORE
'email-webmail-firefox-fix' => 'Email (webmail - fix for Firefox)', // TODO
'email-webmail-firefox-fix' => 'Email (webmail - fix for Firefox)', // IGNORE
'facebook' => 'Facebook', // IGNORE
'gnusocial' => 'GNU social', // IGNORE
'jdh' => 'Journal du hacker', // IGNORE
Expand Down
27 changes: 18 additions & 9 deletions app/i18n/en/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,19 +184,28 @@
'title' => 'User registration form',
),
'tos' => array(
'disabled' => 'is not given', // TODO
'enabled' => '<a href="./?a=tos">is enabled</a>', // TODO
'help' => 'How to <a href="https://freshrss.github.io/FreshRSS/en/admins/12_User_management.html#enable-terms-of-service-tos" target="_blank">enable the Terms of Service</a>', // TODO
'disabled' => 'is not given',
'enabled' => '<a href="./?a=tos">is enabled</a>',
'help' => 'How to <a href="https://freshrss.github.io/FreshRSS/en/admins/12_User_management.html#enable-terms-of-service-tos" target="_blank">enable the Terms of Service</a>',
),
),
'update' => array(
'_' => 'Update system',
'apply' => 'Apply',
'_' => 'Update FreshRSS',
'apply' => 'Start update',
'changelog' => 'Changelog',
'check' => 'Check for new updates',
'current_version' => 'Your current version of FreshRSS is %s.',
'last' => 'Last verification: %s',
'none' => 'No update to apply',
'title' => 'Update system',
'copiedFromURL' => 'update.php copied from %s to ./data',
'current_version' => 'Current installed version',
'last' => 'Last check',
'loading' => 'Updating…',
'none' => 'No update available',
'releaseChannel' => array(
'_' => 'Release channel',
'edge' => 'Rolling release (“edge”)',
'latest' => 'Stable release (“latest”)',
),
'title' => 'Update FreshRSS',
'viaGit' => 'Update via git and Github.com started',
),
'user' => array(
'admin' => 'Administrator',
Expand Down
6 changes: 3 additions & 3 deletions app/i18n/en/conf.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
'display' => array(
'_' => 'Display',
'darkMode' => array(
'_' => 'Automatic dark mode (beta)', // TODO
'auto' => 'Auto', // TODO
'no' => 'No', // TODO
'_' => 'Automatic dark mode (beta)',
'auto' => 'Auto',
'no' => 'No',
),
'icon' => array(
'bottom_line' => 'Bottom line',
Expand Down
6 changes: 3 additions & 3 deletions app/i18n/en/feedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@
'renamed' => 'Label “%s” has been renamed to “%s”.',
),
'update' => array(
'can_apply' => 'FreshRSS will now be updated to the <strong>version %s</strong>.',
'can_apply' => 'An update of FreshRSS is available: <strong>Version %s</strong>.',
'error' => 'The update process has encountered an error: %s',
'file_is_nok' => 'New <strong>version %s</strong> available, but check permissions on <em>%s</em> directory. HTTP server must have have write permission',
'file_is_nok' => 'An update of FreshRSS is available (<strong>Version %s</strong>), but check permissions on <em>%s</em> directory. HTTP server must have have write permission',
'finished' => 'Update complete!',
'none' => 'No update to apply',
'none' => 'No update available',
'server_not_found' => 'Update server cannot be found. [%s]',
),
'user' => array(
Expand Down
6 changes: 3 additions & 3 deletions app/i18n/en/gen.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
'queries' => 'User queries',
'reading' => 'Reading',
'search' => 'Search words or #tags',
'search_help' => 'See documentation for advanced <a href="https://freshrss.github.io/FreshRSS/en/users/10_filter.html#with-the-search-field" target="_blank">search parameters</a>', // TODO
'search_help' => 'See documentation for advanced <a href="https://freshrss.github.io/FreshRSS/en/users/10_filter.html#with-the-search-field" target="_blank">search parameters</a>',
'sharing' => 'Sharing',
'shortcuts' => 'Shortcuts',
'stats' => 'Statistics',
Expand All @@ -196,11 +196,11 @@
'archiveORG' => 'archive.org',
'archivePH' => 'archive.ph',
'blogotext' => 'Blogotext',
'buffer' => 'Buffer', // IGNORE
'buffer' => 'Buffer',
'clipboard' => 'Clipboard',
'diaspora' => 'Diaspora*',
'email' => 'Email',
'email-webmail-firefox-fix' => 'Email (webmail - fix for Firefox)', // TODO
'email-webmail-firefox-fix' => 'Email (webmail - fix for Firefox)',
'facebook' => 'Facebook',
'gnusocial' => 'GNU social',
'jdh' => 'Journal du hacker',
Expand Down
2 changes: 1 addition & 1 deletion app/i18n/en/sub.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
'xpath' => 'XPath for:',
),
'rss' => 'RSS / Atom (default)',
'xml_xpath' => 'XML + XPath', // TODO
'xml_xpath' => 'XML + XPath',
),
'maintenance' => array(
'clear_cache' => 'Clear cache',
Expand Down
9 changes: 9 additions & 0 deletions app/i18n/es/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,20 @@
'update' => array(
'_' => 'Actualizar sistema',
'apply' => 'Aplicar',
'changelog' => 'Changelog', // TODO
'check' => 'Buscar actualizaciones',
'copiedFromURL' => 'update.php copied from %s to ./data', // TODO
'current_version' => 'Dispones de la versión %s de FreshRSS.',
'last' => 'Última comprobación: %s',
'loading' => 'Updating…', // TODO
'none' => 'No hay actualizaciones disponibles',
'releaseChannel' => array(
'_' => 'Release channel', // TODO
'edge' => 'Rolling release (“edge”)', // TODO
'latest' => 'Stable release (“latest”)', // TODO
),
'title' => 'Actualizar sistema',
'viaGit' => 'Update via git and Github.com started', // TODO
),
'user' => array(
'admin' => 'Administrador',
Expand Down
9 changes: 9 additions & 0 deletions app/i18n/fr/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,20 @@
'update' => array(
'_' => 'Système de mise à jour',
'apply' => 'Appliquer la mise à jour',
'changelog' => 'Journal des modifications',
'check' => 'Vérifier les mises à jour',
'copiedFromURL' => 'update.php copié depuis %s vers ./data',
'current_version' => 'Votre version actuelle de FreshRSS est la %s.',
'last' => 'Dernière vérification : %s',
'loading' => 'Mise à jour en cours…',
'none' => 'Aucune mise à jour à appliquer',
'releaseChannel' => array(
'_' => 'Canal de publication',
'edge' => 'Publication continue (“edge”)',
'latest' => 'Publication stable (“latest”)',
),
'title' => 'Système de mise à jour',
'viaGit' => 'Mise à jour via git et Github.com démarrée',
),
'user' => array(
'admin' => 'Administrateur',
Expand Down
9 changes: 9 additions & 0 deletions app/i18n/he/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,20 @@
'update' => array(
'_' => 'מערכת העדכון',
'apply' => 'החלת העדכון',
'changelog' => 'Changelog', // TODO
'check' => 'בדיקת עדכונים חדשים',
'copiedFromURL' => 'update.php copied from %s to ./data', // TODO
'current_version' => 'Your current version of FreshRSS is the %s.',
'last' => 'תאריך בדיקה אחרון: %s',
'loading' => 'Updating…', // TODO
'none' => 'אין עדכון להחלה',
'releaseChannel' => array(
'_' => 'Release channel', // TODO
'edge' => 'Rolling release (“edge”)', // TODO
'latest' => 'Stable release (“latest”)', // TODO
),
'title' => 'מערכת העדכון',
'viaGit' => 'Update via git and Github.com started', // TODO
),
'user' => array(
'admin' => 'Administrator', // TODO
Expand Down
Loading

0 comments on commit 6ec544e

Please sign in to comment.