github.com/vantum/vantum@v0.0.0-20180815184342-fe37d5f7a990/swarm/api/http/templates.go (about)

     1  // Copyright 2017 The go-ethereum Authors
     2  // This file is part of the go-ethereum library.
     3  //
     4  // The go-ethereum library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The go-ethereum library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package http
    18  
    19  import (
    20  	"html/template"
    21  	"path"
    22  
    23  	"github.com/vantum/vantum/swarm/api"
    24  )
    25  
    26  type htmlListData struct {
    27  	URI  *api.URI
    28  	List *api.ManifestList
    29  }
    30  
    31  var htmlListTemplate = template.Must(template.New("html-list").Funcs(template.FuncMap{"basename": path.Base}).Parse(`
    32  <!DOCTYPE html>
    33  <html>
    34  <head>
    35    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    36    <meta name="viewport" content="width=device-width, initial-scale=1">
    37  		<link rel="shortcut icon" type="image/x-icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHsAAAB5CAYAAAAZD150AAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9Ii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ZWVBKI/srEZ74PY2MEA6ETW4wC7MXXvVdxiytWQV8CVIvpoMeQM1Fdm9jfG1xTEWJpspqG/VUozXgO6BMhGWTbZ1M8/dUMibaPgb2O/neoqQbX7+ZMNVjAr+in0HJkUsitsqE+u0axvj8ewPwDiQbPPjQz/Jl8F4Cfu+Ri0do4VUKUfT151Fte3P7fs6AXDcc57twIT+Me2XL2L/dlIdxV8mOruN0YhkF4w9yZ4oxqrJlhy/VXRstNg4GZs/hmNjukEh3ci2TmuJat2KO7sCm/kmx8MOinhkohIwGngSo3PfHMYVZOcxXtnGWGYgpyv4SZAdCjZg8dPtgIUvJ5yqdZJtS+drDsknUMA32LdhzJKI8ZVgJA6RvoBpY1xGthiZORD4yYIiE8M4SbIDaX5o7lws4GWcIGacunEDF3yJKflvqP4o+1rGLMtOYPw1ML4cEASeEkfvvl8Qo4Gfj6X7/DdJmQbZAZ9BmRNQxOsIwX4XBVzBhR+Ei6tkG4IyjNxb38fqxwqKzLpOHLTtRRrwqnWmYYpx71WOcaYJmld+roG5BuYamGtgroG5BuYamJoG/h/ff6XOIB4wOAAAAABJRU5ErkJggg=="/>
    38  	<title>Swarm index of {{ .URI }}</title>
    39  </head>
    40  
    41  <body>
    42    <h1>Swarm index of {{ .URI }}</h1>
    43    <hr>
    44    <table>
    45      <thead>
    46        <tr>
    47  	<th>Path</th>
    48  	<th>Type</th>
    49  	<th>Size</th>
    50        </tr>
    51      </thead>
    52  
    53      <tbody>
    54        {{ range .List.CommonPrefixes }}
    55  	<tr>
    56  	  <td><a href="{{ basename . }}/">{{ basename . }}/</a></td>
    57  	  <td>DIR</td>
    58  	  <td>-</td>
    59  	</tr>
    60        {{ end }}
    61  
    62        {{ range .List.Entries }}
    63  	<tr>
    64  	  <td><a href="{{ basename .Path }}">{{ basename .Path }}</a></td>
    65  	  <td>{{ .ContentType }}</td>
    66  	  <td>{{ .Size }}</td>
    67  	</tr>
    68        {{ end }}
    69    </table>
    70    <hr>
    71  </body>
    72  `[1:]))