NOW MANAGED ON CODEBERG
Licensing: Added links and tests for new licenses endpoint
Dan Browna2fd80954bfd
diff --git a/app/App/MetaController.php b/app/App/MetaController.phpindex 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.jsindex 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.phpindex 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.mdindex 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 filediff --git a/resources/views/help/licenses.blade.php b/resources/views/help/licenses.blade.phpindex a87d9e958..1eb293523 100644--- a/resources/views/help/licenses.blade.php+++ b/resources/views/help/licenses.blade.php@@ -7,39 +7,36 @@<div class="my-l"> </div><div class="card content-wrap auto-height">- <h1 class="list-heading">Licenses</h1>- <p>- 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.- </p>+ <h1 class="list-heading">{{ trans('settings.licenses') }}</h1>+ <p>{{ trans('settings.licenses_desc') }}</p><ul>- <li><a href="#bookstack-license">BookStack License</a></li>- <li><a href="#php-lib-licenses">PHP Library Licenses</a></li>- <li><a href="#js-lib-licenses">JavaScript Library Licenses</a></li>- <li><a href="#js-lib-licenses">Other Licenses</a></li>+ <li><a href="#bookstack-license">{{ trans('settings.licenses_bookstack') }}</a></li>+ <li><a href="#php-lib-licenses">{{ trans('settings.licenses_php') }}</a></li>+ <li><a href="#js-lib-licenses">{{ trans('settings.licenses_js') }}</a></li>+ <li><a href="#other-licenses">{{ trans('settings.licenses_other') }}</a></li></ul></div><div id="bookstack-license" class="card content-wrap auto-height">- <h3 class="list-heading">BookStack License</h3>+ <h3 class="list-heading">{{ trans('settings.licenses_bookstack') }}</h3><div style="white-space: pre-wrap;" class="mb-m">{{ $license }}</div><p>BookStack® is a UK registered trade mark of Daniel Brown. </p></div><div id="php-lib-licenses" class="card content-wrap auto-height">- <h3 class="list-heading">PHP Library Licenses</h3>+ <h3 class="list-heading">{{ trans('settings.licenses_php') }}</h3><div style="white-space: pre-wrap;">{{ $phpLibData }}</div></div><div id="js-lib-licenses" class="card content-wrap auto-height">- <h3 class="list-heading">JavaScript Library Licenses</h3>+ <h3 class="list-heading">{{ trans('settings.licenses_js') }}</h3><div style="white-space: pre-wrap;">{{ $jsLibData }}</div></div><div id="other-licenses" class="card content-wrap auto-height">- <h3 class="list-heading">Other Licenses</h3>+ <h3 class="list-heading">{{ trans('settings.licenses_other') }}</h3><div style="white-space: pre-line;">BookStack makes heavy use of PHP:License: PHP License, version 3.01License File: https://www.php.net/license/3_01.txtdiff --git a/resources/views/settings/layout.blade.php b/resources/views/settings/layout.blade.phpindex 94a8f7725..a59b58d53 100644--- a/resources/views/settings/layout.blade.php+++ b/resources/views/settings/layout.blade.php@@ -18,8 +18,10 @@<h5 class="mt-xl">{{ trans('settings.system_version') }}</h5><div class="py-xs"><a target="_blank" rel="noopener noreferrer" href="https://github.com/BookStackApp/BookStack/releases">- BookStack @if(strpos($version, 'v') !== 0) version @endif {{ $version }}+ BookStack @if(!str_starts_with($version, 'v')) version @endif {{ $version }}</a>+ <br>+ <a target="_blank" href="{{ url('/licenses') }}" class="text-muted">{{ trans('settings.license_details') }}</a></div></div>diff --git a/tests/LicensesTest.php b/tests/LicensesTest.phpnew file mode 100644index 000000000..a7fb803c0--- /dev/null+++ b/tests/LicensesTest.php@@ -0,0 +1,24 @@+<?php++namespace Tests;++class LicensesTest extends TestCase+{+ public function test_licenses_endpoint()+ {+ $resp = $this->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');+ }+}