2020-10-26 14:55:40 +00:00
|
|
|
local ZK = {}
|
2020-10-26 18:32:27 +00:00
|
|
|
|
2021-04-30 13:30:43 +00:00
|
|
|
local ls = require 'zettelkasten.files'
|
2020-10-30 15:04:23 +00:00
|
|
|
local o = require 'zettelkasten.options'
|
2020-11-04 21:27:30 +00:00
|
|
|
local anchor = require 'zettelkasten.anchor'
|
|
|
|
local action = require 'zettelkasten.action'
|
2020-10-26 14:55:40 +00:00
|
|
|
|
2020-10-29 11:18:19 +00:00
|
|
|
-- Returns all zettel in path as a
|
|
|
|
-- { "anchor" = "path/to/zettel/anchor filename.md" }
|
|
|
|
-- table.
|
|
|
|
-- Recurses into subdirectories if recursive argument is true.
|
|
|
|
function ZK.get_zettel_list(path, recursive)
|
2021-04-30 15:32:03 +00:00
|
|
|
return ls.get_anchors_and_paths(ls.get_all_files(path, recursive or false))
|
2020-10-29 11:18:19 +00:00
|
|
|
end
|
|
|
|
|
2020-10-31 10:01:53 +00:00
|
|
|
-- Return a valid zettelkasten anchor for the current time,
|
|
|
|
-- composed of yymmddHHMM.
|
2020-11-04 21:27:30 +00:00
|
|
|
function ZK.get_anchor() return anchor.create() end
|
2020-10-30 15:30:37 +00:00
|
|
|
|
2020-11-04 21:27:30 +00:00
|
|
|
-- Open link under cursor, or next on line
|
|
|
|
function ZK.open_link() return action.open_selected() end
|
|
|
|
|
|
|
|
return {
|
|
|
|
get_zettel_list = ZK.get_zettel_list,
|
|
|
|
get_anchor = ZK.get_anchor,
|
|
|
|
open_link = ZK.open_link
|
|
|
|
}
|