Skip to content

Commit

Permalink
💫 Perf: 优化文件结构,移除无用的设置项
Browse files Browse the repository at this point in the history
  • Loading branch information
BigCoke233 committed Aug 26, 2022
1 parent 3b87366 commit 1c32e66
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 44 deletions.
2 changes: 2 additions & 0 deletions change-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
- 新增:归档页面小规模重做,增加了展开和收起框
- 移除:取消了主题样式选择选项,保留原先的 Journal 样式
- 移除:移除了 Pangu.php(即为中文英文之间添加空格的脚本)
- 移除:站点统计代码设置,可以在自定义页脚里写入,避免重复故删除
- 优化:文件和代码结构
- 优化:BracketDown 插件支持的 `<details>` 标签动画更加丝滑
- 优化:更进 BracketDown 插件新内容,优化其在主题中的样式
- 修复:PHP 8.0.0 以上版本由文章浏览量统计功能引起的问题
Expand Down
43 changes: 9 additions & 34 deletions includes/footer.php
Original file line number Diff line number Diff line change
@@ -1,43 +1,18 @@
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<footer id="footer" role="contentinfo">
&copy; <?php
if($this->options->startDate==''){
echo date('Y');
}else{
$date=explode('-', $this->options->startDate);
if($date[0]==date('Y')){
echo date('Y');
}elseif($date[0]<date('Y')){
echo $date[0].' - '.date('Y');
}else{
echo '<span style="cursor:help" onclick="Toaster.send(\'博主把建站日期写错啦\');">偷偷告诉你,其实我是时空旅行者</span>';
}
}
?> <a href="<?php $this->options->siteUrl(); ?>"><?php $this->options->title(); ?></a>.
<br />
<?php if ($this->options->icpNum):?>
<a rel="nofollow" href="http://beian.miit.gov.cn"> <?php $this->options->icpNum(); ?> </a>
<br />
<?php endif;
if ($this->options->EnableBusuanzi == 'able' ): ?>
<span id="busuanzi_value_site_pv">......</span> 次访问 ·
<span id="busuanzi_value_site_uv">......</span> 位访客
<?php endif; ?>
&copy; <?php Matcha::copyrightYear(); ?> <a href="<?php $this->options->siteUrl(); ?>"><?php $this->options->title(); ?></a>.
<?php Matcha::footerInfo(); ?>
<!-- 返回顶部按钮 -->
<div id="gotop"><button id="back2top"><span class="iconfont">&#xe749;</span></button></div>
</footer>
</div>
</div>

<?php if ($this->options->EnableBusuanzi == 'able' ): ?>
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<?php endif; ?>
<footer id="script"><?php
Matcha::footerSetting();
Matcha::footer();
$this->footer();
?></footer>

<script>siteurl='<?php Utils::indexHome(); ?>';
pjaxCallback=function(){<?php $this->options->pjaxCallback(); ?>};
AjaxCommentEnabled='<?php $this->options->EnableAjaxComment(); ?>';
RandomLinks='<?php $this->options->EnableRandomLinks(); ?>';</script>

<?php //输出统计代码、js 引用等
if ($this->options->statCode) { $this->options->statCode(); } ?></div>
<?php Matcha::footer(); $this->footer(); ?>
</body>
</html>
5 changes: 0 additions & 5 deletions includes/sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,4 @@
<li>Powered by <a rel="nofollow" target="_blank" href="http://www.typecho.org" class="no-linkTarget">Typecho</a></li>
</ul>
</section>
</div>

<!-- 返回顶部按钮 -->
<div id="gotop">
<button id="back2top"><span class="iconfont">&#xe749;</span></button>
</div>
50 changes: 50 additions & 0 deletions libs/Matcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ public static function footer() {
Helper::options()->customFooter();
}

/**
* 将主题设置传递给前端
*/
static public function footerSetting() {
echo '<script>';
echo 'siteurl="'; Utils::indexHome(); echo '";'; //站点 url
echo 'pjaxCallback=function(){'.Helper::options()->pjaxCallback.'};';
echo 'AjaxCommentEnabled="'.Helper::options()->EnableAjaxComment.'";';
echo 'RandomLinks="'.Helper::options()->EnableRandomLinks.'";';
echo '</script>';
}

/**
* 输出 js 引用
*/
Expand Down Expand Up @@ -245,6 +257,44 @@ public static function date($created)
}
}

/**
* 页脚版权信息 年份
*/
static public function copyrightYear()
{
if(Helper::options()->startDate==''){
echo date('Y');
}else{
$date=explode('-', Helper::options()->startDate);
if($date[0]==date('Y')){
echo date('Y');
}elseif($date[0]<date('Y')){
echo $date[0].' - '.date('Y');
}else{
echo '<span style="cursor:help" onclick="Toaster.send(\'博主把建站日期写错啦\');">[偷偷告诉你,其实我是时空旅行者]</span>';
}
}
}

/**
* 页脚 额外信息
*/
static public function footerInfo()
{
//备案号
if (Helper::options()->icpNum!='') {
echo '<br />';
echo '<a rel="nofollow" href="http://beian.miit.gov.cn"> '.Helper::options()->icpNum.' </a>';
}
//不蒜子统计
if (Helper::options()->EnableBusuanzi=='able') {
echo '<br />';
echo '<span id="busuanzi_value_site_pv">......</span> 次访问 ·
<span id="busuanzi_value_site_uv">......</span> 位访客 ';
echo '<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>';
}
}

/**
* LazyLoad
*/
Expand Down
5 changes: 0 additions & 5 deletions libs/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ function themeConfig($form) {
$form->addInput($icpNum);
$startDate = new Typecho_Widget_Helper_Form_Element_Text('startDate', NULL, date('Y-m-d'), _t('网站建立日期'), _t('用于显示在页脚的版权信息,以及计算网站建立时长,格式为 Y-m-d'));
$form->addInput($startDate);
$statCode = new Typecho_Widget_Helper_Form_Element_Textarea('statCode', NULL, NULL, _t('站点统计代码'), _t('
<p class="description">在这里填入 <b>带 script 标签的</b> 站点统计代码,留空则不显示。</p>
<hr class="line"></hr>
'));
$form->addInput($statCode);

/**
* 附加功能 & 实验性功能
Expand Down

0 comments on commit 1c32e66

Please sign in to comment.