声明


此篇文章主要是记录自己在handsome模板中修改的一些源代码,以便日后改动以及更新并添加功能。
若有改动即及时更新,勿忘!!!

添加表情

添加表情

  • /handsome/usr/OwO.json文件中下方添加了以下代码

"葫芦侠":{
    "type": "image",
    "name": "raw",
    "container":[
      {
        "icon": "write_face_25",
        "text": "滑稽"
      },{
        "icon": "write_face_01",
        "text": "呵呵"
      },{
        "icon": "write_face_02",
        "text": "哈哈"
      },{
        "icon": "write_face_03",
        "text": "吐舌"
      },{
        "icon": "write_face_04",
        "text": "啊"
      },{
        "icon": "write_face_05",
        "text": "酷"
      },{
        "icon": "write_face_06",
        "text": "怒"
      },{
        "icon": "write_face_07",
        "text": "开心"
      },{
        "icon": "write_face_08",
        "text": "汗"
      },{
        "icon": "write_face_09",
        "text": "大哭"
      },{
        "icon": "write_face_10",
        "text": "黑线"
      },{
        "icon": "write_face_11",
        "text": "鄙视"
      },{
        "icon": "write_face_12",
        "text": "不高兴"
      },{
        "icon": "write_face_13",
        "text": "真棒"
      },{
        "icon": "write_face_14",
        "text": "钱"
      },{
        "icon": "write_face_15",
        "text": "疑问"
      },{
        "icon": "write_face_16",
        "text": "阴险"
      },{
        "icon": "write_face_17",
        "text": "吐"
      },{
        "icon": "write_face_18",
        "text": "咦"
      },{
        "icon": "write_face_19",
        "text": "委屈"
      },{
        "icon": "write_face_20",
        "text": "花心"
      },{
        "icon": "write_face_21",
        "text": "呼~"
      },{
        "icon": "write_face_22",
        "text": "笑眼"
      },{
        "icon": "write_face_23",
        "text": "冷"
      },{
        "icon": "write_face_24",
        "text": "太开心"
      },{
        "icon": "write_face_26",
        "text": "勉强"
      },{
        "icon": "write_face_27",
        "text": "狂汗"
      },{
        "icon": "write_face_28",
        "text": "乖"
      },{
        "icon": "write_face_29",
        "text": "睡觉"
      },{
        "icon": "write_face_30",
        "text": "惊哭"
      },{
        "icon": "write_face_31",
        "text": "生气"
      },{
        "icon": "write_face_32",
        "text": "惊讶"
      },{
        "icon": "write_face_33",
        "text": "喷"
      }
    ]
  }


"皮皮":{
    "type": "image",
    "name": "pipi",
    "container":[
      {
        "icon": "emoji_brother_01",
        "text": "大笑"
      },{
        "icon": "emoji_brother_02",
        "text": "有趣的"
      },{
        "icon": "emoji_brother_03",
        "text": "喝酒"
      },{
        "icon": "emoji_brother_04",
        "text": "捂脸哭"
      },{
        "icon": "emoji_brother_05",
        "text": "大哭"
      },{
        "icon": "emoji_brother_06",
        "text": "爱"
      },{
        "icon": "emoji_brother_07",
        "text": "怒"
      },{
        "icon": "emoji_brother_08",
        "text": "色"
      },{
        "icon": "emoji_brother_09",
        "text": "感动"
      },{
        "icon": "emoji_brother_10",
        "text": "思考"
      },{
        "icon": "emoji_brother_11",
        "text": "吃惊"
      },{
        "icon": "emoji_brother_12",
        "text": "呕吐"
      },{
        "icon": "emoji_brother_13",
        "text": "尴尬"
      },{
        "icon": "emoji_brother_14",
        "text": "石化"
      }
    ]
  }




后台 -> 外观 -> 设置外观 -> 开发者设置 -> 自定义CSS中添加.emotion-raw{width:24px;}.emotion-pipi{width: 24px;}并保存

百度收录检测

百度收录检测

  • post.php文件中添加了以下代码,代码在78~79
<!--百度收录-->
<li class="meta-baidu"><span class="post-icons"><i class="glyphicon glyphicon-refresh" id="baidu_icon"></i></span><span class="meta-value" id="baidu_result">加载中</span></li>
  • 还在post.php文件中添加了以下代码,代码在128~161
