From 5f9eb0b6fd9c83bd51da3ba3347695d6bc8cab57 Mon Sep 17 00:00:00 2001 From: printempw Date: Sat, 14 Jan 2017 23:33:01 +0800 Subject: [PATCH] add option for sending usage statistics --- app/Http/Controllers/AdminController.php | 2 ++ app/Providers/AppServiceProvider.php | 3 ++- config/options.php | 3 ++- resources/assets/src/js/general.js | 6 +++--- resources/lang/en/options.yml | 4 ++++ resources/lang/zh_CN/options.yml | 4 ++++ resources/views/admin/master.tpl | 16 ++++++++++++++++ 7 files changed, 33 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 3ff06d1f..c9c3d683 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -136,6 +136,8 @@ class AdminController extends Controller $form->textarea('comment_script')->rows(6)->description(OptionForm::AUTO_DETECT); + $form->checkbox('allow_sending_statistic')->label(OptionForm::AUTO_DETECT)->hint(OptionForm::AUTO_DETECT); + })->handle(function() { if (substr($_POST['site_url'], -1) == "/") $_POST['site_url'] = substr($_POST['site_url'], 0, -1); diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 284f8bbe..d7d2380f 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -36,7 +36,8 @@ class AppServiceProvider extends ServiceProvider Event::listen(Events\RenderingHeader::class, function($event) { // provide some application information for javascript $blessing = array_merge(Arr::except(config('app'), ['key', 'providers', 'aliases', 'cipher', 'log', 'url']), [ - 'baseUrl' => url('/'), + 'base_url' => url('/'), + 'site_name' => option('site_name') ]); $event->addContent(''); diff --git a/config/options.php b/config/options.php index f1c34b0d..28545da4 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-31 23:34:17 + * @Last Modified time: 2017-01-14 22:05:22 */ return [ @@ -20,6 +20,7 @@ return [ 'custom_js' => '', 'allow_chinese_playername' => 'true', 'comment_script' => '', + 'allow_sending_statistic' => 'true', 'user_initial_score' => '1000', 'sign_gap_time' => '24', 'sign_score' => '10,100', diff --git a/resources/assets/src/js/general.js b/resources/assets/src/js/general.js index 549f9bbc..674fbb5c 100644 --- a/resources/assets/src/js/general.js +++ b/resources/assets/src/js/general.js @@ -2,7 +2,7 @@ * @Author: printempw * @Date: 2016-09-15 10:39:41 * @Last Modified by: printempw -* @Last Modified time: 2016-12-17 18:47:02 +* @Last Modified time: 2017-01-14 22:36:55 */ 'use strict'; @@ -22,7 +22,7 @@ function logout(with_out_confirm, callback) { html: json.msg }); window.setTimeout(function() { - window.location = blessing.baseUrl; + window.location = blessing.base_url; }, 1000); }); }); @@ -36,7 +36,7 @@ function logout(with_out_confirm, callback) { function do_logout(callback) { $.ajax({ type: "POST", - url: blessing.baseUrl + "/auth/logout", + url: blessing.base_url + "/auth/logout", dataType: "json", success: function(json) { if (callback) callback(json); diff --git a/resources/lang/en/options.yml b/resources/lang/en/options.yml index 54f1f1fb..d553956e 100644 --- a/resources/lang/en/options.yml +++ b/resources/lang/en/options.yml @@ -83,6 +83,10 @@ auto_del_invalid_texture: comment_script: title: Comment Script description: Placeholders are available in comment scripts. {tid} will be replaced with texture id, {name} will be replaced with texture name, {url} will be replaced with current URL. +allow_sending_statistic: + title: Statistics + label: Send usage statistics anonymously. + hint: Information about privacy will nerver be sent. announ: title: Site Announcement diff --git a/resources/lang/zh_CN/options.yml b/resources/lang/zh_CN/options.yml index c9e23fbc..98567972 100644 --- a/resources/lang/zh_CN/options.yml +++ b/resources/lang/zh_CN/options.yml @@ -83,6 +83,10 @@ auto_del_invalid_texture: comment_script: title: 评论代码 description: 评论代码内可使用占位符,{tid} 将会被自动替换为材质的 id,{name} 会被替换为材质名称,{url} 会被替换为当前页面地址。 +allow_sending_statistic: + title: 统计信息 + label: 发送程序使用情况统计信息以帮助开发 + hint: 隐私信息不会被收集 announ: title: 站点公告 diff --git a/resources/views/admin/master.tpl b/resources/views/admin/master.tpl index affe16c3..736a955d 100644 --- a/resources/views/admin/master.tpl +++ b/resources/views/admin/master.tpl @@ -128,6 +128,22 @@ @endif + @if (option('allow_sending_statistic')) + + @endif + @yield('script')