mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-11-03 19:17:29 -05:00 
			
		
		
		
	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.
This commit is contained in:
		
							parent
							
								
									e7457b43e4
								
							
						
					
					
						commit
						e81369e220
					
				@ -16,6 +16,7 @@ package fileserver
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"bytes"
 | 
						"bytes"
 | 
				
			||||||
 | 
						_ "embed"
 | 
				
			||||||
	"encoding/json"
 | 
						"encoding/json"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
@ -31,6 +32,9 @@ import (
 | 
				
			|||||||
	"go.uber.org/zap"
 | 
						"go.uber.org/zap"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//go:embed browse.html
 | 
				
			||||||
 | 
					var defaultBrowseTemplate string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Browse configures directory browsing.
 | 
					// Browse configures directory browsing.
 | 
				
			||||||
type Browse struct {
 | 
					type Browse struct {
 | 
				
			||||||
	// Use this template file instead of the default browse template.
 | 
						// Use this template file instead of the default browse template.
 | 
				
			||||||
 | 
				
			|||||||
@ -1,20 +1,4 @@
 | 
				
			|||||||
// Copyright 2015 Matthew Holt and The Caddy Authors
 | 
					<!DOCTYPE html>
 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// Licensed under the Apache License, Version 2.0 (the "License");
 | 
					 | 
				
			||||||
// you may not use this file except in compliance with the License.
 | 
					 | 
				
			||||||
// You may obtain a copy of the License at
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
//     http://www.apache.org/licenses/LICENSE-2.0
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// Unless required by applicable law or agreed to in writing, software
 | 
					 | 
				
			||||||
// distributed under the License is distributed on an "AS IS" BASIS,
 | 
					 | 
				
			||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
					 | 
				
			||||||
// See the License for the specific language governing permissions and
 | 
					 | 
				
			||||||
// limitations under the License.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
package fileserver
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
const defaultBrowseTemplate = `<!DOCTYPE html>
 | 
					 | 
				
			||||||
<html>
 | 
					<html>
 | 
				
			||||||
	<head>
 | 
						<head>
 | 
				
			||||||
		<title>{{html .Name}}</title>
 | 
							<title>{{html .Name}}</title>
 | 
				
			||||||
@ -477,4 +461,4 @@ footer {
 | 
				
			|||||||
			timeList.forEach(localizeDatetime);
 | 
								timeList.forEach(localizeDatetime);
 | 
				
			||||||
		</script>
 | 
							</script>
 | 
				
			||||||
	</body>
 | 
						</body>
 | 
				
			||||||
</html>`
 | 
					</html>
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user