diff --git a/src/atom.ml b/src/atom.ml index d65e65d..ff5a55d 100644 --- a/src/atom.ml +++ b/src/atom.ml @@ -18,7 +18,7 @@ let opt_element tag_name content body = let entry config url node_fn note = let open Logarion in let meta = note.Note.meta in - let u = "note/" ^ Meta.slug meta in + let u = "note/" ^ Meta.alias meta in let open Meta in let open Author in ("" diff --git a/src/file.ml b/src/file.ml index 558074d..54eb9c0 100644 --- a/src/file.ml +++ b/src/file.ml @@ -58,7 +58,7 @@ let note_with_alias store alias = |> Array.to_list |> List.filter (fun file -> BatString.ends_with file Lpath.extension) |> List.fold_left cons_valid_meta [] - |> List.filter (fun note -> Meta.slug note.Note.meta = alias) + |> List.filter (fun note -> Meta.alias note.Note.meta = alias) |> List.fast_sort (fun a b -> recency_order a.Note.meta b.Note.meta) in try Some (List.hd notes) diff --git a/src/html.ml b/src/html.ml index 5c9d388..7f7411e 100644 --- a/src/html.ml +++ b/src/html.ml @@ -42,7 +42,7 @@ let of_note ?(header_tpl=None) ?(note_tpl=None) blog_url lgrn ymd = let article_link meta = let open Logarion in - let u = "/note/" ^ Meta.slug meta in + let u = "/note/" ^ Meta.alias meta in let d = let open Meta in Unsafe.data Note.(meta.Meta.title ^ (Meta.Date.pretty_date (meta.date |> Meta.Date.last))) diff --git a/src/logarion.ml b/src/logarion.ml index 7cd6885..34a2671 100644 --- a/src/logarion.ml +++ b/src/logarion.ml @@ -1,5 +1,5 @@ module Id = Meta.Id -type slug_t = string +type alias_t = string module Configuration = struct type t = { @@ -35,7 +35,7 @@ module Configuration = struct } end -module SlugMap = Meta.SlugMap +module AliasMap = Meta.AliasMap module Make (Store : Store.T) = struct type t = { diff --git a/src/lpath.ml b/src/lpath.ml index 58ac973..0b778f2 100644 --- a/src/lpath.ml +++ b/src/lpath.ml @@ -36,12 +36,12 @@ let fpath_of_note = function Note n -> (fpath_of_repo n.repo // notes // n.basen let string_of_note n = fpath_of_note n |> to_string let note_of_basename repo s = Note { repo; basename = v s } -let slug_of_note = function Note n -> n.basename |> rem_ext |> to_string -let note_of_slug repo slug = note_of_basename repo (slug ^ extension) +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 basename = v @@ Meta.string_slug title 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 if Sys.file_exists (to_string (notes_fpath // candidate)) diff --git a/src/meta.ml b/src/meta.ml index 4abf830..01344f1 100644 --- a/src/meta.ml +++ b/src/meta.ml @@ -86,7 +86,7 @@ let stringset_csv set = let f elt a = if a <> "" then a ^ ", " ^ elt else elt in StringSet.fold f set "" -let string_slug t = +let string_alias t = let is_reserved = function | '!' | '*' | '\'' | '(' | ')' | ';' | ':' | '@' | '&' | '=' | '+' | '$' | ',' | '/' | '?' | '#' | '[' | ']' | ' ' | '\t' | '\x00' -> true @@ -111,7 +111,7 @@ type t = { series: StringSet.t; abstract: string; uuid: Id.t; - slug: string; + alias: string; } [@@deriving lens { submodule = true }] let blank ?(uuid=(Id.generate ())) () = { @@ -124,17 +124,17 @@ let blank ?(uuid=(Id.generate ())) () = { series = StringSet.empty; abstract = ""; uuid; - slug = ""; + alias = ""; } let listed e = CategorySet.listed e.categories let published e = CategorySet.published e.categories let unique_topics ts x = StringSet.union ts x.topics -module SlugMap = Map.Make(String) +module AliasMap = Map.Make(String) module IdMap = Map.Make(Id) -let slug meta = if meta.slug = "" then string_slug meta.title else meta.slug +let alias meta = if meta.alias = "" then string_alias meta.title else meta.alias let value_with_name (meta as m) = function | "title" -> m.title @@ -151,7 +151,7 @@ let value_with_name (meta as m) = function | "keywords" -> stringset_csv m.keywords; | "series" -> stringset_csv m.series; | "uuid" -> Id.to_string m.uuid - | "slug" -> slug m + | "alias" -> alias m | e -> invalid_arg e let with_kv meta (k,v) = @@ -178,7 +178,7 @@ let with_kv meta (k,v) = | "series" -> { meta with series = trim v |> list_of_csv |> StringSet.of_list } | "uuid" -> (match Id.of_string v with Some id -> (uuid ^= id) meta | None -> meta) - | "slug" -> { meta with slug = v } + | "alias" -> { meta with alias = v } | _ -> meta let to_string (meta as m) = @@ -208,7 +208,7 @@ let to_string (meta as m) = s "series" (stringset_csv m.series); s "abstract" m.abstract; s "uuid" (Uuidm.to_string m.uuid); - s "slug" m.slug + s "alias" m.alias ] in String.concat "" rows diff --git a/src/template.ml b/src/template.ml index 40a3d27..2709f31 100644 --- a/src/template.ml +++ b/src/template.ml @@ -72,7 +72,7 @@ let fold_note ymd = let fold_meta (meta : Meta.t) = let open Logarion in let escaped e = match e with - | "url" -> "/note/" ^ Meta.slug meta + | "url" -> "/note/" ^ Meta.alias meta | "date" | "date_created" | "date_edited" | "date_published" | "date_human" -> "" | tag -> Meta.value_with_name meta tag in @@ -87,7 +87,7 @@ let fold_header blog_url title = let fold_list ?(item_tpl=None) ~from ~n notes = let simple meta = - "
  • " + "
  • " ^ meta.Meta.title ^ " ~ " ^ Meta.Date.(pretty_date (last meta.Meta.date)) ^ "
  • " in