<!-- 百度收录 -->
<script src="/assets/js/jquery-3.4.1.min.js"></script>
<script>
    function baidu_check(){
        $.getJSON("https://www.teamep.cn/api/baidu.php?domain="+window.location.href,function(result){ 
            if (result.code == 200) {
                $('#baidu_icon').removeClass('glyphicon-refresh');
                $('#baidu_icon').addClass('glyphicon-ok-circle');
                $('#baidu_result').text('百度已收录');
            }else if(result.code == 403){
                $('#baidu_icon').removeClass('glyphicon-refresh');
                $('#baidu_icon').addClass('glyphicon-info-sign');
                $('#baidu_result').text('百度未收录');
                baidu_push();
            }else{
                 $('#baidu_icon').removeClass('glyphicon-refresh');
                $('#baidu_icon').addClass('glyphicon-remove-circle');
                $('#baidu_result').text('查询收录失败');
            }
        });
    }
    function baidu_push(){
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    }
    baidu_check();
</script>

访问量统计及响应时间

访问量

  • /handsome/libs/Content.php文件中的第12~41行添加了以下代码
/**
 * 访问总量
 */
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;
}
  • /handsome/component/sidebar.php文件的100-106行添加了以下代码
<li class="list-group-item text-second"><span class="blog-info-icons"> <i data-feather="user"></i></span> <span class="badge pull-right"><?php echo theAllViews();?></span><?php _me("访客总数") ?></li>       
<li class="list-group-item text-second"><span class="blog-info-icons"> <i data-feather="clock"></i></span> <span class="badge pull-right"><?php echo timer_stop();?></span><?php _me("响应耗时") ?></li>

全站字数

全站字数

  • /handsome/component/sidebar.php文件的3-16行添加了以下代码
<?php
//字数统计
function allOfCharacters() {
    $chars = 0;
    $db = Typecho_Db::get();
    $select = $db ->select('text')->from('table.contents');
    $rows = $db->fetchAll($select);
    foreach ($rows as $row) { $chars += mb_strlen(trim($row['text']), 'UTF-8'); }
    $unit = '';
    if($chars >= 10000)     { $chars /= 10000; $unit = '万'; } 
    else if($chars >= 1000) { $chars /= 1000;  $unit = '千'; }
    $out = sprintf('%.2lf %s',$chars, $unit);
    return $out;
}
?>
  • /handsome/component/sidebar.php文件的122-124行添加了以下代码
<li class="list-group-item text-second"><span class="blog-info-icons"><i data-feather="edit-2"></i></span><span class="badge pull-right"><?php echo allOfCharacters(); ?></span><?php _me("全站字数") ?></li>

底部背景颜色修改

底部颜色修改

  • /handsome/component/footer.php文件中第五行修改的代码如下

源代码

<div class="wrapper bg-light">

修改后的代码

<div class="wrapper bg-light" style="background-color: #FFF;">

添加足迹

添加足迹


通过 jVectorMap 可以制作旅行足迹地图,并且嵌入到自己的博客之中,展示自己的旅行足迹。

在根目录放入了footprint文件夹,并把下载出来的文件放入了footprint文件夹中
在此期间也发现了原博主的注释错误,按照原博主的经度纬度填写之后不显示
错误的注释
自己尝试换了一下位置,就显示了,所以应该是纬度,经度
有效方法
也许是自己服务器不支持,或者总总
配置好之后就可以发文章,或者界面了,内容如下。!!!是为了可以解析HTML代码

!!!
<iframe style="max-width: 100%" 
      frameborder="no" 
      border="0" 
      marginwidth="0" 
      marginheight="0" 
      width="100%" 
      height="420px" 
      src="https://www.teamep.cn/footprint/index.html">                                        
</iframe>
!!!

演示
请移步左边

右侧栏随机图片

右侧栏随机图标


把原来的图片删除更换成十二生肖图片了,一共十二张
暂时没动源代码,此处待更新



给左侧栏友链添加头像

给左侧栏友链添加头像

  • /handsome/component/aside.php文件中修改以下代码

