时间过得真快,上一次的「Issue」都已经是去年的事了。那么2021年的第一篇文章就由 「Mikusa Yearly Issue 2」开始吧!没错,说年更,那就是年更。毕竟我没啥技术力。

为 VOID 增加表情

一直想往VOID里增加点表情包。尝试过照猫画虎,但总失败。不过前两天看到「为VOID主题增加自定义表情包」提到了具体的修改方法:需要使用「UrlEncode」转码并删去其中的%才能显示带中文的表情。因此再次将增加表情的想法提上日程。

加个表情并不是啥难事,只是不会编程的话纯手写费手。也许我应该直接找A酱。

我想添加的是B站的2233娘,虽然有版权风险,但不是啥盈利性目的应该没啥事。


修改OwO.json文件
VOID/assets/libs/owo/OwO_02.json中插入:

    "2233娘": {
        "type": "image",
        "container": [{
                "icon": "<img class=\"biaoqing\" data-src=\"/usr/themes/VOID/assets/libs/owo/biaoqing/2233/2233E5A898_E7ACACE4B880.png\">",
                "data": "",
                "text": "2233娘_第一"
            },
            {
                "icon": "<img class=\"biaoqing\" data-src=\"/usr/themes/VOID/assets/libs/owo/biaoqing/2233/2233E5A898_E697A0E8AFAD.png\">",
                "data": "",
                "text": "2233娘_无语"
            },
            {
                "icon": "<img class=\"biaoqing\" data-src=\"/usr/themes/VOID/assets/libs/owo/biaoqing/2233/2233E5A898_E59090E9AD82.png\">",
                "data": "",
                "text": "2233娘_吐魂"
            },
            {
                "icon": "<img class=\"biaoqing\" data-src=\"/usr/themes/VOID/assets/libs/owo/biaoqing/2233/2233E5A898_E5A794E5B188.png\">",
                "data": "",
                "text": "2233娘_委屈"
            },
            {
                "icon": "<img class=\"biaoqing\" data-src=\"/usr/themes/VOID/assets/libs/owo/biaoqing/2233/2233E5A898_E593ADE6B3A3.png\">",
                "data": "",
                "text": "2233娘_哭泣"
            },
            {
                "icon": "<img class=\"biaoqing\" data-src=\"/usr/themes/VOID/assets/libs/owo/biaoqing/2233/2233E5A898_E98381E997B7.png\">",
                "data": "",
                "text": "2233娘_郁闷"
            },
            {
                "icon": "<img class=\"biaoqing\" data-src=\"/usr/themes/VOID/assets/libs/owo/biaoqing/2233/2233E5A898_E59BB0E68391.png\">",
                "data": "",
                "text": "2233娘_困惑"
            },
            {
                "icon": "<img class=\"biaoqing\" data-src=\"/usr/themes/VOID/assets/libs/owo/biaoqing/2233/2233E5A898_E7949FE6B094.png\">",
                "data": "",
                "text": "2233娘_生气"
            },
            {
                "icon": "<img class=\"biaoqing\" data-src=\"/usr/themes/VOID/assets/libs/owo/biaoqing/2233/2233E5A898_E59083E6838A.png\">",
                "data": "",
                "text": "2233娘_吃惊"
            },
            {
                "icon": "<img class=\"biaoqing\" data-src=\"/usr/themes/VOID/assets/libs/owo/biaoqing/2233/2233E5A898_E6B197.png\">",
                "data": "",
                "text": "2233娘_汗"
            },
            {
                "icon": "<img class=\"biaoqing\" data-src=\"/usr/themes/VOID/assets/libs/owo/biaoqing/2233/2233E5A898_E5A4A7E7AC91.png\">",
                "data": "",
                "text": "2233娘_大笑"
            },
            {
                "icon": "<img class=\"biaoqing\" data-src=\"/usr/themes/VOID/assets/libs/owo/biaoqing/2233/2233E5A898_E5969DE6B0B4.png\">",
                "data": "",
                "text": "2233娘_喝水"
            },
            {
                "icon": "<img class=\"biaoqing\" data-src=\"/usr/themes/VOID/assets/libs/owo/biaoqing/2233/2233E5A898_E880B6.png\">",
                "data": "",
                "text": "2233娘_耶"
            },
            {
                "icon": "<img class=\"biaoqing\" data-src=\"/usr/themes/VOID/assets/libs/owo/biaoqing/2233/2233E5A898_E58D96E8908C.png\">",
                "data": "",
                "text": "2233娘_卖萌"
            },
            {
                "icon": "<img class=\"biaoqing\" data-src=\"/usr/themes/VOID/assets/libs/owo/biaoqing/2233/2233E5A898_E79691E997AE.png\">",
                "data": "",
                "text": "2233娘_疑问"
            }
        ]
    },



