Commit
Author: Kevin Schoon [kevinschoon@gmail.com]
Hash: e64e6a2d3d2639f0c391d554760976edeaa5ab16
Timestamp: Wed, 16 Sep 2020 16:53:37 +0000 (4 years ago)

+9 -8 +/-2 browse
show slug on list output
1diff --git a/lib/note.ml b/lib/note.ml
2index eaab044..6fef4ff 100644
3--- a/lib/note.ml
4+++ b/lib/note.ml
5 @@ -1,6 +1,6 @@
6 open Core
7
8- type t = { frontmatter : Ezjsonm.t option; markdown : Omd.t ; slug : Slug.t}
9+ type t = { frontmatter : Ezjsonm.t option; markdown : Omd.t; slug : Slug.t }
10
11 let build ?(tags = []) ?(content = "") ~title slug =
12 let frontmatter =
13 @@ -9,7 +9,7 @@ let build ?(tags = []) ?(content = "") ~title slug =
14 [ ("title", Ezjsonm.string title); ("tags", Ezjsonm.strings tags) ])
15 in
16 let markdown = Omd.of_string content in
17- { frontmatter; markdown ; slug}
18+ { frontmatter; markdown; slug }
19
20 let get_title t =
21 let title =
22 @@ -43,8 +43,7 @@ let get_tags t =
23 | None -> [] )
24 | None -> []
25
26- let get_path t =
27- Slug.get_path t.slug
28+ let get_path t = Slug.get_path t.slug
29
30 let tokenize t =
31 let rec _tokenize markdown =
32 @@ -158,7 +157,7 @@ let of_string ~data slug =
33 else
34 let frontmatter = None in
35 let markdown = Omd.of_string data in
36- { frontmatter; markdown; slug}
37+ { frontmatter; markdown; slug }
38
39 module Filter = struct
40 type strategy = Keys | Fulltext
41 @@ -214,6 +213,7 @@ module Display = struct
42 ("title", [ Bold; Underlined ]);
43 ("tags", [ Bold; Underlined ]);
44 ("words", [ Bold; Underlined ]);
45+ ("slug", [ Bold; Underlined ]);
46 ];
47 ]
48 @ List.fold ~init:[]
49 @@ -223,7 +223,8 @@ module Display = struct
50 let word_count =
51 (Core.sprintf "%d" (List.length (tokenize note)), [ Reset ])
52 in
53- accm @ [ [ title; tags; word_count ] ])
54+ let slug = (Slug.to_string note.slug, [ Reset ]) in
55+ accm @ [ [ title; tags; word_count; slug ] ])
56 notes
57
58 let fixed_spacing cells =
59 @@ -258,7 +259,7 @@ module Display = struct
60 let cell_width = List.nth_exn widths i in
61 let padding = cell_width - String.length text in
62 String.concat
63- [ accm; (sprintf styles "%s" text) ; (String.make padding ' ') ])
64+ [ accm; sprintf styles "%s" text; String.make padding ' ' ])
65 row;
66 ])
67 cells
68 diff --git a/lib/slug.ml b/lib/slug.ml
69index 71a0ec4..a4abcbc 100644
70--- a/lib/slug.ml
71+++ b/lib/slug.ml
72 @@ -6,7 +6,7 @@ let get_path t = t.path
73
74 let to_string t =
75 let date_str = Date.format t.date "%Y%m%d" in
76- sprintf "note-%s-%d" date_str t.index
77+ sprintf "%s-%d" date_str t.index
78
79 let of_path path =
80 (* note-20010103-0.md *)