<!--友情链接-->
<li>
    <a class="auto">
        <span class="pull-right text-muted">
            <i class="fontello icon-fw fontello-angle-right text"></i>
            <i class="fontello icon-fw fontello-angle-down text-active"></i>
        </span>
        <span class="nav-icon"><i data-feather="user"></i></span>
        <span><?php _me("友链") ?></span>
    </a>
    <ul class="nav nav-sub dk">
        <li class="nav-sub-header">
           <a data-no-instant>
                <span><?php _me("友链") ?></span>
            </a>
        </li>
        <!--使用links插件,输出全站友链-->
        <?php $mypattern1 = "<li data-original-title=\"{title}\" data-toggle=\"tooltip\" 
data-placement=\"top\"><a href=\"{url}\" target=\"_blank\"><span>{name}</span></a></li>";
                  Handsome_Plugin::output($mypattern1, 0, "ten");?>
    </ul>
</li>

<!--友情链接-->
<style>
    #user_img{
        width: 24px;
        border-radius: 50%;
    }
</style>
<li>
    <a class="auto">
        <span class="pull-right text-muted">
            <i class="fontello icon-fw fontello-angle-right text"></i>
            <i class="fontello icon-fw fontello-angle-down text-active"></i>
        </span>
        <span class="nav-icon"><i data-feather="user"></i></span>
        <span><?php _me("友链") ?></span>
    </a>
    <ul class="nav nav-sub dk">
        <li class="nav-sub-header">
           <a data-no-instant>
                <span><?php _me("友链") ?></span>
            </a>
        </li>
        <!--使用links插件,输出全站友链-->
        <?php $mypattern1 = "<li data-original-title=\"{title}\" data-toggle=\"tooltip\" 
data-placement=\"top\"><a href=\"{url}\" target=\"_blank\"><img src=\"{image}\" id=\"user_img\" \>&emsp;<span>{name}</span></a></li>";
                  Handsome_Plugin::output($mypattern1, 0, "ten");?>
    </ul>
</li>


UserAgent插件

UserAgent插件


显示评论人使用的操作系统和浏览器信息(Handsome主题专用)

  • /handsome/component/comments.php文件的 79 行修改了一下代码

源代码

<b class="fn"><?php echo $author; ?></b><?php echo $Identity; ?>

修改之后的代码

<b class="fn"><?php echo $author; ?></b><?php echo $Identity; ?><?php UserAgent_Plugin::get_useragent($comments->agent,$comments->ip); ?>

在根目录的config.inc.php文件中的末尾添加了以下代码

//** 防止CDN造成无法获取客户真实IP地址 */
if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) 
{
    $list = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
    $_SERVER['REMOTE_ADDR'] = $list[0];
}

文章声明

文章声明


/handsome/post.php文件中的95~109行,添加了以下代码
样式是填写在后台中的,无修改源代码

<br>
<!-- 风格线 -->
<div class="cutline">
    <span>
        <a style="color:#F17B8F;color: #F17B8F;border-bottom: 0px solid #999!important;" href="https://www.teamep.cn" title="Anemone bolg">
            正文到此结束
        </a>
    </span>
</div>
<div class="cpright">
    <span>本文作者:
        <span class="sr-only"><?php _me("作者") ?>:</span> <a class="meta-value" href="<?php $this->author->permalink(); ?>" rel="author"> <?php $this->author(); ?></a></span>&nbsp;&nbsp;&nbsp;文章标题:<a href="<?php $this->permalink() ?>"><?php $this->title() ?></a><br><span>本文地址:<a href="<?php $this->permalink() ?>"><?php $this->permalink() ?></a></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br><span>版权说明:若无注明,本文皆为“<a href="<?php $this->options->siteUrl(); ?>" target="_blank" data-original-title="<?php $this->options->title() ?>"><?php $this->options->title() ?></a>”原创,转载请保留文章出处。
    </span>
</div>

新增黑匣子

黑匣子

/handsome/component/headnav.php文件中的173 ~ 180新增以下代码

<!-- 黑匣子 -->
<li>
  <a class="feathericons dropdown-toggle" href="https://www.teamep.cn/box.html">
      <span>
          <i class="glyphicon glyphicon-inbox" style="padding-top: 5px;"></i>
      </span>
  </a>
</li>



本文作者: 博主:    文章标题:handsome修改记录[持续更新]
本文地址:https://www.teamep.cn/handsome.html     
版权说明:若无注明,本文皆为“指间”原创,转载请保留文章出处。
最后修改:2020 年 08 月 09 日 03 : 36 PM
如果觉得我的文章对你有用,请随意赞赏