support custom favicons
This commit is contained in:
parent
e67257f95c
commit
252d77c525
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user