update api

pull/144/head
spirit 2019-11-27 23:32:41 +08:00
parent 5197e50c2e
commit b770426ce1
11 changed files with 77 additions and 104 deletions

3
cover/img.txt 100644
View File

@ -0,0 +1,3 @@
https://cdn.jsdelivr.net/gh/mashirozx/Sakura@3.3.2/cover/gallery/pixar_up_movie_balloons_desktop_1920x1080_hd-wallpaper-507967.jpg
https://cdn.jsdelivr.net/gh/mashirozx/Sakura@3.3.2/cover/gallery/beyond_by_auroralion-dan5njb.jpg
https://cdn.jsdelivr.net/gh/mashirozx/Sakura@3.3.2/cover/gallery/海の空(56993195)_by_夏T.jpg

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');
}
?>

2
feature/img.txt 100644
View File

@ -0,0 +1,2 @@
https://cdn.jsdelivr.net/gh/mashirozx/Sakura@3.3.2/feature/gallery/1.jpg
https://cdn.jsdelivr.net/gh/mashirozx/Sakura@3.3.2/feature/gallery/2.jpg

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

@ -276,13 +276,14 @@ EOS;
* @rest api接口路径https://sakura.2heng.xin/wp-json/sakura/v1/image/cover * @rest api接口路径https://sakura.2heng.xin/wp-json/sakura/v1/image/cover
*/ */
function cover_gallery() { function cover_gallery() {
$img_array = glob(get_wp_root_path(). "/themes/Sakura/cover/gallery/*.{gif,jpg,png}",GLOB_BRACE); $img_array = file(get_wp_root_path(). "/themes/Sakura/cover/img.txt");
$img = array_rand($img_array); $img = mt_rand(0, count($img_array) - 1);
$imgurl = $img_array[$img]; $imgurl = trim($img_array[$img]);
$mimetype = end(getimagesize($imgurl)); $data = array( 'cover image' );
$imgdata = file_get_contents($imgurl); $response = new WP_REST_Response($data);
header("Content-type: ".$mimetype); $response->set_status( 302 );
echo $imgdata; $response->header( 'Location', $imgurl);
return $response;
} }
/* /*
@ -290,11 +291,12 @@ function cover_gallery() {
* @rest api接口路径https://sakura.2heng.xin/wp-json/sakura/v1/image/feature * @rest api接口路径https://sakura.2heng.xin/wp-json/sakura/v1/image/feature
*/ */
function feature_gallery() { function feature_gallery() {
$img_array = glob(get_wp_root_path(). "/themes/Sakura/feature/gallery/*.{gif,jpg,png}",GLOB_BRACE); $img_array = file(get_wp_root_path(). "/themes/Sakura/feature/img.txt");
$img = array_rand($img_array); $img = mt_rand(0, count($img_array) - 1);
$imgurl = $img_array[$img]; $imgurl = trim($img_array[$img]);
$mimetype = end(getimagesize($imgurl)); $data = array( 'feature image' );
$imgdata = file_get_contents($imgurl); $response = new WP_REST_Response($data);
header("Content-type: ".$mimetype); $response->set_status( 302 );
echo $imgdata; $response->header( 'Location', $imgurl);
return $response;
} }

Binary file not shown.

View File

