勉强从灾难中恢复
作者:V君 发布于:2023-5-3 20:49 Wednesday 分类:小服杂记
数据库和备份的树莓派双双失效,找到一份年初的备份,还好这半年没写博客
总算是修好邮件通知功能了
作者:V君 发布于:2022-5-28 19:15 Saturday 分类:小服杂记
这次排查过程我只能用下面的两张梗图来形容。
首先不知道如何断点调试运行在 Apache 的 PHP,那就只能找到输出日志的方法,然后拼命打log。(第一张梗图)
其次打了 log 得到的错误信息莫名其妙,可能是发邮件的库和自己搭的邮件服务器存在兼容问题,调着调着莫名其妙又通了,然后去掉打 log 的代码,做出思考状。(第二张梗图)
引入ace编辑器用作代码高亮(杀鸡焉用牛刀?
作者:V君 发布于:2020-3-20 22:57 Friday 分类:小服杂记
博客中有不少文章把代码段贴出来,有(dan)空(teng)的时候想办法去弄点样式,没(lan)空的时候就直接贴纯文本。是时候应该解决一下了。那就去看看用什么组件好吧。
(放狗出去找)发现了 highlight.js ,看起来不错,但不支持显示行号,并且作者也不打算实现它。那就再找找吧,(找了一会儿),想起 ace 编辑器了,如果只要设置成只读,它就是一个优秀的代码高亮组件,还能折叠代码块。
废话少说开始干!首先找到代码插入点,这次我选择在 content/templates/default/footer.php 底部的 #wrap 结束标记后面,插入 CDN 库引用然后写了下面的代码来启用。
先TL;DR一下使用方法:在需要高亮的元素上增加以下属性
- highlight="ace" 启用代码高亮
- ace-lang="javascript" 必选,指定代码语言
- ace-theme="chrome" 可选,配色主题
代码语言和配色主题可以参照源代码文件名。
注释掉 log 语句并甩锅给 IE(
//replace nbsp \xa0 to normal space \x20
function normalizeSpaces(elm){
var nodes = elm.childNodes;
for (var i=0; i < nodes.length; ++i){
if(nodes[i].nodeName === "#text") nodes[i].textContent = nodes[i].textContent.split("\xa0").join('\x20');
else normalizeSpaces(nodes[i]);
}
}
if (ace===undefined){
console.log('highlight: ace undefined, no works');
}else{
var items = document.querySelectorAll('[highlight=ace]');
//console.log(`highlight: found ${items.length} element(s) to highlight, dealing with it.`);
for (var i=0;i<items.length;++i){
var item = items[i];
var aceLang=item.getAttribute("ace-lang");
if (aceLang === null){
//console.warn(`highlight: the highlight element #${i} missing attribute 'ace-lang', skipped`);
continue;
}
normalizeSpaces(item);
var aceTheme=item.getAttribute("ace-theme");
if (aceTheme === null) aceTheme = "Chrome";
var editor = ace.edit(item);
editor.setReadOnly(true);
editor.setOptions({maxLines: Infinity});
editor.setTheme("ace/theme/"+aceTheme);
editor.session.setMode("ace/mode/"+aceLang);
editor.setValue( editor.getValue().split('\n').join('\r\n'));
editor.getSession().selection.clearSelection();
}
}
继续水
标签: 软件开发 javascript Web技术
将全部公开的SVN项目迁移到Git了
作者:V君 发布于:2020-3-19 20:12 Thursday 分类:小服杂记
由于 SVN 的占用空间日益增大,目前又主要以 Git 为主,使得备份空间占用变得越来越没有意义,因此花了几天时间来搬运。在这里向大家分担一下这个过程。其实也不复杂,只是比较繁琐。因为找不到好用的迁移方法,我用的是最笨的手动方式,即从 SVN 导出最新版然后推送到 Git。
找到办法之后就可以制定行动方案了,因为博客上面许多文章都引用了 SVN 的链接,得找出它们,将引用的项目搬到 Git,然后更新链接。大概被分成了如下 3 个阶段:
- 直接从数据库中搜索带有 SVN 链接文章
- 导出最新版,创建 Git 仓库,导入并检查编译
- 推送,然后重新回到步骤 1 直到所有文章都处理完
最后把 SVN 的公开访问关闭了,如果有需要访问原 SVN 有、但没被文章引用的项目,请留言,我会考虑为其创建公开的 Git 仓库。
标签: 源码管理
在 IIS 使用 web.config 配置域名端口跳转
作者:V君 发布于:2020-2-9 0:21 Sunday 分类:小服杂记
— TL;DR —
按需将以下配置节点添加到 web.config ,修改目标域名,完成。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering>
<fileExtensions allowUnlisted="true">
<remove fileExtension=".cs" />
</fileExtensions>
</requestFiltering>
</security>
<rewrite>
<rules>
<rule name="RedirectGogs" stopProcessing="true" enabled="true">
<match url="^gogs/(.*$)" />
<action type="Redirect" redirectType="Temporary" url="https://gogs.topcl.net:8443/{R:1}"/>
</rule>
<rule name="RedirectExaWww" stopProcessing="true" enabled="true">
<match url="^(?![\._].*$).*" />
<conditions>
<add input="{HTTP_HOST}" pattern="www\.example\.com" />
</conditions>
<action type="Redirect" redirectType="Temporary" url="https://blog.example.com:8443/{R:0}"/>
</rule>
<rule name="RedirectExa" stopProcessing="true" enabled="true">
<match url="^(?![\._].*$).*" />
<conditions>
<add input="{HTTP_HOST}" pattern="example\.com" />
</conditions>
<action type="Redirect" redirectType="Temporary" url="https://blog.example.com:8443/{R:0}"/>
</rule>
<rule name="DefultRedirectBlog" stopProcessing="true" enabled="true">
<match url="^(?![\._].*$).*" />
<action type="Redirect" redirectType="Temporary" url="https://blog.topcl.net:8443/{R:0}"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
— 听我扯扯 —
咋一看,不就是 rewrite + redirect (307) 不就好? 其实没有那么简单,比如源代码连接里以 .cs 后缀的代码文件 (例)就在跳转的时候被 IIS 拦下来 404 了,因此还得额外加白。你可能会担心安全风险,但我这个空间仅仅用来跳转,根目录下只有这个 web.config 文件。
二月份的文章也只能这么水了,因为疫情只能把自己关在家
— 更新 —
将正则表达式改为 ^(?![\._].*$).* 可以忽略以指定字符开头的路径,方便申请 Let's 证书和临时放些文件,使配置更灵活
— 更新Ⅱ —
使用 conditions 实现别名支持,使空间变跳转 hub,将其利用价值榨干
blogger
Google Web Translator
热门日志
随机日志
最新日志
最新评论
- V君
@Soar:DHCP 协议相... - V君
@Soar:当然是非... - Soar
@V君:谢谢 有空... - Soar
搞一个 1230v3+B85... - V君
@Soar:另外,也可... - V君
@Soar:iscsi服务端... - Soar
难怪这么卡,尤其... - Soar
clone了源码,提示... - V君
@springwood:怎么... - springwood
最近在做 vue + f...
分类
存档
- 2023年7月(1)
- 2023年5月(1)
- 2022年11月(1)
- 2022年10月(1)
- 2022年9月(1)
- 2022年8月(1)
- 2022年7月(1)
- 2022年6月(1)
- 2022年5月(2)
- 2022年4月(1)
- 2022年3月(1)
- 2022年2月(1)
- 2022年1月(1)
- 2021年12月(1)
- 2021年11月(1)
- 2021年10月(1)
- 2021年9月(1)
- 2021年8月(1)
- 2021年7月(1)
- 2021年6月(1)
- 2021年5月(1)
- 2021年4月(1)
- 2021年3月(1)
- 2021年2月(1)
- 2021年1月(1)
- 2020年12月(1)
- 2020年11月(1)
- 2020年10月(2)
- 2020年9月(1)
- 2020年8月(1)
- 2020年7月(1)
- 2020年6月(1)
- 2020年5月(1)
- 2020年4月(2)
- 2020年3月(3)
- 2020年2月(1)
- 2020年1月(1)
- 2019年12月(1)
- 2019年11月(1)
- 2019年10月(1)
- 2019年9月(1)
- 2019年8月(2)
- 2019年7月(1)
- 2019年6月(1)
- 2019年5月(1)
- 2019年4月(1)
- 2019年3月(1)
- 2019年2月(1)
- 2019年1月(2)
- 2018年12月(2)
- 2018年11月(1)
- 2018年10月(3)
- 2018年9月(4)
- 2018年8月(6)
- 2018年7月(4)
- 2018年6月(1)
- 2018年5月(2)
- 2018年4月(2)
- 2018年3月(3)
- 2018年2月(1)
- 2018年1月(1)
- 2017年12月(1)
- 2017年10月(2)
- 2017年9月(1)
- 2017年8月(2)
- 2017年7月(1)
- 2017年6月(5)
- 2017年5月(2)
- 2017年4月(2)
- 2017年3月(3)
- 2017年2月(2)
- 2017年1月(2)
- 2016年12月(3)
- 2016年11月(2)
- 2016年10月(3)
- 2016年9月(4)
- 2016年8月(2)
- 2016年7月(4)
- 2016年6月(3)
- 2016年5月(1)
- 2016年4月(4)
- 2016年3月(3)
- 2016年2月(1)
- 2016年1月(5)
- 2015年12月(4)
- 2015年11月(5)
- 2015年10月(1)
- 2015年9月(6)
- 2015年8月(4)
- 2015年7月(1)
- 2015年6月(6)
- 2015年5月(3)
- 2015年4月(3)
- 2015年3月(2)
- 2015年2月(1)
- 2015年1月(3)
- 2014年12月(1)
- 2014年11月(1)
- 2014年10月(1)
- 2014年9月(3)
- 2014年8月(1)
- 2014年7月(1)
- 2014年6月(1)
- 2014年5月(3)
- 2014年4月(1)
- 2014年3月(1)
- 2014年2月(2)
- 2014年1月(1)
- 2013年12月(2)
- 2013年11月(2)
- 2013年10月(1)
- 2013年9月(3)
- 2013年8月(14)
- 2013年7月(7)
- 2013年4月(1)
- 2013年3月(4)
- 2013年2月(6)
- 2013年1月(6)
- 2012年12月(8)
- 2012年11月(6)