Specify update source by environment variable

This commit is contained in:
printempw 2018-08-15 18:46:57 +08:00 committed by Pig Fang
parent e1d686d1a7
commit 5b3b2da64c
9 changed files with 48 additions and 53 deletions

View File

@ -59,7 +59,7 @@ class UpdateController extends Controller
public function __construct(\GuzzleHttp\Client $guzzle)
{
$this->updateSource = option('update_source');
$this->updateSource = config('app.update_source');
$this->currentVersion = config('app.version');
$this->guzzle = $guzzle;
@ -110,18 +110,15 @@ class UpdateController extends Controller
}
}
$update = Option::form('update', OptionForm::AUTO_DETECT, function ($form) {
$form->checkbox('check_update')->label();
$form->text('update_source')->description();
})->handle()->always(function ($form) {
try {
$response = $this->guzzle->request('GET', option('update_source'), $this->guzzleConfig)->getBody();
} catch (Exception $e) {
$form->addMessage(trans('admin.update.errors.connection').e($e->getMessage()), 'danger');
}
});
$connectivity = true;
return view('admin.update')->with('info', $info)->with('update', $update);
try {
$this->guzzle->request('GET', $this->updateSource, $this->guzzleConfig);
} catch (Exception $e) {
$connectivity = $e->getMessage();
}
return view('admin.update', compact('info', 'connectivity'));
}
public function checkUpdates()

View File

@ -6,11 +6,24 @@ return [
| Application Version
|--------------------------------------------------------------------------
|
| Version of Blessing Skin Server
| Version of Blessing Skin Server.
|
*/
'version' => '3.4.0',
/*
|--------------------------------------------------------------------------
| Update Source
|--------------------------------------------------------------------------
|
| Where to get information of new versions.
|
*/
'update_source' => menv(
'UPDATE_SOURCE',
'https://work.prinzeugen.net/blessing-skin-server/update.json'
),
/*
|--------------------------------------------------------------------------
| Application Environment

View File

@ -30,8 +30,6 @@ return [
'score_per_player' => '100',
'sign_after_zero' => 'false',
'version' => '',
'check_update' => 'true',
'update_source' => 'https://work.prinzeugen.net/update.json',
'copyright_text' => '<strong>Copyright &copy; '.getdate()['year'].' <a href="{site_url}">{site_name}</a>.</strong> All rights reserved.',
'auto_del_invalid_texture' => 'false',
'allow_downloading_texture' => 'true',

View File

@ -152,18 +152,19 @@ update:
cautions:
title: Cautions
text: |
Please choose update source according to your host location.
Low-speed connection between update source and your host will cause long-time loading at checking/downloading page.
Please choose update source according to your host's network environment.
Low-speed connection between update source and your host will cause long-time loading at checking and downloading page.
To change the default update source, please refer to <a target="_blank" href="https://github.com/printempw/blessing-skin-server/wiki/%E6%9B%B4%E6%96%B0%E6%BA%90%E5%88%97%E8%A1%A8">this wiki article</a>.
download:
downloading: Downloading update package...
size: "Size of package:"
errors:
errors:
prefix: "An error occured: "
connection: "Unable to access to current update source. Details:"
write-permission: Unable to make cache directory. Please sure permission.
unzip: "Failed to unzip update file. Error code: "
connection: We can't connect to the update source. :error
write-permission: Unable to create the cache directory. Please check the permission.
unzip: "Failed to extract update package. Error code: "
overwrite: Unable to overwrite files.
invalid-action: Invalid action

View File

@ -148,14 +148,4 @@ resources:
description: If your CDN doesn't cache 404 pages, please turn this on. A flood of requests to un-existent players will greatly slow down the site.
cache_expire_time:
title: Cache Exipre Time
hint: In seconds, 86400 = one day, 31536000 = one year
update:
title: Check Update
check_update:
title: Check Update
label: Check update automatically and notify me.
update_source:
title: Update Source
description: 'Available update source list can be found at: <a href="https://github.com/printempw/blessing-skin-server/wiki/%E6%9B%B4%E6%96%B0%E6%BA%90%E5%88%97%E8%A1%A8">@GitHub Wiki</a>'
hint: In seconds, 86400 = one day, 31536000 = one year.

View File

@ -153,7 +153,8 @@ update:
title: 注意事项
text: |
请根据你的主机所在位置(国内/国外)选择更新源。
如错选至相对于你的主机速度较慢的源,可能会造成检查/下载更新页面长时间无响应。
如错选至相对于你的主机速度较慢的源,可能会造成检查与下载更新页面长时间无响应。
如何更换更新源?<a target="_blank" href="https://github.com/printempw/blessing-skin-server/wiki/%E6%9B%B4%E6%96%B0%E6%BA%90%E5%88%97%E8%A1%A8">点击了解详情</a>。
download:
downloading: 正在下载更新包
@ -161,8 +162,8 @@ update:
errors:
prefix: 发生错误:
connection: 无法访问当前更新源。详细信息:
write-permission: 的服务器不支持自动更新:创建下载缓存文件夹失败,请检查目录权限。
connection: 无法访问当前更新源。详细信息::error
write-permission: 的服务器不支持自动更新:创建下载缓存文件夹失败,请检查目录权限。
unzip: 更新包解压缩失败。错误代码:
overwrite: 您的服务器不支持自动更新:无法覆盖文件。

View File

@ -149,13 +149,3 @@ resources:
cache_expire_time:
title: 缓存失效时间
hint: 秒数86400 = 一天31536000 = 一年
update:
title: 更新选项
check_update:
title: 检查更新
label: 自动检查更新并提示
update_source:
title: 更新源
description: 可用的更新源列表可以在这里查看:<a href="https://github.com/printempw/blessing-skin-server/wiki/%E6%9B%B4%E6%96%B0%E6%BA%90%E5%88%97%E8%A1%A8">@GitHub Wiki</a>

View File

@ -94,9 +94,12 @@
<!-- App Scripts -->
@include('common.dependencies.script')
@if (option('check_update'))
<script>$(document).ready(checkForUpdates);</script>
@endif
<script>
$(document).ready(() => {
checkForUpdates();
checkForPluginUpdates();
});
</script>
@if (option('allow_sending_statistics'))
<script>sendFeedback();</script>

View File

@ -64,7 +64,13 @@
</tbody>
</table>
@else
<div class="callout callout-success">@lang('admin.update.info.up-to-date')</div>
@if ($connectivity === true)
<div class="callout callout-success">{{ trans('admin.update.info.up-to-date') }}</div>
@else
<div class="callout callout-danger">{{ trans('admin.update.errors.connection', ['error' => $connectivity]) }}</div>
@endif
<table class="table">
<tbody>
<tr>
@ -103,10 +109,6 @@
</div>
</div>
<div class="col-md-6">
{!! $update->render() !!}
</div>
</div>
</section><!-- /.content -->
</div><!-- /.content-wrapper -->