feat: add carousel functions (#283)

pull/292/head
Seaton Jiang 2020-09-30 18:28:06 +08:00
parent 9bd7059848
commit b0ae3c9491
No known key found for this signature in database
GPG Key ID: C1086BAE716FF138
7 changed files with 321 additions and 123 deletions

View File

@ -532,6 +532,16 @@ button:focus {
5.
--------------------------------------------------------------*/
.k-main .board .article-carousel {
margin: 0 0 23px;
}
.k-main .board .article-carousel li {
margin-bottom: 0 !important;
padding: 0 !important;
list-style: none !important;
}
.k-main .board .article-panel {
margin: 0 0 23px;
border-radius: 0;

File diff suppressed because one or more lines are too long

View File

@ -16,6 +16,21 @@ jQuery(document).ready(function ($) {
$('#section-' + id + '_links').show()
}
jQuery('#g_carousel').click(function () {
for (let i = 1; i < 6; i++) {
jQuery('#section-c_i_' + [i]).fadeToggle(400)
jQuery('#section-c_u_' + [i]).fadeToggle(400)
}
})
if (jQuery('#g_carousel:checked').val() !== undefined) {
for (let i = 1; i < 6; i++) {
console.log('#c_i_' + [i])
jQuery('#section-c_i_' + [i]).show()
jQuery('#section-c_u_' + [i]).show()
}
}
jQuery('#g_cos').click(function () {
jQuery('#section-g_cos_bucketname').fadeToggle(400)
jQuery('#section-g_cos_url').fadeToggle(400)

View File

@ -438,4 +438,53 @@ function wpdocs_save_meta_box( $post_id ) {
update_post_meta($post_id, $meta_box['name'].'_value', $data);
}
}
add_action( 'save_post', 'wpdocs_save_meta_box' );
add_action( 'save_post', 'wpdocs_save_meta_box' );
// 主页轮播
function kratos_carousel(){
$output = '';
$carousel_img= null;
$carousel_url= null;
if(kratos_option('g_carousel', false)){
for($i=1; $i<6; $i++){
$carousel_img_{$i} = kratos_option("c_i_{$i}") ? kratos_option("c_i_{$i}") : "";
$carousel_url_{$i} = kratos_option("c_u_{$i}") ? kratos_option("c_u_{$i}") : "";
if($carousel_img_{$i} ){
$carousel_img[] = $carousel_img_{$i};
$carousel_url[] = $carousel_url_{$i};
}
}
if(is_array($carousel_img)){
$count = count($carousel_img);
} else {
$count = '0';
}
$output = '<div class="carousel article-carousel slide" id="carouselControls" data-ride="carousel"><ol class="carousel-indicators">';
for($i=0; $i<$count; $i++){
$output .= '<li data-target="#carouselControls" data-slide-to="'.$i.'"';
if($i==0) $output .= 'class="active"';
$output .= '></li>';
};
$output .='</ol><div class="carousel-inner">';
for($i=0;$i<$count;$i++){
$output .= '<div class="carousel-item';
if($i==0) $output .= ' active';
$output .= '">';
if(!empty($carousel_url[$i])){
$output .= '<a href="'.$carousel_url[$i].'" target="_blank"><img src="'.$carousel_img[$i].'" class="d-block w-100"></a>';
}else{
$output .= '<img src="'.$carousel_img[$i].'" class="d-block w-100">';
}
$output .= "</div>";
};
$output .= '</div><a class="carousel-control-prev" href="#carouselControls" role="button" data-slide="prev"><span class="carousel-control-prev-icon" aria-hidden="true"></span></a>';
$output .= '<a class="carousel-control-next" href="#carouselControls" role="button" data-slide="next"><span class="carousel-control-next-icon" aria-hidden="true"></span></a></div>';
}
if(is_array($carousel_img)){
echo $output;
}
}

View File

@ -192,7 +192,6 @@ function kratos_options()
'std' => ASSET_PATH . '/assets/img/wechat.png',
'type' => 'upload',
'class' => 'hidden',
'type' => 'upload',
);
$options[] = array(
@ -294,6 +293,83 @@ function kratos_options()
'type' => 'upload',
);
$options[] = array(
'name' => __('首页轮播', 'kratos'),
'desc' => __('开启站点首页轮播功能', 'kratos'),
'id' => 'g_carousel',
'type' => 'checkbox',
);
$options[] = array(
'name' => __('轮播一(图片)', 'kratos'),
'id' => 'c_i_1',
'class' => 'hidden',
'type' => 'upload',
);
$options[] = array(
'name' => __('轮播一(网址)', 'kratos'),
'id' => 'c_u_1',
'class' => 'hidden',
'type' => 'text',
);
$options[] = array(
'name' => __('轮播二(图片)', 'kratos'),
'id' => 'c_i_2',
'class' => 'hidden',
'type' => 'upload',
);
$options[] = array(
'name' => __('轮播二(网址)', 'kratos'),
'id' => 'c_u_2',
'class' => 'hidden',
'type' => 'text',
);
$options[] = array(
'name' => __('轮播三(图片)', 'kratos'),
'id' => 'c_i_3',
'class' => 'hidden',
'type' => 'upload',
);
$options[] = array(
'name' => __('轮播三(网址)', 'kratos'),
'id' => 'c_u_3',
'class' => 'hidden',
'type' => 'text',
);
$options[] = array(
'name' => __('轮播四(图片)', 'kratos'),
'id' => 'c_i_4',
'class' => 'hidden',
'type' => 'upload',
);
$options[] = array(
'name' => __('轮播四(网址)', 'kratos'),
'id' => 'c_u_4',
'class' => 'hidden',
'type' => 'text',
);
$options[] = array(
'name' => __('轮播五(图片)', 'kratos'),
'id' => 'c_i_5',
'class' => 'hidden',
'type' => 'upload',
);
$options[] = array(
'name' => __('轮播五(网址)', 'kratos'),
'id' => 'c_u_5',
'class' => 'hidden',
'type' => 'text',
);
$options[] = array(
'name' => __('文章配置', 'kratos'),
'type' => 'heading',
@ -335,7 +411,6 @@ function kratos_options()
'std' => ASSET_PATH . '/assets/img/donate.png',
'type' => 'upload',
'class' => 'hidden',
'type' => 'upload',
);
$options[] = array(
@ -344,7 +419,6 @@ function kratos_options()
'std' => ASSET_PATH . '/assets/img/donate.png',
'type' => 'upload',
'class' => 'hidden',
'type' => 'upload',
);
$options[] = array(

View File

@ -11,7 +11,9 @@ get_header(); ?>
<div class="container">
<div class="row">
<div class="col-lg-8 board">
<?php if(is_search()){ ?>
<?php if(is_home() && kratos_option('g_carousel', false)){
kratos_carousel();
} if(is_search()){ ?>
<div class="article-panel">
<div class="search-title"><?php _e('搜索内容:', 'kratos');the_search_query(); ?></div>
</div>

View File

@ -3,7 +3,7 @@ msgid ""
msgstr ""
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
"Project-Id-Version: Kratos\n"
"POT-Creation-Date: 2020-09-27 08:38+0800\n"
"POT-Creation-Date: 2020-09-30 18:27+0800\n"
"PO-Revision-Date: 2020-02-14 23:32+0800\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -78,7 +78,7 @@ msgstr ""
msgid "搜点什么呢?"
msgstr ""
#: header.php:76 inc/theme-options.php:485
#: header.php:76 inc/theme-options.php:559
msgid "一款专注于用户阅读体验的响应式博客主题"
msgstr ""
@ -233,7 +233,7 @@ msgstr ""
msgid "描述"
msgstr ""
#: inc/theme-article.php:397 inc/theme-options.php:219
#: inc/theme-article.php:397 inc/theme-options.php:218
msgid "关键词"
msgstr ""
@ -293,11 +293,11 @@ msgstr ""
msgid "知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议"
msgstr ""
#: inc/theme-options.php:42 inc/theme-options.php:468
#: inc/theme-options.php:42 inc/theme-options.php:542
msgid "图片导航"
msgstr ""
#: inc/theme-options.php:43 inc/theme-options.php:460
#: inc/theme-options.php:43 inc/theme-options.php:534
msgid "颜色导航"
msgstr ""
@ -429,7 +429,7 @@ msgstr ""
msgid "Chrome 移动端浏览器导航栏的颜色"
msgstr ""
#: inc/theme-options.php:184 inc/theme-options.php:342
#: inc/theme-options.php:184 inc/theme-options.php:417
msgid "微信二维码"
msgstr ""
@ -437,393 +437,441 @@ msgstr ""
msgid "开启页面右下角浮动微信二维码"
msgstr ""
#: inc/theme-options.php:199
#: inc/theme-options.php:198
msgid "404 页面图片"
msgstr ""
#: inc/theme-options.php:206
#: inc/theme-options.php:205
msgid "收录配置"
msgstr ""
#: inc/theme-options.php:211
#: inc/theme-options.php:210
msgid "分享图片"
msgstr ""
#: inc/theme-options.php:212
#: inc/theme-options.php:211
msgid "搜索引擎或者社交工具分享首页时抓取的图片"
msgstr ""
#: inc/theme-options.php:220
#: inc/theme-options.php:219
msgid "每个关键词之间需要用「英文逗号」分割"
msgstr ""
#: inc/theme-options.php:226
#: inc/theme-options.php:225
msgid "站点描述"
msgstr ""
#: inc/theme-options.php:232
#: inc/theme-options.php:231
msgid "统计代码"
msgstr ""
#: inc/theme-options.php:233
#: inc/theme-options.php:232
msgid "注意:输入 HTML/JS 代码时请注意辨别代码安全!"
msgstr ""
#: inc/theme-options.php:239
#: inc/theme-options.php:238
msgid "robots.txt 配置"
msgstr ""
#: inc/theme-options.php:240
#: inc/theme-options.php:239
msgid "- 需要 "
msgstr ""
#: inc/theme-options.php:240
#: inc/theme-options.php:239
msgid " 是开启的状态,下面的配置才会生效"
msgstr ""
#: inc/theme-options.php:245
#: inc/theme-options.php:244
msgid "- 如果网站根目录下已经有 robots.txt 文件,下面的配置不会生效"
msgstr ""
#: inc/theme-options.php:250
#: inc/theme-options.php:249
msgid "- 点击 "
msgstr ""
#: inc/theme-options.php:250
#: inc/theme-options.php:249
msgid " 查看配置是否生效,如果网站开启了 CDN可能需要刷新缓存才会生效"
msgstr ""
#: inc/theme-options.php:261
#: inc/theme-options.php:260
msgid "首页配置"
msgstr ""
#: inc/theme-options.php:266
#: inc/theme-options.php:265
msgid "哀悼功能"
msgstr ""
#: inc/theme-options.php:267
#: inc/theme-options.php:266
msgid "开启站点首页黑白功能用于R.I.P."
msgstr ""
#: inc/theme-options.php:273
#: inc/theme-options.php:272
msgid "特色图片"
msgstr ""
#: inc/theme-options.php:274
#: inc/theme-options.php:273
msgid "开启站点首页特色图片功能"
msgstr ""
#: inc/theme-options.php:281
#: inc/theme-options.php:280
msgid "默认特色图"
msgstr ""
#: inc/theme-options.php:282
#: inc/theme-options.php:281
msgid "当文章中没有图片并且没有设置特色图时在首页显示"
msgstr ""
#: inc/theme-options.php:290
#: inc/theme-options.php:289
msgid "无内容图片"
msgstr ""
#: inc/theme-options.php:291
#: inc/theme-options.php:290
msgid "当搜索不到文章或文章分类中没有文章时显示"
msgstr ""
#: inc/theme-options.php:298
msgid "文章配置"
#: inc/theme-options.php:297
msgid "首页轮播"
msgstr ""
#: inc/theme-options.php:303
msgid "知识共享协议"
#: inc/theme-options.php:298
msgid "开启站点首页轮播功能"
msgstr ""
#: inc/theme-options.php:304
msgid "开启文章知识共享协议"
msgid "轮播一(图片)"
msgstr ""
#: inc/theme-options.php:310
msgid "选择文章的知识共享协议"
#: inc/theme-options.php:311
msgid "轮播一(网址)"
msgstr ""
#: inc/theme-options.php:319
msgid "网易云音乐"
#: inc/theme-options.php:318
msgid "轮播二(图片)"
msgstr ""
#: inc/theme-options.php:320
msgid "开启网易云音乐自动播放"
#: inc/theme-options.php:325
msgid "轮播二(网址)"
msgstr ""
#: inc/theme-options.php:326
msgid "文章打赏"
#: inc/theme-options.php:332
msgid "轮播三(图片)"
msgstr ""
#: inc/theme-options.php:327
msgid "开启文章页面打赏功能"
#: inc/theme-options.php:339
msgid "轮播三(网址)"
msgstr ""
#: inc/theme-options.php:333
msgid "支付宝二维码"
#: inc/theme-options.php:346
msgid "轮播四(图片)"
msgstr ""
#: inc/theme-options.php:351
msgid "页面布局"
#: inc/theme-options.php:353
msgid "轮播四(网址)"
msgstr ""
#: inc/theme-options.php:352
msgid "是否显示侧边栏小工具(默认显示侧边栏),仅在文章页面生效"
msgstr ""
#: inc/theme-options.php:362
msgid "站长配置"
#: inc/theme-options.php:360
msgid "轮播五(图片)"
msgstr ""
#: inc/theme-options.php:367
msgid "个人头像"
msgid "轮播五(网址)"
msgstr ""
#: inc/theme-options.php:374
msgid "文章配置"
msgstr ""
#: inc/theme-options.php:379
msgid "知识共享协议"
msgstr ""
#: inc/theme-options.php:380
msgid "开启文章知识共享协议"
msgstr ""
#: inc/theme-options.php:386
msgid "选择文章的知识共享协议"
msgstr ""
#: inc/theme-options.php:395
msgid "网易云音乐"
msgstr ""
#: inc/theme-options.php:396
msgid "开启网易云音乐自动播放"
msgstr ""
#: inc/theme-options.php:402
msgid "文章打赏"
msgstr ""
#: inc/theme-options.php:403
msgid "开启文章页面打赏功能"
msgstr ""
#: inc/theme-options.php:409
msgid "支付宝二维码"
msgstr ""
#: inc/theme-options.php:425
msgid "页面布局"
msgstr ""
#: inc/theme-options.php:426
msgid "是否显示侧边栏小工具(默认显示侧边栏),仅在文章页面生效"
msgstr ""
#: inc/theme-options.php:436
msgid "站长配置"
msgstr ""
#: inc/theme-options.php:441
msgid "个人头像"
msgstr ""
#: inc/theme-options.php:448
msgid "个人昵称"
msgstr ""
#: inc/theme-options.php:381 inc/theme-widgets.php:178
#: inc/theme-options.php:455 inc/theme-widgets.php:178
msgid "个人简介"
msgstr ""
#: inc/theme-options.php:382 inc/theme-widgets.php:195
#: inc/theme-options.php:456 inc/theme-widgets.php:195
#: pages/page-toolbar.php:18
msgid "保持饥渴的专注,追求最佳的品质"
msgstr ""
#: inc/theme-options.php:388
#: inc/theme-options.php:462
msgid "邮件配置"
msgstr ""
#: inc/theme-options.php:393
#: inc/theme-options.php:467
msgid "SMTP 服务"
msgstr ""
#: inc/theme-options.php:394
#: inc/theme-options.php:468
msgid "开启 SMTP 服务功能"
msgstr ""
#: inc/theme-options.php:400
#: inc/theme-options.php:474
msgid "邮件服务器"
msgstr ""
#: inc/theme-options.php:401
#: inc/theme-options.php:475
msgid "填写发件服务器地址"
msgstr ""
#: inc/theme-options.php:408
#: inc/theme-options.php:482
msgid "服务器端口"
msgstr ""
#: inc/theme-options.php:409
#: inc/theme-options.php:483
msgid "填写发件服务器端口"
msgstr ""
#: inc/theme-options.php:416
#: inc/theme-options.php:490
msgid "授权方式"
msgstr ""
#: inc/theme-options.php:417
#: inc/theme-options.php:491
msgid "填写登录鉴权的方式ssl 或 tls"
msgstr ""
#: inc/theme-options.php:424
#: inc/theme-options.php:498
msgid "邮箱帐号"
msgstr ""
#: inc/theme-options.php:425
#: inc/theme-options.php:499
msgid "填写邮箱账号"
msgstr ""
#: inc/theme-options.php:432
#: inc/theme-options.php:506
msgid "邮箱密码"
msgstr ""
#: inc/theme-options.php:433
#: inc/theme-options.php:507
msgid "填写邮箱密码"
msgstr ""
#: inc/theme-options.php:446
#: inc/theme-options.php:520
msgid "顶部配置"
msgstr ""
#: inc/theme-options.php:451
#: inc/theme-options.php:525
msgid "顶部样式"
msgstr ""
#: inc/theme-options.php:452
#: inc/theme-options.php:526
msgid "请选择顶部样式(颜色导航或图片导航)"
msgstr ""
#: inc/theme-options.php:476
#: inc/theme-options.php:550
msgid "副标题"
msgstr ""
#: inc/theme-options.php:484
#: inc/theme-options.php:558
msgid "标题描述"
msgstr ""
#: inc/theme-options.php:492
#: inc/theme-options.php:566
msgid "页脚配置"
msgstr ""
#: inc/theme-options.php:497
#: inc/theme-options.php:571
msgid "选择需要开启的社交图标"
msgstr ""
#: inc/theme-options.php:498
#: inc/theme-options.php:572
msgid "国内平台"
msgstr ""
#: inc/theme-options.php:503
#: inc/theme-options.php:577
msgid "新浪微博"
msgstr ""
#: inc/theme-options.php:510
#: inc/theme-options.php:584
msgid "例如https://weibo.com/xxxxx"
msgstr ""
#: inc/theme-options.php:516
#: inc/theme-options.php:590
msgid "哔哩哔哩"
msgstr ""
#: inc/theme-options.php:523
#: inc/theme-options.php:597
msgid "例如https://space.bilibili.com/xxxxx"
msgstr ""
#: inc/theme-options.php:529
#: inc/theme-options.php:603
msgid "CODING"
msgstr ""
#: inc/theme-options.php:536
#: inc/theme-options.php:610
msgid "例如https://xxxxx.coding.net/u/xxxxx"
msgstr ""
#: inc/theme-options.php:542
#: inc/theme-options.php:616
msgid "码云 Gitee"
msgstr ""
#: inc/theme-options.php:549
#: inc/theme-options.php:623
msgid "例如https://gitee.com/xxxxx"
msgstr ""
#: inc/theme-options.php:555
#: inc/theme-options.php:629
msgid "海外平台"
msgstr ""
#: inc/theme-options.php:560
#: inc/theme-options.php:634
msgid "Twitter"
msgstr ""
#: inc/theme-options.php:567
#: inc/theme-options.php:641
msgid "例如https://twitter.com/xxxxx"
msgstr ""
#: inc/theme-options.php:573
#: inc/theme-options.php:647
msgid "Telegram"
msgstr ""
#: inc/theme-options.php:580
#: inc/theme-options.php:654
msgid "例如https://t.me/xxxxx"
msgstr ""
#: inc/theme-options.php:586
#: inc/theme-options.php:660
msgid "LinkedIn"
msgstr ""
#: inc/theme-options.php:593
#: inc/theme-options.php:667
msgid "例如https://www.linkedin.com/in/xxxxx"
msgstr ""
#: inc/theme-options.php:599
#: inc/theme-options.php:673
msgid "YouTube"
msgstr ""
#: inc/theme-options.php:606
#: inc/theme-options.php:680
msgid "例如https://www.youtube.com/channel/xxxxx"
msgstr ""
#: inc/theme-options.php:612
#: inc/theme-options.php:686
msgid "Github"
msgstr ""
#: inc/theme-options.php:619
#: inc/theme-options.php:693
msgid "例如https://github.com/xxxxx"
msgstr ""
#: inc/theme-options.php:625
#: inc/theme-options.php:699
msgid "Stack Overflow"
msgstr ""
#: inc/theme-options.php:632
#: inc/theme-options.php:706
msgid "例如https://stackoverflow.com/users/xxxxx"
msgstr ""
#: inc/theme-options.php:638
#: inc/theme-options.php:712
msgid "其他"
msgstr ""
#: inc/theme-options.php:643
#: inc/theme-options.php:717
msgid "电子邮箱"
msgstr ""
#: inc/theme-options.php:650
#: inc/theme-options.php:724
msgid "例如mailto:xxxxx@gmail.com"
msgstr ""
#: inc/theme-options.php:656
#: inc/theme-options.php:730
msgid "工信部备案信息"
msgstr ""
#: inc/theme-options.php:658
#: inc/theme-options.php:732
msgid "例如京ICP证xxxxxx号"
msgstr ""
#: inc/theme-options.php:663
#: inc/theme-options.php:737
msgid "公安网备案信息"
msgstr ""
#: inc/theme-options.php:665
#: inc/theme-options.php:739
msgid "例如:京公网安备 xxxxxxxxxxxx号"
msgstr ""
#: inc/theme-options.php:670
#: inc/theme-options.php:744
msgid "公安网备案连接"
msgstr ""
#: inc/theme-options.php:672
#: inc/theme-options.php:746
msgid ""
"例如http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=xxxxx"
msgstr ""
#: inc/theme-options.php:677
#: inc/theme-options.php:751
msgid "版权信息"
msgstr ""
#: inc/theme-options.php:684
#: inc/theme-options.php:758
msgid "广告配置"
msgstr ""
#: inc/theme-options.php:689
#: inc/theme-options.php:763
msgid "文章页面广告"
msgstr ""
#: inc/theme-options.php:690
#: inc/theme-options.php:764
msgid "开启顶部广告"
msgstr ""
#: inc/theme-options.php:703 inc/theme-options.php:723
#: inc/theme-options.php:777 inc/theme-options.php:797
msgid "选填广告连接,如果不填则只显示图片"
msgstr ""
#: inc/theme-options.php:710
#: inc/theme-options.php:784
msgid "开启底部广告"
msgstr ""
#: inc/theme-options.php:730
#: inc/theme-options.php:804
msgid "关于主题"
msgstr ""
@ -1042,11 +1090,11 @@ msgstr ""
msgid "没有可用的修改日志"
msgstr ""
#: index.php:16
#: index.php:18
msgid "搜索内容:"
msgstr ""
#: index.php:34
#: index.php:36
msgid "很抱歉,没有找到任何内容"
msgstr ""