2017-10-08 04:48:58 +00:00
|
|
|
// Package blog is a web application which lets you host your own web blog,
|
|
|
|
// photo albums, wiki, etc.
|
|
|
|
//
|
|
|
|
// It is currently under early development and is not yet stable.
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
2017-11-03 16:52:40 +00:00
|
|
|
"fmt"
|
|
|
|
"os"
|
2017-10-08 04:48:58 +00:00
|
|
|
|
|
|
|
"github.com/kirsle/blog/core"
|
2017-11-03 16:52:40 +00:00
|
|
|
"github.com/kirsle/blog/core/jsondb"
|
2017-10-08 04:48:58 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Build-time config constants.
|
|
|
|
var (
|
|
|
|
Version = "0.0.1"
|
|
|
|
Build = "live"
|
|
|
|
DocumentRoot = "root"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Command line args.
|
|
|
|
var (
|
|
|
|
fDebug bool
|
|
|
|
fAddress string
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
flag.BoolVar(&fDebug, "debug", false, "Debug mode")
|
|
|
|
flag.BoolVar(&fDebug, "d", false, "Debug mode (alias)")
|
|
|
|
flag.StringVar(&fAddress, "address", ":8000", "Bind address")
|
|
|
|
flag.StringVar(&fAddress, "a", ":8000", "Bind address (alias)")
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
flag.Parse()
|
2017-11-03 16:52:40 +00:00
|
|
|
userRoot := flag.Arg(0)
|
|
|
|
if userRoot == "" {
|
|
|
|
fmt.Printf("Need user root\n")
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2017-10-08 04:48:58 +00:00
|
|
|
|
2017-11-03 16:52:40 +00:00
|
|
|
app := core.New(DocumentRoot, userRoot)
|
|
|
|
if fDebug {
|
|
|
|
app.Debug = true
|
|
|
|
jsondb.SetDebug(true)
|
|
|
|
}
|
2017-10-08 04:48:58 +00:00
|
|
|
app.ListenAndServe(fAddress)
|
|
|
|
}
|