mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-21 06:19:38 +08:00
Extract some helper functions to view
This commit is contained in:
parent
634f0b726a
commit
29b0c1e5a3
@ -16,15 +16,6 @@ if (! function_exists('get_base_url')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('avatar')) {
|
||||
function avatar(User $user, $size)
|
||||
{
|
||||
$fname = base64_encode($user->email).'.png?tid='.$user->avatar;
|
||||
|
||||
return url("avatar/$size/$fname");
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('webpack_assets')) {
|
||||
function webpack_assets($relativeUri)
|
||||
{
|
||||
@ -107,20 +98,6 @@ if (! function_exists('bs_header_extra')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('bs_favicon')) {
|
||||
function bs_favicon()
|
||||
{
|
||||
// Fallback to default favicon
|
||||
$url = Str::startsWith($url = (option('favicon_url') ?: config('options.favicon_url')), 'http') ? $url : url($url);
|
||||
|
||||
return <<< ICONS
|
||||
<link rel="shortcut icon" href="$url">
|
||||
<link rel="icon" type="image/png" href="$url" sizes="192x192">
|
||||
<link rel="apple-touch-icon" href="$url" sizes="180x180">
|
||||
ICONS;
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('bs_menu')) {
|
||||
function bs_menu($type)
|
||||
{
|
||||
@ -224,34 +201,6 @@ if (! function_exists('bs_copyright')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('bs_custom_copyright')) {
|
||||
function bs_custom_copyright()
|
||||
{
|
||||
return get_string_replaced(option_localized('copyright_text'), [
|
||||
'{site_name}' => option_localized('site_name'),
|
||||
'{site_url}' => option('site_url'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('bs_role')) {
|
||||
function bs_role(User $user = null)
|
||||
{
|
||||
$user = $user ?: auth()->user();
|
||||
|
||||
$roles = [
|
||||
User::NORMAL => 'normal',
|
||||
User::BANNED => 'banned',
|
||||
User::ADMIN => 'admin',
|
||||
User::SUPER_ADMIN => 'super-admin',
|
||||
];
|
||||
|
||||
$role = Arr::get($roles, $user->permission);
|
||||
|
||||
return trans("admin.users.status.$role");
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('option')) {
|
||||
/**
|
||||
* Get / set the specified option value.
|
||||
|
@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>@yield('title') - {{ option_localized('site_name') }}</title>
|
||||
{!! bs_favicon() !!}
|
||||
@include('common.favicon')
|
||||
<!-- Tell the browser to be responsive to screen width -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
@ -54,18 +54,7 @@
|
||||
|
||||
<!-- sidebar: style can be found in sidebar.less -->
|
||||
<section class="sidebar">
|
||||
|
||||
<!-- Sidebar user panel (optional) -->
|
||||
<div class="user-panel">
|
||||
<div class="pull-left image">
|
||||
<img src="{{ avatar($user, 45) }}" alt="User Image">
|
||||
</div>
|
||||
<div class="pull-left info">
|
||||
<p class="nickname">{{ $user->nickname ?? $user->email }}</p>
|
||||
<i class="fas fa-circle text-success"></i> {{ bs_role($user) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@include('common.user-panel')
|
||||
<!-- Sidebar Menu -->
|
||||
<ul class="sidebar-menu tree" data-widget="tree">
|
||||
<li class="header">@lang('general.admin-panel')</li>
|
||||
@ -87,7 +76,7 @@
|
||||
{!! bs_copyright() !!}
|
||||
</div>
|
||||
<!-- Default to the left -->
|
||||
{!! bs_custom_copyright() !!}
|
||||
@include('common.custom-copyright')
|
||||
</footer>
|
||||
|
||||
</div><!-- ./wrapper -->
|
||||
|
@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>@yield('title') - {{ option_localized('site_name') }}</title>
|
||||
{!! bs_favicon() !!}
|
||||
@include('common.favicon')
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
@include('common.seo-meta-tags')
|
||||
|
8
resources/views/common/custom-copyright.blade.php
Normal file
8
resources/views/common/custom-copyright.blade.php
Normal file
@ -0,0 +1,8 @@
|
||||
{!!
|
||||
get_string_replaced(
|
||||
option_localized('copyright_text'), [
|
||||
'{site_name}' => option_localized('site_name'),
|
||||
'{site_url}' => option('site_url'),
|
||||
]
|
||||
)
|
||||
!!}
|
6
resources/views/common/favicon.blade.php
Normal file
6
resources/views/common/favicon.blade.php
Normal file
@ -0,0 +1,6 @@
|
||||
@php
|
||||
$faviconUrl = Str::startsWith($url = (option('favicon_url') ?: config('options.favicon_url')), 'http') ? $url : url($url);
|
||||
@endphp
|
||||
<link rel="shortcut icon" href="{{ $faviconUrl }}">
|
||||
<link rel="icon" type="image/png" href="{{ $faviconUrl }}" sizes="192x192">
|
||||
<link rel="apple-touch-icon" href="{{ $faviconUrl }}" sizes="180x180">
|
@ -4,7 +4,7 @@
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
@if (app('request')->is('skinlib*') || app('request')->is('/'))
|
||||
<!-- The user image in the navbar-->
|
||||
<img src="{{ avatar($user, 25) }}" class="user-image" alt="User Image">
|
||||
<img src="{{ url("avatar/25/".base64_encode($user->email).'.png?tid='.$user->avatar) }}" class="user-image" alt="User Image">
|
||||
@else
|
||||
<i class="fas fa-user"></i>
|
||||
@endif
|
||||
@ -15,7 +15,7 @@
|
||||
<ul class="dropdown-menu">
|
||||
<!-- The user image in the menu -->
|
||||
<li class="user-header">
|
||||
<img src="{{ avatar($user, 128) }}" alt="User Image">
|
||||
<img src="{{ url("avatar/128/".base64_encode($user->email).'.png?tid='.$user->avatar) }}" alt="User Image">
|
||||
<p>{{ $user->email }}</p>
|
||||
</li>
|
||||
@admin($user)
|
||||
|
18
resources/views/common/user-panel.blade.php
Normal file
18
resources/views/common/user-panel.blade.php
Normal file
@ -0,0 +1,18 @@
|
||||
@php
|
||||
$roles = [
|
||||
App\Models\User::BANNED => 'banned',
|
||||
App\Models\User::NORMAL => 'normal',
|
||||
App\Models\User::ADMIN => 'admin',
|
||||
App\Models\User::SUPER_ADMIN => 'super-admin',
|
||||
];
|
||||
$role = $roles[$user->permission];
|
||||
@endphp
|
||||
<div class="user-panel">
|
||||
<div class="pull-left image">
|
||||
<img src="{{ url("avatar/45/".base64_encode($user->email).'.png?tid='.$user->avatar) }}" alt="User Image">
|
||||
</div>
|
||||
<div class="pull-left info">
|
||||
<p class="nickname">{{ $user->nickname ?? $user->email }}</p>
|
||||
<i class="fas fa-circle text-success"></i> @lang("admin.users.status.$role")
|
||||
</div>
|
||||
</div>
|
@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>{{ option_localized('site_name') }}</title>
|
||||
{!! bs_favicon() !!}
|
||||
@include('common.favicon')
|
||||
<!-- Tell the browser to be responsive to screen width -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
@ -121,7 +121,7 @@
|
||||
{!! bs_copyright() !!}
|
||||
</div>
|
||||
<!-- Default to the left -->
|
||||
{!! bs_custom_copyright() !!}
|
||||
@include('common.custom-copyright')
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>@yield('title') - {{ option_localized('site_name') }}</title>
|
||||
{!! bs_favicon() !!}
|
||||
@include('common.favicon')
|
||||
<!-- Tell the browser to be responsive to screen width -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
@ -77,7 +77,7 @@
|
||||
{!! bs_copyright() !!}
|
||||
</div>
|
||||
<!-- Default to the left -->
|
||||
{!! bs_custom_copyright() !!}
|
||||
@include('common.custom-copyright')
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>@yield('title') - {{ option_localized('site_name') }}</title>
|
||||
{!! bs_favicon() !!}
|
||||
@include('common.favicon')
|
||||
<!-- Tell the browser to be responsive to screen width -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
@ -54,18 +54,7 @@
|
||||
|
||||
<!-- sidebar: style can be found in sidebar.less -->
|
||||
<section class="sidebar">
|
||||
|
||||
<!-- Sidebar user panel (optional) -->
|
||||
<div class="user-panel">
|
||||
<div class="pull-left image">
|
||||
<img src="{{ avatar($user, 45) }}" alt="User Image">
|
||||
</div>
|
||||
<div class="pull-left info">
|
||||
<p class="nickname">{{ $user->nickname ?? $user->email }}</p>
|
||||
<i class="fas fa-circle text-success"></i> {{ bs_role($user) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@include('common.user-panel')
|
||||
<!-- Sidebar Menu -->
|
||||
<ul class="sidebar-menu tree" data-widget="tree">
|
||||
<li class="header">@lang('general.user-center')</li>
|
||||
@ -92,7 +81,7 @@
|
||||
{!! bs_copyright() !!}
|
||||
</div>
|
||||
<!-- Default to the left -->
|
||||
{!! bs_custom_copyright() !!}
|
||||
@include('common.custom-copyright')
|
||||
</footer>
|
||||
|
||||
</div><!-- ./wrapper -->
|
||||
|
Loading…
Reference in New Issue
Block a user