-
思源笔记丨动态图标使用笔记
2024-11-10 19:30我用模板无法设置图标
.action{/* 获取今天日期和星期 */} .action{ $today := now | date "2006-01-02" } .action{ $weekday := now | date "Mon" } .action{/* 定义每个星期几对应的颜色 */} .action{ $weekdayColors := dict "Mon" "E55D3B" "Tue" "FFA95C" "Wed" "FAD155" "Thu" "8BC34A" "Fri" "5BC0DE" "Sat" "5FADE2" "Sun" "C481BD" } .action{/* 获取当前星期的颜色 */} .action{ $color := index $weekdayColors $weekday } .action{/* 设置文档图标:选择type6,仅返回星期样式 */} {: icon="api/icon/getDynamicIcon?type=6&date=.action{ $today }&color=.action{ $color }" type="doc"}
-
思源笔记丨动态图标使用笔记
2024-11-10 17:34或者也可自定义颜色
- 日记:格式“2024-11-10”
import json import re import os from datetime import datetime def update_sy_file(file_path): # 读取 .sy 文件内容 with open(file_path, "r", encoding="utf-8") as file: content = file.read() # 解析 JSON 数据 data = json.loads(content) # 使用正则表达式提取 title 中的日期 title = data.get("Properties", {}).get("title", "") match = re.match(r"^(\d{4})-(\d{2})-(\d{2})$", title) if match: year, month, day = match.groups() formatted_date = f"{year}-{month}-{day}" # 获取日期对应的星期几 date_obj = datetime.strptime(formatted_date, "%Y-%m-%d") weekday = date_obj.weekday() # 星期一是0,星期日是6 # 根据星期几设置颜色 colors = ["E55D3B", "FFA95C", "FAD155", "8BC34A", "5BC0DE", "5FADE2", "C481BD"] color = colors[weekday] # 更新 icon 属性 new_icon = f"api/icon/getDynamicIcon?type=6&color={color}&date={formatted_date}&lang=zh_CN&weekdayType=1" data["Properties"]["icon"] = new_icon # 将更新后的数据写回文件 with open(file_path, "w", encoding="utf-8") as file: json.dump(data, file, ensure_ascii=False) print(f"Updated icon for file: {file_path}") def process_directory(directory_path): # 遍历目录及其子目录中的所有文件 for root, _, files in os.walk(directory_path): for file in files: if file.endswith(".sy"): file_path = os.path.join(root, file) update_sy_file(file_path) # 使用示例 process_directory(r"D:\1STUDY\SIYUAN\data\20231007210051-jpydsvc")
- 月:格式“11”
import json import re import json import re import os def update_sy_file(file_path): # 读取 .sy 文件内容 with open(file_path, "r", encoding="utf-8") as file: content = file.read() # 解析 JSON 数据 data = json.loads(content) # 使用正则表达式提取 title 中的日期 title = data.get("Properties", {}).get("title", "") # path = data.get("Path", "") match = re.match(r"^(\d{2})$", title) # 匹配2位数字的月份 if match: month = match.group(1) # 使用group(1)而不是groups(1) formatted_date = f"{whatyear}-{month}-01" # 定义每个月份对应的颜色 month_colors = { "01": "FFFF99", # 正月-黄白游 "02": "A64236", # 二月-朱草 "03": "422166", # 三月-凝夜紫 "04": "C25160", # 四月-唇脂 "05": "D5DBAA", # 五月-筠雾碧 "06": "E3B1C3", # 六月-夕岚 "07": "88B5DA", # 七月-窃蓝 "08": "F5F2EA", # 八月-凝脂 "09": "941D24", # 九月-朱樱 "10": "DC82A7", # 十月-龙膏烛 "11": "E7CCE7", # 十一月-银红 "12": "92BCC6", # 十二月-青白玉 } # 获取对应月份的颜色 color = month_colors.get(month, "#FFFFFF") # 默认颜色为白色 # 更新 icon 属性 new_icon = f"api/icon/getDynamicIcon?type=3&date={formatted_date}&color={color}" data["Properties"]["icon"] = new_icon # 将更新后的数据写回文件 with open(file_path, "w", encoding="utf-8") as file: json.dump(data, file, ensure_ascii=False) print(f"Updated icon for file: {file_path}") def process_directory(directory_path): # 只遍历当前目录下的文件,不递归进入子目录 for item in os.listdir(directory_path): full_path = os.path.join(directory_path, item) if os.path.isfile(full_path) and item.endswith('.sy'): update_sy_file(full_path) whatyear = "2024" # 使用示例 process_directory(r"D:\1STUDY\SIYUAN\data\20231007210051-jpydsvc\20231212180155-4yzi6wx\20231230220908-wq15x5o")# 2024
- 日记:格式“2024-11-10”
-
思源笔记丨动态图标使用笔记
2024-11-10 16:42补一个默认设置的脚本
- 日记:格式“2024-11-10”
import json import re import os def update_sy_file(file_path): # 读取 .sy 文件内容 with open(file_path, "r", encoding="utf-8") as file: content = file.read() # 解析 JSON 数据 data = json.loads(content) # 使用正则表达式提取 title 中的日期 title = data.get("Properties", {}).get("title", "") match = re.match(r"^(\d{4})-(\d{2})-(\d{2})$", title) if match: year, month, day = match.groups() formatted_date = f"{year}-{month}-{day}" # 更新 icon 属性 new_icon = f"api/icon/getDynamicIcon?type=6&color=red&date={formatted_date}" data["Properties"]["icon"] = new_icon # 将更新后的数据写回文件 with open(file_path, "w", encoding="utf-8") as file: json.dump(data, file, ensure_ascii=False) print(f"Updated icon for file: {file_path}") def process_directory(directory_path): # 遍历目录及其子目录中的所有文件 for root, _, files in os.walk(directory_path): for file in files: if file.endswith(".sy"): file_path = os.path.join(root, file) update_sy_file(file_path) # 使用示例 process_directory(r"D:\1STUDY\SIYUAN\data\20231007210051-jpydsvc")
- 月:格式“11”
import json import re import os def update_sy_file(file_path): # 读取 .sy 文件内容 with open(file_path, "r", encoding="utf-8") as file: content = file.read() # 解析 JSON 数据 data = json.loads(content) # 使用正则表达式提取 title 中的日期 title = data.get("Properties", {}).get("title", "") # path = data.get("Path", "") match = re.match(r"^(\d{2})$", title) # 匹配2位数字的月份 if match: month = match.group(1) # 使用group(1)而不是groups(1) formatted_date = f"{whatyear}-{month}-01" # 更新 icon 属性 new_icon = f"api/icon/getDynamicIcon?type=3&date={formatted_date}" data["Properties"]["icon"] = new_icon # 将更新后的数据写回文件 with open(file_path, "w", encoding="utf-8") as file: json.dump(data, file, ensure_ascii=False) print(f"Updated icon for file: {file_path}") def process_directory(directory_path): # 只遍历当前目录下的文件,不递归进入子目录 for item in os.listdir(directory_path): full_path = os.path.join(directory_path, item) if os.path.isfile(full_path) and item.endswith('.sy'): update_sy_file(full_path) whatyear = "2023" # 使用示例 process_directory(r"D:\1STUDY\SIYUAN\data\20231007210051-jpydsvc\20231212180155-4yzi6wx\20231212180155-jzvvkz7")# 2024
- 日记:格式“2024-11-10”
-
有没有画廊视图的替代品?
2024-10-12 10:05.av__cellassetimg { width: 100% !important; height: auto !important; max-height: none !important; }
数据库图片全宽 css
-
批量导入文档到数据库 0.0.6 版全新发布
2024-10-10 10:09请教一下如何获取到数据库绑定块 id 的面包屑 · Issue #71 · OpaqueGlass/syplugin-hierarchyNavigate (github.com)
我也向层级导航插件的作者询问了 他对获取面包屑比较熟练
-
批量导入文档到数据库 0.0.6 版全新发布
2024-10-09 19:10感谢大佬 脚本很有用 我这里还有个需求不知道能不能实现 我用
select * from blocks
where path like '%${docBlockId}%' and markdown like '%✨%' and (type ='p' or type='h' or type='d' or type='t') order by created asc,sort asc ;来整理一个文档的所有标记好的知识点用于复习 同时 我希望他们添加到数据库时能够读取他们的面包屑该如何实现 (面包屑不行,母一级标题也行 )我想到的可以用脚本先写入面包屑到属性里 -
aris 主题左上角思源的图标被吃掉一块
2024-09-13 09:55自定义外观 css
#dockLeft { z-index: 0!important; /* Add additional styles here */ }
-
数据库一些列的值能否自动获取文档里的数据
2024-06-24 16:22大佬,可以根据标题序号获取所属文档的对应标题吗,数据库长这样 章节是数据列
我让 gpt4 写都搞不定
```go .action{ $d := .章节 | int } .action{ $blocks := queryBlocks "SELECT root_id FROM blocks WHERE id='?'" .id } .action{ if not (empty $blocks) } .action{ $rootID := (first $blocks).root_id } .action{ $chapters := queryBlocks "SELECT * FROM blocks WHERE root_id = '?' AND type = 'h1' AND subtype = 'h1'" $rootID } .action{ $currentChapter := 1 } .action{ $title := "" } .action{ range $chapters } .action{ if eq $currentChapter $d } .action{ $title = .Content } .action{ end } .action{ $currentChapter = add $currentChapter 1 } .action{ end } .action{ if ne $title "" } .action{ $title } .action{ else } 无 .action{ end } .action{ end }