@ -1,8 +1,8 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Sakura\n" "Project-Id-Version: Sakura\n"
"POT-Creation-Date: 2019-11-17 21:32+0800\n" "POT-Creation-Date: 2019-11-27 23:10+0800\n"
"PO-Revision-Date: 2019-11-17 21:32+0800\n" "PO-Revision-Date: 2019-11-27 23:10+0800\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
"Language: en_US\n" "Language: en_US\n"
@ -171,41 +171,41 @@ msgstr ""
msgid "Edit" msgid "Edit"
msgstr "" msgstr ""
#: functions.php:485 #: functions.php:486
msgid "" msgid ""
"Please install pulgin <a href=\"https://wordpress.org/plugins/wp-statistics/" "Please install pulgin <a href=\"https://wordpress.org/plugins/wp-statistics/"
"\" target=\"_blank\">WP-Statistics</a>" "\" target=\"_blank\">WP-Statistics</a>"
msgstr "" msgstr ""
#: functions.php:538 #: functions.php:536
msgid "This guy is so lazy ╮(╯▽╰)╭" msgid "This guy is so lazy ╮(╯▽╰)╭"
msgstr "" msgstr ""
#: functions.php:1248 #: functions.php:1246
msgid "All expand/collapse" msgid "All expand/collapse"
msgstr "" msgstr ""
#: functions.php:1259 options.php:840 #: functions.php:1257 options.php:840
msgid " " msgid " "
msgstr "" msgstr ""
#: functions.php:1263 #: functions.php:1261
msgid " post(s)" msgid " post(s)"
msgstr "" msgstr ""
#: functions.php:1285 functions.php:1288 inc/theme_plus.php:479 #: functions.php:1283 functions.php:1286 inc/theme_plus.php:479
msgid "Dashboard" msgid "Dashboard"
msgstr "" msgstr ""
#: functions.php:1501 #: functions.php:1499
msgid "<b>ERROR</b>: This email domain (<b>@" msgid "<b>ERROR</b>: This email domain (<b>@"
msgstr "" msgstr ""
#: functions.php:1581 #: functions.php:1603
msgid "QQ" msgid "QQ"
msgstr "" msgstr ""
#: functions.php:1637 #: functions.php:1659
msgid "Sidebar" msgid "Sidebar"
msgstr "" msgstr ""
@ -214,7 +214,7 @@ msgstr ""
msgid "page %s " msgid "page %s "
msgstr "" msgstr ""
#: inc/api.php:253 inc/theme_plus.php:728 #: inc/api.php:252 inc/theme_plus.php:728
msgid "The comment is private" msgid "The comment is private"
msgstr "" msgstr ""
@ -690,9 +690,9 @@ msgstr ""
#: options.php:268 #: options.php:268
msgid "" msgid ""
"The default image displayed without the article feature image set, use " "The default image to be displayed without the feature map of the article. "
"random cover if left blank (the image to be displayed is placed in the /wp-" "Leave blank here to use the built-in API (write the URL of the image to be "
"content/themes/Sakura/feature/gallery/ directory)" "displayed randomly to the /feature/img.txt file)"
msgstr "" msgstr ""
#: options.php:274 #: options.php:274
@ -870,8 +870,8 @@ msgstr ""
#: options.php:423 #: options.php:423
msgid "" msgid ""
"Leave this blank to use the built-in API (put the images that need to be " "Leave blank here to use the built-in API (write the URL of the image that "
"randomly displayed into the /cover/gallery/ directory)" "needs to be displayed randomly to the /cover/img.txt file))"
msgstr "" msgstr ""
#: options.php:429 #: options.php:429
@ -1005,8 +1005,6 @@ msgid "Post share"
msgstr "" msgstr ""
#: options.php:587 #: options.php:587
#, fuzzy
#| msgid "Previous"
msgid "Previous and Next" msgid "Previous and Next"
msgstr "Previous" msgstr "Previous"

View File

