记录下魔改的内容,防止以后忘了怎么改回去2333

部分改动涉及到源码,请注意备份

主题

主题来自handsome

魔改版主题

魔改版主题来自神代綺凜主题

本站基于Sanakey的插件实现上述魔改

参考下面这篇文章

代码块美化

代码块美化基于如下插件

文末版权信息

基于如下插件

网站底部

在主题后台设置自定义CSS添加如下代码

/*底部页脚*/
.github-badge {
  display: inline-block;
  border-radius: 4px;
  text-shadow: none;
  font-size: 12px;
  color: #fff;
  line-height: 15px;
  background-color: #abbac3;
  margin-bottom: 5px
}
.github-badge .badge-subject {
  display: inline-block;
  background-color: #4d4d4d;
  padding: 4px 4px 4px 6px;
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px
}
.github-badge .badge-value {
  display: inline-block;
  padding: 4px 6px 4px 4px;
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px
}
.github-badge .bg-blue {
  background-color: #007ec6
}
.github-badge .bg-orange {
  background-color: #ffa500
}
.github-badge .bg-red {
  background-color: #f00
}
.github-badge .bg-green {
  background-color: #3bca6e
}
.github-badge .bg-purple {
  background-color: #ab34e9
}

博客底部左侧信息如下

<div class="github-badge">
<a href="#" title="©2018-2020">
<span class="badge-subject">Copyright</span><span class="badge-value bg-blue">&copy;2018-2020</span>
</a></div>
&nbsp;|&nbsp; <div class="github-badge"><a href="/sitemap.xml" target="_blank"><span class="badge-subject">SiteMap</span><span class="badge-value bg-blue">站点地图</span></a></div>

博客底部右侧信息如下

<div class="github-badge">
<a href="http://www.typecho.org" target="_blank" title="由 Typecho 强力驱动">
<span class="badge-subject">Powered</span><span class="badge-value bg-blue">Typecho</span>
</a>
</div>
&nbsp;|&nbsp; 
<div class="github-badge">
<a href="https://www.ihewro.com/archives/489/" target="_blank" title="站点使用 handsome 主题,作者:友人C">
<span class="badge-subject">Theme</span><span class="badge-value bg-orange">Handsome</span>
</a>
</div>

修改handsome/component/footer.php

    <div class="wrapper bg-light">
      <span class="pull-right hidden-xs text-ellipsis">
      <?php $this->options->BottomInfo(); ?>
      </span>
        <span class="text-ellipsis"><?php
            $this->options->BottomleftInfo(); ?></span>
    </div>
      <!--可以去除主题版权信息,最好保留版权信息或者添加主题信息到友链,谢谢你的理解-->

评论通知

邮件通知

邮件通知基于如下插件

详情参照这篇文章

微信通知

微信通知基于如下插件

UserAgent

滑稽表情包

  1. 复制owo.json到handsome/usr/
  2. 复制paopao文件夹到handsome/usr/img/emotion/
  3. 清除一下游览器缓存,然后刷新即可

响应耗时和访客统计

handsome作者对functions.php文件进行了加密

因此我们将修改放在handsome/libs/Content.php

修改Content.php起始处为

<?php
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
/**
 * 访问总量
 */
 function theAllViews(){
         $db = Typecho_Db::get();
         $row = $db->fetchAll('SELECT SUM(VIEWS) FROM `typecho_contents`');
             echo number_format($row[0]['SUM(VIEWS)']);
 }
/**
 * 响应时间
 */
function timer_start() {
    global $timestart;
    $mtime = explode( ' ', microtime()  );
    $timestart = $mtime[1] + $mtime[0];
    return true; 
}
timer_start();
function timer_stop( $display = 0, $precision = 3  ) {
    global $timestart, $timeend;
    $mtime = explode( ' ', microtime()  );
    $timeend = $mtime[1] + $mtime[0];
    $timetotal = number_format( $timeend - $timestart, $precision  );
    $r = $timetotal < 1 ? $timetotal * 1000 . " ms" : $timetotal . " s";
    if ( $display  ) {
        echo $r;
    }
    return $r;
}
/**
 * Content.php
 * Author     : hewro
 * Date       : 2017/05/21
 * Version    : 1.0.0
 * Description: 使用PHP方法输出内容
 */

然后修改component/sidebar.php,在大约100行左右,最后活动处的</li>标签之后添加如下代码

<li class="list-group-item text-second"> <i class="glyphicon glyphicon-user text-muted"></i> <span class="badge
pull-right"><?php echo theAllViews();?></span><?php _me("访客总数") ?></li>
<li class="list-group-item text-second"> <i class="glyphicon glyphicon-time text-muted"></i> <span class="badge
pull-right"><?php echo timer_stop();?></span><?php _me("响应耗时") ?></li>

首页文章同时显示浏览数和评论数

默认是不显示浏览数的,只有评论数

打开handsome/libs/Content.php第1100~1200行左右
找到如下代码

<span class="m-r-sm right-small-icons"><i data-feather="user"></i></span><a href="{$parameterArray['authorUrl']}">{$parameterArray['author']}</a></li>

<li><span class="right-small-icons m-r-sm"><i data-feather="clock"></i></span>{$dateString}</li>
// 下面添加这行代码
<i class="fontello fontello-eye text-muted"></i>&nbsp;{$viewNumString}

添加心知天气

打开心知天气,地址:https://www.seniverse.com/widget 进入后配置好内容,然后点击下方的生成代码

打开handsome/component/headnav.php,在57行左右

<a href="" style="display: none" id="searchUrl"></a>
<!-- / search form -->
<!-- 在这之后添加心知天气生成的结果 -->

注意,这里需要修改心知天气的代码结构,否则会错位

将 <div id="tp-weather-widget">
改成 <div id="tp-weather-widget" class="navbar-form navbar-form-sm navbar-left shift">

修改主题播放器音量

handsome默认的播放器音量是无法进行设置的,所以会存在音乐播放后声音过大的问题

这里通过在主题后台自定义js脚本中添加以下代码实现

window.onload = function() {
  setTimeout(() => {
    document.querySelector('.skPlayer-source').volume = 0.3;
  }, 3000);
}

问题

如果底部footer栏和右侧sidebar栏有重合

修改handsome.min.css文件

.wrapper{padding: 15px;}
修改为
.wrapper{padding: 11px;}

如果希望右侧sidebar栏有透明底色并且悬浮不透明

修改插件KirinShiKi/css/kirin.css文件

第 188 行

aside.col.w-md.no-border-xs {
    transition:all .3s;
    opacity: 0.9 !important;
}
aside.col.w-md.no-border-xs:hover {
    opacity: 1 !important;
}

参考

Last modification:June 18th, 2020 at 11:12 am
如果觉得我的文章对你有用,请随意赞赏