chouann
关注
100529 号成员,2023-03-02 01:21:30 加入
1
个人主页 浏览
2h37m
在线时长
  • 思源能否实现 iCloud 式的「使用时同步」?

    2024-12-04 04:21

    这样可以,但是非原生支持效果会差很多。比如说,原生支持的话,视频可以正常显示长度、预览图,点一下播放就会自动下载并开始播放。外链就没法实现这么自然地使用了

  • 思源能否实现 iCloud 式的「使用时同步」?

    2024-12-03 20:08

    是增量的,但是附件需要下载时间

  • 是否有人用思源实现了生词本?

    2024-10-10 23:19

    当前页单词

    WITH subpages AS (
        SELECT id, content, path
        FROM blocks
        WHERE type = 'd' AND path LIKE '%/.block{.root_id}/______________-_______.sy'
    )
    SELECT 
        '[' || s.content || '](siyuan://blocks/' || s.id || ')' AS __1____pre__单词,
        (SELECT b1.content 
         FROM blocks b1 
         WHERE b1.root_id = s.id 
           AND b1.type = 'p' 
           AND b1.parent_id = (SELECT id FROM blocks WHERE root_id = s.id AND type = 'h' AND content = '汉义' AND subtype = 'h3')
         LIMIT 1) AS __2____pre__汉义
    FROM subpages s
    ORDER BY s.path
    LIMIT 100
    
  • 是否有人用思源实现了生词本?

    2024-10-10 23:19

    主要功能是通过 sql 查询挂件来实现的,相关的 sql 如下,因为我这个是韩语的生词本,所以针对韩语词尾变形作了优化,英语、其它语言的话,相应修改就行。

    单词本

    
    WITH RECURSIVE
      hanyi_blocks(id, parent_id, root_id, content, type, subtype, level) AS (
        SELECT id, parent_id, root_id, content, type, subtype, 0
        FROM blocks
        WHERE type = 'h' AND content = '汉义' AND subtype = 'h3'
      
        UNION ALL
      
        SELECT b.id, b.parent_id, b.root_id, b.content, b.type, b.subtype, hb.level + 1
        FROM blocks b
        JOIN hanyi_blocks hb ON b.parent_id = hb.id
        WHERE hb.level < 5  -- 限制递归深度,防止查询过大
      ),
      ciyuan_blocks(id, parent_id, root_id, content, type, subtype, level) AS (
        SELECT id, parent_id, root_id, content, type, subtype, 0
        FROM blocks
        WHERE type = 'h' AND content = '词源' AND subtype = 'h3'
      
        UNION ALL
      
        SELECT b.id, b.parent_id, b.root_id, b.content, b.type, b.subtype, hb.level + 1
        FROM blocks b
        JOIN ciyuan_blocks hb ON b.parent_id = hb.id
        WHERE hb.level < 5  -- 限制递归深度,防止查询过大
      )
    SELECT
        '[' || b.content || '](siyuan://blocks/' || b.id || ')' AS __1____pre__单词,
        (
            SELECT GROUP_CONCAT(cb.content, '
    ')
            FROM hanyi_blocks cb
            WHERE cb.root_id = b.id AND cb.type = 'p'  -- 只选择段落类型的块
            ORDER BY cb.id
        ) AS __2____pre__汉义,
        (
            SELECT GROUP_CONCAT(cb.content, '
    ')
            FROM ciyuan_blocks cb
            WHERE cb.root_id = b.id AND cb.type = 'p'  -- 只选择段落类型的块
            ORDER BY cb.id
        ) AS __3____pre__词源,
        b.created AS __4____date__创建日期
    FROM
        blocks AS b
    WHERE
        b.type = 'd'
        AND b.content REGEXP '^[\x{AC00}-\x{D7AF}\s]+$'  -- 筛选文档标题为纯韩语字符(允许空格)
        AND EXISTS (
            SELECT 1
            FROM blocks hb
            WHERE hb.parent_id = b.id AND hb.type = 'h' AND hb.subtype = 'h3' AND hb.content = '汉义'
        )
    ORDER BY
        b.created DESC
    LIMIT 1000
    

    例句

    WITH RECURSIVE
    current_document AS (
        SELECT 
            content AS title,
            CASE 
                WHEN content LIKE '%다' THEN substr(content, 1, length(content) - 1)
                ELSE content
            END AS root
        FROM blocks
        WHERE id = '.root{.id}'  -- 获取当前文档的ID
    ),
    vowel_changes(from_vowel, to_vowel) AS (
        SELECT '이', '여' UNION ALL
        SELECT '으', '어' UNION ALL
        SELECT '아', '어' UNION ALL
        SELECT '오', '와' UNION ALL
        SELECT '우', '워' UNION ALL
        SELECT '이', '에' UNION ALL
        SELECT '지', '져' UNION ALL
        SELECT '치', '쳐' UNION ALL
        SELECT '비', '벼' UNION ALL
        SELECT '피', '펴' UNION ALL
        SELECT '기', '겨' UNION ALL
        SELECT '키', '켜' UNION ALL
        SELECT '시', '셔' UNION ALL
        SELECT '디', '뎌' UNION ALL
        SELECT '티', '텨' UNION ALL
        SELECT '히', '혀' UNION ALL
        SELECT '미', '며' UNION ALL
        SELECT '니', '녀' UNION ALL
        SELECT '리', '려'
    ),
    possible_changes(original, changed, level) AS (
        SELECT root, root, 0
        FROM current_document
      
        UNION ALL
      
        SELECT 
            pc.original,
            substr(pc.changed, 1, instr(pc.changed, vc.from_vowel) - 1) || 
            vc.to_vowel || 
            substr(pc.changed, instr(pc.changed, vc.from_vowel) + length(vc.from_vowel)),
            pc.level + 1
        FROM possible_changes pc
        JOIN vowel_changes vc
        WHERE pc.changed LIKE '%' || vc.from_vowel || '%'
        AND pc.level < 2  -- 限制递归深度
    )
    SELECT DISTINCT
        '[' || replace(b.content, pc.changed, '==' || pc.changed || '==') || '](siyuan://blocks/' || b.id || ')' AS __1____pre__例句,
    	b.hpath AS __2__文档路径,
        cd.title AS __3__搜索词,
        pc.changed AS __4__匹配形式
    FROM
        blocks AS b,
        current_document cd,
        possible_changes pc
    WHERE
        b.type = 'p'
        AND b.hpath LIKE '%韩语%'
        AND (
            b.content LIKE '%' || pc.changed || '%'
            OR b.content LIKE '%' || pc.changed || '다%'
            OR b.content LIKE '%' || pc.changed || '어%'
            OR b.content LIKE '%' || pc.changed || '아%'
            OR b.content LIKE '%' || pc.changed || '여%'
            OR b.content LIKE '%' || pc.changed || '야%'
        )
        AND b.root_id != '.root{.id}'  -- 排除当前文档
    GROUP BY b.id
    ORDER BY
        b.path
    LIMIT 30
    
  • 是否有人用思源实现了生词本?

    2024-10-10 23:14

    我的灵感来自于集市里的单词本模板,在那个基础上进行了自己的修改,可以参考一下。
    每篇文章中,自动汇总这篇文档的生词(原理是搜寻这篇文章的子文章)
    image.png

    每个生词就是一页,可以自动全局搜索文章中的例句:

    image.png

    有一个单词本的页面进行所有生词的汇总:

    image.png