github.com/janotchain/janota@v0.0.0-20220824112012-93ea4c5dee78/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/ethereum/go-ethereum/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    <title>Swarm index of {{ .URI }}</title>
    38  </head>
    39  
    40  <body>
    41    <h1>Swarm index of {{ .URI }}</h1>
    42    <hr>
    43    <table>
    44      <thead>
    45        <tr>
    46  	<th>Path</th>
    47  	<th>Type</th>
    48  	<th>Size</th>
    49        </tr>
    50      </thead>
    51  
    52      <tbody>
    53        {{ range .List.CommonPrefixes }}
    54  	<tr>
    55  	  <td><a href="{{ basename . }}/?list=true">{{ basename . }}/</a></td>
    56  	  <td>DIR</td>
    57  	  <td>-</td>
    58  	</tr>
    59        {{ end }}
    60  
    61        {{ range .List.Entries }}
    62  	<tr>
    63  	  <td><a href="{{ basename .Path }}">{{ basename .Path }}</a></td>
    64  	  <td>{{ .ContentType }}</td>
    65  	  <td>{{ .Size }}</td>
    66  	</tr>
    67        {{ end }}
    68    </table>
    69    <hr>
    70  </body>
    71  `[1:]))