Generate extra data in controllers
This commit is contained in:
parent
84b2a5f0a4
commit
f6040707e1
|
|
@ -104,7 +104,10 @@ class AdminController extends Controller
|
|||
$form->textarea('custom_js', 'JavaScript')->rows(6);
|
||||
})->addMessage()->handle();
|
||||
|
||||
return view('admin.customize', ['forms' => compact('homepage', 'customJsCss')]);
|
||||
return view('admin.customize', [
|
||||
'forms' => compact('homepage', 'customJsCss'),
|
||||
'extra' => ['currentSkin' => option('color_scheme')]
|
||||
]);
|
||||
}
|
||||
|
||||
public function score()
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class AuthController extends Controller
|
|||
public function register()
|
||||
{
|
||||
if (option('user_can_register')) {
|
||||
return view('auth.register');
|
||||
return view('auth.register', ['extra' => ['player' => option('register_with_player_name')]]);
|
||||
} else {
|
||||
throw new PrettyPageException(trans('auth.register.close'), 7);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ class ClosetController extends Controller
|
|||
{
|
||||
public function index()
|
||||
{
|
||||
return view('user.closet')->with('user', Auth::user());
|
||||
return view('user.closet')
|
||||
->with('user', Auth::user())
|
||||
->with('extra', ['unverified' => option('require_verification') && ! $user->verified]);
|
||||
}
|
||||
|
||||
public function getClosetData(Request $request)
|
||||
|
|
|
|||
|
|
@ -56,7 +56,14 @@ class PlayerController extends Controller
|
|||
|
||||
return view('user.player')
|
||||
->with('players', $user->players->toArray())
|
||||
->with('user', $user);
|
||||
->with('user', $user)
|
||||
->with('extra', [
|
||||
'rule' => trans('user.player.player-name-rule.'.option('player_name_rule')),
|
||||
'length' => trans(
|
||||
'user.player.player-name-length',
|
||||
['min' => option('player_name_length_min'), 'max' => option('player_name_length_max')]
|
||||
)
|
||||
]);
|
||||
}
|
||||
|
||||
public function listAll()
|
||||
|
|
|
|||
|
|
@ -151,7 +151,14 @@ class SkinlibController extends Controller
|
|||
return view('skinlib.show')
|
||||
->with('texture', $texture)
|
||||
->with('with_out_filter', true)
|
||||
->with('user', $user);
|
||||
->with('user', $user)
|
||||
->with('extra', [
|
||||
'download' => option('allow_downloading_texture'),
|
||||
'currentUid' => $user ? $user->uid : 0,
|
||||
'admin' => $user && $user->isAdmin(),
|
||||
'inCloset' => $user && $user->closet()->where('tid', $texture->tid)->count() > 0,
|
||||
'nickname' => ($up = User::find($texture->uploader)) ? $up->nickname : null
|
||||
]);
|
||||
}
|
||||
|
||||
public function info($tid)
|
||||
|
|
@ -167,6 +174,18 @@ class SkinlibController extends Controller
|
|||
{
|
||||
return view('skinlib.upload')
|
||||
->with('user', Auth::user())
|
||||
->with('extra', [
|
||||
'rule' => ($regexp = option('texture_name_regexp'))
|
||||
? trans('skinlib.upload.name-rule-regexp', compact('regexp'))
|
||||
: trans('skinlib.upload.name-rule'),
|
||||
'privacyNotice' => trans(
|
||||
'skinlib.upload.private-score-notice',
|
||||
['score' => option('private_score_per_storage')]
|
||||
),
|
||||
'scorePublic' => intval(option('score_per_storage')),
|
||||
'scorePrivate' => intval(option('private_score_per_storage')),
|
||||
'award' => intval(option('score_award_per_texture')),
|
||||
])
|
||||
->with('with_out_filter', true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,8 @@ class UpdateController extends Controller
|
|||
$connectivity = $e->getMessage();
|
||||
}
|
||||
|
||||
return view('admin.update', compact('info', 'connectivity'));
|
||||
$extra = ['canUpdate' => $info['new_version_available']];
|
||||
return view('admin.update', compact('info', 'connectivity', 'extra'));
|
||||
}
|
||||
|
||||
public function checkUpdates()
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ class UserController extends Controller
|
|||
'storage' => $this->calculatePercentageUsed($user->getStorageUsed(), option('score_per_storage')),
|
||||
],
|
||||
'announcement' => app('parsedown')->text(option_localized('announcement')),
|
||||
'extra' => ['unverified' => option('require_verification') && ! $user->verified],
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -157,7 +158,13 @@ class UserController extends Controller
|
|||
|
||||
public function profile()
|
||||
{
|
||||
return view('user.profile')->with('user', Auth::user());
|
||||
$user = Auth::user();
|
||||
return view('user.profile')
|
||||
->with('user', $user)
|
||||
->with('extra', [
|
||||
'unverified' => option('require_verification') && ! $user->verified,
|
||||
'admin' => $user->isAdmin(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function handleProfile(Request $request)
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ export default {
|
|||
privacyNotice: blessing.extra.privacyNotice,
|
||||
scorePublic: blessing.extra.scorePublic,
|
||||
scorePrivate: blessing.extra.scorePrivate,
|
||||
award: +blessing.extra.award,
|
||||
award: blessing.extra.award,
|
||||
width2d: 64,
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -37,9 +37,7 @@
|
|||
</div><!-- /.content-wrapper -->
|
||||
|
||||
<script>
|
||||
blessing.extra = {
|
||||
currentSkin: "{{ option('color_scheme') }}"
|
||||
};
|
||||
blessing.extra = @json($extra);
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -133,9 +133,7 @@
|
|||
</div><!-- /.modal -->
|
||||
|
||||
<script>
|
||||
blessing.extra = {
|
||||
canUpdate: {{ $info['new_version_available'] ? 'true' : 'false' }}
|
||||
}
|
||||
blessing.extra = @json($extra)
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
<script>
|
||||
Object.defineProperty(blessing, 'extra', {
|
||||
configurable: false,
|
||||
get: () => Object.freeze({ tooManyFails: {{ cache(sha1('login_fails_'.get_client_ip())) > 3 ? 'true' : 'false' }} })
|
||||
get: () => Object.freeze(@json(['tooManyFails' => cache(sha1('login_fails_'.get_client_ip())) > 3]))
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -20,9 +20,7 @@
|
|||
|
||||
<script>
|
||||
Object.defineProperty(blessing, 'extra', {
|
||||
get: () => Object.freeze({
|
||||
player: {{ option('register_with_player_name') ? 'true' : 'false' }},
|
||||
}),
|
||||
get: () => Object.freeze(@json($extra)),
|
||||
configurable: false
|
||||
})
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -47,13 +47,7 @@
|
|||
<script>
|
||||
Object.defineProperty(blessing, 'extra', {
|
||||
configurable: false,
|
||||
get: () => Object.freeze({
|
||||
download: {{ option('allow_downloading_texture') ? 'true' : 'false' }},
|
||||
currentUid: {{ is_null($user) ? '0' : $user->uid }},
|
||||
admin: {{ $user && $user->isAdmin() ? 'true' : 'false' }},
|
||||
inCloset: {{ $user && $user->closet()->where('tid', $texture->tid)->count() > 0 ? 'true' : 'false' }},
|
||||
nickname: @php echo ($up = \App\Models\User::find($texture->uploader)) ? '"'.$up->nickname.'"' : 'null' @endphp
|
||||
})
|
||||
get: () => Object.freeze(@json($extra))
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -19,12 +19,6 @@
|
|||
</div><!-- /.content-wrapper -->
|
||||
|
||||
<script>
|
||||
blessing.extra = {
|
||||
rule: "{{ option('texture_name_regexp') ? trans('skinlib.upload.name-rule-regexp', compact('regexp')) : trans('skinlib.upload.name-rule') }}",
|
||||
privacyNotice: "@lang('skinlib.upload.private-score-notice', ['score' => option('private_score_per_storage')])",
|
||||
scorePublic: {{ option('score_per_storage') }},
|
||||
scorePrivate: {{ option('private_score_per_storage') }},
|
||||
award: {{ option('score_award_per_texture') }},
|
||||
}
|
||||
blessing.extra = @json($extra)
|
||||
</script>
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -22,10 +22,8 @@
|
|||
</div><!-- /.content-wrapper -->
|
||||
|
||||
<script>
|
||||
Object.defineProperty(blessing, 'extra', {
|
||||
get: () => Object.freeze({
|
||||
unverified: {{ option('require_verification') && !$user->verified ? 'true' : 'false' }}
|
||||
})
|
||||
})
|
||||
Object.defineProperty(blessing, 'extra', {
|
||||
get: () => Object.freeze(@json($extra))
|
||||
})
|
||||
</script>
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -74,10 +74,8 @@
|
|||
</div><!-- /.modal -->
|
||||
|
||||
<script>
|
||||
Object.defineProperty(blessing, 'extra', {
|
||||
get: () => Object.freeze({
|
||||
unverified: {{ option('require_verification') && !$user->verified ? 'true' : 'false' }}
|
||||
})
|
||||
})
|
||||
Object.defineProperty(blessing, 'extra', {
|
||||
get: () => Object.freeze(@json($extra))
|
||||
})
|
||||
</script>
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -18,10 +18,7 @@
|
|||
</div><!-- /.content-wrapper -->
|
||||
|
||||
<script>
|
||||
blessing.extra = {
|
||||
rule: "@lang('user.player.player-name-rule.'.option('player_name_rule'))",
|
||||
length: "@lang('user.player.player-name-length', ['min' => option('player_name_length_min'), 'max' => option('player_name_length_max')])"
|
||||
}
|
||||
blessing.extra = @json($extra)
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -18,12 +18,9 @@
|
|||
</div><!-- /.content-wrapper -->
|
||||
|
||||
<script>
|
||||
Object.defineProperty(blessing, 'extra', {
|
||||
configurable: false,
|
||||
get: () => Object.freeze({
|
||||
admin: {{ (string) $user->isAdmin() ?: 'false' }},
|
||||
unverified: {{ option('require_verification') && !$user->verified ? 'true' : 'false' }}
|
||||
}),
|
||||
})
|
||||
Object.defineProperty(blessing, 'extra', {
|
||||
configurable: false,
|
||||
get: () => Object.freeze(@json($extra)),
|
||||
})
|
||||
</script>
|
||||
@endsection
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user