github.com/kyleu/dbaudit@v0.0.2-0.20240321155047-ff2f2c940496/views/vfile/Tree.html.go (about) 1 // Code generated by qtc from "Tree.html". DO NOT EDIT. 2 // See https://github.com/valyala/quicktemplate for details. 3 4 // <!-- Content managed by Project Forge, see [projectforge.md] for details. --> 5 6 //line views/vfile/Tree.html:2 7 package vfile 8 9 //line views/vfile/Tree.html:2 10 import ( 11 "path" 12 "strings" 13 14 "github.com/kyleu/dbaudit/app" 15 "github.com/kyleu/dbaudit/app/controller/cutil" 16 "github.com/kyleu/dbaudit/app/lib/filesystem" 17 "github.com/kyleu/dbaudit/app/util" 18 "github.com/kyleu/dbaudit/views/components" 19 ) 20 21 //line views/vfile/Tree.html:13 22 import ( 23 qtio422016 "io" 24 25 qt422016 "github.com/valyala/quicktemplate" 26 ) 27 28 //line views/vfile/Tree.html:13 29 var ( 30 _ = qtio422016.Copy 31 _ = qt422016.AcquireByteBuffer 32 ) 33 34 //line views/vfile/Tree.html:13 35 func StreamTree(qw422016 *qt422016.Writer, t *filesystem.Tree, urlPrefix string, actions func(p string, n *filesystem.Node) map[string]string, as *app.State, ps *cutil.PageState) { 36 //line views/vfile/Tree.html:14 37 components.StreamIndent(qw422016, true, 2) 38 //line views/vfile/Tree.html:14 39 qw422016.N().S(`<ul class="accordion">`) 40 //line views/vfile/Tree.html:16 41 streamtreeNodes(qw422016, t.Nodes, "", urlPrefix, actions, as, ps, 2) 42 //line views/vfile/Tree.html:17 43 components.StreamIndent(qw422016, true, 2) 44 //line views/vfile/Tree.html:17 45 qw422016.N().S(`</ul>`) 46 //line views/vfile/Tree.html:19 47 } 48 49 //line views/vfile/Tree.html:19 50 func WriteTree(qq422016 qtio422016.Writer, t *filesystem.Tree, urlPrefix string, actions func(p string, n *filesystem.Node) map[string]string, as *app.State, ps *cutil.PageState) { 51 //line views/vfile/Tree.html:19 52 qw422016 := qt422016.AcquireWriter(qq422016) 53 //line views/vfile/Tree.html:19 54 StreamTree(qw422016, t, urlPrefix, actions, as, ps) 55 //line views/vfile/Tree.html:19 56 qt422016.ReleaseWriter(qw422016) 57 //line views/vfile/Tree.html:19 58 } 59 60 //line views/vfile/Tree.html:19 61 func Tree(t *filesystem.Tree, urlPrefix string, actions func(p string, n *filesystem.Node) map[string]string, as *app.State, ps *cutil.PageState) string { 62 //line views/vfile/Tree.html:19 63 qb422016 := qt422016.AcquireByteBuffer() 64 //line views/vfile/Tree.html:19 65 WriteTree(qb422016, t, urlPrefix, actions, as, ps) 66 //line views/vfile/Tree.html:19 67 qs422016 := string(qb422016.B) 68 //line views/vfile/Tree.html:19 69 qt422016.ReleaseByteBuffer(qb422016) 70 //line views/vfile/Tree.html:19 71 return qs422016 72 //line views/vfile/Tree.html:19 73 } 74 75 //line views/vfile/Tree.html:21 76 func streamtreeNode(qw422016 *qt422016.Writer, n *filesystem.Node, pth string, urlPrefix string, actions func(p string, n *filesystem.Node) map[string]string, as *app.State, ps *cutil.PageState, indent int) { 77 //line views/vfile/Tree.html:23 78 pathID := n.Name 79 if pth != "" { 80 pathID = pth + "/" + pathID 81 } 82 pathID = strings.ReplaceAll(pathID, "/", "__") 83 84 //line views/vfile/Tree.html:29 85 components.StreamIndent(qw422016, true, indent) 86 //line views/vfile/Tree.html:29 87 qw422016.N().S(`<li>`) 88 //line views/vfile/Tree.html:31 89 components.StreamIndent(qw422016, true, indent+1) 90 //line views/vfile/Tree.html:31 91 qw422016.N().S(`<input id="accordion-`) 92 //line views/vfile/Tree.html:32 93 qw422016.E().S(pathID) 94 //line views/vfile/Tree.html:32 95 qw422016.N().S(`" type="checkbox" hidden="hidden" />`) 96 //line views/vfile/Tree.html:33 97 components.StreamIndent(qw422016, true, indent+1) 98 //line views/vfile/Tree.html:33 99 qw422016.N().S(`<label for="accordion-`) 100 //line views/vfile/Tree.html:34 101 qw422016.E().S(pathID) 102 //line views/vfile/Tree.html:34 103 qw422016.N().S(`">`) 104 //line views/vfile/Tree.html:36 105 var acts map[string]string 106 if actions != nil { 107 acts = actions(pth, n) 108 } 109 110 //line views/vfile/Tree.html:40 111 qw422016.N().S(`<div class="right">`) 112 //line views/vfile/Tree.html:42 113 if n.Size > 0 { 114 //line views/vfile/Tree.html:42 115 qw422016.N().S(`<em>`) 116 //line views/vfile/Tree.html:43 117 qw422016.E().S(util.ByteSizeSI(int64(n.Size))) 118 //line views/vfile/Tree.html:43 119 qw422016.N().S(`</em>`) 120 //line views/vfile/Tree.html:43 121 qw422016.N().S(` `) 122 //line views/vfile/Tree.html:44 123 } 124 //line views/vfile/Tree.html:45 125 for k, v := range acts { 126 //line views/vfile/Tree.html:45 127 qw422016.N().S(`<a href="`) 128 //line views/vfile/Tree.html:46 129 qw422016.E().S(v) 130 //line views/vfile/Tree.html:46 131 qw422016.N().S(`">`) 132 //line views/vfile/Tree.html:46 133 qw422016.E().S(k) 134 //line views/vfile/Tree.html:46 135 qw422016.N().S(`</a>`) 136 //line views/vfile/Tree.html:47 137 } 138 //line views/vfile/Tree.html:47 139 qw422016.N().S(`</div>`) 140 //line views/vfile/Tree.html:49 141 components.StreamExpandCollapse(qw422016, indent+2, ps) 142 //line views/vfile/Tree.html:50 143 if n.Dir { 144 //line views/vfile/Tree.html:51 145 components.StreamSVGRef(qw422016, `folder`, 15, 15, ``, ps) 146 //line views/vfile/Tree.html:52 147 } else { 148 //line views/vfile/Tree.html:53 149 components.StreamSVGRef(qw422016, `file`, 15, 15, ``, ps) 150 //line views/vfile/Tree.html:54 151 } 152 //line views/vfile/Tree.html:55 153 qw422016.N().S(` `) 154 //line views/vfile/Tree.html:55 155 qw422016.E().S(n.Name) 156 //line views/vfile/Tree.html:56 157 components.StreamIndent(qw422016, true, indent+1) 158 //line views/vfile/Tree.html:56 159 qw422016.N().S(`</label>`) 160 //line views/vfile/Tree.html:58 161 components.StreamIndent(qw422016, true, indent+1) 162 //line views/vfile/Tree.html:58 163 qw422016.N().S(`<div class="bd"><div><div>`) 164 //line views/vfile/Tree.html:60 165 if len(n.Children) == 0 { 166 //line views/vfile/Tree.html:61 167 components.StreamIndent(qw422016, true, indent+2) 168 //line views/vfile/Tree.html:61 169 qw422016.N().S(`<div>`) 170 //line views/vfile/Tree.html:62 171 qw422016.E().S(n.Name) 172 //line views/vfile/Tree.html:62 173 qw422016.N().S(`</div>`) 174 //line views/vfile/Tree.html:63 175 } else { 176 //line views/vfile/Tree.html:64 177 components.StreamIndent(qw422016, true, indent+2) 178 //line views/vfile/Tree.html:64 179 qw422016.N().S(`<ul class="accordion" style="margin-left:`) 180 //line views/vfile/Tree.html:65 181 qw422016.N().D((indent / 3) * 6) 182 //line views/vfile/Tree.html:65 183 qw422016.N().S(`px; margin-bottom: 0;">`) 184 //line views/vfile/Tree.html:66 185 streamtreeNodes(qw422016, n.Children, path.Join(pth, n.Name), urlPrefix, actions, as, ps, indent+3) 186 //line views/vfile/Tree.html:67 187 components.StreamIndent(qw422016, true, indent+2) 188 //line views/vfile/Tree.html:67 189 qw422016.N().S(`</ul>`) 190 //line views/vfile/Tree.html:69 191 } 192 //line views/vfile/Tree.html:70 193 components.StreamIndent(qw422016, true, indent+1) 194 //line views/vfile/Tree.html:70 195 qw422016.N().S(`</div></div></div>`) 196 //line views/vfile/Tree.html:72 197 components.StreamIndent(qw422016, true, indent) 198 //line views/vfile/Tree.html:72 199 qw422016.N().S(`</li>`) 200 //line views/vfile/Tree.html:74 201 } 202 203 //line views/vfile/Tree.html:74 204 func writetreeNode(qq422016 qtio422016.Writer, n *filesystem.Node, pth string, urlPrefix string, actions func(p string, n *filesystem.Node) map[string]string, as *app.State, ps *cutil.PageState, indent int) { 205 //line views/vfile/Tree.html:74 206 qw422016 := qt422016.AcquireWriter(qq422016) 207 //line views/vfile/Tree.html:74 208 streamtreeNode(qw422016, n, pth, urlPrefix, actions, as, ps, indent) 209 //line views/vfile/Tree.html:74 210 qt422016.ReleaseWriter(qw422016) 211 //line views/vfile/Tree.html:74 212 } 213 214 //line views/vfile/Tree.html:74 215 func treeNode(n *filesystem.Node, pth string, urlPrefix string, actions func(p string, n *filesystem.Node) map[string]string, as *app.State, ps *cutil.PageState, indent int) string { 216 //line views/vfile/Tree.html:74 217 qb422016 := qt422016.AcquireByteBuffer() 218 //line views/vfile/Tree.html:74 219 writetreeNode(qb422016, n, pth, urlPrefix, actions, as, ps, indent) 220 //line views/vfile/Tree.html:74 221 qs422016 := string(qb422016.B) 222 //line views/vfile/Tree.html:74 223 qt422016.ReleaseByteBuffer(qb422016) 224 //line views/vfile/Tree.html:74 225 return qs422016 226 //line views/vfile/Tree.html:74 227 } 228 229 //line views/vfile/Tree.html:76 230 func streamtreeNodes(qw422016 *qt422016.Writer, nodes filesystem.Nodes, pth string, urlPrefix string, actions func(p string, n *filesystem.Node) map[string]string, as *app.State, ps *cutil.PageState, indent int) { 231 //line views/vfile/Tree.html:77 232 for _, n := range nodes { 233 //line views/vfile/Tree.html:78 234 streamtreeNode(qw422016, n, pth, urlPrefix, actions, as, ps, indent+1) 235 //line views/vfile/Tree.html:79 236 } 237 //line views/vfile/Tree.html:80 238 } 239 240 //line views/vfile/Tree.html:80 241 func writetreeNodes(qq422016 qtio422016.Writer, nodes filesystem.Nodes, pth string, urlPrefix string, actions func(p string, n *filesystem.Node) map[string]string, as *app.State, ps *cutil.PageState, indent int) { 242 //line views/vfile/Tree.html:80 243 qw422016 := qt422016.AcquireWriter(qq422016) 244 //line views/vfile/Tree.html:80 245 streamtreeNodes(qw422016, nodes, pth, urlPrefix, actions, as, ps, indent) 246 //line views/vfile/Tree.html:80 247 qt422016.ReleaseWriter(qw422016) 248 //line views/vfile/Tree.html:80 249 } 250 251 //line views/vfile/Tree.html:80 252 func treeNodes(nodes filesystem.Nodes, pth string, urlPrefix string, actions func(p string, n *filesystem.Node) map[string]string, as *app.State, ps *cutil.PageState, indent int) string { 253 //line views/vfile/Tree.html:80 254 qb422016 := qt422016.AcquireByteBuffer() 255 //line views/vfile/Tree.html:80 256 writetreeNodes(qb422016, nodes, pth, urlPrefix, actions, as, ps, indent) 257 //line views/vfile/Tree.html:80 258 qs422016 := string(qb422016.B) 259 //line views/vfile/Tree.html:80 260 qt422016.ReleaseByteBuffer(qb422016) 261 //line views/vfile/Tree.html:80 262 return qs422016 263 //line views/vfile/Tree.html:80 264 }