1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| {% import ( "encoding/base64" "path/filepath" "unicode/utf8"
"{{{ .Package }}}/app" "{{{ .Package }}}/app/controller/cutil" "{{{ .Package }}}/app/lib/filesystem" "{{{ .Package }}}/app/util" ) %}
{% func Detail(path []string, b []byte, urlPrefix string, additionalLinks map[string]string, as *app.State, ps *cutil.PageState) %} <div class="right"></div> <h3> {%- if additionalLinks != nil && len(additionalLinks) > 0 -%} <div class="right"> {%- for k, v := range additionalLinks -%} <a href="{%s v %}"><button>{%s k %}</button></a> {%- endfor -%} </div> {%- endif -%} {%- for idx, p := range path -%}/<a href="{%s urlPrefix %}/{%s filepath.Join(path[:idx + 1]...) %}">{%s p %}</a>{%- endfor -%} <em>({%s util.ByteSizeSI(int64(len(b))) %})</em> </h3> <div class="mt"> {%- if len(b) > (1024 * 128) -%} <em>File is {%d len(b) %} bytes, which is too large for the file viewer</em> {%- elseif utf8.Valid(b) -%} {%- code out, _ := cutil.FormatFilename(string(b), path[len(path)-1]) -%} {%s= out %} {%- else -%}
{%- if imgType := filesystem.ImageType(path...); imgType != "" -%} <img src="data:image/{%s imgType %};base64,{%s base64.StdEncoding.EncodeToString(b) %}" /> <hr /> {%- endif -%}
{%- code exif, err := filesystem.ExifExtract(b) -%} {%- if err == nil -%} <div class="overflow full-width"> <table> <thead> <tr> <th>EXIF Name</th> <th>Value</th> </tr> </thead> <tbody> {%- for k, v := range exif -%} <tr> <td>{%s k %}</td> <td>{%v v %}</td> </tr> {%- endfor -%} </tbody> </table> </div> {%- else -%} <em>File is binary and contains no exif header</em> {%- endif -%} {%- endif -%} </div> {% endfunc %}
|