@ -1,9 +1,8 @@
#, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
"Project-Id-Version: Sakura\n" "Project-Id-Version: Sakura\n"
"POT-Creation-Date: 2019-11-17 21:32+0800\n" "POT-Creation-Date: 2019-11-27 23:10+0800\n"
"PO-Revision-Date: 2019-11-01 14:27+0800\n" "PO-Revision-Date: 2019-11-01 14:27+0800\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
@ -170,41 +169,41 @@ msgstr ""
msgid "Edit" msgid "Edit"
msgstr "" msgstr ""
#: functions.php:485 #: functions.php:486
msgid "" msgid ""
"Please install pulgin <a href=\"https://wordpress.org/plugins/wp-statistics/\" target=\"_blank" "Please install pulgin <a href=\"https://wordpress.org/plugins/wp-statistics/\" target=\"_blank"
"\">WP-Statistics</a>" "\">WP-Statistics</a>"
msgstr "" msgstr ""
#: functions.php:538 #: functions.php:536
msgid "This guy is so lazy ╮(╯▽╰)╭" msgid "This guy is so lazy ╮(╯▽╰)╭"
msgstr "" msgstr ""
#: functions.php:1248 #: functions.php:1246
msgid "All expand/collapse" msgid "All expand/collapse"
msgstr "" msgstr ""
#: functions.php:1259 options.php:840 #: functions.php:1257 options.php:840
msgid " " msgid " "
msgstr "" msgstr ""
#: functions.php:1263 #: functions.php:1261
msgid " post(s)" msgid " post(s)"
msgstr "" msgstr ""
#: functions.php:1285 functions.php:1288 inc/theme_plus.php:479 #: functions.php:1283 functions.php:1286 inc/theme_plus.php:479
msgid "Dashboard" msgid "Dashboard"
msgstr "" msgstr ""
#: functions.php:1501 #: functions.php:1499
msgid "<b>ERROR</b>: This email domain (<b>@" msgid "<b>ERROR</b>: This email domain (<b>@"
msgstr "" msgstr ""
#: functions.php:1581 #: functions.php:1603
msgid "QQ" msgid "QQ"
msgstr "" msgstr ""
#: functions.php:1637 #: functions.php:1659
msgid "Sidebar" msgid "Sidebar"
msgstr "" msgstr ""
@ -213,7 +212,7 @@ msgstr ""
msgid "page %s " msgid "page %s "
msgstr "" msgstr ""
#: inc/api.php:253 inc/theme_plus.php:728 #: inc/api.php:252 inc/theme_plus.php:728
msgid "The comment is private" msgid "The comment is private"
msgstr "" msgstr ""
@ -685,9 +684,9 @@ msgstr ""
#: options.php:268 #: options.php:268
msgid "" msgid ""
"The default image displayed without the article feature image set, use random cover if left " "The default image to be displayed without the feature map of the article. Leave blank here to "
"blank (the image to be displayed is placed in the /wp-content/themes/Sakura/feature/gallery/ " "use the built-in API (write the URL of the image to be displayed randomly to the /feature/img."
"directory)" "txt file)"
msgstr "" msgstr ""
#: options.php:274 #: options.php:274
@ -861,8 +860,8 @@ msgstr ""
#: options.php:423 #: options.php:423
msgid "" msgid ""
"Leave this blank to use the built-in API (put the images that need to be randomly displayed " "Leave blank here to use the built-in API (write the URL of the image that needs to be "
"into the /cover/gallery/ directory)" "displayed randomly to the /cover/img.txt file))"
msgstr "" msgstr ""
#: options.php:429 #: options.php:429

Binary file not shown.

View File

