diff options
| author | BigCoke233 <hi@guhub.cn> | 2020-07-30 23:45:41 +0800 |
|---|---|---|
| committer | BigCoke233 <hi@guhub.cn> | 2020-07-30 23:45:41 +0800 |
| commit | 23c8e8fed64c5995101cc9ceb08706d8849b0a3c (patch) | |
| tree | 0b5cd4eb18caf8313f41911b1d208c3da2c72c88 | |
| parent | 7168e743fe802cc977ce8fe990f09bf87ba46eaa (diff) | |
:zap: Add: 各种优化、新增和修复
- 新增:支持自定义「导航栏图标按钮」
- 新增:文章目录(使用 `{:toc:}` 在文中插入目录)
- 新增:归档页面中添加「文章分类」栏目
- 优化:将设置项「Pjax 完成后执行事件」更改为更准确的「Pjax 回调函数」
- 修复:一个存在了超久的拼写错误(`paresNav`=>`parseNav`)
- 修复:archive 页面(即分类、标签、搜索等)文章头图问题
| -rw-r--r-- | README.md | 11 | ||||
| -rw-r--r-- | archive.php | 2 | ||||
| -rw-r--r-- | assets/css/main/nav.css | 5 | ||||
| -rw-r--r-- | assets/css/main/post.css | 25 | ||||
| -rw-r--r-- | includes/header.php | 18 | ||||
| -rw-r--r-- | libs/Contents.php | 44 | ||||
| -rwxr-xr-x | libs/Options.php | 8 | ||||
| -rw-r--r-- | libs/lang/en-us.php | 1 | ||||
| -rw-r--r-- | libs/lang/moe.php | 3 | ||||
| -rw-r--r-- | libs/lang/zh-cn.php | 1 | ||||
| -rw-r--r-- | libs/lang/zh-tw.php | 1 | ||||
| -rw-r--r-- | pagefile.php | 10 | ||||
| -rw-r--r-- | themeConfig.php | 2 |
13 files changed, 119 insertions, 12 deletions
@@ -168,6 +168,17 @@ $ git clone https://github.com/BigCoke233/miracles.git - 优化:用 alertify.js 替换自己的提示框 - 优化:页面/文章评论列表隐藏时,不显示评论数 +**v20200730A** + +~~咕了半个月的更新~~ + +- 新增:支持自定义「导航栏图标按钮」 +- 新增:文章目录(使用 `{:toc:}` 在文中插入目录) +- 新增:归档页面中添加「文章分类」栏目 +- 优化:将设置项「Pjax 完成后执行事件」更改为更准确的「Pjax 回调函数」 +- 修复:一个存在了超久的拼写错误(`paresNav`=>`parseNav`) +- 修复:archive 页面(即分类、标签、搜索等)文章头图问题 + </details> ## 📝 计划 diff --git a/archive.php b/archive.php index 0c2c159..cb852ae 100644 --- a/archive.php +++ b/archive.php @@ -14,7 +14,7 @@ $this->need('includes/header.php'); <div class="col-md-6 post-banner-box"> <a href="<?php $this->permalink(); ?>" class="post-link"> <div class="post-banner"> - <img src="/usr/themes/Miracles/images/loading/<?php echo $this->options->loading_image ?>.gif" data-gisrc="<?php if($this->fields->banner && $this->fields->banner=!''): ?><?php echo $this->fields->banner(); ?><?php else: ?><?php Utils::indexTheme('images/postbg/'); ?><?php echo mt_rand(1,20); ?>.jpg<?php endif; ?>"> + <img src="<?php echo Utils::addLoadingImages($this->options->CDN, $this->options->loading_image, 'normal'); ?>" data-gisrc="<?php Utils::postBanner($this); ?>"> </div> </a> </div> diff --git a/assets/css/main/nav.css b/assets/css/main/nav.css index dfd0d59..8ae1ba2 100644 --- a/assets/css/main/nav.css +++ b/assets/css/main/nav.css @@ -230,6 +230,7 @@ background: rgb(240,240,240);
}
.drawer-icon {
+ display: inline-block;
height: 45px;
width: 45px;
border-radius: 100%;
@@ -238,10 +239,14 @@ margin: 0 3px;
border: none;
outline: none;
+ padding: 1px 6px;
}
.drawer-icon:hover {
background: rgb(240,240,240);
}
+a.drawer-icon {
+ line-height: 2.55
+}
/* Search/Login/Menu */
.search,.login,.mobile-menu {
diff --git a/assets/css/main/post.css b/assets/css/main/post.css index 5dc5a95..5520a93 100644 --- a/assets/css/main/post.css +++ b/assets/css/main/post.css @@ -444,3 +444,28 @@ .post-item-content{
padding: 0 35px 10px 35px;
}
+
+/* 文章目录 **/
+
+.toc-box {
+ border: 1px solid #ddd;
+ background: rgb(245,245,245);
+ padding: 1em 2em;
+ border-radius: .2em
+}
+
+.toc-level-3 {
+ margin-left: 1em;
+}
+
+.toc-level-4 {
+ margin-left: 2em;
+}
+
+.toc-level-5 {
+ margin-left: 3em;
+}
+
+.toc-level-6 {
+ margin-left: 4em;
+}
\ No newline at end of file diff --git a/includes/header.php b/includes/header.php index 4130d78..a35fdc9 100644 --- a/includes/header.php +++ b/includes/header.php @@ -44,7 +44,7 @@ ->parse('<div class="col-6"><a href="{permalink}">{title}</a></div>'); } else { - echo Contents::paresNav($this->options->customNav, "mobile"); + echo Contents::parseNav($this->options->customNav, "mobile"); }?> </div></div></div> <div class="mobile-menu-footer"> @@ -56,9 +56,13 @@ <nav class="small-screen nav nav-mobile nav-fixed"<?php if($this->options->navStyle==1): ?> style="display:none!important"<?php endif; ?> id="navBarMobile"> <div class="nav-mobile-content" role="navigation"> <a href="<?php $this->options->SiteUrl(); ?>" style="float:left"><i class="iconfont icon-xuanzhongshangcheng"></i></a> + <?php if(!$this->options->customNavIcon)://如果没有自定义图标 ?> <a id="search-open-mobile" style="float:left"><i class="iconfont icon-chaxun"></i></a> <a id="login-open-mobile" style="float:left"><i class="iconfont icon-user"></i></a> <a id="toggle-dark-mobile" style="float:left"><i class="iconfont icon-sun"></i></a> + <?php else://如果有自定义图标 + echo Contents::parseNavIcon($this->options->customNavIcon, "mobile"); + endif; ?> <a id="toggle-mobile-menu-button" style="float:right">MENU <i class="iconfont icon-list"></i></a> </div> </nav> @@ -78,13 +82,17 @@ ->parse('<a href="{permalink}">{title}</a>'); } else { - echo Contents::paresNav($this->options->customNav, "top-nav"); + echo Contents::parseNav($this->options->customNav, "top-nav"); }?> </span> </p> + <?php if(!$this->options->customNavIcon)://如果没有自定义图标 ?> <button class="nav-icon-button search-button" id="search-open-button"><i class="iconfont icon-chaxun"></i></button> <button class="nav-icon-button login-button" id="login-open"><i class="iconfont icon-user"></i></button> <button class="nav-icon-button setting-button" id="toggle-dark-button"><i class="iconfont icon-sun"></i></button> + <?php else://如果有自定义图标 + echo Contents::parseNavIcon($this->options->customNavIcon, "top-nav"); + endif; ?> </div> </nav> <?php elseif($this->options->navStyle==1): ?> @@ -106,14 +114,18 @@ ->parse('<a href="{permalink}" onclick="toggleDrawer()">{title}</a>'); } else { - echo Contents::paresNav($this->options->customNav, "drawer"); + echo Contents::parseNav($this->options->customNav, "drawer"); }?> </div> </div> <div class="drawer-footer"> + <?php if(!$this->options->customNavIcon)://如果没有自定义图标 ?> <button class="drawer-icon" id="search-open-button"><i class="iconfont icon-chaxun"></i></button> <button class="drawer-icon" id="login-open"><i class="iconfont icon-user"></i></button> <button class="drawer-icon" id="toggle-dark-button"><i class="iconfont icon-sun"></i></button> + <?php else://如果有自定义图标 + echo Contents::parseNavIcon($this->options->customNavIcon, "drawer"); + endif; ?> </div> </div></nav> <?php endif;?> diff --git a/libs/Contents.php b/libs/Contents.php index d821b72..b1b8db9 100644 --- a/libs/Contents.php +++ b/libs/Contents.php @@ -32,7 +32,7 @@ class Contents //Links $text = Contents::parseLink($text); //toc - $text = preg_replace('/{:toc:}/s',Contents::tableOfContents($text),$text); + $text = preg_replace('/{:toc:}/s', '<div class="toc-box">'.Contents::tableOfContents($text).'</div>', $text); } return $text; } @@ -277,7 +277,7 @@ class Contents /** * 解析自定义导航栏 */ - static public function paresNav($data, $type) { + static public function parseNav($data, $type) { $de_json = json_decode($data, true); $count_json = count($de_json); for ($i = 0; $i < $count_json; $i++) { @@ -296,6 +296,46 @@ class Contents } } + static public function parseNavIcon($data, $type) { + $de_json = json_decode($data, true); + $count_json = count($de_json); + for ($i = 0; $i < $count_json; $i++) { + $icon = $de_json[$i]['icon']; + $link = $de_json[$i]['link']; + $action = $de_json[$i]['action']; + //定义 class + if($type=="top-nav"){ + $class = 'nav-icon-button'; + } + elseif($type=="drawer"){ + $class = 'drawer-icon'; + } + elseif($type=="mobile"){ + $class = 'nav-mobile-icon'; + } + else{ + $class= 'unknown'; + } + if($de_json[$i]['class']) $class.= ' '.$de_json[$i]['class'];//自定义 class + //计算 right 距离 + $right_more=$i*45; + $right=20+$right_more; + //添加 $other + if($type=="top-nav") $other=' style="right: '.$right.'px"'; + //输出导航图标按钮 + if($type=="top-nav"||$type=="drawer"){ + if(!$action): echo '<a href="'.$link.'" class="'.$class.'"'.$other.'><i class="iconfont icon-'.$icon.'"></i></a>'; + else: echo '<button class="'.$class.'" onclick="'.$action.'"'.$other.'><i class="iconfont icon-'.$icon.'"></i></button>'; + endif; + } + elseif($type=="mobile"){ + if(!$action): echo '<a style="float:left" href="'.$link.'"'.$other.'><i class="iconfont icon-'.$icon.'"></i></a>'; + else: echo '<a style="float:left" onclick="'.$action.'"'.$other.'><i class="iconfont icon-'.$icon.'"></i></a>'; + endif; + } + } + } + /** * 根据 id 返回对应的对象 * 此方法在 Typecho 1.2 以上可以直接调用 Helper::widgetById(); diff --git a/libs/Options.php b/libs/Options.php index d1b5f13..cda0f9e 100755 --- a/libs/Options.php +++ b/libs/Options.php @@ -129,8 +129,10 @@ function themeConfig($form) { $form->addInput($navAero);
$navSlide = new Typecho_Widget_Helper_Form_Element_Select('navSlide',array('0'=>'是','1'=>'否'),'0','Headroom','开启后,访客向下滚动页面时导航栏收起,向上滚动时导航栏展示');
$form->addInput($navSlide);
- $customNav = new Typecho_Widget_Helper_Form_Element_Textarea('customNav', NULL, NULL, _t('自定义导航栏'), _t('按照格式书写,自定义导航栏内容,留空则读取所有的独立页面,书写的格式请查看 wiki<hr>'));
- $form->addInput($customNav);
+ $customNav = new Typecho_Widget_Helper_Form_Element_Textarea('customNav', NULL, NULL, _t('自定义导航栏'), _t('按照格式书写,自定义导航栏内容,留空则读取所有的独立页面,书写的格式请查看 wiki'));
+ $form->addInput($customNav);
+ $customNavIcon = new Typecho_Widget_Helper_Form_Element_Textarea('customNavIcon', NULL, NULL, _t('自定义导航小图标'), _t('按照格式书写,自定义内导航栏右侧的小图标,留空则展示默认的图标按钮,书写的格式请查看 wiki<hr>'));
+ $form->addInput($customNavIcon);
//index-banner
$bannerUrl = new Typecho_Widget_Helper_Form_Element_Text('bannerUrl', NULL, NULL, _t('<h2>首页大图 Banner</h2>图片 Url'), _t('首页大图的图片地址'));
@@ -146,7 +148,7 @@ function themeConfig($form) { '1'=>'开启'
),'1','<h2>Pjax 预加载</h2>是否开启','Pjax 预加载功能的开关');
$form->addInput($pjax);
- $pjax_complete = new Typecho_Widget_Helper_Form_Element_Textarea('pjax_complete', NULL, NULL, _t('完成后执行事件'), _t('Pjax 跳转页面后执行的事件,写入 js 代码,一般将 Pjax 重载(回调)函数写在这里。<hr>'));
+ $pjax_complete = new Typecho_Widget_Helper_Form_Element_Textarea('pjax_complete', NULL, NULL, _t('Pjax 回调函数'), _t('Pjax 跳转页面后执行的事件,写入 js 代码,一般将 Pjax 重载(回调)函数写在这里。<hr>'));
$form->addInput($pjax_complete);
//improve
diff --git a/libs/lang/en-us.php b/libs/lang/en-us.php index 97358cc..e908ff4 100644 --- a/libs/lang/en-us.php +++ b/libs/lang/en-us.php @@ -54,6 +54,7 @@ $GLOBALS['headerTexts'] = array( $GLOBALS['archivePageTexts'] = array( "archiveTagTitle" => "Tags", "archivePostTitle" => "Posts", + "archiveCategoryTitle" => "Category", "archiveTimeYear" => "", "archiveYearTotal" => "%s articles in total", "archiveStart" => "Everything started on %s" diff --git a/libs/lang/moe.php b/libs/lang/moe.php index 53d4235..fbbc5a2 100644 --- a/libs/lang/moe.php +++ b/libs/lang/moe.php @@ -59,7 +59,8 @@ $GLOBALS['headerTexts'] = array( ); //归档页面 $GLOBALS['archivePageTexts'] = array( - "archiveTagTitle" => "博主贴的标签", + "archiveTagTitle" => "博主贴的标签", + "archiveCategoryTitle" => "乱分的类", "archivePostTitle" => "博主写的水文", "archiveTimeYear" => "年的水", "archiveYearTotal" => "这年水了 %s 篇文", diff --git a/libs/lang/zh-cn.php b/libs/lang/zh-cn.php index 967817a..c4d4220 100644 --- a/libs/lang/zh-cn.php +++ b/libs/lang/zh-cn.php @@ -61,6 +61,7 @@ $GLOBALS['headerTexts'] = array( $GLOBALS['archivePageTexts'] = array( "archiveTagTitle" => "文章标签", "archivePostTitle" => "文章归档", + "archiveCategoryTitle" => "文章分类", "archiveTimeYear" => "年", "archiveYearTotal" => "共 %s 篇文章", "archiveStart" => "一切开始于 %s" diff --git a/libs/lang/zh-tw.php b/libs/lang/zh-tw.php index 96d479d..f23580c 100644 --- a/libs/lang/zh-tw.php +++ b/libs/lang/zh-tw.php @@ -61,6 +61,7 @@ $GLOBALS['headerTexts'] = array( $GLOBALS['archivePageTexts'] = array( "archiveTagTitle" => "文章標籤", "archivePostTitle" => "文章歸檔", + "archiveCategoryTitle" => "文章分類", "archiveTimeYear" => "年", "archiveYearTotal" => "共 %s 篇文章", "archiveStart" => "壹切開始於 %s" diff --git a/pagefile.php b/pagefile.php index d444708..69b17cc 100644 --- a/pagefile.php +++ b/pagefile.php @@ -21,7 +21,15 @@ $this->need('includes/header.php'); <?php endwhile; ?>
</ul>
<?php endif; ?>
- <br />
+
+ <h2><?php gtecho('archivePageTexts','archiveCategoryTitle'); ?></h2>
+ <?php $this->widget('Widget_Metas_Category_List')->to($category); ?>
+ <ul class="tags-list category">
+ <?php while($category->next()): ?>
+ <li class="tags-item"><a class="no-line" href="<?php $category->permalink(); ?>" title="<?php $category->name(); ?>"><?php $category->name(); ?></a></li>
+ <?php endwhile; ?>
+ </ul>
+
<h2><?php gtecho('archivePageTexts','archivePostTitle'); ?></h2>
<ul class="archives-list"><?php
$archives = Contents::archives($this);
diff --git a/themeConfig.php b/themeConfig.php index 6a04147..bb0285e 100644 --- a/themeConfig.php +++ b/themeConfig.php @@ -46,7 +46,7 @@ $GLOBALS['miraclesTimThumbAllowList'] = array ( //是否压缩 HTML 源代码 //压缩能优化页面传输速度,但可能会给服务器增加一定负担(不过也还好 -$GLOBALS['miraclesIfCompressHTML'] = 'on'; +$GLOBALS['miraclesIfCompressHTML'] = 'off'; /** ========= NOTICE ========== * * 每次更新前都请备份您的 themeConfig.php 文件 |
