Skip to content

Commit f1e016a

Browse files
committed
update
1 parent bdd36e3 commit f1e016a

File tree

7 files changed

+760
-1
lines changed

7 files changed

+760
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ A curated collection of plugins, templates, and utilities for [SilverBullet](htt
55
## 📦 Available Libraries
66

77
- [Bashcode](https://github.com/malys/silverbullet-libraries/blob/main/src/BashCode.md) - Quickly insert bash code. - (2025-11-16)
8+
- [Breadcrumb](https://github.com/malys/silverbullet-libraries/blob/main/src/Breadcrumb.md) - Generate breadcrumbs for a page
9+
- [Cursorposition](https://github.com/malys/silverbullet-libraries/blob/main/src/CursorPosition.md) - Generate and copy links to specific cursor positions and headers in markdown documents - (2025-11-01)
810
- [Embededitor](https://github.com/malys/silverbullet-libraries/blob/main/src/EmbedEditor.md) - Insert Iframe with editors. - (2025-11-16)
911
- [Externaltransclusion](https://github.com/malys/silverbullet-libraries/blob/main/src/ExternalTransclusion.md) - Transclude data form external resource. - (2025-11-16)
1012
- [Fasttagexplorer](https://github.com/malys/silverbullet-libraries/blob/main/src/FastTagExplorer.md) - Generate wall of children page tags - (2025-11-16)
@@ -19,9 +21,11 @@ A curated collection of plugins, templates, and utilities for [SilverBullet](htt
1921
- [Organization Employee](https://github.com/malys/silverbullet-libraries/blob/main/src/Organization/Organization-Employee.md) - Organization employee template - (2025-11-01)
2022
- [Organization Vcfexport](https://github.com/malys/silverbullet-libraries/blob/main/src/Organization/Organization-VCFExport.md) - Generate VCF of company's employees. - (2025-11-16)
2123
- [Replaceplaceholders](https://github.com/malys/silverbullet-libraries/blob/main/src/ReplacePlaceholders.md) - Replace Placeholders feature allows you to easily replace placeholders in your markdown content with specific values - (2025-11-16)
24+
- [Riskaudit](https://github.com/malys/silverbullet-libraries/blob/main/src/RiskAudit.md) - Enhanced Risk Audit for SilverBullet that analyzes scripts for potentially dangerous constructs and API calls.
2225
- [Taiga](https://github.com/malys/silverbullet-libraries/blob/main/src/Taiga.md) - Taiga, open-source project management tool, integration. - (2025-11-16)
2326
- [Theme Malys](https://github.com/malys/silverbullet-libraries/blob/main/src/Theme/theme-malys.md) - Dark theme thought for readibility and productivity. - (2025-11-16)
2427
- [Utilities](https://github.com/malys/silverbullet-libraries/blob/main/src/Utilities.md) - List of reusable functions. - (2025-11-16)
28+
- [Vikunja](https://github.com/malys/silverbullet-libraries/blob/main/src/Vikunja.md) - Vikunja, open-source project management tool, integration.
2529
- [Vscodepalette](https://github.com/malys/silverbullet-libraries/blob/main/src/VSCodePalette.md) - universal palette (as VScode Palette), use '>' to execute commands - (2025-11-16)
2630

2731
## 🛠️ Installation

Repository/malys.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ uri: https://github.com/malys/silverbullet-libraries/blob/main/src/BashCode.md
99
website: https://github.com/malys/silverbullet-libraries/blob/main/src/BashCode.md
1010
description: "Quickly insert bash code."
1111
---
12+
name: "Breadcrumb"
13+
uri: https://github.com/malys/silverbullet-libraries/blob/main/src/Breadcrumb.md
14+
website: https://github.com/malys/silverbullet-libraries/blob/main/src/Breadcrumb.md
15+
description: "Generate breadcrumbs for a page"
16+
---
17+
name: "Cursorposition"
18+
uri: https://github.com/malys/silverbullet-libraries/blob/main/src/CursorPosition.md
19+
website: https://github.com/malys/silverbullet-libraries/blob/main/src/CursorPosition.md
20+
description: "Generate and copy links to specific cursor positions and headers in markdown documents"
21+
---
1222
name: "Embededitor"
1323
uri: https://github.com/malys/silverbullet-libraries/blob/main/src/EmbedEditor.md
1424
website: https://github.com/malys/silverbullet-libraries/blob/main/src/EmbedEditor.md
@@ -79,6 +89,11 @@ uri: https://github.com/malys/silverbullet-libraries/blob/main/src/ReplacePlaceh
7989
website: https://github.com/malys/silverbullet-libraries/blob/main/src/ReplacePlaceholders.md
8090
description: "Replace Placeholders feature allows you to easily replace placeholders in your markdown content with specific values"
8191
---
92+
name: "Riskaudit"
93+
uri: https://github.com/malys/silverbullet-libraries/blob/main/src/RiskAudit.md
94+
website: https://github.com/malys/silverbullet-libraries/blob/main/src/RiskAudit.md
95+
description: "Enhanced Risk Audit for SilverBullet that analyzes scripts for potentially dangerous constructs and API calls."
96+
---
8297
name: "Taiga"
8398
uri: https://github.com/malys/silverbullet-libraries/blob/main/src/Taiga.md
8499
website: https://github.com/malys/silverbullet-libraries/blob/main/src/Taiga.md
@@ -94,6 +109,11 @@ uri: https://github.com/malys/silverbullet-libraries/blob/main/src/Utilities.md
94109
website: https://github.com/malys/silverbullet-libraries/blob/main/src/Utilities.md
95110
description: "List of reusable functions."
96111
---
112+
name: "Vikunja"
113+
uri: https://github.com/malys/silverbullet-libraries/blob/main/src/Vikunja.md
114+
website: https://github.com/malys/silverbullet-libraries/blob/main/src/Vikunja.md
115+
description: "Vikunja, open-source project management tool, integration."
116+
---
97117
name: "Vscodepalette"
98118
uri: https://github.com/malys/silverbullet-libraries/blob/main/src/VSCodePalette.md
99119
website: https://github.com/malys/silverbullet-libraries/blob/main/src/VSCodePalette.md

src/Breadcrumb.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
author: malys
3+
description: Generate breadcrumbs for a page
4+
name: "Library/Malys/Breadcrumb"
5+
tags: meta/library
6+
---
7+
# Top breadcrumbs
8+
This plugin generates breadcrumbs for a page. Breadcrumbs are useful for navigation, especially when your page hierarchy is deep.
9+
This plugin is useful when you want to easily navigate to a page at any level of the hierarchy.
10+
It also provides a way to visualize the hierarchy by showing the path to the page.
11+
12+
> **example**
13+
> [🏡 home](https://xx/home)/[z-custom](https://xx/z-custom) /[breadcrumbs](https://xx/z-custom/breadcrumbs)  -[template](https://xx/z-custom/breadcrumbs/template)
14+
15+
16+
## Source
17+
```space-lua
18+
yg = yg or {}
19+
yg.t_bc = template.new[==[[[${name}]]/ ​]==]
20+
yg.t_bcsub = template.new[==[-[[${name}]]​]==]
21+
22+
function yg.breadcrumbs(path)
23+
local mypage = path or editor.getCurrentPage()
24+
local parts = string.split(mypage, "/")
25+
local crumbs = {}
26+
for i, part in ipairs(parts) do
27+
local current = table.concat(parts, "/", 1, i)
28+
table.insert(crumbs, {name = current})
29+
end
30+
return crumbs
31+
end
32+
33+
function yg.bc(path)
34+
return template.each(yg.breadcrumbs(path), yg.t_bc)
35+
.. template.each(yg.children(path), yg.t_bcsub)
36+
end
37+
38+
function yg.children(path)
39+
local crumbsChildren = {}
40+
local mypage = path or editor.getCurrentPage()
41+
local pages = {}
42+
43+
for _, page in ipairs(space.listPages()) do
44+
if page.name:find("^" .. mypage .. "/") and mypage ~= page.name then
45+
table.insert(pages, page)
46+
end
47+
end
48+
49+
table.sort(pages, function(a, b) return a.lastModified > b.lastModified end)
50+
51+
for i = 1, math.min(7, #pages) do
52+
table.insert(crumbsChildren, {name = pages[i].ref})
53+
end
54+
55+
return crumbsChildren
56+
end
57+
58+
function widgets.breadcrumbs()
59+
return widget.new {
60+
markdown = yg.bc()
61+
}
62+
end
63+
64+
event.listen {
65+
name = "hooks:renderTopWidgets",
66+
run = function(e)
67+
return widgets.breadcrumbs()
68+
end
69+
}
70+
```

src/CursorPosition.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
author: malys
3+
description: Generate and copy links to specific cursor positions and headers in markdown documents
4+
name: "Library/Malys/CursorPosition"
5+
tags: meta/library
6+
---
7+
# Cursor Position Link Generator
8+
9+
This script provides functionality to generate and copy links to specific cursor positions and headers within markdown documents. It's particularly useful for creating precise references within a document or across multiple documents.
10+
11+
## Features
12+
13+
- **External Links**: Generate full URLs pointing to specific cursor positions or headers
14+
- **Internal Links**: Create markdown-style internal links for use within the same document
15+
16+
## Usage
17+
18+
### External Links (Ctrl+Shift+C)
19+
Copies a full URL to the current cursor position or header to the clipboard.
20+
- If the cursor is on a header line: Creates a URL with the header as an anchor (e.g., `https://your-host/Page#Header Name`)
21+
- If not on a header: Creates a URL with the cursor position (e.g., `https://your-host/Page@123`)
22+
23+
### Internal Links (Ctrl+Shift+L)
24+
Copies a markdown-style internal link to the current cursor position or header.
25+
- If on a header: Creates a link like `[Header Name@123]`
26+
- If not on a header: Creates a link like `[Page Name@123]`
27+
---
28+
## Source
29+
```space-lua
30+
-- [[Page#Header]] -> http(s)://host/Page#Header
31+
-- [[Page@pos]] -> http(s)://host/Page@pos
32+
33+
local function replace_space_with_percent20(s)
34+
local parts = {}
35+
for i = 1, #s do
36+
local c = s:sub(i, i)
37+
if c == " " then
38+
parts[#parts+1] = "%20"
39+
else
40+
parts[#parts+1] = c
41+
end
42+
end
43+
return table.concat(parts)
44+
end
45+
46+
local function build_page_url(pageName)
47+
-- get direct url from js
48+
local BASE_URL = js.window.location.origin
49+
local path = replace_space_with_percent20(pageName)
50+
if BASE_URL:sub(-1) == "/" then
51+
return BASE_URL .. path
52+
else
53+
return BASE_URL .. "/" .. path
54+
end
55+
end
56+
57+
command.define {
58+
name = "Cursor: Copy external link",
59+
key = "Ctrl-Shift-c",
60+
run = function()
61+
local currentLine = editor.getCurrentLine().text
62+
local pageName = editor.getCurrentPage()
63+
local pos = editor.getCursor()
64+
local headerMarks, headerName = string.match(currentLine, "^(#+) +(.+)$")
65+
66+
local pageUrl = build_page_url(pageName)
67+
local out
68+
if headerMarks and headerName and headerName:match("%S") then
69+
headerName = headerName:match("^%s*(.+)")
70+
headerName = replace_space_with_percent20(headerName)
71+
out = string.format("%s#%s", pageUrl, headerName)
72+
-- editor.flashNotification("Copied header external link: " .. out, "info")
73+
editor.flashNotification("Copied header link: " .. out, "info")
74+
else
75+
out = string.format("%s@%d", pageUrl, pos)
76+
-- editor.flashNotification("Copied cursor external link: " .. out, "info")
77+
editor.flashNotification("Copied cursor link: " .. out, "info")
78+
end
79+
80+
editor.copyToClipboard(out)
81+
end
82+
}
83+
84+
85+
command.define {
86+
name = "Cursor: Copy internal link",
87+
key = "Ctrl-Shift-l",
88+
run = function()
89+
local currentLine = editor.getCurrentLine().text
90+
local pageName = editor.getCurrentPage()
91+
local pos = editor.getCursor()
92+
local headerMarks, headerName = string.match(currentLine, "^(#+) +(.+)$")
93+
94+
local out
95+
if headerMarks and headerName and headerName:match("%S") then
96+
headerName = headerName:match("^%s*(.+)")
97+
out = string.format("[[%s@%s]]", replace_space_with_percent20(headerName), pos)
98+
editor.flashNotification("Copied header internal link: " .. out, "info")
99+
else
100+
out = string.format("[[%s@%d]]", replace_space_with_percent20(pageName), pos)
101+
editor.flashNotification("Copied cursor internal link: " .. out, "info")
102+
end
103+
104+
editor.copyToClipboard(out)
105+
end
106+
}
107+
108+
```

src/GitHistory.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,13 @@ local LOG_ENABLE = false
8888
8989
local function log(...)
9090
if LOG_ENABLE and utilities and utilities.debug then
91-
-- utilities.debug(table.concat({...}, " "))
91+
if type(utilities.debug) == "function" then
92+
utilities.debug(table.concat({...}, " "))
93+
end
9294
end
9395
end
9496
97+
9598
local current_panel_id = "rhs"
9699
local is_panel_visible = false
97100

0 commit comments

Comments
 (0)