diff --git a/app/Http/Controllers/SetupController.php b/app/Http/Controllers/SetupController.php index 3d15fc77..762f2943 100644 --- a/app/Http/Controllers/SetupController.php +++ b/app/Http/Controllers/SetupController.php @@ -36,7 +36,14 @@ class SetupController extends Controller return redirect('setup/info'); } catch (\Exception $e) { - return view('setup.wizard.database'); + return view('setup.wizard.database', [ + 'host' => env('DB_HOST'), + 'port' => env('DB_PORT'), + 'username' => env('DB_USERNAME'), + 'password' => env('DB_PASSWORD'), + 'database' => env('DB_DATABASE'), + 'prefix' => env('DB_PREFIX'), + ]); } } @@ -155,8 +162,7 @@ class SetupController extends Controller $filesystem->put(storage_path('install.lock'), ''); return view('setup.wizard.finish')->with([ - 'email' => $request->input('email'), - 'password' => $request->input('password'), + 'email' => $request->input('email'), ]); } diff --git a/app/Providers/ViewServiceProvider.php b/app/Providers/ViewServiceProvider.php index 62bd9e2c..db98060c 100644 --- a/app/Providers/ViewServiceProvider.php +++ b/app/Providers/ViewServiceProvider.php @@ -3,12 +3,13 @@ namespace App\Providers; use View; +use App\Services\Webpack; use App\Http\View\Composers; use Illuminate\Support\ServiceProvider; class ViewServiceProvider extends ServiceProvider { - public function boot() + public function boot(Webpack $webpack) { View::composer(['home', '*.base', 'shared.header'], function ($view) { $view->with([ @@ -59,5 +60,16 @@ class ViewServiceProvider extends ServiceProvider .'?onload=vueRecaptchaApiLoaded&render=explicit' ); }); + + View::composer(['errors.*', 'setup.*'], function ($view) use ($webpack) { + $view->with([ + 'styles' => [ + $webpack->url('setup.css'), + ], + 'scripts' => [ + $webpack->url('language-chooser.js'), + ], + ]); + }); } } diff --git a/resources/assets/src/scripts/language-chooser.ts b/resources/assets/src/scripts/language-chooser.ts new file mode 100644 index 00000000..38dc0472 --- /dev/null +++ b/resources/assets/src/scripts/language-chooser.ts @@ -0,0 +1,6 @@ +const chooser: HTMLInputElement | null = document.querySelector('#language-chooser') +if (chooser) { + chooser.addEventListener('change', () => { + window.location.href = `?lang=${chooser.value}` + }) +} diff --git a/resources/lang/en/setup.yml b/resources/lang/en/setup.yml index a5ee0be1..6c52bc3a 100644 --- a/resources/lang/en/setup.yml +++ b/resources/lang/en/setup.yml @@ -66,10 +66,10 @@ wizard: text: To proceed with the installation, please fill this form with the details of the initial admin account. Don't worry, you can always change these settings later. admin-email: Admin Email - admin-notice: This is the UNIQUE super admin account who can GIVE or CANCEL other users' admin privilege. + admin-notice: This is the UNIQUE super admin account who can GIVE or CANCEL other users' admin privilege. nickname: Nickname password: Password - pwd-notice: Attention: You will need the password to log in. Please keep it at a secure place. + pwd-notice: 'Attention: You will need the password to log in. Please keep it at a secure place.' confirm-pwd: Confirm password site-name: Site name site-name-notice: This will be shown on every page. diff --git a/resources/lang/zh_CN/setup.yml b/resources/lang/zh_CN/setup.yml index c2e37050..d35f7f84 100644 --- a/resources/lang/zh_CN/setup.yml +++ b/resources/lang/zh_CN/setup.yml @@ -65,10 +65,10 @@ wizard: text: 你需要填写一些基本信息。无需担心填错,这些信息以后可以再次修改。 admin-email: 管理员邮箱 - admin-notice: 这是唯一的超级管理员账号,可添加或移除其他管理员。 + admin-notice: 这是唯一的超级管理员账号,可添加或移除其他管理员。 nickname: 昵称 password: 密码 - pwd-notice: 重要:你将需要此密码来登录管理皮肤站,请将其保存在安全的位置。 + pwd-notice: 重要:你将需要此密码来登录管理皮肤站,请将其保存在安全的位置。 confirm-pwd: 重复密码 site-name: 站点名称 site-name-notice: 将会显示在首页以及标题栏 diff --git a/resources/views/errors/403.blade.php b/resources/views/errors/403.blade.php deleted file mode 100644 index 4ae982b2..00000000 --- a/resources/views/errors/403.blade.php +++ /dev/null @@ -1,11 +0,0 @@ -@extends('errors.general') - -@section('title', '403 Forbidden') - -@section('content') -
@lang('errors.exception.detail', ['msg' => $exception->getMessage() ?: trans('errors.http.msg-403')])
-@endsection diff --git a/resources/views/errors/403.twig b/resources/views/errors/403.twig new file mode 100644 index 00000000..799c03ce --- /dev/null +++ b/resources/views/errors/403.twig @@ -0,0 +1,9 @@ +{% extends 'errors.base' %} + +{% block title %}403 Forbidden{% endblock %} + +{% block message %} ++ {{ trans('errors.exception.detail', {msg: exception.message ?: trans('errors.http.msg-403')}) }} +
+{% endblock %} diff --git a/resources/views/errors/404.blade.php b/resources/views/errors/404.blade.php deleted file mode 100644 index 78f779be..00000000 --- a/resources/views/errors/404.blade.php +++ /dev/null @@ -1,11 +0,0 @@ -@extends('errors.general') - -@section('title', '404 Not Found') - -@section('content') -@lang('errors.exception.detail', ['msg' => $exception->getMessage() ?: trans('errors.http.msg-404')])
-@endsection diff --git a/resources/views/errors/404.twig b/resources/views/errors/404.twig new file mode 100644 index 00000000..e3ecce88 --- /dev/null +++ b/resources/views/errors/404.twig @@ -0,0 +1,9 @@ +{% extends 'errors.base' %} + +{% block title %}404 Not Found{% endblock %} + +{% block message %} ++ {{ trans('errors.exception.detail', {msg: exception.message ?: trans('errors.http.msg-404')}) }} +
+{% endblock %} diff --git a/resources/views/errors/500.blade.php b/resources/views/errors/500.blade.php deleted file mode 100644 index 81cdb272..00000000 --- a/resources/views/errors/500.blade.php +++ /dev/null @@ -1,11 +0,0 @@ -@extends('errors.general') - -@section('title', '500 Internal Server Error') - -@section('content') -{{ trans('errors.exception.detail', ['msg' => $exception->getMessage() ?: trans('errors.http.msg-500')]) }}
-@endsection diff --git a/resources/views/errors/500.twig b/resources/views/errors/500.twig new file mode 100644 index 00000000..0a531795 --- /dev/null +++ b/resources/views/errors/500.twig @@ -0,0 +1,9 @@ +{% extends 'errors.base' %} + +{% block title %}500 Internal Server Error{% endblock %} + +{% block message %} ++ {{ trans('errors.exception.detail', {msg: exception.message ?: trans('errors.http.msg-500')}) }} +
+{% endblock %} diff --git a/resources/views/errors/503.blade.php b/resources/views/errors/503.blade.php deleted file mode 100644 index 02d4fb1c..00000000 --- a/resources/views/errors/503.blade.php +++ /dev/null @@ -1,11 +0,0 @@ -@extends('errors.general') - -@section('title', '503 Service Unavailable') - -@section('content') -@lang('errors.exception.detail', ['msg' => $exception->getMessage() ?: trans('errors.http.msg-503')])
-@endsection diff --git a/resources/views/errors/503.twig b/resources/views/errors/503.twig new file mode 100644 index 00000000..13df13fd --- /dev/null +++ b/resources/views/errors/503.twig @@ -0,0 +1,9 @@ +{% extends 'errors.base' %} + +{% block title %}503 Service Unavailable{% endblock %} + +{% block message %} ++ {{ trans('errors.exception.detail', {msg: exception.message ?: trans('errors.http.msg-503')}) }} +
+{% endblock %} diff --git a/resources/views/errors/base.twig b/resources/views/errors/base.twig new file mode 100644 index 00000000..04d5c867 --- /dev/null +++ b/resources/views/errors/base.twig @@ -0,0 +1,27 @@ + + + + + + + ++ {{ site_name }} +
+{{ $message }}
- -{!! nl2br(trans('errors.exception.message')) !!}
- -@endsection diff --git a/resources/views/errors/exception.twig b/resources/views/errors/exception.twig new file mode 100644 index 00000000..ac89d51b --- /dev/null +++ b/resources/views/errors/exception.twig @@ -0,0 +1,8 @@ +{% extends 'errors.base' %} + +{% block title %}{{ trans('errors.general.title') }}{% endblock %} + +{% block message %} +{{ message }}
+{{ trans('errors.exception.message')|nl2br }}
+{% endblock %} diff --git a/resources/views/errors/general.blade.php b/resources/views/errors/general.blade.php deleted file mode 100644 index 90674497..00000000 --- a/resources/views/errors/general.blade.php +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - -{{ option_localized('site_name') }}
- -@yield('content') - - - - - - diff --git a/resources/views/errors/languages.twig b/resources/views/errors/languages.twig new file mode 100644 index 00000000..b92b42d5 --- /dev/null +++ b/resources/views/errors/languages.twig @@ -0,0 +1,10 @@ + diff --git a/resources/views/errors/pretty.blade.php b/resources/views/errors/pretty.blade.php deleted file mode 100644 index 7b632136..00000000 --- a/resources/views/errors/pretty.blade.php +++ /dev/null @@ -1,12 +0,0 @@ -@extends('errors.general') - -@section('title', trans('errors.general.title')) - -@section('content') -@lang('errors.exception.code', ['code' => $code])
-{!! trans('errors.exception.detail', ['msg' => $message]) !!}
-@endsection diff --git a/resources/views/errors/pretty.twig b/resources/views/errors/pretty.twig new file mode 100644 index 00000000..10e85585 --- /dev/null +++ b/resources/views/errors/pretty.twig @@ -0,0 +1,8 @@ +{% extends 'errors.base' %} + +{% block title %}{{ trans('errors.general.title') }}{% endblock %} + +{% block message %} +{{ trans('errors.exception.code', {code: code}) }}
+{{ trans('errors.exception.detail', {msg: message})|nl2br }}
+{% endblock %} diff --git a/resources/views/setup/base.twig b/resources/views/setup/base.twig new file mode 100644 index 00000000..9933535b --- /dev/null +++ b/resources/views/setup/base.twig @@ -0,0 +1,31 @@ + + + + + + + +@lang('setup.locked.text')
-- @lang('setup.locked.button') -
-@endsection diff --git a/resources/views/setup/locked.twig b/resources/views/setup/locked.twig new file mode 100644 index 00000000..5763ca84 --- /dev/null +++ b/resources/views/setup/locked.twig @@ -0,0 +1,12 @@ +{% extends 'setup.base' %} + +{% block subtitle %}{{ trans('setup.locked.title') }}{% endblock %} + +{% block content %} +{{ trans('setup.locked.text') }}
++ + {{ trans('setup.locked.button') }} + +
+{% endblock %} diff --git a/resources/views/setup/master.blade.php b/resources/views/setup/master.blade.php deleted file mode 100644 index 6f9368f2..00000000 --- a/resources/views/setup/master.blade.php +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - -- - {{ option_localized('site_name') }} - -
- -@yield('content') - - - - diff --git a/resources/views/setup/updates/success.blade.php b/resources/views/setup/updates/success.blade.php deleted file mode 100644 index 8e2e5db8..00000000 --- a/resources/views/setup/updates/success.blade.php +++ /dev/null @@ -1,14 +0,0 @@ -@extends('setup.updates.master') - -@section('content') -@lang('setup.updates.success.text', ['version' => config('app.version')])
- -- @lang('setup.updates.welcome.button') -
-@endsection diff --git a/resources/views/setup/updates/success.twig b/resources/views/setup/updates/success.twig new file mode 100644 index 00000000..8c988b54 --- /dev/null +++ b/resources/views/setup/updates/success.twig @@ -0,0 +1,16 @@ +{% extends 'setup.base' %} + +{% block title %}{{ trans('setup.updates.master.title') }}{% endblock %} + +{% block subtitle %}{{ trans('setup.updates.success.title') }}{% endblock %} + +{% block content %} ++ {{ trans('setup.updates.success.text', {version: config('app.version')}) }} +
++ + {{ trans('setup.updates.welcome.button') }} + +
+{% endblock %} diff --git a/resources/views/setup/updates/welcome.blade.php b/resources/views/setup/updates/welcome.blade.php deleted file mode 100644 index 7b43913b..00000000 --- a/resources/views/setup/updates/welcome.blade.php +++ /dev/null @@ -1,16 +0,0 @@ -@extends('setup.updates.master') - -@section('content') -{!! nl2br(trans('setup.updates.welcome.text', ['version' => config('app.version')])) !!}
- -- - @lang('setup.updates.welcome.button') - -
-@endsection diff --git a/resources/views/setup/updates/welcome.twig b/resources/views/setup/updates/welcome.twig new file mode 100644 index 00000000..97ba61dd --- /dev/null +++ b/resources/views/setup/updates/welcome.twig @@ -0,0 +1,16 @@ +{% extends 'setup.base' %} + +{% block title %}{{ trans('setup.updates.master.title') }}{% endblock %} + +{% block subtitle %}{{ trans('setup.updates.welcome.title') }}{% endblock %} + +{% block content %} ++ {{ trans('setup.updates.welcome.text', {version: config('app.version')})|nl2br }} +
++ + {{ trans('setup.updates.welcome.button') }} + +
+{% endblock %} diff --git a/resources/views/setup/wizard/database.blade.php b/resources/views/setup/wizard/database.blade.php deleted file mode 100644 index 031be2c8..00000000 --- a/resources/views/setup/wizard/database.blade.php +++ /dev/null @@ -1,90 +0,0 @@ -@extends('setup.master') - -@section('content') -@lang('setup.wizard.database.text')
- - -@endsection - -@section('script') - -@endsection diff --git a/resources/views/setup/wizard/database.twig b/resources/views/setup/wizard/database.twig new file mode 100644 index 00000000..235e2166 --- /dev/null +++ b/resources/views/setup/wizard/database.twig @@ -0,0 +1,136 @@ +{% extends 'setup.base' %} + +{% block subtitle %}{{ trans('setup.wizard.database.title') }}{% endblock %} + +{% block content %} +{{ trans('setup.wizard.database.text') }}
+ +{% endblock %} diff --git a/resources/views/setup/wizard/finish.blade.php b/resources/views/setup/wizard/finish.blade.php deleted file mode 100644 index 25fd0f4f..00000000 --- a/resources/views/setup/wizard/finish.blade.php +++ /dev/null @@ -1,24 +0,0 @@ -@extends('setup.master') - -@section('content') -@lang('setup.wizard.finish.text')
- -| @lang('auth.email') | -{{ $email }} | -
|---|---|
| @lang('auth.password') | -{{ $password }} |
-
{{ trans('setup.wizard.finish.text') }}
+| {{ trans('auth.email') }} | +{{ email }} | +
|---|
+ + {{ trans('general.index') }} + +
+{% endblock %} diff --git a/resources/views/setup/wizard/info.blade.php b/resources/views/setup/wizard/info.blade.php deleted file mode 100644 index 2ae6b39c..00000000 --- a/resources/views/setup/wizard/info.blade.php +++ /dev/null @@ -1,71 +0,0 @@ -@extends('setup.master') - -@section('content') -@lang('setup.wizard.info.text')
- - -@endsection diff --git a/resources/views/setup/wizard/info.twig b/resources/views/setup/wizard/info.twig new file mode 100644 index 00000000..9f5e96c1 --- /dev/null +++ b/resources/views/setup/wizard/info.twig @@ -0,0 +1,112 @@ +{% extends 'setup.base' %} + +{% block subtitle %}{{ trans('setup.wizard.info.title') }}{% endblock %} + +{% block content %} +{{ trans('setup.wizard.info.text') }}
+ +{% endblock %} diff --git a/resources/views/setup/wizard/language.blade.php b/resources/views/setup/wizard/language.blade.php deleted file mode 100644 index ae1e08a8..00000000 --- a/resources/views/setup/wizard/language.blade.php +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/resources/views/setup/wizard/welcome.blade.php b/resources/views/setup/wizard/welcome.blade.php deleted file mode 100644 index bfe7e498..00000000 --- a/resources/views/setup/wizard/welcome.blade.php +++ /dev/null @@ -1,13 +0,0 @@ -@extends('setup.master') - -@section('content') -@lang('setup.wizard.welcome.text', ['version' => config('app.version')])
- -- @lang('setup.wizard.welcome.button') -
-@endsection diff --git a/resources/views/setup/wizard/welcome.twig b/resources/views/setup/wizard/welcome.twig new file mode 100644 index 00000000..5e0b2993 --- /dev/null +++ b/resources/views/setup/wizard/welcome.twig @@ -0,0 +1,12 @@ +{% extends 'setup.base' %} + +{% block subtitle %}{{ trans('setup.wizard.welcome.title') }}{% endblock %} + +{% block content %} +{{ trans('setup.wizard.welcome.text', {version: config('app.version')}) }}
+ +{% endblock %} diff --git a/routes/web.php b/routes/web.php index 64092e2d..f4004ac0 100644 --- a/routes/web.php +++ b/routes/web.php @@ -179,6 +179,5 @@ Route::group(['prefix' => 'setup'], function () { Route::group(['middleware' => 'authorize'], function () { Route::view('/update', 'setup.updates.welcome')->middleware('setup'); Route::any('/exec-update', 'SetupController@update')->middleware('setup'); - Route::view('/changelog', 'setup.updates.changelog'); }); }); diff --git a/tests/HttpTest/ControllersTest/AuthControllerTest.php b/tests/HttpTest/ControllersTest/AuthControllerTest.php index d2e26dad..bcabff1c 100644 --- a/tests/HttpTest/ControllersTest/AuthControllerTest.php +++ b/tests/HttpTest/ControllersTest/AuthControllerTest.php @@ -171,7 +171,7 @@ class AuthControllerTest extends TestCase $this->get('/auth/register')->assertSee('Register'); option(['user_can_register' => false]); - $this->get('/auth/register')->assertSee(trans('auth.register.close')); + $this->get('/auth/register')->assertSee(e(trans('auth.register.close'))); } public function testHandleRegister() diff --git a/tests/HttpTest/ControllersTest/PluginControllerTest.php b/tests/HttpTest/ControllersTest/PluginControllerTest.php index ed15c015..48b95a41 100644 --- a/tests/HttpTest/ControllersTest/PluginControllerTest.php +++ b/tests/HttpTest/ControllersTest/PluginControllerTest.php @@ -62,7 +62,7 @@ class PluginControllerTest extends TestCase // Plugin is enabled but it doesn't have config view $this->get('/admin/plugins/config/fake3') - ->assertSee(trans('admin.plugins.operations.no-config-notice')) + ->assertSee(e(trans('admin.plugins.operations.no-config-notice'))) ->assertNotFound(); // Plugin has config view diff --git a/tests/HttpTest/ControllersTest/SetupControllerTest.php b/tests/HttpTest/ControllersTest/SetupControllerTest.php index 7d44ea14..7a2e99a6 100644 --- a/tests/HttpTest/ControllersTest/SetupControllerTest.php +++ b/tests/HttpTest/ControllersTest/SetupControllerTest.php @@ -185,8 +185,7 @@ class SetupControllerTest extends TestCase 'site_name' => 'bs', 'generate_random' => true, ])->assertSee(trans('setup.wizard.finish.title')) - ->assertSee('a@b.c') - ->assertSee('12345678'); + ->assertSee('a@b.c'); $superAdmin = \App\Models\User::find(1); $this->assertEquals('a@b.c', $superAdmin->email); $this->assertTrue($superAdmin->verifyPassword('12345678')); diff --git a/tests/HttpTest/ControllersTest/TextureControllerTest.php b/tests/HttpTest/ControllersTest/TextureControllerTest.php index 7085bd25..06d71e56 100644 --- a/tests/HttpTest/ControllersTest/TextureControllerTest.php +++ b/tests/HttpTest/ControllersTest/TextureControllerTest.php @@ -158,7 +158,7 @@ class TextureControllerTest extends TestCase $player = factory(Player::class)->create(); $this->get("/skin/{$player->name}.png") - ->assertSee(trans('general.texture-not-uploaded', ['type' => 'skin'])); + ->assertSee(e(trans('general.texture-not-uploaded', ['type' => 'skin']))); $player->tid_skin = $skin->tid; $player->save(); diff --git a/tests/HttpTest/MiddlewareTest/ForbiddenIETest.php b/tests/HttpTest/MiddlewareTest/ForbiddenIETest.php index 443f0497..c6837d96 100644 --- a/tests/HttpTest/MiddlewareTest/ForbiddenIETest.php +++ b/tests/HttpTest/MiddlewareTest/ForbiddenIETest.php @@ -6,7 +6,9 @@ class ForbiddenIETest extends TestCase { public function testHandle() { - $this->get('/', ['user-agent' => 'MSIE'])->assertSee(trans('errors.http.ie')); - $this->get('/', ['user-agent' => 'Trident'])->assertSee(trans('errors.http.ie')); + $this->get('/', ['user-agent' => 'MSIE']) + ->assertSee(e(trans('errors.http.ie'))); + $this->get('/', ['user-agent' => 'Trident']) + ->assertSee(e(trans('errors.http.ie'))); } } diff --git a/webpack.config.js b/webpack.config.js index 90cbd2ad..209c6aea 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -14,6 +14,7 @@ const config = { entry: { index: './resources/assets/src/index.ts', 'check-updates': './resources/assets/src/scripts/check-updates.ts', + 'language-chooser': './resources/assets/src/scripts/language-chooser.ts', style: [ 'bootstrap/dist/css/bootstrap.min.css', 'admin-lte/dist/css/alt/AdminLTE-without-plugins.min.css',