修改Contents.php文件
VOID/libs/Contents.php中,第196行插入:

        $content = preg_replace_callback('/\:\$\(\s*(.*?)\s*\)/is',
            array('Contents', 'parse2233BiaoqingCallback'), $content);

第232行处插入:

    /**
     * 2233娘表情回调函数
     *
     * @return string
     */
    private static function parse2233BiaoqingCallback($match)
    {
        return '<img class="biaoqing" src="/usr/themes/VOID/assets/libs/owo/biaoqing/2233/'. str_replace('%', '', urlencode($match[1])) . '.png">';
    }


最终效果就是这样,要记得刷新浏览器缓存才能看到:

VOID 开发版已经添加了这个表情。详见 GitHub,或者直接点击:https://github.com/AlanDecode/Typecho-Theme-VOID/archive/nightly.zip 下载开发版本。

后来我又想加入崩坏3的表情,步骤一致:


修改OwO.json文件

    "崩坏3": {
        "type": "image",
        "container": [{
                "icon": "<img class=\"biaoqing\" data-src=\"/usr/themes/VOID/assets/libs/owo/biaoqing/bh3/E5B4A9E59D8F3_E884B1E99D9E.png\">",
                "data": "",
                "text": "崩坏3_脱非"
            },
            {
                "icon": "<img class=\"biaoqing\" data-src=\"/usr/themes/VOID/assets/libs/owo/biaoqing/bh3/E5B4A9E59D8F3_E585A5E6ACA7.png\">",
                "data": "",
                "text": "崩坏3_入欧"
            },
            {
                "icon": "<img class=\"biaoqing\" data-src=\"/usr/themes/VOID/assets/libs/owo/biaoqing/bh3/E5B4A9E59D8F3_E4BA8CE883A1.png\">",
                "data": "",
                "text": "崩坏3_二胡"
            },
            {
                "icon": "<img class=\"biaoqing\" data-src=\"/usr/themes/VOID/assets/libs/owo/biaoqing/bh3/E5B4A9E59D8F3_E594A2E59190.png\">",
                "data": "",
                "text": "崩坏3_唢呐"
            },
            {
                "icon": "<img class=\"biaoqing\" data-src=\"/usr/themes/VOID/assets/libs/owo/biaoqing/bh3/E5B4A9E59D8F3_E790B5E790B6.png\">",
                "data": "",
                "text": "崩坏3_琵琶"
            },
            {
                "icon": "<img class=\"biaoqing\" data-src=\"/usr/themes/VOID/assets/libs/owo/biaoqing/bh3/E5B4A9E59D8F3_E7AC9BE5AD90.png\">",
                "data": "",
                "text": "崩坏3_笛子"
            },
            {
                "icon": "<img class=\"biaoqing\" data-src=\"/usr/themes/VOID/assets/libs/owo/biaoqing/bh3/E5B4A9E59D8F3_E995B2.png\">",
                "data": "",
                "text": "崩坏3_镲"
            }
        ]
    },



修改Contents.php文件

        $content = preg_replace_callback('/\:\!\(\s*(.*?)\s*\)/is',
            array('Contents', 'parsebh3BiaoqingCallback'), $content); 
    /**
     * 崩坏3表情回调函数
     *
     * @return string
     */
     private static function parsebh3BiaoqingCallback($match)
     {
         return '<img class="biaoqing" src="/usr/themes/VOID/assets/libs/owo/biaoqing/bh3/'. str_replace('%', '', urlencode($match[1])) . '.png">';
     }

目前就先添加这几个用用。

修改 Copyright 插件

因为使用了很多 Pixiv 的图片作为文章头图,而我声明图片来源的方法是在文章首段末尾加上「封面图:xxxx」。这当然没啥问题,直到我注意到「Copyright」这个插件,才意识到使用插件可能是个更好的方法。所以我又是一番依样画葫芦,修改了下这个插件,效果如下:

使用方法是新建一个cover字符字段,填写如

<a href="https://www.pixiv.net/artworks/86011816" target="_blank" >2020.11 / gracile #Pixiv</a>

的字段值,即可显示。因为不会,所以不支持使用markdown直接显示链接。

修改后的插件放在 GitHub 上,如果有需要可以下载使用。

博客的备份问题

起先使用宝塔面板的时候,我就有设置定时备份。然而在我整理备份文件的时候才发现没有备份数据库。我还想翻翻看自己的黑历史……

但是我在里头找到了博客建成的截图。一开始用的是「NexT.Mist」主题。

而这个点击鼠标的爱心特效,是因为感觉很炫酷,所以就立马放到博客里了。没事干就点这个爱心,玩了好几天……

然后就一不小心被我删库了 。那时候还没明白数据库的作用,因此一开始写的东西就没能找回来,不然也是个可以回忆的东西呢。现在备份策略做得很完善了,用的是这个脚本:GitHub。每天自动备份数据库和程序文件,存储在又拍云。防范于未然。

水文结束。

最后

祝各位2021新年快乐!