From 989a83eb027977c3c2e018d8fed71797b33b68fe Mon Sep 17 00:00:00 2001 From: bel Date: Mon, 14 Feb 2022 22:12:26 -0700 Subject: [PATCH] gr filetree hard --- spike/review/reinvent/ezmded/ui/files.ctmpl | 6 +- spike/review/reinvent/ezmded/ui/index.html | 456 ------------------ spike/review/reinvent/ezmded/ui/render.go | 40 +- .../ezmded/ui/templates/_editor.ctmpl | 6 +- .../ezmded/ui/templates/_filetree.ctmpl | 48 +- .../ezmded/ui/templates/_import.ctmpl | 53 ++ 6 files changed, 137 insertions(+), 472 deletions(-) delete mode 100644 spike/review/reinvent/ezmded/ui/index.html diff --git a/spike/review/reinvent/ezmded/ui/files.ctmpl b/spike/review/reinvent/ezmded/ui/files.ctmpl index 73781d1..01b3e81 100644 --- a/spike/review/reinvent/ezmded/ui/files.ctmpl +++ b/spike/review/reinvent/ezmded/ui/files.ctmpl @@ -2,13 +2,13 @@
- {{ .Title }} - {{ template "_import" . }} + {{ .This.Title }} + {{ template "_import" }}

- {{ template "_searchbar" . }} + {{ template "_searchbar" }}
{{ template "_filetree" . }}
diff --git a/spike/review/reinvent/ezmded/ui/index.html b/spike/review/reinvent/ezmded/ui/index.html deleted file mode 100644 index a187906..0000000 --- a/spike/review/reinvent/ezmded/ui/index.html +++ /dev/null @@ -1,456 +0,0 @@ - - -
- Notes - - - - - - - - - - - - - - -
- -
-
-
- - -
-
-
-
-
-
-
-
-

- - - - - - - - - -

-
-
-
- -
- - -
-
-
-
- -
- -
- diff --git a/spike/review/reinvent/ezmded/ui/render.go b/spike/review/reinvent/ezmded/ui/render.go index 5db4c81..e09b26a 100644 --- a/spike/review/reinvent/ezmded/ui/render.go +++ b/spike/review/reinvent/ezmded/ui/render.go @@ -36,10 +36,42 @@ func main() { return oneT } data := map[string]interface{}{ - "Title": "my title here", - "ID": "my-id-here", - "PID": "my-pid-here", - "PTitle": "my parent title here", + "This": map[string]interface{}{ + "ID": "id00/id11", + "Title": "title11", + "PID": "id00", + "PTitle": "title00", + }, + "Tree": []map[string]interface{}{ + map[string]interface{}{ + "ID": "id00", + "Title": "title00", + "PID": "", + "PTitle": "", + }, + map[string]interface{}{ + "ID": "id00/id10", + "Title": "title10", + }, + map[string]interface{}{ + "ID": "id00/id11", + "Title": "title11", + "PID": "", + "PTitle": "", + }, + map[string]interface{}{ + "ID": "id00/id11/id20", + "Title": "title20", + "PID": "", + "PTitle": "", + }, + map[string]interface{}{ + "ID": "id01", + "Title": "title01", + "PID": "", + "PTitle": "", + }, + }, } if err := recursePwd(func(p string) error { switch path.Ext(p) { diff --git a/spike/review/reinvent/ezmded/ui/templates/_editor.ctmpl b/spike/review/reinvent/ezmded/ui/templates/_editor.ctmpl index fcc5fd1..bc87bb5 100644 --- a/spike/review/reinvent/ezmded/ui/templates/_editor.ctmpl +++ b/spike/review/reinvent/ezmded/ui/templates/_editor.ctmpl @@ -153,11 +153,11 @@ / - {{ if ne .PID "" }} - {{ .PTitle }} / + {{ if ne .This.PID "" }} + {{ .This.PTitle }} / {{ end }} - {{ .Title }} + {{ .This.Title }}
diff --git a/spike/review/reinvent/ezmded/ui/templates/_filetree.ctmpl b/spike/review/reinvent/ezmded/ui/templates/_filetree.ctmpl index 49b699f..43fc545 100644 --- a/spike/review/reinvent/ezmded/ui/templates/_filetree.ctmpl +++ b/spike/review/reinvent/ezmded/ui/templates/_filetree.ctmpl @@ -1,9 +1,45 @@ -{{ define "_filetree" }} -
- My file tree - - {{ range $key, $value := .Branches }} - +{{ $filetreeLevel := 0 }} + +{{ define "_filetreeLevelUpOpen" }} + {{ if gt .Level $filetreeLevel }} +
+ {{ $filetreeLevel = $filetreeLevel + 1 }} + {{ template "_filetreeLevelUpOpen" . }} {{ end }} +{{ end }} + +{{ define "_filetreeCloseAll" }} + {{ if lt 0 $filetreeLevel }} +
+ {{ $filetreeLevel = $filetreeLevel - 1 }} + {{ template "_filetreeCloseAll" . }} + {{ end }} +{{ end }} + +{{ define "_filetreeLevelDownOpen" }} + {{ if lt .Level $filetreeLevel }} + + {{ $filetreeLevel = $filetreeLevel - 1 }} + {{ template "_filetreeLevelDownOpen" . }} + {{ end }} +{{ end }} + +{{ define "_filetreeRecurse" }} + + {{ range . }} + {{ template "_filetreeLevelUpOpen" . }} + {{ template "_filetreeLevelDownOpen" . }} + <details> + <summary> + <a href="/files/{{ .ID }}">{{ .Title }}</a> + </summary> + {{ end }} + {{ template "_filetreeLevelDownOpen" . }} +{{ end }} + +{{ define "_filetree" }} +input = {{ . }} +<div> + {{ template "_filetreeRecurse" .Tree }} </div> {{ end }} diff --git a/spike/review/reinvent/ezmded/ui/templates/_import.ctmpl b/spike/review/reinvent/ezmded/ui/templates/_import.ctmpl index e579451..7f3e3d6 100644 --- a/spike/review/reinvent/ezmded/ui/templates/_import.ctmpl +++ b/spike/review/reinvent/ezmded/ui/templates/_import.ctmpl @@ -14,4 +14,57 @@ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/light.css"> <link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css"> --> +<style> + html, body { + background-color: #f8f8f8; + } + .lr_fullscreen { + width: 90%; + max-width: 1024px; + margin-right: auto; + margin-left: auto; + } + .tb_fullscreen { + margin-top: 1em; + } + .columns { + display: flex; + flex-direction: row; + } + .rows { + width: 100%; + display: flex; + flex-direction: column; + } + .thic_flex { + text-align: left; + flex-grow: 1; + } + .mia { + display: none; + } + .align_left { + text-align: left; + } + .tb_buffer { + margin-top: 1em; + margin-bottom: 1em; + } + .r_buffer { + margin-right: 1em; + } + .l_buffer { + margin-left: 1em; + } + .monospace { + font-family: Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace; + } + .lil_btn { + width: initial; + display: inline-block; + } + input, label, textarea { + margin: initial; + } +</style> {{ end }}