抓住暑假的尾巴用Linux C/C++写个静态博客

190 阅读1分钟

在Linux下用C/C++写个服务器后台。

yadihttpd 文件服务器作为博客后台

完成的功能:

✅ 打印日志,读取消息头,日志文件名根据时间生成

✅ epoll版本并返回相应文件

✅ 日志队列,自动切换,写日志单独线程

✅ 大文件支持

✅ 文件读取权限限制

✅ 静态博客后台

然后搞个域名,弄个SSL证书,博客如下:

hqinglau的博客

具体页面如下,简约风,nice:

image.png

写个脚本批量markdown转html,顺便生成主页。

批量转换脚本:

#!/bin/bash
declare -A dimap;
eval `awk '{printf("dimap[%s]=%s;",$1,$2)}' filename2name.txt`
echo > tmp.mdfile
echo > ../index.html
for filename in $(ls);do 
    suffix=${filename##*.}; 
    if [ "$suffix" != "md" ]; then 
        continue;
    fi 
    name=${filename:0:${#filename}-3}
    marked -o ../blog/${name}.html < ${filename}
           echo "${filename}:${dimap[${name}]}  to html done."
    echo -e "[${dimap[${name}]}](blog/${name}.html)\n" >> tmp.mdfile
done
echo "<h2>博客列表</h2><hr>" >> ../index.html
marked -o tmpindex.html < tmp.mdfile
cat tmpindex.html >> ../index.html
rm tmpindex.html
echo "index built done"

嫌麻烦可以写个crontab定期执行。

然后网站发布博客只要在自己电脑上markdown写好,发送到服务器,over。