Turn repository directory into notes folder

This commit is contained in:
Stavros Polymenis 2017-08-26 23:54:54 +01:00
parent f0fed31f85
commit c2c1a50da2
3 changed files with 5 additions and 12 deletions

View File

@ -39,7 +39,6 @@ module Configuration = struct
let open Config.Validation in
empty
&> is_directory repo
&> is_directory Lpath.(fpath_of_notes (notes_of_repo config.repository))
end
module AliasMap = Meta.AliasMap

View File

@ -1,11 +1,9 @@
open Fpath
type repo_t = Repo of t
type note_t = Note of { repo: repo_t; basename: t }
type notes_t = Notes of t
type config_t = Config of t
let extension = ".ymd"
let notes = v "notes"
let path_exists x = to_string x |> Sys.file_exists
@ -28,11 +26,7 @@ let fpath_of_repo = function Repo p -> p
let string_of_repo r = fpath_of_repo r |> to_string
let repo_of_string s = Repo (v s)
let fpath_of_notes = function Notes ns -> ns
let string_of_notes ns = fpath_of_notes ns |> to_string
let notes_of_repo r = Notes (fpath_of_repo r // notes)
let fpath_of_note = function Note n -> (fpath_of_repo n.repo // notes // n.basename)
let fpath_of_note = function Note n -> (fpath_of_repo n.repo // n.basename)
let string_of_note n = fpath_of_note n |> to_string
let note_of_basename repo s = Note { repo; basename = v s }
@ -40,7 +34,7 @@ let alias_of_note = function Note n -> n.basename |> rem_ext |> to_string
let note_of_alias repo alias = note_of_basename repo (alias ^ extension)
let versioned_basename_of_title ?(version=0) repo (title : string) =
let notes_fpath = fpath_of_repo repo // notes in
let notes_fpath = fpath_of_repo repo in
let basename = v @@ Meta.string_alias title in
let rec next version =
let candidate = basename |> add_ext (string_of_int version) |> add_ext extension in

View File

@ -19,7 +19,7 @@ let to_list ?(order) lens_fn store =
lens_fn note :: list
with Note.Syntax_error str -> prerr_endline str; list
in
Lpath.(notes_of_repo repo_path |> string_of_notes)
Lpath.string_of_repo repo_path
|> Sys.readdir
|> Array.to_list
|> List.filter (fun file -> BatString.ends_with file Lpath.extension)
@ -38,7 +38,7 @@ let note_with_id store id =
with Note.Syntax_error str -> prerr_endline str; false
in
let notes =
Lpath.(notes_of_repo repo_path |> string_of_notes)
Lpath.string_of_repo repo_path
|> Sys.readdir
|> Array.to_list
|> List.filter (fun file -> BatString.ends_with file Lpath.extension)
@ -54,7 +54,7 @@ let note_with_alias store alias =
in
let recency_order a b = Meta.(Date.compare b.date a.date) in
let notes =
Lpath.(notes_of_repo repo_path |> string_of_notes)
Lpath.string_of_repo repo_path
|> Sys.readdir
|> Array.to_list
|> List.filter (fun file -> BatString.ends_with file Lpath.extension)