add static folder for air gapped deployments

This commit is contained in:
taahado5 2022-04-30 12:33:46 +02:00 committed by Lena Fuhrimann
parent 06262f38ed
commit 145de780e4
7 changed files with 75 additions and 6 deletions

View file

@ -20,6 +20,9 @@ import (
//go:embed web/template //go:embed web/template
var templateFS embed.FS var templateFS embed.FS
//go:embed static
var staticFS embed.FS
func main() { func main() {
var accessKeyID, secretAccessKey, iamEndpoint string var accessKeyID, secretAccessKey, iamEndpoint string
@ -68,6 +71,11 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
// Set up templates
statics, err := fs.Sub(staticFS, "static")
if err != nil {
log.Fatal(err)
}
// Set up S3 client // Set up S3 client
opts := &minio.Options{ opts := &minio.Options{
@ -93,6 +101,7 @@ func main() {
// Set up router // Set up router
r := mux.NewRouter() r := mux.NewRouter()
r.Handle("/", http.RedirectHandler("/buckets", http.StatusPermanentRedirect)).Methods(http.MethodGet) r.Handle("/", http.RedirectHandler("/buckets", http.StatusPermanentRedirect)).Methods(http.MethodGet)
r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.FS(statics)))).Methods(http.MethodGet)
r.Handle("/buckets", s3manager.HandleBucketsView(s3, templates, allowDelete)).Methods(http.MethodGet) r.Handle("/buckets", s3manager.HandleBucketsView(s3, templates, allowDelete)).Methods(http.MethodGet)
r.Handle("/buckets/{bucketName}", s3manager.HandleBucketView(s3, templates, allowDelete, listRecursive)).Methods(http.MethodGet) r.Handle("/buckets/{bucketName}", s3manager.HandleBucketView(s3, templates, allowDelete, listRecursive)).Methods(http.MethodGet)
r.Handle("/api/buckets", s3manager.HandleCreateBucket(s3)).Methods(http.MethodPost) r.Handle("/api/buckets", s3manager.HandleCreateBucket(s3)).Methods(http.MethodPost)

View file

@ -0,0 +1,23 @@
/* fallback */
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(2fcrYFNaTjcS6g4U3t-Y5ZjZjT5FdEJ140U2DJYC3mY.woff2) format('woff2');
}
.material-icons {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px;
line-height: 1;
letter-spacing: normal;
text-transform: none;
display: inline-block;
white-space: nowrap;
word-wrap: normal;
direction: ltr;
-webkit-font-feature-settings: 'liga';
-webkit-font-smoothing: antialiased;
}

31
static/css/materialize.min.css vendored Normal file

File diff suppressed because one or more lines are too long

2
static/js/jquery-3.6.0.min.js vendored Normal file

File diff suppressed because one or more lines are too long

6
static/js/materialize.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -9,8 +9,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link rel="stylesheet" href="/static/css/material-fonts.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" integrity="sha256-OweaP/Ic6rsV+lysfyS4h+LM6sRwuO3euTYfr6M124g=" crossorigin="anonymous" /> <link rel="stylesheet" href="/static/css/materialize.min.css" />
</head> </head>
<body> <body>
@ -18,11 +18,9 @@
{{ template "content" . }} {{ template "content" . }}
<script <script
src="https://code.jquery.com/jquery-3.6.0.min.js" src="/static/js/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous"
></script> ></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js" integrity="sha256-U/cHDMTIHCeMcvehBv1xQ052bPSbJtbuiw4QA9cTKz0=" crossorigin="anonymous"></script> <script src="/static/js/materialize.min.js"></script>
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
$('.dropdown-trigger').dropdown(); $('.dropdown-trigger').dropdown();