Licensing: Added links and tests for new licenses endpoint

For #4907
This commit is contained in:
Dan Brown 2024-03-23 22:04:18 +00:00
parent 0c524c7c8f
commit a2fd80954b
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
7 changed files with 52 additions and 15 deletions

View File

@ -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')),

View File

@ -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));

View File

@ -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.

View File

@ -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.

View File

@ -7,39 +7,36 @@
<div class="my-l">&nbsp;</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.01
License File: https://www.php.net/license/3_01.txt

View File

@ -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>

24
tests/LicensesTest.php Normal file
View File

@ -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');
}
}