Add basic styling to listing page, fix previous directory link.

This commit is contained in:
Gabriel Simmer 2019-02-24 01:02:03 -08:00
parent 7b091438d4
commit 4bd60c6c1d
No known key found for this signature in database
GPG key ID: 0394452F45EF2817
4 changed files with 39 additions and 9 deletions

View file

@ -10,16 +10,16 @@
<body>
<main>
<div>
<h1>{{$path}}</h1>
<h1>{{$prefix}}/{{$path}}</h1>
</div>
<div class="content">
<a href="/{{$prefix}}{{$prev}}">..</a> <br>
<p class="directory"><a href="/{{$prefix}}/{{$prev}}">..</a></p>
{{range $file := .Files}}
{{ if $file.IsDir }}
<a href="/{{$prefix}}/{{$path}}/{{$file.Name}}">{{$file.Name}}</a> <br>
<p class="directory"><a href="/{{$prefix}}/{{$path}}/{{$file.Name}}">{{$file.Name}}/</a></p>
{{ end }}
{{ if not $file.IsDir }}
<a href="/{{$singleprefix}}/{{$path}}/{{$file.Name}}">{{$file.Name}}</a> <br>
<p class="file"><a href="/{{$singleprefix}}/{{$path}}/{{$file.Name}}">{{$file.Name}}</a></p>
{{end}}
{{end}}
</div>

View file

@ -0,0 +1,32 @@
body {
font-family: Open Sans, Arial, sans-serif;
color: #454545;
font-size: 16px;
margin: 2em auto;
max-width: 800px;
padding: 1em;
line-height: 1.4;
text-align: justify;
background-color: #fefefe;
}
.directory, .file {
margin: 0;
border: 1px solid #454545;
margin-top: -1px;
padding: 0.5em;
-webkit-transition: background-color 0.5s linear;
-moz-transition: background-color 0.5s linear;
-ms-transition: background-color 0.5s linear;
-o-transition: background-color 0.5s linear;
transition: background-color 0.5s linear;
}
.directory:hover, .file:hover {
background-color: lightgray;
-webkit-transition: background-color 0.5s linear;
-moz-transition: background-color 0.5s linear;
-ms-transition: background-color 0.5s linear;
-o-transition: background-color 0.5s linear;
transition: background-color 0.5s linear;
}

View file

@ -2,7 +2,6 @@ package files
import (
"encoding/json"
"fmt"
"github.com/gmemstr/nas/common"
"github.com/gorilla/mux"
"html/template"
@ -75,7 +74,7 @@ func Listing(tier string) common.Handler {
Prefix: prefix,
SinglePrefix: singleprefix,
}
fmt.Println(prefix)
t, err := template.ParseFiles("assets/web/listing.html")
if err != nil {
panic(err)
@ -93,7 +92,6 @@ func ViewFile(tier string) common.Handler {
return func(rc *common.RouterContext, w http.ResponseWriter, r *http.Request) *common.HTTPError {
vars := mux.Vars(r)
id := vars["file"]
fmt.Println(id)
d, err := ioutil.ReadFile("assets/config/config.json")
if err != nil {

View file

@ -49,7 +49,7 @@ func Init() *mux.Router {
rootHandler(),
)).Methods("GET")
r.Handle("/files", Handle(
r.Handle("/files/", Handle(
files.Listing("hot"),
)).Methods("GET")
r.Handle(`/files/{file:[a-zA-Z0-9=\-\/.]+}`, Handle(
@ -59,7 +59,7 @@ func Init() *mux.Router {
files.ViewFile("hot"),
)).Methods("GET")
r.Handle("/archive", Handle(
r.Handle("/archive/", Handle(
files.Listing("cold"),
)).Methods("GET")
r.Handle(`/archive/{file:[a-zA-Z0-9=\-\/.]+}`, Handle(