2.2.20250722 编码体系

#知识管理能力 #卡片盒笔记法 #数字花园 #编码 #方法论

简介::基于[[卡片盒笔记法]],建立卡片之间的连接,当然可以使用[[MOC]],也可以使用编码

卢曼的卡片盒,使用的是实体:通过主题箱子和编码系统进行组织,如果这套系统移植到数字化系统上,那就是:索引+卡片盒+编码

  • 索引是moc
  • 卡片盒是标签,双链
  • 编码:用0-9进行分类+英文单词

image.png|600

编码体系

  • 第一位是大类
  • 第二位是大类的分支
  • 第三位是排序位,使用数字

案例:1.1.1

利用的原理

编码体系

/* setTitleFromFilename.js */
async function setTitleFromFilename() {
  const file = app.workspace.getActiveFile();
  if (!file) return;

  /* ===== 排除指定文件 ===== */
  if (['Inbox', '待办记录.components','酷口家数字花园'].includes(file.basename)) return;

/* ===== 排除指定文件夹 ===== */
if (file.path.startsWith('9文献笔记/wu/')) return;

  /* ========== 1. 读取并标准化标签 ========== */
  const cache = app.MetadataCache.getFileCache(file);
  const rawTags = cache?.frontmatter?.tags ?? cache?.frontmatter?.tag ?? [];
  const tags = Array.isArray(rawTags)
    ? rawTags.map(t => String(t).toLowerCase())
    : [String(rawTags).toLowerCase()];

  /* ========== 2. 标签 → 前缀 映射表(按优先级排序) ========== */
  const tagRules = [
    { match: ['进行中'],        prefix: '0.0' },
    { match: ['记录'],        prefix: '1.0' },
    { match: ['行业'],        prefix: '1.0' },
    { match: ['企业'],        prefix: '1.1' },
    { match: ['动漫','电影','电视剧','书名','奖项','小说'],        prefix: '1.3' },
    { match: ['职业'],        prefix: '1.4' },
    { match: ['能力'],        prefix: '1.5' },
    { match: ['moc'],        prefix: '1.6' },
    { match: ['思维模型'],    prefix: '2.1' },
    { match: ['技术'],        prefix: '2.2' },
    { match: ['方法论'],      prefix: '2.2' },
    { match: ['概念笔记'],      prefix: '2.3' },
    { match: ['学科'],      prefix: '2.4' },
    { match: ['人物', '角色','同事','亲属','下属','同事'], prefix: '3.1' },
    { match: ['客户'],        prefix: '3.7' },
    { match: ['门派'],        prefix: '3.2' },
    { match: ['大学'],        prefix: '3.3' },
    { match: ['活动'],        prefix: '3.4' },
    { match: ['传记','基本资料'],        prefix: '3.5' },
    { match: ['节日'],        prefix: '3.6' },
    { match: ['组织'],        prefix: '3.6' },
    { match: ['行为设计能力'],        prefix: '3.6' },
    { match: ['作家','演员'],        prefix: '3.0' },
    { match: ['城市', '地名','省份','国家'], prefix: '4.1' },
    { match: ['河流','湖泊'], prefix: '4.2' },
    { match: ['山脉'], prefix: '4.3' },
    { match: ['建筑','景点'], prefix: '4.4' },
    { match: ['国家','朝代'], prefix: '4.5' },
    { match: ['app','法宝','品牌','硬件','水果','经济作物','美食','食物'],         prefix: '5.1' },
    { match: ['插件'],        prefix: '5.2' },
    { match: ['灵兽'],         prefix: '5.2' },
    { match: ['功法'],        prefix: '5.3' },
    { match: ['大事记'],        prefix: '6.0' },
    { match: ['攻略'],        prefix: '6.1' },
    { match: ['事件'],        prefix: '6.2' },
    { match: ['灾难'],        prefix: '6.3' },
    { match: ['项目'],        prefix: '6.4' },
   { match: ['视觉笔记'],        prefix: '7.0' },
    { match: ['清单'],        prefix: '7.1' },
    { match: ['需求池'],        prefix: '7.2' },
    { match: ['反思记录'],        prefix: '8.2' },
    { match: ['上线记录'],        prefix: '8.0' },
    { match: ['会议纪要'],        prefix: '8.8' },
    { match: ['充值记录'],        prefix: '8.3' },
    { match: ['参考资料','书名'], prefix: '9.1' },
    { match: ['自媒体'],      prefix: '9.2' },
    { match: ['剪藏记录'],      prefix: '9.3' },
    { match: ['书单'],      prefix: '9.4' },
    { match: ['读书笔记','听书稿','听书导图','原文笔记'],      prefix: '9.5' }



  ];

  /* ========== 3. 根据标签确定前缀(命中即停) ========== */
  let prefixBase = '8.1';
  for (const rule of tagRules) {
    if (rule.match.some(k => tags.includes(k))) {
      prefixBase = rule.prefix;
      break;
    }
  }

  /* ========== 4. 拼完整前缀:基础 + 年月日 ========== */
  const today = new Date();
  const y = today.getFullYear();
  const m = String(today.getMonth() + 1).padStart(2, '0');
  const d = String(today.getDate()).padStart(2, '0');
  const datePart = `${y}${m}${d}`;
  const datePrefix = `${prefixBase}.${datePart}`;


/* ========== 5. 处理 title ========== */
const currentTitle = String(cache?.frontmatter?.title ?? '').trim();
const shouldPrefix = prefixBase;                   // 不含日期
const shouldFull   = `${prefixBase}.${datePart}`;  // 含今天日期

const parts = currentTitle.match(/^([\d.]+)\s*(.*)$/);
const oldPrefixRaw = parts ? parts[1] : '';
const body         = parts ? parts[2] : (currentTitle || file.basename);

// 只取前两段,忽略第三段及以后
const pureOld = oldPrefixRaw.replace(/\.\d{8}$/, '').split('.').slice(0, 2).join('.');
let newTitle = '';

if (pureOld !== shouldPrefix) {
  // 规则1:标签不一致 → 重拼
  newTitle = `${shouldFull} ${body.trim()}`;
} else if (/^\d$/.test(pureOld)) {
  // 规则2:单数字且一致 → 重拼
  newTitle = `${shouldFull} ${body.trim()}`;
} else {
  // 规则3:X.X.X 且一致 → 仅补空格
  newTitle = `${oldPrefixRaw} ${body.trim()}`;
}

if (newTitle !== currentTitle) {
  await app.fileManager.processFrontMatter(file, fm => fm.title = newTitle);
  //new Notice(`✅ 标题:${newTitle}`);
}

/* ========== 6. 写回 frontmatter ========== */
 // await app.fileManager.processFrontMatter(file, fm => {
//    fm.title = newTitle;   // 保持原有 title
//    fm.标题  = newTitle;   // 新增:同步到「标题」属性
 // });
  //new Notice(`✅ 标题:${newTitle}`);




}

module.exports = setTitleFromFilename;




跟多的编码,请参考:[[编码]]的探索过程

滚动至顶部
酷口家数字花园 粤ICP备17140089号-1