@ -102,6 +102,7 @@ func setup() *web.Mux {
log . Fatal ( "Could not create metadata directory:" , err )
log . Fatal ( "Could not create metadata directory:" , err )
}
}
if Config . siteURL != "" {
// ensure siteURL ends wth '/'
// ensure siteURL ends wth '/'
if lastChar := Config . siteURL [ len ( Config . siteURL ) - 1 : ] ; lastChar != "/" {
if lastChar := Config . siteURL [ len ( Config . siteURL ) - 1 : ] ; lastChar != "/" {
Config . siteURL = Config . siteURL + "/"
Config . siteURL = Config . siteURL + "/"
@ -113,6 +114,9 @@ func setup() *web.Mux {
}
}
Config . sitePath = parsedUrl . Path
Config . sitePath = parsedUrl . Path
} else {
Config . sitePath = "/"
}
// Template setup
// Template setup
p2l , err := NewPongo2TemplatesLoader ( )
p2l , err := NewPongo2TemplatesLoader ( )
@ -121,7 +125,6 @@ func setup() *web.Mux {
}
}
TemplateSet := pongo2 . NewSet ( "templates" , p2l )
TemplateSet := pongo2 . NewSet ( "templates" , p2l )
TemplateSet . Globals [ "sitename" ] = Config . siteName
TemplateSet . Globals [ "sitename" ] = Config . siteName
TemplateSet . Globals [ "siteurl" ] = Config . siteURL
TemplateSet . Globals [ "sitepath" ] = Config . sitePath
TemplateSet . Globals [ "sitepath" ] = Config . sitePath
TemplateSet . Globals [ "using_auth" ] = Config . authFile != ""
TemplateSet . Globals [ "using_auth" ] = Config . authFile != ""
err = populateTemplatesMap ( TemplateSet , Templates )
err = populateTemplatesMap ( TemplateSet , Templates )
@ -193,7 +196,7 @@ func main() {
"Allow hotlinking of files" )
"Allow hotlinking of files" )
flag . StringVar ( & Config . siteName , "sitename" , "linx" ,
flag . StringVar ( & Config . siteName , "sitename" , "linx" ,
"name of the site" )
"name of the site" )
flag . StringVar ( & Config . siteURL , "siteurl" , "http://" + Config . bind + "/ " ,
flag . StringVar ( & Config . siteURL , "siteurl" , "" ,
"site base url (including trailing slash)" )
"site base url (including trailing slash)" )
flag . Int64Var ( & Config . maxSize , "maxsize" , 4 * 1024 * 1024 * 1024 ,
flag . Int64Var ( & Config . maxSize , "maxsize" , 4 * 1024 * 1024 * 1024 ,
"maximum upload file size in bytes (default 4GB)" )
"maximum upload file size in bytes (default 4GB)" )
@ -232,16 +235,16 @@ func main() {
log . Fatal ( "Could not bind: " , err )
log . Fatal ( "Could not bind: " , err )
}
}
log . Printf ( "Serving over fastcgi, bound on %s, using siteurl %s " , Config . bind , Config . siteURL )
log . Printf ( "Serving over fastcgi, bound on %s" , Config . bind )
fcgi . Serve ( listener , mux )
fcgi . Serve ( listener , mux )
} else if Config . certFile != "" {
} else if Config . certFile != "" {
log . Printf ( "Serving over https, bound on %s, using siteurl %s " , Config . bind , Config . siteURL )
log . Printf ( "Serving over https, bound on %s" , Config . bind )
err := graceful . ListenAndServeTLS ( Config . bind , Config . certFile , Config . keyFile , mux )
err := graceful . ListenAndServeTLS ( Config . bind , Config . certFile , Config . keyFile , mux )
if err != nil {
if err != nil {
log . Fatal ( err )
log . Fatal ( err )
}
}
} else {
} else {
log . Printf ( "Serving over http, bound on %s, using siteurl %s " , Config . bind , Config . siteURL )
log . Printf ( "Serving over http, bound on %s" , Config . bind )
err := graceful . ListenAndServe ( Config . bind , mux )
err := graceful . ListenAndServe ( Config . bind , mux )
if err != nil {
if err != nil {
log . Fatal ( err )
log . Fatal ( err )