github.com/kyleu/dbaudit@v0.0.2-0.20240321155047-ff2f2c940496/views/vfile/Detail.html.go (about) 1 // Code generated by qtc from "Detail.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/Detail.html:2 7 package vfile 8 9 //line views/vfile/Detail.html:2 10 import ( 11 "encoding/base64" 12 "path/filepath" 13 "unicode/utf8" 14 15 "github.com/kyleu/dbaudit/app" 16 "github.com/kyleu/dbaudit/app/controller/cutil" 17 "github.com/kyleu/dbaudit/app/lib/filesystem" 18 "github.com/kyleu/dbaudit/app/util" 19 ) 20 21 //line views/vfile/Detail.html:13 22 import ( 23 qtio422016 "io" 24 25 qt422016 "github.com/valyala/quicktemplate" 26 ) 27 28 //line views/vfile/Detail.html:13 29 var ( 30 _ = qtio422016.Copy 31 _ = qt422016.AcquireByteBuffer 32 ) 33 34 //line views/vfile/Detail.html:13 35 func StreamDetail(qw422016 *qt422016.Writer, path []string, b []byte, urlPrefix string, additionalLinks map[string]string, as *app.State, ps *cutil.PageState) { 36 //line views/vfile/Detail.html:13 37 qw422016.N().S(` 38 <div class="right"></div> 39 <h3> 40 `) 41 //line views/vfile/Detail.html:16 42 if additionalLinks != nil && len(additionalLinks) > 0 { 43 //line views/vfile/Detail.html:16 44 qw422016.N().S(` <div class="right"> 45 `) 46 //line views/vfile/Detail.html:18 47 for k, v := range additionalLinks { 48 //line views/vfile/Detail.html:18 49 qw422016.N().S(` <a href="`) 50 //line views/vfile/Detail.html:19 51 qw422016.E().S(v) 52 //line views/vfile/Detail.html:19 53 qw422016.N().S(`"><button>`) 54 //line views/vfile/Detail.html:19 55 qw422016.E().S(k) 56 //line views/vfile/Detail.html:19 57 qw422016.N().S(`</button></a> 58 `) 59 //line views/vfile/Detail.html:20 60 } 61 //line views/vfile/Detail.html:20 62 qw422016.N().S(` </div> 63 `) 64 //line views/vfile/Detail.html:22 65 } 66 //line views/vfile/Detail.html:23 67 for idx, p := range path { 68 //line views/vfile/Detail.html:23 69 qw422016.N().S(`/<a href="`) 70 //line views/vfile/Detail.html:23 71 qw422016.E().S(urlPrefix) 72 //line views/vfile/Detail.html:23 73 qw422016.N().S(`/`) 74 //line views/vfile/Detail.html:23 75 qw422016.E().S(filepath.Join(path[:idx+1]...)) 76 //line views/vfile/Detail.html:23 77 qw422016.N().S(`">`) 78 //line views/vfile/Detail.html:23 79 qw422016.E().S(p) 80 //line views/vfile/Detail.html:23 81 qw422016.N().S(`</a>`) 82 //line views/vfile/Detail.html:23 83 } 84 //line views/vfile/Detail.html:23 85 qw422016.N().S(` <em>(`) 86 //line views/vfile/Detail.html:24 87 qw422016.E().S(util.ByteSizeSI(int64(len(b)))) 88 //line views/vfile/Detail.html:24 89 qw422016.N().S(`)</em> 90 </h3> 91 <div class="mt"> 92 `) 93 //line views/vfile/Detail.html:27 94 if len(b) > (1024 * 128) { 95 //line views/vfile/Detail.html:27 96 qw422016.N().S(` <em>File is `) 97 //line views/vfile/Detail.html:28 98 qw422016.N().D(len(b)) 99 //line views/vfile/Detail.html:28 100 qw422016.N().S(` bytes, which is too large for the file viewer</em> 101 `) 102 //line views/vfile/Detail.html:29 103 } else if utf8.Valid(b) { 104 //line views/vfile/Detail.html:30 105 out, _ := cutil.FormatFilename(string(b), path[len(path)-1]) 106 107 //line views/vfile/Detail.html:30 108 qw422016.N().S(` `) 109 //line views/vfile/Detail.html:31 110 qw422016.N().S(out) 111 //line views/vfile/Detail.html:31 112 qw422016.N().S(` 113 `) 114 //line views/vfile/Detail.html:32 115 } else { 116 //line views/vfile/Detail.html:32 117 qw422016.N().S(` 118 `) 119 //line views/vfile/Detail.html:34 120 if imgType := filesystem.ImageType(path...); imgType != "" { 121 //line views/vfile/Detail.html:34 122 qw422016.N().S(` <img alt="Image of type [`) 123 //line views/vfile/Detail.html:35 124 qw422016.E().S(imgType) 125 //line views/vfile/Detail.html:35 126 qw422016.N().S(`]" src="data:image/`) 127 //line views/vfile/Detail.html:35 128 qw422016.E().S(imgType) 129 //line views/vfile/Detail.html:35 130 qw422016.N().S(`;base64,`) 131 //line views/vfile/Detail.html:35 132 qw422016.E().S(base64.StdEncoding.EncodeToString(b)) 133 //line views/vfile/Detail.html:35 134 qw422016.N().S(`" /> 135 <hr /> 136 `) 137 //line views/vfile/Detail.html:37 138 } 139 //line views/vfile/Detail.html:37 140 qw422016.N().S(` 141 `) 142 //line views/vfile/Detail.html:39 143 exif, err := filesystem.ExifExtract(b) 144 145 //line views/vfile/Detail.html:40 146 if err == nil { 147 //line views/vfile/Detail.html:40 148 qw422016.N().S(` <div class="overflow full-width"> 149 <table> 150 <thead> 151 <tr> 152 <th>EXIF Name</th> 153 <th>Value</th> 154 </tr> 155 </thead> 156 <tbody> 157 `) 158 //line views/vfile/Detail.html:50 159 for k, v := range exif { 160 //line views/vfile/Detail.html:50 161 qw422016.N().S(` <tr> 162 <td>`) 163 //line views/vfile/Detail.html:52 164 qw422016.E().S(k) 165 //line views/vfile/Detail.html:52 166 qw422016.N().S(`</td> 167 <td>`) 168 //line views/vfile/Detail.html:53 169 qw422016.E().V(v) 170 //line views/vfile/Detail.html:53 171 qw422016.N().S(`</td> 172 </tr> 173 `) 174 //line views/vfile/Detail.html:55 175 } 176 //line views/vfile/Detail.html:55 177 qw422016.N().S(` </tbody> 178 </table> 179 </div> 180 `) 181 //line views/vfile/Detail.html:59 182 } else { 183 //line views/vfile/Detail.html:59 184 qw422016.N().S(` <em>File is binary and contains no exif header</em> 185 `) 186 //line views/vfile/Detail.html:61 187 } 188 //line views/vfile/Detail.html:62 189 } 190 //line views/vfile/Detail.html:62 191 qw422016.N().S(` </div> 192 `) 193 //line views/vfile/Detail.html:64 194 } 195 196 //line views/vfile/Detail.html:64 197 func WriteDetail(qq422016 qtio422016.Writer, path []string, b []byte, urlPrefix string, additionalLinks map[string]string, as *app.State, ps *cutil.PageState) { 198 //line views/vfile/Detail.html:64 199 qw422016 := qt422016.AcquireWriter(qq422016) 200 //line views/vfile/Detail.html:64 201 StreamDetail(qw422016, path, b, urlPrefix, additionalLinks, as, ps) 202 //line views/vfile/Detail.html:64 203 qt422016.ReleaseWriter(qw422016) 204 //line views/vfile/Detail.html:64 205 } 206 207 //line views/vfile/Detail.html:64 208 func Detail(path []string, b []byte, urlPrefix string, additionalLinks map[string]string, as *app.State, ps *cutil.PageState) string { 209 //line views/vfile/Detail.html:64 210 qb422016 := qt422016.AcquireByteBuffer() 211 //line views/vfile/Detail.html:64 212 WriteDetail(qb422016, path, b, urlPrefix, additionalLinks, as, ps) 213 //line views/vfile/Detail.html:64 214 qs422016 := string(qb422016.B) 215 //line views/vfile/Detail.html:64 216 qt422016.ReleaseByteBuffer(qb422016) 217 //line views/vfile/Detail.html:64 218 return qs422016 219 //line views/vfile/Detail.html:64 220 }