【3】代码和主题修改
本来是参考emlog的开发文档, 直接调用emlog的API接口。但是发现有几个问题,因此借助大模型快速修复了一下,最新的代码已修复,大家可进行下载。
git clone https://github.com/apostle9891/emlog_modify.git
1 emlog 问题
1.1 文章发布
文章发布发现传入正确的sort_id分类管理并不生效,在include/controller/api_controller.php原因是多了2个空格,在以下:
124 $logData = [
125 'title' => $title,
126 'content' => $content,
127 'excerpt' => $excerpt,
128 'author' => $author_uid,
129 'sortid' => $sort_id,
130 'cover' => $cover,
131 'date' => strtotime($post_date ?: date('Y-m-d H:i:s')),
132 'hide' => $draft === 'y' ? 'y' : 'n',
133 'checked' => $checked,
134 'alias' => $alias,
135 'top ' => $top, # top多了空格
136 'sortop ' => $sortop, # 多了空格
137 'allow_remark' => $allow_remark,
138 'password' => $password,
139 'link' => $link,
140 'template' => $template,
141 ];
去掉空格可以完成。
1.2 新增alias别名
alias别名是很有用的,比如以前我的域名是https://blog.askerlab.com/?post=1,如果文档删除了,对应的链接又重新生成,会不同。而通过在obsidian和后台配置别名,则可以每次链接名称都是一样的,启用链接别名。

emlog因为有源码,通过大模型分析源码发现其实后台是支持alias别名控制的,所以重新修改了对应的代码,使用git 生成了一个patch,也可以直接通过git clone https://github.com/apostle9891/emlog_modify.git下载所有代码
可以在对应的emlog的源码中,执行如下操作:
vim fix_bug.patch
将如下代码复制进去:
diff --git a/include/controller/api_controller.php b/include/controller/api_controller.php
old mode 100644
new mode 100755
index 8a6bb1e8..349d205f
--- a/include/controller/api_controller.php
+++ b/include/controller/api_controller.php
@@ -132,8 +132,8 @@ class Api_Controller
'hide' => $draft === 'y' ? 'y' : 'n',
'checked' => $checked,
'alias' => $alias,
- 'top ' => $top,
- 'sortop ' => $sortop,
+ 'top' => $top,
+ 'sortop' => $sortop,
'allow_remark' => $allow_remark,
'password' => $password,
'link' => $link,
@@ -164,6 +164,13 @@ class Api_Controller
$tags = strip_tags(Input::postStrVar('tags'));
$author_uid = Input::postIntVar('author_uid', 1);
$draft = Input::postStrVar('draft', 'n');
+ $alias = Input::postStrVar('alias');
+ $top = Input::postStrVar('top', 'n');
+ $sortop = Input::postStrVar('sortop', 'n');
+ $allow_remark = Input::postStrVar('allow_remark', 'n');
+ $password = Input::postStrVar('password');
+ $link = Input::postStrVar('link');
+ $template = Input::postStrVar('template');
$field_keys = Input::postStrArray('field_keys');
$field_values = Input::postStrArray('field_values');
@@ -173,19 +180,35 @@ class Api_Controller
Output::error('parameter error');
}
+ // 检查文章别名
+ if (!preg_match('/^[a-zA-Z0-9_-]+$/', $alias)) {
+ $alias = '';
+ }
+ if (!empty($alias)) {
+ $logalias_cache = $this->Cache->readCache('logalias');
+ $alias = $this->Log_Model->checkAlias($alias, $logalias_cache, $id);
+ }
+
if ($this->curUid) {
$author_uid = $this->curUid;
}
$logData = [
- 'title' => $title,
- 'content' => $content,
- 'excerpt' => $excerpt,
- 'sortid' => $sort_id,
- 'cover' => $cover,
- 'author' => $author_uid,
- 'date' => strtotime($post_date ?: date('Y-m-d H:i:s')),
- 'hide' => $draft === 'y' ? 'y' : 'n',
+ 'title' => $title,
+ 'content' => $content,
+ 'excerpt' => $excerpt,
+ 'sortid' => $sort_id,
+ 'cover' => $cover,
+ 'author' => $author_uid,
+ 'date' => strtotime($post_date ?: date('Y-m-d H:i:s')),
+ 'hide' => $draft === 'y' ? 'y' : 'n',
+ 'alias' => $alias,
+ 'top' => $top,
+ 'sortop' => $sortop,
+ 'allow_remark' => $allow_remark,
+ 'password' => $password,
+ 'link' => $link,
+ 'template' => $template,
];
$this->Log_Model->updateLog($logData, $id, $author_uid);
最终打补丁
# 检查补丁
git apply --check fix_bug.patch
# 打补丁
git apply fix_bug.patch
2 主题问题
使用cursor修改了对应代码,支持目录。
本文发布于2025年10月31日16:04,已经过了118天,若内容或图片失效,请留言反馈 -
obsidian修改字体间距
背景 我的方案是使用云盘进行obsidian的文件同步的,各端都使用云盘进行数据的同步。最近刚买了macmini,配置在obsidian同步的时候,macos不知道为什么".obsidian"隐藏文件...
2024/11/18
-
优必选小方头刷小智机器人
1. 背景 最近在调研看智能萌宠机器人,正好看到网上有人买了优必选的小方头机器来刷目前的小智,所以买来试试。小方头机器人在2019年9月20日发布,售价1099元,现在咸鱼100块钱就能买到;小智机器...
2025/03/27
-
dify和ragflow同时启动redis冲突
1. 背景 在同一台服务器上同时启动 Dify 和 Ragflow 时,可能会遇到 Redis 容器冲突的问题。具体表现为:当两个服务都启动后,其中一个服务的 Redis 容器可能会被删除,导致该服务...
2025/03/20
-
cursor内claude4.0 中国区无法使用解决方案
相信最近大家在使用cursor的claude4.0的时候突然发现提示: https://blog.askerlab.com/content/uploadfile/202511/c97117620656...
2025/07/20
求索空间
apostle9891
360视觉云
360智慧生活
gitea
导航
hoppscotch
暂无评论