github.com/kyleu/dbaudit@v0.0.2-0.20240321155047-ff2f2c940496/views/vfile/Detail.html (about)

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