refactor(sterni/blërg): use namespaces for entries
The array listing was pretty nice for debugging, but having arrays where every element has a different meaning as an interface between different parts of the code is not great. Refactoring will be less frustrating if we just store everything using a key-value scheme in namespaces. Change-Id: I806fea247b6f996dbdd93df24f3fdb762340f043 Reviewed-on: https://cl.tvl.fyi/c/depot/+/13017 Autosubmit: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
eeba67de1c
commit
5db216b4ef
1 changed files with 10 additions and 8 deletions
|
|
@ -52,8 +52,10 @@ MailNotesBackend ← {𝕊 mailDir:
|
||||||
th ← ⍉⟨≠ms,≠headerNames⟩⥊headerNames Hdrs ms
|
th ← ⍉⟨≠ms,≠headerNames⟩⥊headerNames Hdrs ms
|
||||||
dh ← Dates ms
|
dh ← Dates ms
|
||||||
ah ← (("com.apple.mail-note"⊸≡⊑)˘/⊢) ⍉th∾dh≍ms
|
ah ← (("com.apple.mail-note"⊸≡⊑)˘/⊢) ⍉th∾dh≍ms
|
||||||
{𝕊 ·‿id‿title‿date‿path:
|
{𝕊 ·‿uuid‿title‿time‿path:
|
||||||
⟨AsciiDown id, title, date, {"execline-cd"‿𝕩‿"mshow"‿"-x"‿path ⋄ R "mn2html"‿path}⟩
|
title ⇐ ⋄ time ⇐
|
||||||
|
id ⇐ AsciiDown uuid
|
||||||
|
Render ⇐ {"execline-cd"‿𝕩‿"mshow"‿"-x"‿path ⋄ R "mn2html"‿path}
|
||||||
}˘ ah
|
}˘ ah
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -70,11 +72,11 @@ RenderPage ← {
|
||||||
<h1>"‿𝕨‿"</h1>"‿𝕩
|
<h1>"‿𝕨‿"</h1>"‿𝕩
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteEntry ← {outDir 𝕊 id‿title‿·‿renderEntry:
|
WriteEntry ← {outDir 𝕊 entry:
|
||||||
entryDir ← MkDirP outDir •file.At id
|
entryDir ← MkDirP outDir •file.At entry.id
|
||||||
(entryDir •file.At "index.html") •file.Chars title RenderPage RenderEntry entryDir
|
(entryDir •file.At "index.html") •file.Chars entry.title RenderPage entry.Render entryDir
|
||||||
# TODO(sterni): urlencode
|
# TODO(sterni): urlencode
|
||||||
"<li><a href="""∾id∾""">"∾title∾"</a></li>"
|
"<li><a href="""∾entry.id∾""">"∾entry.title∾"</a></li>"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Main
|
# Main
|
||||||
|
|
@ -87,10 +89,10 @@ mailDir‿outDir ← {
|
||||||
}
|
}
|
||||||
|
|
||||||
m ← MailNotesBackend mailDir
|
m ← MailNotesBackend mailDir
|
||||||
entries ← ((⍒ 2⊸⊑˘)⊏⊢) m.Entries @
|
entries ← (<"time") ((⍒∘(•ns.Get˜¨))⊏⊢) m.Entries @
|
||||||
|
|
||||||
title ← "blërg"
|
title ← "blërg"
|
||||||
|
|
||||||
MkDirP outDir
|
MkDirP outDir
|
||||||
entryIndex ← (< outDir⊸WriteEntry)˘ entries
|
entryIndex ← outDir⊸WriteEntry¨ entries
|
||||||
(outDir •file.At "index.html") •file.Chars title RenderPage ∾"<ul>"∾entryIndex∾"</ul>"
|
(outDir •file.At "index.html") •file.Chars title RenderPage ∾"<ul>"∾entryIndex∾"</ul>"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue