예제 #1
0
파일: server.go 프로젝트: gssdromen/goblog
//Server ...
func Server(port int) {
	log.Info("Server start. Please visit http://localhost:" + strconv.Itoa(port))
	log.Infoln("Press ctrl-c to stop")
	http.Handle("/dashboard/blog/new", http.HandlerFunc(newBlogHandle))
	http.Handle("/dashboard/generate", http.HandlerFunc(generateHandle))
	http.Handle("/dashboard/deploy", http.HandlerFunc(deployHandle))
	http.Handle("/dashboard/", http.StripPrefix("/dashboard/", http.FileServer(http.Dir(blog.ThemeDir+"/dashboard"))))
	var config = blog.GetConfig()
	http.Handle("/", http.FileServer(http.Dir(config.PublicDir)))
	fmt.Println(blog.ThemeDir + "/dashboard")
	if err := graceful.ListenAndServe(":"+strconv.Itoa(port), nil); err != nil {
		log.Errorln("[Fail] fail to start server: ", err)
	}
}
예제 #2
0
파일: command.go 프로젝트: flytiny/goblog
func workspace() {
	config := blog.GetConfig()
	jconfig, _ := json.MarshalIndent(config, "", "    ")
	ioutil.WriteFile("config.json", jconfig, os.ModePerm)
	os.MkdirAll(config.PublicDir, os.ModePerm)
	os.MkdirAll(config.SourceDir+"/articles", os.ModePerm)
	os.MkdirAll(config.SourceDir+"/data", os.ModePerm)
	err := exec.Command("cp", "-R", blog.ThemeDir+"/data/", config.PublicDir).Run()
	if err != nil {
		log.Errorln(err)
		return
	}
	log.Infoln("Init workspace done")
}
예제 #3
0
파일: command.go 프로젝트: gssdromen/goblog
func init() {
	config = blog.GetConfig()
}