Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 01:30 UTC
fileserver: Move default browse template into a separate file (#4417)
This makes it easier for users to find the default browse template if they want to create a custom template based on that. It also makes it easier to view the template with proper syntax highlighting.
Jeremy Lin committed
Nov 15, 2021 at 10:53 UTC
e81369e2208e47d9650f9699ad8bc7692640b275
2 files changed
+7
-19
modules/caddyhttp/fileserver/browse.go
+4
@@ -16,6 +16,7 @@ package fileserver
16
17
import (
18
"bytes"
19
+ _ "embed"
20
"encoding/json"
21
"fmt"
22
"net/http"
@@ -31,6 +32,9 @@ import (
32
"go.uber.org/zap"
33
)
34
35
+//go:embed browse.html
36
+var defaultBrowseTemplate string
37
+
38
// Browse configures directory browsing.
39
type Browse struct {
40
// Use this template file instead of the default browse template.
modules/caddyhttp/fileserver/browse.html
renamed
+3
-19
@@ -1,20 +1,4 @@
1
-// Copyright 2015 Matthew Holt and The Caddy Authors
2
-//
3
-// Licensed under the Apache License, Version 2.0 (the "License");
4
-// you may not use this file except in compliance with the License.
5
-// You may obtain a copy of the License at
6
-//
7
-// http://www.apache.org/licenses/LICENSE-2.0
8
-//
9
-// Unless required by applicable law or agreed to in writing, software
10
-// distributed under the License is distributed on an "AS IS" BASIS,
11
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
-// See the License for the specific language governing permissions and
13
-// limitations under the License.
14
-
15
-package fileserver
16
-
17
-const defaultBrowseTemplate = `<!DOCTYPE html>
1
+<!DOCTYPE html>
2
<html>
3
<head>
4
<title>{{html .Name}}</title>
@@ -40,7 +24,7 @@ h1 a:hover {
24
}
25
26
a:visited {
43
- color: #800080;
27
+ color: #800080;
28
}
29
30
header,
@@ -477,4 +461,4 @@ footer {
461
timeList.forEach(localizeDatetime);
462
</script>
463
</body>
480
-</html>`
464
+</html>