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"
|
2018-05-12 04:29:18 +00:00
|
|
|
"math/rand"
|
2017-11-03 16:52:40 +00:00
|
|
|
"os"
|
2018-05-12 04:29:18 +00:00
|
|
|
"time"
|
2017-10-08 04:48:58 +00:00
|
|
|
|
2018-05-12 03:15:16 +00:00
|
|
|
_ "github.com/jinzhu/gorm/dialects/sqlite" // SQLite DB
|
2018-02-12 00:24:43 +00:00
|
|
|
"github.com/kirsle/blog"
|
2018-02-10 02:46:58 +00:00
|
|
|
"github.com/kirsle/blog/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)")
|
2018-05-12 04:29:18 +00:00
|
|
|
rand.Seed(time.Now().UnixNano())
|
2017-10-08 04:48:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2018-02-12 00:24:43 +00:00
|
|
|
app := blog.New(DocumentRoot, userRoot)
|
2017-11-03 16:52:40 +00:00
|
|
|
if fDebug {
|
|
|
|
app.Debug = true
|
2017-12-23 02:34:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set $JSONDB_DEBUG=1 to debug JsonDB; it's very noisy!
|
|
|
|
if os.Getenv("JSONDB_DEBUG") != "" {
|
2017-11-03 16:52:40 +00:00
|
|
|
jsondb.SetDebug(true)
|
|
|
|
}
|
2017-12-23 02:34:58 +00:00
|
|
|
|
2018-02-10 18:08:45 +00:00
|
|
|
app.Run(fAddress)
|
2017-10-08 04:48:58 +00:00
|
|
|
}
|