support custom favicons
This commit is contained in:
parent
e67257f95c
commit
252d77c525
@ -11,6 +11,7 @@ type ServerOptions struct {
|
|||||||
Timezone string
|
Timezone string
|
||||||
DateFormat string
|
DateFormat string
|
||||||
DBFilePath string
|
DBFilePath string
|
||||||
|
FaviconFilePath string
|
||||||
AllowDBDownload bool
|
AllowDBDownload bool
|
||||||
RecentChanges int
|
RecentChanges int
|
||||||
GzipCompressionLevel int
|
GzipCompressionLevel int
|
||||||
@ -24,6 +25,7 @@ func DefaultOptions() *ServerOptions {
|
|||||||
Timezone: "UTC",
|
Timezone: "UTC",
|
||||||
DateFormat: time.RFC822Z,
|
DateFormat: time.RFC822Z,
|
||||||
DBFilePath: "wiki.db",
|
DBFilePath: "wiki.db",
|
||||||
|
FaviconFilePath: "", // no favicon
|
||||||
AllowDBDownload: true,
|
AllowDBDownload: true,
|
||||||
RecentChanges: 20,
|
RecentChanges: 20,
|
||||||
GzipCompressionLevel: 9,
|
GzipCompressionLevel: 9,
|
||||||
|
@ -42,6 +42,10 @@ func (this *WikiServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.Header().Set("Content-Type", "text/css")
|
w.Header().Set("Content-Type", "text/css")
|
||||||
w.Write(tmplWikiCss)
|
w.Write(tmplWikiCss)
|
||||||
return
|
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)
|
pto := DefaultPageTemplateOptions(this.opts)
|
||||||
|
@ -13,10 +13,12 @@ func main() {
|
|||||||
|
|
||||||
bindAddr := flag.String("listen", "127.0.0.1:80", "Bind address")
|
bindAddr := flag.String("listen", "127.0.0.1:80", "Bind address")
|
||||||
dbPath := flag.String("database", "wiki.db", "Database file")
|
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()
|
flag.Parse()
|
||||||
|
|
||||||
opts := yatwiki3.DefaultOptions()
|
opts := yatwiki3.DefaultOptions()
|
||||||
opts.DBFilePath = *dbPath
|
opts.DBFilePath = *dbPath
|
||||||
|
opts.FaviconFilePath = *faviconPath
|
||||||
|
|
||||||
ws, err := yatwiki3.NewWikiServer(opts)
|
ws, err := yatwiki3.NewWikiServer(opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user