@ -1,8 +1,8 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Sakura\n" "Project-Id-Version: Sakura\n"
"POT-Creation-Date: 2019-11-17 21:32+0800\n" "POT-Creation-Date: 2019-11-27 23:14+0800\n"
"PO-Revision-Date: 2019-11-17 21:32+0800\n" "PO-Revision-Date: 2019-11-27 23:14+0800\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
"Language: zh_CN\n" "Language: zh_CN\n"
@ -171,7 +171,7 @@ msgstr "否"
msgid "Edit" msgid "Edit"
msgstr "编辑" msgstr "编辑"
#: functions.php:485 #: functions.php:486
msgid "" msgid ""
"Please install pulgin <a href=\"https://wordpress.org/plugins/wp-statistics/" "Please install pulgin <a href=\"https://wordpress.org/plugins/wp-statistics/"
"\" target=\"_blank\">WP-Statistics</a>" "\" target=\"_blank\">WP-Statistics</a>"
@ -179,35 +179,35 @@ msgstr ""
"请安装插件 <a href=\"https://wordpress.org/plugins/wp-statistics/\" target=" "请安装插件 <a href=\"https://wordpress.org/plugins/wp-statistics/\" target="
"\"_blank\">WP-Statistics</a>" "\"_blank\">WP-Statistics</a>"
#: functions.php:538 #: functions.php:536
msgid "This guy is so lazy ╮(╯▽╰)╭" msgid "This guy is so lazy ╮(╯▽╰)╭"
msgstr "这家伙好懒╮(╯▽╰)╭" msgstr "这家伙好懒╮(╯▽╰)╭"
#: functions.php:1248 #: functions.php:1246
msgid "All expand/collapse" msgid "All expand/collapse"
msgstr "全部展开/收缩" msgstr "全部展开/收缩"
#: functions.php:1259 options.php:840 #: functions.php:1257 options.php:840
msgid " " msgid " "
msgstr "" msgstr ""
#: functions.php:1263 #: functions.php:1261
msgid " post(s)" msgid " post(s)"
msgstr " 篇文章" msgstr " 篇文章"
#: functions.php:1285 functions.php:1288 inc/theme_plus.php:479 #: functions.php:1283 functions.php:1286 inc/theme_plus.php:479
msgid "Dashboard" msgid "Dashboard"
msgstr "管理中心" msgstr "管理中心"
#: functions.php:1501 #: functions.php:1499
msgid "<b>ERROR</b>: This email domain (<b>@" msgid "<b>ERROR</b>: This email domain (<b>@"
msgstr "" msgstr ""
#: functions.php:1581 #: functions.php:1603
msgid "QQ" msgid "QQ"
msgstr "" msgstr ""
#: functions.php:1637 #: functions.php:1659
msgid "Sidebar" msgid "Sidebar"
msgstr "侧栏" msgstr "侧栏"
@ -216,7 +216,7 @@ msgstr "侧栏"
msgid "page %s " msgid "page %s "
msgstr "第 %s 页 " msgstr "第 %s 页 "
#: inc/api.php:253 inc/theme_plus.php:728 #: inc/api.php:252 inc/theme_plus.php:728
msgid "The comment is private" msgid "The comment is private"
msgstr "该评论为私密评论" msgstr "该评论为私密评论"
@ -697,12 +697,12 @@ msgstr "默认文章特色图"
#: options.php:268 #: options.php:268
msgid "" msgid ""
"The default image displayed without the article feature image set, use " "The default image to be displayed without the feature map of the article. "
"random cover if left blank (the image to be displayed is placed in the /wp-" "Leave blank here to use the built-in API (write the URL of the image to be "
"content/themes/Sakura/feature/gallery/ directory)" "displayed randomly to the /feature/img.txt file)"
msgstr "" msgstr ""
"在未设置文章特色图的情况下展示的默认图像,留空则调用本地随机封面(要展示的图" "在未设置文章特色图的情况下展示的默认图像,此处留空则使用内置API将需要随机展"
"片放入 /wp-content/themes/Sakura/feature/gallery/ 目录" "示的图片url写入 /feature/img.txt 文件"
#: options.php:274 #: options.php:274
msgid "Comment shrink" msgid "Comment shrink"
@ -881,9 +881,10 @@ msgstr "封面图"
#: options.php:423 #: options.php:423
msgid "" msgid ""
"Leave this blank to use the built-in API (put the images that need to be " "Leave blank here to use the built-in API (write the URL of the image that "
"randomly displayed into the /cover/gallery/ directory)" "needs to be displayed randomly to the /cover/img.txt file))"
msgstr "此处留空则使用内置API将需要随机展示的图片放入 /cover/gallery/ 目录)" msgstr ""
"此处留空则使用内置API将需要随机展示的图片url写入 /cover/img.txt 文件)"
#: options.php:429 #: options.php:429
msgid "Background image filter" msgid "Background image filter"
@ -1779,8 +1780,6 @@ msgid "This username has been registered."
msgstr "该用户名已被注册。" msgstr "该用户名已被注册。"
#: user/page-register.php:24 #: user/page-register.php:24
#, fuzzy
#| msgid "Please enter email address."
msgid "Please enter email address." msgid "Please enter email address."
msgstr "请填写电子邮件地址。" msgstr "请填写电子邮件地址。"
@ -1821,8 +1820,6 @@ msgid "Sign up"
msgstr "注 册" msgstr "注 册"
#: user/page-register.php:92 #: user/page-register.php:92
#, fuzzy
#| msgid "Registration is not open yet"
msgid "Registration is not open yet." msgid "Registration is not open yet."
msgstr "暂未开放注册。" msgstr "暂未开放注册。"

View File

@ -265,7 +265,7 @@ function optionsframework_options() {
$options[] = array( $options[] = array(
'name' => __('Default article feature image', 'sakura'),/*默认文章特色图*/ '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/ 目录*/ 'desc' => __('The default image to be displayed without the feature map of the article. Leave blank here to use the built-in API (write the URL of the image to be displayed randomly to the /feature/img.txt file)', 'sakura'),/*在未设置文章特色图的情况下展示的默认图像,此处留空则使用内置API将需要随机展示的图片url写入 /feature/img.txt 文件*/
'id' => 'default_feature_image', 'id' => 'default_feature_image',
'std' => 'https://api.mashiro.top/feature/', 'std' => 'https://api.mashiro.top/feature/',
'type' => 'text'); 'type' => 'text');
@ -420,7 +420,7 @@ function optionsframework_options() {
$options[] = array( $options[] = array(
'name' => __('Cover image', 'sakura'),/*封面图*/ '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/ 目录*/ 'desc' => __('Leave blank here to use the built-in API (write the URL of the image that needs to be displayed randomly to the /cover/img.txt file))', 'sakura'),/*此处留空则使用内置API将需要随机展示的图片url写入 /cover/img.txt 文件*/
'id' => 'cover_img', 'id' => 'cover_img',
'std' => '', 'std' => '',
'type' => 'text'); 'type' => 'text');