From a2fd80954bfd0b2a98d54b9ad2c68628cd1e2b1c Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Sat, 23 Mar 2024 22:04:18 +0000 Subject: [PATCH] Licensing: Added links and tests for new licenses endpoint For #4907 --- app/App/MetaController.php | 2 +- dev/build/esbuild.js | 4 ++++ lang/en/settings.php | 8 ++++++++ readme.md | 2 ++ resources/views/help/licenses.blade.php | 23 ++++++++++------------ resources/views/settings/layout.blade.php | 4 +++- tests/LicensesTest.php | 24 +++++++++++++++++++++++ 7 files changed, 52 insertions(+), 15 deletions(-) create mode 100644 tests/LicensesTest.php diff --git a/app/App/MetaController.php b/app/App/MetaController.php index 3d3a8d2c8..1515b4f7e 100644 --- a/app/App/MetaController.php +++ b/app/App/MetaController.php @@ -56,7 +56,7 @@ class MetaController extends Controller */ public function licenses() { - $this->setPageTitle('Licenses'); + $this->setPageTitle(trans('settings.licenses')); return view('help.licenses', [ 'license' => file_get_contents(base_path('LICENSE')), diff --git a/dev/build/esbuild.js b/dev/build/esbuild.js index c47727c2c..53fbf0189 100644 --- a/dev/build/esbuild.js +++ b/dev/build/esbuild.js @@ -30,6 +30,10 @@ esbuild.build({ format: 'esm', minify: isProd, logLevel: 'info', + banner: { + js: '// See the "/licenses" URI for full package license details', + css: '/* See the "/licenses" URI for full package license details */', + }, }).then(result => { fs.writeFileSync('esbuild-meta.json', JSON.stringify(result.metafile)); }).catch(() => process.exit(1)); diff --git a/lang/en/settings.php b/lang/en/settings.php index 7b7f5d2a2..f4c84092c 100644 --- a/lang/en/settings.php +++ b/lang/en/settings.php @@ -276,6 +276,14 @@ return [ 'webhooks_last_errored' => 'Last Errored:', 'webhooks_last_error_message' => 'Last Error Message:', + // Licensing + 'licenses' => 'Licenses', + 'licenses_desc' => 'This page details license information for BookStack in addition to the projects & libraries that are used within BookStack. Many projects listed may only be used in a development context.', + 'licenses_bookstack' => 'BookStack License', + 'licenses_php' => 'PHP Library Licenses', + 'licenses_js' => 'JavaScript Library Licenses', + 'licenses_other' => 'Other Licenses', + 'license_details' => 'License Details', //! If editing translations files directly please ignore this in all //! languages apart from en. Content will be auto-copied from en. diff --git a/readme.md b/readme.md index 5457ddfb5..17e1a05f6 100644 --- a/readme.md +++ b/readme.md @@ -158,3 +158,5 @@ Note: This is not an exhaustive list of all libraries and projects that would be * [PHPStan](https://phpstan.org/) & [Larastan](https://github.com/nunomaduro/larastan) - _[MIT](https://github.com/phpstan/phpstan/blob/master/LICENSE) and [MIT](https://github.com/nunomaduro/larastan/blob/master/LICENSE.md)_ * [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) - _[BSD 3-Clause](https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt)_ * [JakeArchibald/IDB-Keyval](https://github.com/jakearchibald/idb-keyval) - _[Apache-2.0](https://github.com/jakearchibald/idb-keyval/blob/main/LICENCE)_ + +For a detailed breakdown of the JavaScript & PHP projects imported & used via NPM & composer package managers, along with their licenses, please see the [dev/licensing/js-library-licenses.txt](dev/licensing/js-library-licenses.txt) and [dev/licensing/php-library-licenses.txt](dev/licensing/php-library-licenses.txt) files. \ No newline at end of file diff --git a/resources/views/help/licenses.blade.php b/resources/views/help/licenses.blade.php index a87d9e958..1eb293523 100644 --- a/resources/views/help/licenses.blade.php +++ b/resources/views/help/licenses.blade.php @@ -7,39 +7,36 @@
 
-

Licenses

-

- This page details license information for BookStack in addition to the projects & libraries that are used within BookStack. - Many projects listed may only be used in a development context. -

+

{{ trans('settings.licenses') }}

+

{{ trans('settings.licenses_desc') }}

-

BookStack License

+

{{ trans('settings.licenses_bookstack') }}

{{ $license }}

BookStack® is a UK registered trade mark of Daniel Brown.

-

PHP Library Licenses

+

{{ trans('settings.licenses_php') }}

{{ $phpLibData }}
-

JavaScript Library Licenses

+

{{ trans('settings.licenses_js') }}

{{ $jsLibData }}
-

Other Licenses

+

{{ trans('settings.licenses_other') }}

BookStack makes heavy use of PHP: License: PHP License, version 3.01 License File: https://www.php.net/license/3_01.txt diff --git a/resources/views/settings/layout.blade.php b/resources/views/settings/layout.blade.php index 94a8f7725..a59b58d53 100644 --- a/resources/views/settings/layout.blade.php +++ b/resources/views/settings/layout.blade.php @@ -18,8 +18,10 @@
{{ trans('settings.system_version') }}
diff --git a/tests/LicensesTest.php b/tests/LicensesTest.php new file mode 100644 index 000000000..a7fb803c0 --- /dev/null +++ b/tests/LicensesTest.php @@ -0,0 +1,24 @@ +get('/licenses'); + $resp->assertOk(); + $resp->assertSee('Licenses'); + $resp->assertSee('PHP Library Licenses'); + $resp->assertSee('Dan Brown and the BookStack Project contributors'); + $resp->assertSee('doctrine/dbal'); + $resp->assertSee('@codemirror/lang-html'); + } + + public function test_licenses_linked_to_from_settings() + { + $resp = $this->asAdmin()->get('/settings/features'); + $html = $this->withHtml($resp); + $html->assertLinkExists(url('/licenses'), 'License Details'); + } +}