Merge pull request #16 from mashirozx/dev

Dev
pull/180/head
Ekkles 2019-12-06 21:41:25 +13:00 committed by GitHub
commit d19358f915
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 1181 additions and 1059 deletions

View File

@ -5,10 +5,10 @@
![Sakura](https://view.moezx.cc/images/2018/05/26/sakura.png)
![PHP version](https://img.shields.io/badge/PHP-7.1+-4F5B93.svg?style=flat-square)
![WP version](https://img.shields.io/badge/WordPress-5.0+-0073aa.svg?style=flat-square)
[![GitHub release](https://img.shields.io/github/release/mashirozx/Sakura.svg?style=flat-square)](https://github.com/mashirozx/Sakura/releases/latest)
[![Github commits (since latest release)](https://img.shields.io/github/commits-since/mashirozx/Sakura/latest.svg?style=flat-square)](https://github.com/mashirozx/Sakura/commits/)
![PHP version](https://shader.2heng.xin/badge/PHP-7.1+-4F5B93.svg?style=flat-square&logo=php)
![WP version](https://shader.2heng.xin/badge/WordPress-5.3-0073aa.svg?style=flat-square&logo=wordpress)
[![GitHub release](https://img.shields.io/github/v/release/mashirozx/Sakura.svg?style=flat-square&logo=github)](https://github.com/mashirozx/Sakura/releases/latest)
[![Github commits (since latest release)](https://img.shields.io/github/commits-since/mashirozx/Sakura/latest.svg?style=flat-square&logo=git&color=important)](https://github.com/mashirozx/Sakura/commits/)
[![](https://data.jsdelivr.com/v1/package/gh/moezx/cdn/badge)](https://www.jsdelivr.com/package/gh/moezx/cdn)
在 Louie 基于 Fuzzz 的 [Akina](http://www.akina.pw/themeakina) 主题修改的主题 [Siren](https://github.com/louie-senpai/Siren) 基础上三次修改 =.=

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 248 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

View File

@ -1,14 +0,0 @@
<?php
$img_array = glob("gallery/*.{gif,jpg,png}",GLOB_BRACE);
$img = array_rand($img_array);
$imgurl=$img_array[$img];
if($imgurl) {
header("Location: " . $imgurl);
exit();
} else {
exit('error');
}
?>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 486 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 732 KiB

View File

@ -1,14 +0,0 @@
<?php
$img_array = glob("gallery/*.{gif,jpg,png}",GLOB_BRACE);
$img = array_rand($img_array);
$imgurl=$img_array[$img];
if($imgurl) {
header("Location: " . $imgurl);
exit();
} else {
exit('error');
}
?>

View File

@ -1565,29 +1565,15 @@ function html_tag_parser($content) {
if (preg_match_all('/\!\{.*?\)\[.*?\]/i', $content,$matches)){
$i=0;
if ($i<sizeof($matches)) {
$content=str_replace($matches[$i],preg_replace(
'/!\{([^\{\}]+)*\}\('.$url_regex.'\)\['.$url_regex.'\]/i',
'<a data-fancybox="gallery"
data-caption="$1"
class="fancybox"
href="$2"
alt="$1"
title="$1"><img src="$7" target="_blank" rel="nofollow" class="fancybox"></a>',
$matches[$i]),
$content);
$content=str_replace(
$matches[$i],
preg_replace('/!\{([^\{\}]+)*\}\('.$url_regex.'\)\['.$url_regex.'\]/i','<a href="$2"><img src="$7" alt="$1" title="$1"></a>',$matches[$i]),
$content
);
$i++;
}
}
$content=preg_replace(
'/!\{([^\{\}]+)*\}\('.$url_regex.'\)/i',
'<a data-fancybox="gallery"
data-caption="$1"
class="fancybox"
href="$2"
alt="$1"
title="$1"><img src="$2" target="_blank" rel="nofollow" class="fancybox"></a>',
$content
);
$content=preg_replace('/!\{([^\{\}]+)*\}\('.$url_regex.'\)/i','<a href="$2"><img src="$2" alt="$1" title="$1"></a>',$content);
//Github cards
$content=preg_replace(
@ -1645,12 +1631,7 @@ function change_avatar($avatar){
// default feature image
function DEFAULT_FEATURE_IMAGE() {
if ( empty( akina_option('default_feature_image' )) ) {
return get_template_directory_uri().'/feature/index.php?'.rand(1,1000);
//return 'https://api.mashiro.top/feature/?'.rand(1,1000);
} else {
return akina_option('default_feature_image').'?'.rand(1,1000);
}
return rest_url('sakura/v1/image/feature').'?'.rand(1,1000);
}
//防止设置置顶文章造成的图片同侧bug
@ -1733,4 +1714,35 @@ function allow_more_tag_in_comment() {
$allowedtags['span'] = array('class'=>array());
}
add_action('pre_comment_on_post', 'allow_more_tag_in_comment');
/*
* 随机图
*/
function create_sakura_table(){
global $wpdb;
$sakura_table_name = $wpdb->base_prefix.'sakura';
require_once(ABSPATH . "wp-admin/includes/upgrade.php");
dbDelta("CREATE TABLE IF NOT EXISTS `" . $sakura_table_name . "` (
`mate_key` varchar(50) COLLATE utf8_bin NOT NULL,
`mate_value` text COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`mate_key`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;");
//default data
$manifest = array(
"mate_key" => "manifest_json",
"mate_value" => file_get_contents(get_template_directory()."/manifest/manifest.json")
);
$time = array(
"mate_key" => "json_time",
"mate_value" => date("Y-m-d H:i:s",time())
);
if ( !$wpdb->get_var("SELECT COUNT(*) FROM $sakura_table_name WHERE mate_key = 'manifest_json'") ){
$wpdb->insert($sakura_table_name,$manifest);
}
if ( !$wpdb->get_var("SELECT COUNT(*) FROM $sakura_table_name WHERE mate_key = 'json_time'") ){
$wpdb->insert($sakura_table_name,$time);
}
}
add_action( 'after_setup_theme', 'create_sakura_table' );
//code end

View File

@ -12,12 +12,78 @@ add_action('rest_api_init', function () {
'methods' => 'GET',
'callback' => 'cache_search_json',
));
register_rest_route('sakura/v1', '/image/cover', array(
'methods' => 'GET',
'callback' => 'cover_gallery',
));
register_rest_route('sakura/v1', '/image/feature', array(
'methods' => 'GET',
'callback' => 'feature_gallery',
));
register_rest_route('sakura/v1', '/image/manifest', array(
'methods' => 'POST',
'callback' => 'update_manifest_json',
));
register_rest_route('sakura/v1', '/qqinfo/json', array(
'methods' => 'GET',
'callback' => 'get_qq_info',
));
});
/**
* QQ info
*/
function get_qq_info(WP_REST_Request $request)
{
if (!check_ajax_referer('wp_rest', '_wpnonce', false)) {
$output = array(
'status' => 403,
'success' => false,
'message' => 'Unauthorized client.'
);
} elseif ($_GET['qq']) {
$qq = $_GET['qq'];
/**
* TODO: 设置host国外服务器默认解析的不是国内IP可能无法获取数据
* 182.254.92.32 r.qzone.qq.com
* 参考https://www.php.net/manual/zh/function.file-get-contents.php#108309
*/
$get_info = file_get_contents('http://r.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg?get_nick=1&uins=' . $qq);
$get_info = mb_convert_encoding($get_info, "UTF-8", "GBK");
$name = json_decode(substr($get_info, 17, -1), true);
if ($name) {
$output = array(
'status' => 200,
'success' => true,
'message' => 'success',
'avatar' => 'https://q.qlogo.cn/headimg_dl?dst_uin=' . $qq . '&spec=100',
'name' => $name[$qq][6],
);
} else {
$output = array(
'status' => 404,
'success' => false,
'message' => 'QQ number not exist.'
);
}
} else {
$output = array(
'status' => 400,
'success' => false,
'message' => 'Bad Request'
);
}
$result = new WP_REST_Response($output, $output['status']);
$result->set_headers(array('Content-Type' => 'application/json'));
return $result;
}
/**
* Image uploader response
*/
function upload_image(WP_REST_Request $request) {
function upload_image(WP_REST_Request $request)
{
// see: https://developer.wordpress.org/rest-api/requests/
// handle file params $file === $_FILES
@ -29,8 +95,7 @@ function upload_image(WP_REST_Request $request) {
*/
// $file = $request->get_file_params();
if (!check_ajax_referer('wp_rest', '_wpnonce', false)) {
$output = array(
'status' => 403,
$output = array('status' => 403,
'success' => false,
'message' => 'Unauthorized client.',
'link' => "https://view.moezx.cc/images/2019/11/14/step04.md.png",
@ -56,7 +121,7 @@ function upload_image(WP_REST_Request $request) {
break;
}
$result = new WP_REST_Response($API_Request, $API_Request->status);
$result = new WP_REST_Response($API_Request, $API_Request['status']);
$result->set_headers(array('Content-Type' => 'application/json'));
return $result;
}
@ -64,13 +129,14 @@ function upload_image(WP_REST_Request $request) {
/**
* Chevereto upload interface
*/
function Chevereto_API($image) {
$upload_url = akina_option('cheverto_url').'/api/1/upload';
function Chevereto_API($image)
{
$upload_url = akina_option('cheverto_url') . '/api/1/upload';
$args = array(
'body' => array(
'source' => base64_encode($image),
'key' => akina_option('chevereto_api_key')
)
'key' => akina_option('chevereto_api_key'),
),
);
$response = wp_remote_post($upload_url, $args);
@ -102,16 +168,17 @@ function Chevereto_API($image) {
/**
* Imgur upload interface
*/
function Imgur_API($image) {
function Imgur_API($image)
{
$client_id = akina_option('imgur_client_id');
$upload_url = akina_option('imgur_upload_image_proxy');
$args = array(
'headers' => array(
'Authorization' => 'Client-ID ' . $client_id
'Authorization' => 'Client-ID ' . $client_id,
),
'body' => array(
'image' => base64_encode($image)
)
'image' => base64_encode($image),
),
);
$response = wp_remote_post($upload_url, $args);
@ -143,7 +210,8 @@ function Imgur_API($image) {
/**
* smms upload interface
*/
function SMMS_API($image) {
function SMMS_API($image)
{
$client_id = akina_option('smms_client_id');
$upload_url = "https://sm.ms/api/v2/upload";
$filename = $image['cmt_img_file']['name'];
@ -170,7 +238,7 @@ function SMMS_API($image) {
$args = array(
'headers' => $headers,
'body' => $fields
'body' => $fields,
);
$response = wp_remote_post($upload_url, $args);
@ -210,7 +278,8 @@ function SMMS_API($image) {
* @rest api接口路径https://sakura.2heng.xin/wp-json/sakura/v1/cache_search/json
* @可在cache_search_json()函数末尾通过设置 HTTP header 控制 json 缓存时间
*/
function cache_search_json() {
function cache_search_json()
{
$vowels = array("[", "{", "]", "}", "<", ">", "\r\n", "\r", "\n", "-", "'", '"', '`', " ", ":", ";", '\\', " ", "toc");
$regex = <<<EOS
/<\/?[a-zA-Z]+("[^"]*"|'[^']*'|[^'">])*>|begin[\S\s]*\/begin|hermit[\S\s]*\/hermit|img[\S\s]*\/img|{{.*?}}|:.*?:/m
@ -218,7 +287,7 @@ EOS;
$posts = new WP_Query('posts_per_page=-1&post_status=publish&post_type=post');
while ($posts->have_posts()): $posts->the_post();
$output .= '{"type":"post","link":"' . get_post_permalink() . '","title":' . json_encode(get_the_title()) . ',"comments":"' . get_comments_number('0', '1', '%') . '","text":' . json_encode(str_replace($vowels, " ", preg_replace($regex, ' ', get_the_content()))) . '},';
$output .= '{"type":"post","link":"' . get_post_permalink() . '","title":' . json_encode(get_the_title()) . ',"comments":"' . get_comments_number('0', '1', '%') . '","text":' . json_encode(str_replace($vowels, " ", preg_replace($regex, ' ', get_the_content()))) . '},';
endwhile;
wp_reset_postdata();
@ -256,9 +325,98 @@ EOS;
$result->set_headers(
array(
'Content-Type' => 'application/json',
'Cache-Control' => 'max-age=3600'// json 缓存控制
'Cache-Control' => 'max-age=3600', // json 缓存控制
)
);
return $result;
}
/*
* 随机封面图 rest api
* @rest api接口路径https://sakura.2heng.xin/wp-json/sakura/v1/image/cover
*/
function cover_gallery() {
global $wpdb;
$img_array = json_decode($wpdb->get_var("SELECT `mate_value` FROM `wp_sakura` WHERE `mate_key`='manifest_json'"), true);
$img = array_rand($img_array);
$img_domain = akina_option('cover_cdn') ? akina_option('cover_cdn') : get_template_directory_uri();
if(strpos($_SERVER['HTTP_ACCEPT'], 'image/webp')) {
$imgurl = $img_domain . "/manifest/" . $img_array[$img]["webp"][0];
} else {
$imgurl = $img_domain . "/manifest/" . $img_array[$img]["jpeg"][0];
}
$data = array('cover image');
$response = new WP_REST_Response($data);
$response->set_status(302);
$response->header('Location', $imgurl);
return $response;
}
/*
* 随机文章特色图 rest api
* @rest api接口路径https://sakura.2heng.xin/wp-json/sakura/v1/image/feature
*/
function feature_gallery() {
global $wpdb;
$img_array = json_decode($wpdb->get_var("SELECT `mate_value` FROM `wp_sakura` WHERE `mate_key`='manifest_json'"), true);
$img = array_rand($img_array);
$img_domain = akina_option('cover_cdn') ? akina_option('cover_cdn') : get_template_directory_uri();
if(strpos($_SERVER['HTTP_ACCEPT'], 'image/webp')) {
$imgurl = $img_domain . "/manifest/" . $img_array[$img]["webp"][1];
} else {
$imgurl = $img_domain . "/manifest/" . $img_array[$img]["jpeg"][1];
}
$data = array('cover image');
$response = new WP_REST_Response($data);
$response->set_status(302);
$response->header('Location', $imgurl);
return $response;
}
/*
* update manifest.json rest api
* @rest api接口路径https://sakura.2heng.xin/wp-json/sakura/v1/image/json
*/
function update_manifest_json() {
$username = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
$user = wp_authenticate($username, $password);
if (is_a($user, 'WP_User')) {
if (in_array('administrator', (array) $user->roles)) {
global $wpdb;
$sakura_table_name = $wpdb->base_prefix.'sakura';
$manifest = array(
"key" => "manifest_json",
"value" => file_get_contents($_FILES["manifest"]["tmp_name"])
);
$time = array(
"key" => "json_time",
"value" => date("Y-m-d H:i:s",time())
);
$wpdb->query("DELETE FROM `wp_sakura` WHERE `mate_key` ='manifest_json'");
$wpdb->query("DELETE FROM `wp_sakura` WHERE `mate_key` ='json_time'");
$wpdb->insert($sakura_table_name,$manifest);
$wpdb->insert($sakura_table_name,$time);
$output = array(
'status' => 200,
'success' => true,
'message' => 'manifest.json has been stored into database'
);
$result = new WP_REST_Response($output, 200);
$result->set_headers(array('Content-Type' => 'application/json'));
return $result;
}
} else {
$output = array(
'status' => 401,
'success' => false,
'message' => 'Not Authorized.'
);
$result = new WP_REST_Response($output, 401);
$result->set_headers(array('Content-Type' => 'application/json'));
return $result;
}
}

View File

@ -78,15 +78,7 @@ if ( akina_option('toggle-menu') == 'no') { ?>
.comments .comments-hidden {display:none !important;}
<?php } // comments ?>
<?php
if (akina_option('cover_img')) {
$imgurl = akina_option('cover_img');
} else {
$imgurl = get_site_url()."/wp-content/themes/Sakura/cover/index.php";
}
$image_api = 'background-image: url("'.$imgurl.'");';
$image_api = 'background-image: url("'.rest_url('sakura/v1/image/cover').'");';
$bg_style = akina_option('focus_height') ? 'background-position: center center;background-attachment: inherit;' : '';
?>
.centerbg{<?php echo $image_api.$bg_style ?>background-position: center center;background-attachment: inherit;}

View File

@ -25,8 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
/* If the user can't edit theme options, no use running this plugin */
define( 'SAKURA_OPTIONS', __('Sakura Options', 'sakura') );
add_action( 'init', 'optionsframework_rolescheck' );
function optionsframework_rolescheck () {
@ -181,8 +179,8 @@ function optionsframework_setdefaults() {
function optionsframework_menu_settings() {
$menu = array(
'page_title' => __( SAKURA_OPTIONS, 'optionsframework'),
'menu_title' => __( SAKURA_OPTIONS, 'optionsframework'),
'page_title' => __('Sakura Options', 'sakura'),
'menu_title' => __('Sakura Options', 'sakura'),
'capability' => 'edit_theme_options',
'menu_slug' => 'options-framework',
'callback' => 'optionsframework_page'
@ -262,7 +260,6 @@ if ( !function_exists( 'optionsframework_page' ) ) :
function optionsframework_page() { ?>
<div id="optionsframework-wrap" class="wrap">
<?php screen_icon( 'themes' ); ?>
<h2 class="nav-tab-wrapper">
<?php echo optionsframework_tabs(); ?>
</h2>
@ -412,7 +409,7 @@ function optionsframework_adminbar() {
$wp_admin_bar->add_menu( array(
'parent' => 'appearance',
'id' => 'of_theme_options',
'title' => __( SAKURA_OPTIONS, 'options_framework_theme' ),
'title' => __('Sakura Options', 'sakura'),
'href' => admin_url( 'themes.php?page=options-framework' )
));
}

View File

@ -13,8 +13,8 @@ mashiro_option.site_name = "<?php echo akina_option('site_name', ''); ?>";
mashiro_option.author_name = "<?php echo akina_option('author_name', ''); ?>";
mashiro_option.template_url = "<?php echo get_template_directory_uri(); ?>";
mashiro_option.site_url = "<?php echo site_url(); ?>";
mashiro_option.qq_api_url = "https://api.2heng.xin/qqinfo/";
mashiro_option.qq_avatar_api_url = "https://api.2heng.xin/qqinfo/";
mashiro_option.qq_api_url = "<?php echo rest_url('sakura/v1/qqinfo/json'); ?>";
// mashiro_option.qq_avatar_api_url = "https://api.2heng.xin/qqinfo/";
mashiro_option.live_search = <?php if ( akina_option('live_search') ){ echo 'true'; } else { echo 'false'; } ?>;
<?php if( akina_option('sakura_skin_bg' )){ $bg_arry=explode(",", akina_option('sakura_skin_bg' ));?>
@ -71,13 +71,7 @@ mashiro_option.jsdelivr_css_src = "https://cdn.jsdelivr.net/gh/mashirozx/Sakura@
mashiro_option.float_player_on = true;
<?php endif; ?>
<?php
if (akina_option('cover_img')) {
$imgurl = akina_option('cover_img');
} else {
$imgurl = get_site_url()."/wp-content/themes/Sakura/cover/index.php";
} ?>
mashiro_option.cover_api = "<?php echo $imgurl; ?>";
mashiro_option.cover_api = "<?php echo rest_url('sakura/v1/image/cover'); ?>";
/*End of Initial Variables*/
</script>

View File

@ -43,11 +43,7 @@ function get_avatar_profile_url(){
* 随机图
*/
function get_random_bg_url(){
if ( empty( akina_option('default_feature_image' )) ) {
return get_template_directory_uri().'/feature/index.php?'.rand(1,1000);
} else {
return akina_option('default_feature_image').'?'.rand(1,1000);
}
return rest_url('sakura/v1/image/feature').'?'.rand(1,1000);
}
@ -118,7 +114,10 @@ if(akina_option('classify_display')){
*/
function comment_add_at( $comment_text, $comment = '') {
if( $comment->comment_parent > 0) {
$comment_text = '<a href="#comment-' . $comment->comment_parent . '" class="comment-at">@'.get_comment_author( $comment->comment_parent ) . '</a>&nbsp;' . $comment_text;
if(substr($comment_text, 0, 3) === "<p>")
$comment_text = str_replace(substr($comment_text, 0, 3), '<p><a href="#comment-' . $comment->comment_parent . '" class="comment-at">@'.get_comment_author( $comment->comment_parent ) . '</a>&nbsp;', $comment_text);
else
$comment_text = '<a href="#comment-' . $comment->comment_parent . '" class="comment-at">@'.get_comment_author( $comment->comment_parent ) . '</a>&nbsp;' . $comment_text;
}
return $comment_text;
}

View File

@ -629,7 +629,7 @@ $(document).on("click", ".sm", function () {
if (confirm(msg) == true) {
$(this).commentPrivate();
} else {
aler("已取消");
alert("已取消");
}
});
$.fn.commentPrivate = function () {
@ -883,12 +883,10 @@ function getqqinfo() {
var qq = cached.filter('#author').val();
$.ajax({
type: 'get',
url: mashiro_option.qq_api_url + '?type=getqqnickname&qq=' + qq,
dataType: 'jsonp',
jsonp: 'callback',
jsonpCallback: 'portraitCallBack',
url: mashiro_option.qq_api_url + '?qq=' + qq + '&_wpnonce=' + Poi.nonce,
dataType: 'json',
success: function (data) {
cached.filter('#author').val(data[qq][6]);
cached.filter('#author').val(data.name);
cached.filter('#email').val($.trim(qq) + '@qq.com');
if (mashiro_option.qzone_autocomplete) {
cached.filter('#url').val('https://user.qzone.qq.com/' + $.trim(qq));
@ -900,12 +898,15 @@ function getqqinfo() {
$('.qq-check').css('display', 'block');
$('.gravatar-check').css('display', 'none');
}
setCookie('user_author', data[qq][6], 30);
setCookie('user_author', data.name, 30);
setCookie('user_qq', qq, 30);
setCookie('is_user_qq', 'yes', 30);
setCookie('user_qq_email', qq + '@qq.com', 30);
setCookie('user_email', qq + '@qq.com', 30);
emailAddressFlag = cached.filter('#email').val();
/***/
$('div.comment-user-avatar img').attr('src', data.avatar);
setCookie('user_avatar', data.avatar, 30);
},
error: function () {
cached.filter('#qq').val('');
@ -915,19 +916,7 @@ function getqqinfo() {
setCookie('user_qq', '', 30);
setCookie('user_email', cached.filter('#email').val(), 30);
setCookie('user_avatar', get_gravatar(cached.filter('#email').val(), 80), 30);
}
});
$.ajax({
type: 'get',
url: mashiro_option.qq_avatar_api_url + '?type=getqqavatar&qq=' + qq,
dataType: 'jsonp',
jsonp: 'callback',
jsonpCallback: 'qqavatarCallBack',
success: function (data) {
$('div.comment-user-avatar img').attr('src', data[qq]);
setCookie('user_avatar', data[qq], 30);
},
error: function () {
/***/
cached.filter('#qq,#email,#url').val('');
if (!cached.filter('#qq').val()) {
$('.qq-check').css('display', 'none');
@ -938,6 +927,27 @@ function getqqinfo() {
}
}
});
// $.ajax({
// type: 'get',
// url: mashiro_option.qq_avatar_api_url + '?type=getqqavatar&qq=' + qq,
// dataType: 'jsonp',
// jsonp: 'callback',
// jsonpCallback: 'qqavatarCallBack',
// success: function (data) {
// $('div.comment-user-avatar img').attr('src', data[qq]);
// setCookie('user_avatar', data[qq], 30);
// },
// error: function () {
// cached.filter('#qq,#email,#url').val('');
// if (!cached.filter('#qq').val()) {
// $('.qq-check').css('display', 'none');
// $('.gravatar-check').css('display', 'block');
// setCookie('user_qq', '', 30);
// $('div.comment-user-avatar img').attr('src', get_gravatar(cached.filter('#email').val(), 80));
// setCookie('user_avatar', get_gravatar(cached.filter('#email').val(), 80), 30);
// }
// }
// });
});
if (getCookie('user_avatar') && getCookie('user_email') && getCookie('is_user_qq') == 'no' && !getCookie('user_qq_email')) {
$('div.comment-user-avatar img').attr('src', getCookie('user_avatar'));

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -25,27 +25,25 @@ class Single(object):
self.hash = hasher.hexdigest()
self.jpeg = 'jpeg/' + self.hash + '.jpeg'
self.webp = 'webp/' + self.hash + '.webp'
self.th_jpeg = 'jpeg/' + self.hash + '.th.jpeg'
self.th_webp = 'webp/' + self.hash + '.th.webp'
self.jpeg_th = 'jpeg/' + self.hash + '.th.jpeg'
self.webp_th = 'webp/' + self.hash + '.th.webp'
def optimize(self):
im = Image.open('gallary/' + self.file).convert('RGB')
im.save(self.jpeg, 'JPEG') # todo: TinyPNG API
im.save(self.webp, 'WEBP')
def thumbnail(self):
im = Image.open('gallary/' + self.file).convert('RGB')
im.thumbnail((450, 300))
im.save(self.th_jpeg, 'JPEG') # todo: TinyPNG API
im.save(self.th_webp, 'WEBP')
im.save(self.jpeg_th, 'JPEG') # todo: TinyPNG API
im.save(self.webp_th, 'WEBP')
def manifest(self):
self.mani[self.hash] = {
'source': self.file,
'jpeg': ['jpeg/' + self.hash + '.jpeg', 'jpeg/' + self.hash + '.th.jpeg'],
'webp': ['webp/' + self.hash + '.webp', 'webp/' + self.hash + '.th.webp']
'jpeg': [self.jpeg, self.jpeg_th],
'webp': [self.webp, self.webp_th]
}
#这个最好新建一个类
def upload_manifest(self):
username = input('Enter your username: ')
password = input('Enter your password: ')
@ -88,4 +86,4 @@ def main():
if __name__ == '__main__':
main()
key = input('`manifest.json` saved. Press any key to quit.')
quit()
quit()

View File

@ -262,13 +262,6 @@ function optionsframework_options() {
'right' => __('Right', 'sakura'),/*向右对齐*/
'alternate' => __('Alternate', 'sakura')/*左右交替*/
));
$options[] = array(
'name' => __('Default article feature image', 'sakura'),/*默认文章特色图*/
'desc' => __('The default image displayed without the article feature image set, use random cover if left blank (the image to be displayed is placed in the /wp-content/themes/Sakura/feature/gallery/ directory)', 'sakura'),/*在未设置文章特色图的情况下展示的默认图像,留空则调用本地随机封面(要展示的图片放入 /wp-content/themes/Sakura/feature/gallery/ 目录)*/
'id' => 'default_feature_image',
'std' => 'https://api.mashiro.top/feature/',
'type' => 'text');
$options[] = array(
'name' => __('Comment shrink', 'sakura'),/*评论收缩*/
@ -418,13 +411,6 @@ function optionsframework_options() {
'std' => '',
'type' => 'text');
$options[] = array(
'name' => __('Cover image', 'sakura'),/*封面图*/
'desc' => __('Leave this blank to use the built-in API (put the images that need to be randomly displayed into the /cover/gallery/ directory)', 'sakura'),/*此处留空则使用内置API将需要随机展示的图片放入 /cover/gallery/ 目录)*/
'id' => 'cover_img',
'std' => '',
'type' => 'text');
$options[] = array(
'name' => __('Background image filter', 'sakura'),/*背景图滤镜*/
'id' => 'focus_img_filter',
@ -748,13 +734,13 @@ function optionsframework_options() {
//后台配置
$options[] = array(
'name' => __('Background configuration', 'sakura'),/*后台配置*/
'name' => __('Dashboard configuration', 'sakura'),/*后台配置*/
'type' => 'heading' );
//后台面板自定义配色方案
$options[] = array(
'name' => __('Background panel custom color scheme', 'sakura'),/*后台面板自定义配色方案*/
'desc' => __('You can design the background panel (/wp-admin/) style yourself below, but before you start, please go to <a href="/wp-admin/profile.php">here</a> to change the color scheme to custom.(Custom).<br><b>Tip: </b>How to match colors? Maybe <a href="https://mashiro.top/color-thief/">this</a> can help you.', 'sakura'),/*你可以在下面自行设计后台面板(/wp-admin/)样式,不过在开始之前请到<a href="/wp-admin/profile.php">这里</a>将配色方案改为自定义Custom。<br><b>Tip: </b>如何搭配颜色?或许<a href="https://mashiro.top/color-thief/">这个</a>可以帮到你。*/
'name' => __('Dashboard panel custom color scheme', 'sakura'),/*后台面板自定义配色方案*/
'desc' => __('You can design the dashboard panel (/wp-admin/) style yourself below, but before you start, please go to <a href="/wp-admin/profile.php">here</a> to change the color scheme to custom.(Custom).<br><b>Tip: </b>How to match colors? Maybe <a href="https://mashiro.top/color-thief/">this</a> can help you.', 'sakura'),/*你可以在下面自行设计后台面板(/wp-admin/)样式,不过在开始之前请到<a href="/wp-admin/profile.php">这里</a>将配色方案改为自定义Custom。<br><b>Tip: </b>如何搭配颜色?或许<a href="https://mashiro.top/color-thief/">这个</a>可以帮到你。*/
'id' => 'scheme_tip',
'std' => '',
'type' => 'typography ');
@ -889,6 +875,13 @@ function optionsframework_options() {
'std' => '',
'type' => 'text');
$options[] = array(
'name' => __('Cover CDN', 'sakura'),/*封面图片库*/
'desc' => __('Fill in the cdn path for random picture display, without adding a slash at the end, for example: https://cdn.jsdelivr.net/gh/mashirozx/sakura@3.3.3, please refer to <a href = "https: //github.com/mashirozx/Sakura/wiki/options">Wiki </a>', 'sakura'),/*填写 cdn 路径用于随机图片展示最后不用加斜杠https://cdn.jsdelivr.net/gh/mashirozx/sakura@3.3.3 ,更多信息请参考<a href="https://github.com/mashirozx/Sakura/wiki/options">Wiki</a>*/
'id' => 'cover_cdn',
'std' => 'https://cdn.jsdelivr.net/gh/mashirozx/sakura@3.3.3',
'type' => 'text');
$options[] = array(
'name' => __('Use the front-end library locally (lib.js、lib.css)', 'sakura'),/*本地调用前端库lib.js、lib.css*/
'desc' => __('The front-end library don\'t load from jsDelivr, not recommand', 'sakura'),/*前端库不走 jsDelivr不建议启用*/