mirror of
https://github.com/typecho/typecho.git
synced 2025-04-21 02:01:52 +02:00
release new version
This commit is contained in:
parent
01d3badc9b
commit
a214977c83
@ -136,18 +136,17 @@ $(document).ready(function () {
|
||||
|
||||
function applyUpdate(update) {
|
||||
if (update.available) {
|
||||
$('<div class="update-check"><p>'
|
||||
$('<div class="update-check message error"><p>'
|
||||
+ '<?php _e('您当前使用的版本是 %s'); ?>'.replace('%s', update.current) + '<br />'
|
||||
+ '<strong><a href="' + update.link + '" target="_blank">'
|
||||
+ '<?php _e('官方最新版本是 %s'); ?>'.replace('%s', update.latest) + '</a></strong></p></div>')
|
||||
.appendTo('.welcome-board').effect('highlight');
|
||||
.insertAfter('.typecho-page-title').effect('highlight');
|
||||
}
|
||||
}
|
||||
|
||||
if (!!update) {
|
||||
applyUpdate($.parseJSON(update));
|
||||
} else {
|
||||
update = '';
|
||||
$.get('<?php $options->index('/action/ajax?do=checkVersion'); ?>', function (o, status, resp) {
|
||||
applyUpdate(o);
|
||||
cache.setItem('update', resp.responseText);
|
||||
|
@ -163,11 +163,11 @@ $(document).ready(function() {
|
||||
})();
|
||||
|
||||
if (dstOffset > 0) {
|
||||
$('<input name="dst" type="hidden" />').insertAfter(form).val(dstOffset);
|
||||
$('<input name="dst" type="hidden" />').appendTo(form).val(dstOffset);
|
||||
}
|
||||
|
||||
// 时区
|
||||
$('<input name="timezone" type="hidden" />').insertAfter(form).val(Math.floor((Date.now() - Date.UTC()) / 1000));
|
||||
$('<input name="timezone" type="hidden" />').appendTo(form).val(- (new Date).getTimezoneOffset() * 60);
|
||||
|
||||
// 自动保存
|
||||
<?php if ($options->autoSave): ?>
|
||||
|
@ -22,7 +22,7 @@ define('__TYPECHO_MB_SUPPORTED__', function_exists('mb_get_info') && function_ex
|
||||
class Typecho_Common
|
||||
{
|
||||
/** 程序版本 */
|
||||
const VERSION = '1.1/17.10.28';
|
||||
const VERSION = '1.1/17.10.29';
|
||||
|
||||
/**
|
||||
* 允许的属性
|
||||
|
@ -44,31 +44,27 @@ class Widget_Ajax extends Widget_Abstract_Options implements Widget_Interface_Do
|
||||
if ($client) {
|
||||
$client->setHeader('User-Agent', $this->options->generator)
|
||||
->setTimeout(10)
|
||||
->send('https://github.com/typecho/typecho/releases.atom');
|
||||
->send('http://typecho.org/version.json');
|
||||
|
||||
/** 匹配内容体 */
|
||||
$response = $client->getResponseBody();
|
||||
preg_match_all("/<link rel=\"alternate\"[^>]+href=\"([^>]*)\"\s*\/>/is", $response, $matches);
|
||||
$result = array('available' => 0);
|
||||
$json = json_decode($response, true);
|
||||
|
||||
list($soft, $version) = explode(' ', $this->options->generator);
|
||||
$current = explode('/', $version);
|
||||
if (!empty($json)) {
|
||||
list($soft, $version) = explode(' ', $this->options->generator);
|
||||
$current = explode('/', $version);
|
||||
|
||||
if ($matches) {
|
||||
foreach ($matches[0] as $key => $val) {
|
||||
$title = trim($matches[1][$key]);
|
||||
if (preg_match("/v([0-9\.]+)\-([0-9\.]+)\-release$/is", $title, $out)) {
|
||||
if (version_compare($out[1], $current[0], '>=')
|
||||
&& version_compare($out[2], $current[1], '>')) {
|
||||
$result = array(
|
||||
'available' => 1,
|
||||
'latest' => $out[1] . '-' . $out[2],
|
||||
'current' => $current[0] . '-' . $current[1],
|
||||
'link' => 'https://github.com' . $matches[1][$key]
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isset($json['release']) && isset($json['version'])
|
||||
&& preg_match("/^[0-9\.]+$/", $json['release'])
|
||||
&& preg_match("/^[0-9\.]+$/", $json['version'])
|
||||
&& version_compare($json['release'], $current[0], '>=')
|
||||
&& version_compare($json['version'], $current[1], '>')) {
|
||||
$result = array(
|
||||
'available' => 1,
|
||||
'latest' => $json['release'] . '-' . $json['version'],
|
||||
'current' => $current[0] . '-' . $current[1],
|
||||
'link' => 'http://typecho.org/download'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user