From 6d6abf41f55eb6222034646940f9fba54003caea Mon Sep 17 00:00:00 2001 From: printempw Date: Sat, 31 Dec 2016 13:36:46 +0800 Subject: [PATCH] add option for customizing favicon --- app/Http/Controllers/AdminController.php | 3 +++ app/helpers.php | 12 ++++++++++++ config/options.php | 5 +++-- resources/views/admin/master.tpl | 2 +- resources/views/auth/master.tpl | 2 +- resources/views/index.tpl | 2 +- resources/views/skinlib/master.tpl | 2 +- resources/views/user/master.tpl | 2 +- 8 files changed, 23 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 5115c09c..0765cba4 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -28,6 +28,9 @@ class AdminController extends Controller { $form->text('home_pic_url', '首页图片地址')->hint('相对于首页的路径或者完整的 URL'); + $form->text('favicon_url', '网站图标')->hint('相对 resources/assets/ 的路径或者完整的 URL') + ->description('所使用的图像必须具有相同的宽度和高度'); + $form->select('copyright_prefer', '程序版权信息') ->option('0', 'Powered with ❤ by Blessing Skin Server.') ->option('1', 'Powered by Blessing Skin Server.') diff --git a/app/helpers.php b/app/helpers.php index 2a5f161a..4080b8dc 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -130,6 +130,18 @@ if (! function_exists('bs_header')) { } } +if (! function_exists('bs_favicon')) { + + function bs_favicon() + { + $url = Str::startsWith($url = option('favicon_url'), 'http') ? $url : assets($url); + + return "". + "". + ""; + } +} + if (! function_exists('bs_menu')) { function bs_menu($type) diff --git a/config/options.php b/config/options.php index 7fdf356e..01021b46 100644 --- a/config/options.php +++ b/config/options.php @@ -3,7 +3,7 @@ * @Author: printempw * @Date: 2016-07-29 11:53:11 * @Last Modified by: printempw - * @Last Modified time: 2016-12-28 12:59:37 + * @Last Modified time: 2016-12-31 13:25:58 */ return [ @@ -40,5 +40,6 @@ return [ 'auto_detect_asset_url' => '1', 'plugins_enabled' => '', 'copyright_prefer' => '0', - 'score_per_closet_item' => '0' + 'score_per_closet_item' => '0', + 'favicon_url' => 'images/favicon.ico' ]; diff --git a/resources/views/admin/master.tpl b/resources/views/admin/master.tpl index d5c35d1b..e0872011 100644 --- a/resources/views/admin/master.tpl +++ b/resources/views/admin/master.tpl @@ -4,7 +4,7 @@ @yield('title') - {{ option('site_name') }} - + {!! bs_favicon() !!} diff --git a/resources/views/auth/master.tpl b/resources/views/auth/master.tpl index fb580381..c72d6cab 100644 --- a/resources/views/auth/master.tpl +++ b/resources/views/auth/master.tpl @@ -4,7 +4,7 @@ @yield('title') - {{ option('site_name') }} - + {!! bs_favicon() !!} {!! bs_header('auth') !!} diff --git a/resources/views/index.tpl b/resources/views/index.tpl index 3d99b20b..6daeed13 100644 --- a/resources/views/index.tpl +++ b/resources/views/index.tpl @@ -4,7 +4,7 @@ {{ option('site_name') }} - + {!! bs_favicon() !!} diff --git a/resources/views/skinlib/master.tpl b/resources/views/skinlib/master.tpl index ced4259c..e102d434 100644 --- a/resources/views/skinlib/master.tpl +++ b/resources/views/skinlib/master.tpl @@ -4,7 +4,7 @@ @yield('title') - {{ option('site_name') }} - + {!! bs_favicon() !!} diff --git a/resources/views/user/master.tpl b/resources/views/user/master.tpl index 04eb84bd..ae9c4692 100644 --- a/resources/views/user/master.tpl +++ b/resources/views/user/master.tpl @@ -4,7 +4,7 @@ @yield('title') - {{ option('site_name') }} - + {!! bs_favicon() !!}