From c2c1a50da2d857788b633e6cc89c848b92bcae07 Mon Sep 17 00:00:00 2001 From: Stavros Polymenis Date: Sat, 26 Aug 2017 23:54:54 +0100 Subject: [PATCH] Turn repository directory into notes folder --- src/core/archive.ml | 1 - src/core/lpath.ml | 10 ++-------- src/store/file.ml | 6 +++--- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/core/archive.ml b/src/core/archive.ml index f52d75b..9227ea8 100644 --- a/src/core/archive.ml +++ b/src/core/archive.ml @@ -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 diff --git a/src/core/lpath.ml b/src/core/lpath.ml index 0b778f2..c46cde5 100644 --- a/src/core/lpath.ml +++ b/src/core/lpath.ml @@ -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 diff --git a/src/store/file.ml b/src/store/file.ml index db36513..5a4dbe5 100644 --- a/src/store/file.ml +++ b/src/store/file.ml @@ -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)