diff --git a/archive.php b/archive.php index 63b5279..342cda4 100644 --- a/archive.php +++ b/archive.php @@ -1,18 +1,22 @@ -<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?> +<?php if (!defined('__TYPECHO_ROOT_DIR__')) { + exit; +} ?> <?php $this->need('page_header.php'); ?> <main class="layout" id="content-inner"> <div class="recent-posts category_ui" id="recent-posts"> <?php if ($this->have()): ?> - <?php while($this->next()): ?> + <?php while ($this->next()): ?> <div class="recent-post-item"> - <wehao class="post_cover"> - <a class="article-title" href="<?php $this->permalink() ?>"> - <img class="post-bg" data-lazy-src="<?php echo get_ArticleThumbnail($this);?>" src="<?php echo GetLazyLoad() ?>" onerror="this.onerror=null;this.src='<?php $this->options->themeUrl('img/404.jpg'); ?>'"></a> - </wehao> - <div class="recent-post-info"> - <a class="article-title" href="<?php $this->permalink() ?>"><?php $this->title() ?></a> + <?php if(noCover($this)): ?> + <wehao class="post_cover"> + <a href="<?php $this->permalink() ?>"> + <img class="post-bg" data-lazy-src="<?php echo get_ArticleThumbnail($this);?>" src="<?php echo GetLazyLoad() ?>" onerror="this.onerror=null;this.src='<?php $this->options->themeUrl('img/404.jpg'); ?>'"></a> + </wehao> + <?php endif ?> + <div class="recent-post-info<?php echo noCover($this) ? '' : ' no-cover'; ?>"> + <a class="article-title" href="<?php $this->permalink(); ?>"><?php $this->title(); ?></a> <div class="article-meta-wrap"> - <?php $this->sticky();?> + <?php $this->sticky(); ?> <span class="post-meta-date" style="display:none;"> <i class="far fa-calendar-alt"></i> <?php _e('发表于 '); ?> <?php $this->date(); ?> @@ -21,8 +25,8 @@ </span> <i class="fas fa-history"></i> <span class="article-meta-label">更新于</span> - <?php echo date('Y-m-d' , $this->modified);?> - <time class="post-meta-date-updated" datetime="<?php echo date('Y-m-d' , $this->modified);?>" title="更新于 "> + <?php echo date('Y-m-d', $this->modified); ?> + <time class="post-meta-date-updated" datetime="<?php echo date('Y-m-d', $this->modified); ?>" title="更新于 "> </time> <span class="article-meta"> <span class="article-meta__separator">|</span> @@ -41,20 +45,20 @@ <span class="article-meta__separator">|</span> <i class="fas fa-comments"></i> <span class="post-meta-date" itemprop="interactionCount"> - <a itemprop="discussionUrl" href="<?php $this->permalink() ?>#comments"> + <a itemprop="discussionUrl" href="<?php $this->permalink(); ?>#comments"> <?php $this->commentsNum('0条评论', '1 条评论', '%d 条评论'); ?> </a> </span> </span> </div> <div class="content"> - <?php if($this->fields->excerpt && $this->fields->excerpt!='') { - echo $this->fields->excerpt; - }else{ - echo $this->excerpt(130); - } - echo '<br><br><a href="',$this->permalink(),'" title="',$this->title(),'">阅读全文...</a>'; - ?> + <?php if ($this->fields->excerpt && $this->fields->excerpt != '') { + echo $this->fields->excerpt; +} else { + echo $this->excerpt(130); +} + echo '<br><br><a href="',$this->permalink(),'" title="',$this->title(),'">阅读全文...</a>'; + ?> </div> </div> </div> @@ -65,7 +69,7 @@ </article> <?php endif; ?> <nav id="pagination"> - <?php $this->pageNav('<i class="fas fa-chevron-left fa-fw"></i>', '<i class="fas fa-chevron-right fa-fw"></i>', 1, '...', array('wrapTag' => 'div', 'wrapClass' => 'pagination', 'itemTag' => '', 'prevClass' => 'extend prev', 'nextClass' => 'extend next', 'currentClass' => 'page-number current' )); ?> + <?php $this->pageNav('<i class="fas fa-chevron-left fa-fw"></i>', '<i class="fas fa-chevron-right fa-fw"></i>', 1, '...', ['wrapTag' => 'div', 'wrapClass' => 'pagination', 'itemTag' => '', 'prevClass' => 'extend prev', 'nextClass' => 'extend next', 'currentClass' => 'page-number current']); ?> </nav> </div><!-- end #main --> <?php $this->need('sidebar.php'); ?> diff --git a/comments.php b/comments.php index 21a0c95..c94acc5 100644 --- a/comments.php +++ b/comments.php @@ -44,7 +44,6 @@ <button class="submit" type="submit" ><?php _e('评论'); ?></button> </div> <?php if($this->options->siteKey !== "" && $this->options->siteKey !== ""){RecapOutPut($this->user->hasLogin()) ;?><script>$(document).ready(function(){if($("#comment_keys").length == 0){$(".g-recaptcha").css({"position":"relative","top":"-40px"})}})</script> <?php }?> - <?php if($this->options->hcaptchaSecretKey !== "" && $this->options->hcaptchaAPIKey !== ""){ RecapOutPut($this->user->hasLogin());?> <script>$(document).ready(function(){if($("#comment_keys").length == 0){$(".h-captcha").css({"position":"relative","top":"-40px"})}})</script> diff --git a/edit/extend.js b/edit/extend.js index f9ce1f3..d57aa0b 100644 --- a/edit/extend.js +++ b/edit/extend.js @@ -200,7 +200,7 @@ $("#ui-datepicker-div").after(` <div class="wmd-prompt-dialog" style="top: 38%;" role="dialog"> <div><p><b>插入代码块(语言版)</b></p></div> <form> -<p>代码语言:<select id="select-code"><option selected="selected" value="other">请选择代码语言</option><option value="asp" mode="vbscript">ASP</option><option value="actionscript" mode="clike">ActionScript(3.0)/Flash/Flex</option><option value="bash" mode="shell">Bash/Bat</option><option value="css" mode="css">CSS</option><option value="c" mode="clike">C</option><option value="cpp" mode="clike">C++</option><option value="csharp" mode="clike">C#</option><option value="coffeescript" mode="coffeescript">CoffeeScript</option><option value="d" mode="d">D</option><option value="dart" mode="dart">Dart</option><option value="delphi" mode="pascal">Delphi/Pascal</option><option value="erlang" mode="erlang">Erlang</option><option value="go" mode="go">Golang</option><option value="groovy" mode="groovy">Groovy</option><option value="html" mode="text/html">HTML</option><option value="java" mode="clike">Java</option><option value="json" mode="text/json">JSON</option><option value="javascript" mode="javascript">Javascript</option><option value="lua" mode="lua">Lua</option><option value="less" mode="css">LESS</option><option value="markdown" mode="gfm">Markdown</option><option value="objective-c" mode="clike">Objective-C</option><option value="php" mode="php">PHP</option><option value="perl" mode="perl">Perl</option><option value="python" mode="python">Python</option><option value="r" mode="r">R</option><option value="rst" mode="rst">reStructedText</option><option value="ruby" mode="ruby">Ruby</option><option value="sql" mode="sql">SQL</option><option value="sass" mode="sass">SASS/SCSS</option><option value="shell" mode="shell">Shell</option><option value="scala" mode="clike">Scala</option><option value="swift" mode="clike">Swift</option><option value="vb" mode="vb">VB/VBScript</option><option value="xml" mode="text/xml">XML</option><option value="yaml" mode="yaml">YAML</option><option value="other">其他语言</option></select></p> +<p>代码语言:<select id="select-code"><option selected="selected" value="other">请选择代码语言</option><option value="asp" mode="vbscript">ASP</option><option value="actionscript" mode="clike">ActionScript(3.0)/Flash/Flex</option><option value="bash" mode="shell">Bash/Bat</option><option value="css" mode="css">CSS</option><option value="c" mode="clike">C</option><option value="cpp" mode="clike">C++</option><option value="csharp" mode="clike">C#</option><option value="coffeescript" mode="coffeescript">CoffeeScript</option><option value="d" mode="d">D</option><option value="dart" mode="dart">Dart</option><option value="delphi" mode="pascal">Delphi/Pascal</option><option value="erlang" mode="erlang">Erlang</option><option value="go" mode="go">Golang</option><option value="groovy" mode="groovy">Groovy</option><option value="html" mode="text/html">HTML</option><option value="java" mode="clike">Java</option><option value="json" mode="text/json">JSON</option><option value="javascript" mode="javascript">Javascript</option><option value="lua" mode="lua">Lua</option><option value="less" mode="css">LESS</option><option value="markdown" mode="gfm">Markdown</option><option value="objective-c" mode="clike">Objective-C</option><option value="php" mode="php">PHP</option><option value="perl" mode="perl">Perl</option><option value="python" mode="python">Python</option><option value="r" mode="r">R</option><option value="rst" mode="rst">reStructedText</option><option value="ruby" mode="ruby">Ruby</option><option value="sql" mode="sql">SQL</option><option value="sass" mode="sass">SASS/SCSS</option><option value="shell" mode="shell">Shell</option><option value="scala" mode="clike">Scala</option><option value="swift" mode="clike">Swift</option><option value="vb" mode="vb">VB/VBScript</option><option value="xml" mode="text/xml">XML</option><option value="yaml" mode="yaml">YAML</option><option value="yml" mode="yml">YML</option><option value="other">其他语言</option></select></p> <textarea rows="10" cols="40" name="insert-codeblock" placeholder="这里填入代码块"></textarea> <button type="button" class="btn btn-s primary btn-ok">确定</button> <button type="button" class="btn btn-s btn-cancel">取消</button></form> diff --git a/footer.php b/footer.php index 03b3a46..79f5c43 100644 --- a/footer.php +++ b/footer.php @@ -93,6 +93,9 @@ </div> <!--搜索end --> <div class="js-pjax"> +<?php if ($this->options->hcaptchaSecretKey !== "" && $this->options->hcaptchaAPIKey !== ""): ?> +<script src="https://hcaptcha.com/1/api.js" async defer></script> +<?php endif ?> <?php if ($this->is('post') || $this->is('page')): ?> <script src="<?php $this->options->themeUrl('js/comjs.js?v1.4.3'); ?>"></script> <?php endif ?> @@ -115,7 +118,7 @@ <script>$(document).ready(function(){var a=document.getElementsByTagName("a");for(let i=0;i<a.length;i++){let domain=document.domain;let url=a[i].href;if(typeof(url)!="undefined"&&url.length!=0&&url.match(domain)==null&&url!="javascript:void(0);"){a[i].setAttribute("target","_BLANK")}}});</script> <?php endif; ?> <?php if($this->is('index')): ?> -<script type="text/javascript" src="<?php $this->options->themeUrl('js/wehao.js?v1.7.0'); ?>"></script> +<script type="text/javascript" src="<?php $this->options->themeUrl('js/wehao.js?v1.7.6'); ?>"></script> <style>#page-header:not(.not-top-img):before {background-color: rgba(0,0,0,0);}</style> <!--打字--> <?php if (is_array($this->options->beautifyBlock) && in_array('ShowTopimg',$this->options->beautifyBlock)): ?> @@ -262,6 +265,11 @@ function butterfly_swiper_injector_config() { NProgress.start(); })), document.addEventListener("pjax:complete", (function() { + <?php if ($this->options->hcaptchaSecretKey !== "" && $this->options->hcaptchaAPIKey !== ""): ?> + hcaptcha.render('h-captcha', { + sitekey: '<?php $this->options->hcaptchaSecretKey() ?>' + }); + <?php endif ?> <?php $this->options->PjaxCallBack() ?> NProgress.done(); window.refreshFn(), @@ -274,6 +282,7 @@ function butterfly_swiper_injector_config() { "object" == typeof _hmt && _hmt.push(["_trackPageview", window.location.pathname]), "function" == typeof loadMeting && document.getElementsByClassName("aplayer").length && loadMeting(), "object" == typeof Prism && Prism.highlightAll(), "object" == typeof preloader && preloader.endLoading() + coverShow() })), document.addEventListener("pjax:error", e => { // 404 === e.request.status && pjax.loadUrl("/404"); diff --git a/functions.php b/functions.php index 6d72f93..f30abb4 100644 --- a/functions.php +++ b/functions.php @@ -44,7 +44,6 @@ function themeConfig($form) { ); $form->addInput($StaticFile->multiMode()); - $CDNURL = new Typecho_Widget_Helper_Form_Element_Text('CDNURL',NULL,NULL, '自定义CDNURL(由@origami-tech提供)', '需要选择博客静态资源加载方式为CDN加载 此项才会生效 且<b>本地加载>自定义CDNURL>jsdelivr源</b><br> @@ -154,7 +153,6 @@ function themeConfig($form) { $categorylink = new Typecho_Widget_Helper_Form_Element_Text('categorylink', NULL,_t('#null'), _t('侧栏分类链接'), _t('需在独立页面创建并手动填入链接')); $form->addInput($categorylink); - $CloseComments = new Typecho_Widget_Helper_Form_Element_Select('CloseComments', array( 'off' => '关闭(默认)', @@ -210,7 +208,10 @@ function themeConfig($form) { '介绍:如果你使用繁体写文章请选择繁体' ); $form->addInput($DefaultEncoding->multiMode()); - + + $themeFontSize = new Typecho_Widget_Helper_Form_Element_Text('themeFontSize', NULL,_t(''), _t('默认字体大小'), _t('填入像素值,例如14px')); + $form->addInput($themeFontSize); + $GravatarSelect = new Typecho_Widget_Helper_Form_Element_Select('GravatarSelect', array( "https://gravatar.loli.net/avatar/" => 'loli(默认)', @@ -226,11 +227,11 @@ function themeConfig($form) { ); $GravatarSelect->setAttribute('id', 'gravatarlist'); $form->addInput($GravatarSelect->multiMode()); - + $baidustatistics = new Typecho_Widget_Helper_Form_Element_Text('baidustatistics', NULL,_t(''), _t('百度统计'), _t('仅需要https://hm.baidu.com/hm.js?xxxxxxxxxxxxxxxxxx部分即可')); $form->addInput($baidustatistics); - $googleadsense = new Typecho_Widget_Helper_Form_Element_Text('googleadsense', NULL,_t(''), _t('谷歌广告'), _t('仅需要https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?xxxxxxxxx部分即可')); + $googleadsense = new Typecho_Widget_Helper_Form_Element_Text('googleadsense', NULL,_t(''), _t('谷歌广告(实验性功能)'), _t('填入client后的部分,如ca-pub-xxxxx')); $form->addInput($googleadsense); $EnablePjax = new Typecho_Widget_Helper_Form_Element_Select('EnablePjax', @@ -247,18 +248,18 @@ function themeConfig($form) { $form->addInput($EnablePjax->multiMode()); $PjaxCallBack = new Typecho_Widget_Helper_Form_Element_Textarea('PjaxCallBack',NULL,NULL, - 'Pjax回调函数(非必填)', - '用于解决开启pjax导致js丢失问题' + 'PJAX回调函数(非必填)', + '用于解决开启pjax导致某些js失效问题(填入js代码)' ); $form->addInput($PjaxCallBack); /* 友链设置 */ $friendset = new Typecho_Widget_Helper_Form_Element_Select('friendset', array( - '1' => '插件模式', - '2' => '主题模式', + '1' => '主题模式', + '2' => '插件模式', ), - '2', + '1', '是否使用Link插件进行友链(需点击<a href="https://github.com/JoyNop/Typecho-Links">这里</a>下载)', '介绍:新手和手残党极其友好,默认从主题读取防止报错' ); @@ -362,8 +363,9 @@ function themeConfig($form) { 'showSnackbar' => _t('是否显示主题以及简繁切换弹窗'), 'showLazyloadBlur' => _t('是否开启懒加载模糊效果'), 'showButterflyClock' => _t('是否开启侧栏显示时钟(需要在下方填写和风和高德key)'), + 'showNoAlertSearch' => _t('是否开启无弹窗搜索框'), ), - array('ShowTopimg','PostShowTopimg','PageShowTopimg','showLineNumber','showSnackbar','showLazyloadBlur'), _t('美化选项')); + array('ShowTopimg','PostShowTopimg','PageShowTopimg','showLineNumber','showSnackbar','showLazyloadBlur','showNoAlertSearch'), _t('美化选项')); $beautifyBlock->setAttribute('id', 'beautifyBlock'); $form->addInput($beautifyBlock->multiMode()); @@ -401,10 +403,10 @@ function themeConfig($form) { $SnackbarPosition = new Typecho_Widget_Helper_Form_Element_Select('SnackbarPosition', array( 'top-left' => '左上(默认)', - 'top-center' => '上中', + 'top-center' => '中上', 'top-right' => '右上', 'bottom-left' => '左下', - 'bottom-center' => '下中', + 'bottom-center' => '中下', 'bottom-right' => '右下', ), 'top-left', @@ -673,6 +675,15 @@ function themeFields($layout) ); $layout->addItem($thumb); + $summaryContent = new Typecho_Widget_Helper_Form_Element_Textarea( + 'summaryContent', + NULL, + NULL, + '自定义文章摘要', + '不喜欢自动生成的摘要?那就来自定义吧!' + ); + $layout->addItem($summaryContent); + $desc = new Typecho_Widget_Helper_Form_Element_Text( 'desc', NULL, @@ -734,8 +745,18 @@ function themeFields($layout) '文章版权说明', '介绍:默认为CC BY-NC-SA 4.0' ); - $layout->addItem($CopyRight); - + $layout->addItem($CopyRight); + + $NoCover = new Typecho_Widget_Helper_Form_Element_Select('NoCover', + array( + 'on' => '显示封面', + 'off' => '不显示封面', + ), + 'on', + '主页是否显示封面', + '介绍:这篇文章看来不需要封面' + ); + $layout->addItem($NoCover); } // 新文章缩略图 function get_ArticleThumbnail($widget){ @@ -795,6 +816,7 @@ function GetRandomThumbnail($widget) // 文章封面缩略图 function GetRandomThumbnailPost($widget) { + $img = ''; if ($widget->fields->thumb) { $img = $widget->fields->thumb; } @@ -1720,7 +1742,7 @@ class editor { public static function reset() { - echo "<script src='" . Helper::options()->themeUrl . '/edit/extend.js?v1.6.3' . "'></script>"; + echo "<script src='" . Helper::options()->themeUrl . '/edit/extend.js?v1.7.6' . "'></script>"; echo "<link rel='stylesheet' href='" . Helper::options()->themeUrl . '/edit/edit.css?v1.6.3' . "'>"; } @@ -1769,7 +1791,8 @@ function RecapOutPut($login) { <div class="g-recaptcha" data-sitekey=' . $siteKey . '></div>'; } if (Helper::options()->hcaptchaSecretKey !== "" && Helper::options()->hcaptchaAPIKey !== "" && !$login) { - echo '<script src="https://www.hCaptcha.com/1/api.js" async defer></script><div class="h-captcha" data-sitekey='. Helper::options()->hcaptchaSecretKey .'></div>'; + echo ' + <div id="h-captcha" class="h-captcha" data-sitekey='. Helper::options()->hcaptchaSecretKey .'></div>'; } } @@ -1819,13 +1842,26 @@ function hcaptcha_filter($comment){ $secret = Helper::options()->hcaptchaAPIKey; $verifyResponse = file_get_contents('https://hcaptcha.com/siteverify?secret='.$secret.'&response='.$_POST['h-captcha-response'].'&remoteip='.$_SERVER['REMOTE_ADDR']); $responseData = json_decode($verifyResponse); - if($responseData->success == true) + if($responseData->success === true || $responseData->success === 1) { return $comments; - }else{ - throw new Typecho_Widget_Exception(_t($responseData->error-codes)); } - } + else{ + switch ($responseData->error-codes) { + case '{[0] => "timeout-or-duplicate"}': + throw new Typecho_Widget_Exception(_t('验证时间超过2分钟或连续重复发言!')); + break; + case '{[0] => "invalid-input-secret"}': + throw new Typecho_Widget_Exception(_t('网站管理员填了无效的siteKey或者secretKey...')); + break; + case '{[0] => "bad-request"}': + throw new Typecho_Widget_Exception(_t('请求错误!请检查网络')); + break; + default: + throw new Typecho_Widget_Exception(_t('很遗憾,您被当成了机器人...')); + } + } + } } } return $comment; @@ -1842,6 +1878,7 @@ function weibohot(){ '综艺' => '综', '音乐' => '音', '盛典' => '盛', + '晚会' => '晚', ); $hotness = array( @@ -1855,6 +1892,7 @@ function weibohot(){ '剧' => 'weibo-jyzy', '综' => 'weibo-jyzy', '盛' => 'weibo-jyzy', + '晚' => 'weibo-jyzy', ); foreach($data as $item){ @@ -1880,3 +1918,27 @@ function weibohot(){ echo '<div class="weibo-list-item"><div class="weibo-hotness '.$hotness[$hot].'">'.$hot.'</div><span class="weibo-title"><a title="'.$item['note'].'" href="https://s.weibo.com/weibo?q=%23' . $item['word'] . '%23" target="_blank" rel="external nofollow noreferrer" style="color:#a08ed5">'.$item['note'].'</a></span><div class="weibo-num"><span>'.$item['num'].'</span></div></div>'; } } + +// 自定义文章摘要 +function summaryContent($widget) +{ + $summaryContent = ''; + if ($widget->fields->summaryContent) { + $summaryContent = $widget->fields->summaryContent; + } + elseif($widget->fields->excerpt && $widget->fields->excerpt!='') { + $summaryContent = $widget->fields->excerpt; + } + else{ + $summaryContent = $widget->excerpt(130); + } + echo $summaryContent; +} + +//主页封面处理函数 +function noCover($widget){ + if($widget->fields->NoCover == "off"){ + return false; + } + return true; +} \ No newline at end of file diff --git a/header_com.php b/header_com.php index 7ca327f..e4e0a98 100644 --- a/header_com.php +++ b/header_com.php @@ -42,7 +42,7 @@ <?php endif; ?> <!--谷歌AdSense广告--> <?php if($this->options->googleadsense != ""): ?> - <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?<?php $this->options->googleadsense(); ?>" crossorigin="anonymous"></script> + <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=<?php $this->options->googleadsense(); ?>" crossorigin="anonymous"></script> <?php endif; ?> <!--图标库--> <link href="https://at.alicdn.com/t/font_3159629_5bvsat8p5l.css" rel="stylesheet" /> @@ -64,6 +64,11 @@ <?php endif; ?> <?php if (!empty($this->options->beautifyBlock) && in_array('showLazyloadBlur',$this->options->beautifyBlock)): ?> <style> + <?php if($this->options->themeFontSize != ""):?> + :root { + --global-font-size: <?php $this->options->themeFontSize() ?>; + } + <?php endif ?> img[data-lazy-src]:not(.loaded) {filter: blur(10px) brightness(1);}img[data-lazy-src].error {filter: none;} <?php $this->options->CustomCSS() ?> </style> @@ -283,6 +288,7 @@ if (fontSizeVal !== undefined) { document.documentElement.style.setProperty('--global-font-size', fontSizeVal + 'px') } + if(/iPadliphoneliPod Macintosh/.test(navigator.userAgent)){document.documentElement.classList.add('apple')} })()</script> <style type="text/css" data-typed-js-css="true"> .typed-cursor { @@ -316,12 +322,14 @@ } </style> <!--额外的--> + <?php if ($this->options->EnableCustomColor === 'true'): ?> <style> ::-webkit-scrollbar-thumb { background-color: <?php $this->options->CustomColorMain()?>!important; } :root { + --global-font-size: 25px!important; --btn-hover-color: <?php $this->options->CustomColorButtonHover()?>; --btn-bg: <?php $this->options->CustomColorButtonBG()?>; --text-bg-hover: <?php $this->options->CustomColorButtonBG()?>; @@ -350,7 +358,9 @@ <script src="<?php $this->options->themeUrl('/js/main.js?v1.7.3'); ?>"> </script> <script src="<?php $this->options->themeUrl('/js/utils.js?v1.7.3'); ?>"> </script> <script src="<?php $this->options->themeUrl('/js/tw_cn.js?v1.7.3'); ?>"> </script> +<?php if (is_array($this->options->beautifyBlock) && !in_array('showNoAlertSearch',$this->options->beautifyBlock)): ?> <script src="<?php $this->options->themeUrl('/js/local-search.js'); ?>"> </script> +<?php endif ?> <?php if($this->options->StaticFile == 'CDN' && $this->options->CDNURL == ''): ?> <script src="https://cdn.staticfile.org/jquery/3.6.0/jquery.min.js"></script> <script src="https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-y/instant.page/5.1.0/instantpage.min.js" type="module"> </script> diff --git a/index.php b/index.php index 2f182ef..bcd8bdb 100644 --- a/index.php +++ b/index.php @@ -7,7 +7,7 @@ * <a href="https://www.wehaox.com">个人网站</a> | <a href="https://blog.wehaox.com/archives/typecho-butterfly.html">主题使用文档</a> * @package Typecho-Butterfly * @author b站:wehao- - * @version 1.7.5 + * @version 1.7.6 * @link https://space.bilibili.com/34174433 */ if (!defined('__TYPECHO_ROOT_DIR__')) exit; @@ -79,11 +79,13 @@ endif; ?> <div class="recent-post-item"> + <?php if(noCover($this)): ?> <wehao class="post_cover"> - <a href="<?php $this->permalink() ?>"> - <img class="post-bg" data-lazy-src="<?php echo get_ArticleThumbnail($this);?>" src="<?php echo GetLazyLoad() ?>" onerror="this.onerror=null;this.src='<?php $this->options->themeUrl('img/404.jpg'); ?>'"></a> + <a href="<?php $this->permalink() ?>"> + <img class="post-bg" data-lazy-src="<?php echo get_ArticleThumbnail($this);?>" src="<?php echo GetLazyLoad() ?>" onerror="this.onerror=null;this.src='<?php $this->options->themeUrl('img/404.jpg'); ?>'"></a> </wehao> - <div class="recent-post-info"> + <?php endif ?> + <div class="recent-post-info<?php echo noCover($this) ? '' : ' no-cover'; ?>"> <a class="article-title" href="<?php $this->permalink() ?>"><?php $this->title() ?></a> <div class="article-meta-wrap"> <?php $this->sticky(); ?> @@ -114,16 +116,11 @@ <a class="twikoo-count" href="<?php $this->permalink() ?>#comments"><?php $this->commentsNum('0条评论', '1 条评论', '%d 条评论'); ?></a> </span> </div> - <div class="content"> - <?php - if($this->fields->excerpt && $this->fields->excerpt!='') { - echo $this->fields->excerpt;} - else{ - echo $this->excerpt(130); - } - echo '<br><br><a href="',$this->permalink(),'" title="',$this->title(),'">阅读全文...</a>'; - ?> - </div> + <div class="content"> + <?php summaryContent($this); + echo '<br><a href="',$this->permalink(),'" title="',$this->title(),'">阅读全文...</a>'; + ?> + </div> </div> </div> <?php endwhile; ?> @@ -137,15 +134,15 @@ <script> function ver() {console.log(` =================================================================== - + ##### # # ##### ##### ###### ##### ###### # # # # # # # # # # # # # # # # - ##### # # # # ##### # # ##### # # + ##### # # # # ##### # # ##### # # # # # # # # # ##### # # # - # # # # # # # # # # # # + # # # # # # # # # # # # ##### #### # # ###### # # # ###### # - 1.7.5 + 1.7.6 =================================================================== `);} -</script> +</script> \ No newline at end of file diff --git a/post.php b/post.php index 52173dd..315d434 100644 --- a/post.php +++ b/post.php @@ -241,4 +241,4 @@ <?php endif?> </main> <!-- end #main--> -<?php $this->need('footer.php'); ?> +<?php $this->need('footer.php'); ?> \ No newline at end of file diff --git a/public/nav.php b/public/nav.php index 65854b8..8feb8a8 100644 --- a/public/nav.php +++ b/public/nav.php @@ -2,7 +2,7 @@ <span id="blog-info"> <a href="<?php $this->options->siteUrl(); ?>"> <?php if($this->options->SiteLogo !== '') : ?> - <img src="<?php $this->options->SiteLogo() ?>" border="0" width="95px" /> + <img src="<?php $this->options->SiteLogo() ?>" width="95px" /> <?php else :?> <span class="site-name"><?php $this->options->title() ?></span> <?php endif ?> @@ -12,7 +12,14 @@ <div id="search-button"> <a class="site-page social-icon search"> <i class="fas fa-search fa-fw"></i> - <span> 搜索</span></a> + <?php if (is_array($this->options->beautifyBlock) && in_array('showNoAlertSearch',$this->options->beautifyBlock)): ?> + <form method="post" action="<?php $this->options->siteUrl(); ?>" role="search" id="dSearch"> + <input type="text" placeholder="搜索" id="dSearchIn" name="s" required="required"> + </form> + <?php else: ?> + <span> 搜索</span> + <?php endif ?> + </a> </div> <div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div> <div class="menus_items"> @@ -58,4 +65,49 @@ <?php $this->options->CustomHeaderLink() ?> </div> </div> - </nav> \ No newline at end of file + </nav> + +<?php if (is_array($this->options->beautifyBlock) && in_array('showNoAlertSearch',$this->options->beautifyBlock)): ?> +<style> +#dSearch{ + display: inline-block; +} +#dSearch>input { + border: none; + opacity: 1; + outline: none; + width: 35px; + text-indent: 2px; + transition: all .5s; + background: transparent; +} +#page-header.nav-fixed #nav ::placeholder, +#page-header.nav-fixed #nav input { + color: var(--font-color); +} + +#nav ::placeholder, +#nav input { + color: var(--light-grey); +} +#page-header.not-top-img #nav ::placeholder, +#page-header.not-top-img #nav input { + color: var(--font-color); + text-shadow: none; +} + +#page-header.nav-fixed #nav a:hover { + color: unset; +} + +</style> +<script> +var input = document.getElementById('dSearchIn'); +input.addEventListener('focus', function() { + input.style.width = '150px'; +}); +input.addEventListener('blur', function() { + input.style.width = '35px'; +}); +</script> +<?php endif ?> \ No newline at end of file