diff --git a/app/Config/Autoload.php b/app/Config/Autoload.php index f314d3d2..1b4bab55 100644 --- a/app/Config/Autoload.php +++ b/app/Config/Autoload.php @@ -48,6 +48,7 @@ class Autoload extends AutoloadConfig 'Modules\Auth' => ROOTPATH . 'modules/Auth/', 'Modules\Analytics' => ROOTPATH . 'modules/Analytics/', 'Modules\Install' => ROOTPATH . 'modules/Install/', + 'Modules\Update' => ROOTPATH . 'modules/Update/', 'Modules\Fediverse' => ROOTPATH . 'modules/Fediverse/', 'Modules\WebSub' => ROOTPATH . 'modules/WebSub/', 'Modules\Api\Rest\V1' => ROOTPATH . 'modules/Api/Rest/V1', diff --git a/app/Database/Migrations/2023-04-09-110000_testing_update.php b/app/Database/Migrations/2023-04-09-110000_testing_update.php new file mode 100644 index 00000000..44681198 --- /dev/null +++ b/app/Database/Migrations/2023-04-09-110000_testing_update.php @@ -0,0 +1,35 @@ +forge->addColumn('podcasts', [ + 'cool_update' => [ + 'type' => 'INT', + 'unsigned' => true, + 'null' => true, + 'after' => 'custom_rss', + ], + ]); + } + + public function down(): void + { + $this->forge->dropColumn('podcasts', 'cool_update'); + } +} diff --git a/app/Resources/icons/information.svg b/app/Resources/icons/information.svg new file mode 100644 index 00000000..39f02fbd --- /dev/null +++ b/app/Resources/icons/information.svg @@ -0,0 +1,4 @@ + + + + diff --git a/docs/src/getting-started/update.md b/docs/src/getting-started/update.md index 1f48e274..98e019fb 100644 --- a/docs/src/getting-started/update.md +++ b/docs/src/getting-started/update.md @@ -9,11 +9,13 @@ After installing Castopod, you may want to update your instance to the latest version in order to enjoy the latest features ✨, bug fixes 🐛 and performance improvements ⚡. -## Automatic update instructions +## Update instructions -> Coming soon... 👀 +0. ⚠️ Before any update, we highly recommend you backup your Castopod files and + database. -## Manual update instructions + - cf. + [Should I make a backup before updating?](#should-i-make-a-backup-before-updating) 1. Go to the [releases page](https://code.castopod.org/adaures/castopod/-/releases) and @@ -26,6 +28,8 @@ improvements ⚡. between the `zip` or `tar.gz` archives - ⚠️ Make sure you download the Castopod Package and **NOT** the Source Code + - Note that you can also download the latest package from + [castopod.org](https://castopod.org/) 3. On your server: @@ -39,19 +43,31 @@ improvements ⚡. ::: -4. Releases may come with additional update instructions (see - [releases page](https://code.castopod.org/adaures/castopod/-/releases)). They - are usually database migration scripts in `.sql` format to update your - database schema. +4. Update your database schema from your `Castopod Admin` > `About` page or by + running: - - 👉 Make sure you run the scripts on your phpmyadmin panel or using command - line to update the database along with the package files! - - cf. - [I haven't updated my instance in a long time… What should I do?](#i-havent-updated-my-instance-in-a-long-time-what-should-i-do) + ```bash + php spark castopod:database-update + ``` -5. If you are using redis, clear your cache. +5. Clear your cache from your `Castopod Admin` > `Settings` > `general` > + `Housekeeping` 6. ✨ Enjoy your fresh instance, you're all done! +::: info Note + +Releases may come with additional update instructions (see +[releases page](https://code.castopod.org/adaures/castopod/-/releases)). + +- cf. + [I haven't updated my instance in a long time… What should I do?](#i-havent-updated-my-instance-in-a-long-time-what-should-i-do) + +::: + +## Fully Automated updates + +> Coming soon... 👀 + ## Frequently asked questions (FAQ) ### Where can I find my Castopod version? diff --git a/modules/Admin/Config/Routes.php b/modules/Admin/Config/Routes.php index 7bf22166..586272ea 100644 --- a/modules/Admin/Config/Routes.php +++ b/modules/Admin/Config/Routes.php @@ -644,5 +644,15 @@ $routes->group( ]); }); }); + + $routes->get('about', 'AboutController', [ + 'as' => 'admin-about', + 'filter' => 'permission:admin.settings', + ]); + + $routes->post('update', 'AboutController::updateAction', [ + 'as' => 'update', + 'filter' => 'permission:admin.settings', + ]); }, ); diff --git a/modules/Admin/Controllers/AboutController.php b/modules/Admin/Controllers/AboutController.php new file mode 100644 index 00000000..02be5c9e --- /dev/null +++ b/modules/Admin/Controllers/AboutController.php @@ -0,0 +1,67 @@ + current_domain(), + 'version' => CP_VERSION, + 'php_version' => PHP_VERSION, + 'os' => PHP_OS, + 'languages' => implode(', ', config('App')->supportedLocales), + ]; + + return view('about', [ + 'info' => $instanceInfo, + ]); + } + + public function updateAction(): RedirectResponse + { + if ($this->request->getPost('action') === 'database') { + return $this->migrateDatabase(); + } + + return redirect()->back() + ->with('error', lang('Security.disallowedAction')); + } + + public function migrateDatabase(): RedirectResponse + { + $migrate = Services::migrations(); + + $migrate->setNamespace('CodeIgniter\Settings') + ->latest(); + $migrate->setNamespace('CodeIgniter\Shield') + ->latest(); + $migrate->setNamespace('Modules\Fediverse') + ->latest(); + $migrate->setNamespace(APP_NAMESPACE) + ->latest(); + $migrate->setNamespace('Modules\WebSub') + ->latest(); + $migrate->setNamespace('Modules\Auth') + ->latest(); + $migrate->setNamespace('Modules\PremiumPodcasts') + ->latest(); + $migrate->setNamespace('Modules\Analytics') + ->latest(); + + return redirect()->back() + ->with('message', lang('AboutCastopod.messages.databaseUpdateSuccess')); + } +} diff --git a/modules/Admin/Language/en/AboutCastopod.php b/modules/Admin/Language/en/AboutCastopod.php new file mode 100644 index 00000000..3fb62aff --- /dev/null +++ b/modules/Admin/Language/en/AboutCastopod.php @@ -0,0 +1,22 @@ + 'About Castopod', + 'host_name' => 'Host name', + 'version' => 'Castopod version', + 'php_version' => 'PHP version', + 'os' => 'Operating System', + 'languages' => 'Languages', + 'update_database' => 'Update database', + 'messages' => [ + 'databaseUpdateSuccess' => 'Database is up to date!', + ], +]; diff --git a/modules/Admin/Language/en/Breadcrumb.php b/modules/Admin/Language/en/Breadcrumb.php index 823ccd65..b1742abf 100644 --- a/modules/Admin/Language/en/Breadcrumb.php +++ b/modules/Admin/Language/en/Breadcrumb.php @@ -19,6 +19,7 @@ return [ 'pages' => 'pages', 'settings' => 'settings', 'theme' => 'theme', + 'about' => 'about', 'add' => 'add', 'new' => 'new', 'edit' => 'edit', diff --git a/modules/Admin/Language/en/Navigation.php b/modules/Admin/Language/en/Navigation.php index 68d4609d..610f1434 100644 --- a/modules/Admin/Language/en/Navigation.php +++ b/modules/Admin/Language/en/Navigation.php @@ -33,6 +33,7 @@ return [ 'settings' => 'Settings', 'settings-general' => 'General', 'settings-theme' => 'Theme', + 'about' => 'About', 'account' => [ 'my-account' => 'My account', 'change-password' => 'Change password', diff --git a/modules/Update/Commands/DatabaseUpdate.php b/modules/Update/Commands/DatabaseUpdate.php new file mode 100644 index 00000000..70a3ad01 --- /dev/null +++ b/modules/Update/Commands/DatabaseUpdate.php @@ -0,0 +1,32 @@ +call('migrate', [ + 'all' => true, + ]); + } +} diff --git a/themes/cp_admin/_sidebar.php b/themes/cp_admin/_sidebar.php index f557e5e9..af545250 100644 --- a/themes/cp_admin/_sidebar.php +++ b/themes/cp_admin/_sidebar.php @@ -53,4 +53,8 @@ $navigation = [ + + + + diff --git a/themes/cp_admin/about.php b/themes/cp_admin/about.php new file mode 100644 index 00000000..8df341bf --- /dev/null +++ b/themes/cp_admin/about.php @@ -0,0 +1,35 @@ +extend('_layout') ?> + +section('title') ?> + +endSection() ?> + +section('pageTitle') ?> + +endSection() ?> + +section('content') ?> + +
+ + +
+ + $value): ?> +
+
+ +
+
+ +
+
+ + +endSection() ?> diff --git a/themes/cp_install/_layout.php b/themes/cp_install/_layout.php index 6d35f502..1065c588 100644 --- a/themes/cp_install/_layout.php +++ b/themes/cp_install/_layout.php @@ -6,8 +6,8 @@ - Castopod Install - + <?= lang('Install.title') ?> +