Last change
on this file since 1 was 1, checked in by fox, 9 years ago |
initial simple example with omd
|
File size:
1012 bytes
|
Rev | Line | |
---|
[1] | 1 | open Fpath
|
---|
| 2 | type repo_t = Repo of t
|
---|
| 3 | type note_t = Note of { repo: repo_t; basename: t }
|
---|
| 4 |
|
---|
| 5 | let fpath_of_repo = function Repo p -> p
|
---|
| 6 | let string_of_repo r = fpath_of_repo r |> to_string
|
---|
| 7 | let repo_of_string s = Repo (v s)
|
---|
| 8 |
|
---|
| 9 | let fpath_of_note = function Note n -> (fpath_of_repo n.repo // n.basename)
|
---|
| 10 | let string_of_note n = fpath_of_note n |> to_string
|
---|
| 11 | let note_of_basename repo s = Note { repo; basename = v s }
|
---|
| 12 |
|
---|
| 13 | let alias_of_note = function Note n -> n.basename |> rem_ext |> to_string
|
---|
| 14 | let note_of_alias repo extension alias = note_of_basename repo (alias ^ extension)
|
---|
| 15 |
|
---|
| 16 | let versioned_basename_of_title ?(version=0) repo extension (title : string) =
|
---|
| 17 | let notes_fpath = fpath_of_repo repo in
|
---|
| 18 | let basename = v @@ Meta.string_alias title in
|
---|
| 19 | let rec next version =
|
---|
| 20 | let candidate = basename |> add_ext (string_of_int version) |> add_ext extension in
|
---|
| 21 | if Sys.file_exists (to_string (notes_fpath // candidate))
|
---|
| 22 | then next (succ version)
|
---|
| 23 | else note_of_basename repo (to_string candidate)
|
---|
| 24 | in
|
---|
| 25 | next version
|
---|
Note:
See
TracBrowser
for help on using the repository browser.