diff --git a/ServerOptions.go b/ServerOptions.go index f082e07..2ea0a18 100644 --- a/ServerOptions.go +++ b/ServerOptions.go @@ -11,6 +11,7 @@ type ServerOptions struct { Timezone string DateFormat string DBFilePath string + FaviconFilePath string AllowDBDownload bool RecentChanges int GzipCompressionLevel int @@ -24,6 +25,7 @@ func DefaultOptions() *ServerOptions { Timezone: "UTC", DateFormat: time.RFC822Z, DBFilePath: "wiki.db", + FaviconFilePath: "", // no favicon AllowDBDownload: true, RecentChanges: 20, GzipCompressionLevel: 9, diff --git a/WikiServer.go b/WikiServer.go index 43c7b9f..7d5b424 100644 --- a/WikiServer.go +++ b/WikiServer.go @@ -42,6 +42,10 @@ func (this *WikiServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/css") w.Write(tmplWikiCss) return + } else if r.URL.Path == this.opts.ExpectBaseURL+"favicon.ico" && len(this.opts.FaviconFilePath) > 0 { + w.Header().Set("Content-Type", "image/x-icon") + http.ServeFile(w, r, this.opts.FaviconFilePath) + return } pto := DefaultPageTemplateOptions(this.opts) diff --git a/cmd/yatwiki-server/main.go b/cmd/yatwiki-server/main.go index e150e0d..cfe9140 100644 --- a/cmd/yatwiki-server/main.go +++ b/cmd/yatwiki-server/main.go @@ -13,10 +13,12 @@ func main() { bindAddr := flag.String("listen", "127.0.0.1:80", "Bind address") dbPath := flag.String("database", "wiki.db", "Database file") + faviconPath := flag.String("favicon", "", "Local disk path to favicon.ico file (leave blank for no favicon)") flag.Parse() opts := yatwiki3.DefaultOptions() opts.DBFilePath = *dbPath + opts.FaviconFilePath = *faviconPath ws, err := yatwiki3.NewWikiServer(opts) if err != nil {