Example #1
0
func LoadTheme(app *webapp.App, themeName string) error {
	cfg := GetConfig()
	app.Log("Use Theme", themeName)
	if err := LoadThemeTemplates(themeName); err != nil {
		return err
	}
	themeURL := path.Join(cfg.Path, "theme", themeName)
	themeStaticURL := path.Join(cfg.Path, "theme", themeName, "static")
	TattooDB.SetVar("ThemeURL", themeURL)
	TattooDB.SetVar("ThemeStaticURL", themeStaticURL)
	return nil
}
Example #2
0
func (db *TattooStorage) Load(app *webapp.App) {
	app.Log("Tattoo DB", "Init DB: Article DB")
	db.ArticleDB.Init("storage/source/", webapp.FILE_STORAGE_MODE_MULIPLE)
	app.Log("Tattoo DB", "Init DB: Article HTML DB")
	db.ArticleHTMLDB.Init("storage/html/", webapp.FILE_STORAGE_MODE_MULIPLE)
	app.Log("Tattoo DB", "Init DB: Article Metadata DB")
	db.MetadataDB.Init("storage/metadata.json", webapp.FILE_STORAGE_MODE_SINGLE)
	app.Log("Tattoo DB", "Init DB: Vars DB")
	db.VarDB.Init("storage/var.json", webapp.FILE_STORAGE_MODE_SINGLE)

	app.Log("Tattoo DB", "Init DB: Comment DB")
	db.CommentDB.Init("storage/comment_source/", webapp.FILE_STORAGE_MODE_MULIPLE)
	app.Log("Tattoo DB", "Init DB: Comment HTML DB")
	db.CommentHTMLDB.Init("storage/comment_html/", webapp.FILE_STORAGE_MODE_MULIPLE)
	app.Log("Tattoo DB", "Init DB: Comment Metadata DB")
	db.CommentMetadataDB.Init("storage/comment_metadata/", webapp.FILE_STORAGE_MODE_MULIPLE)
	app.Log("Tattoo DB", "Init DB: Comment Index DB")
	db.CommentIndexDB.Init("storage/comment_index/", webapp.FILE_STORAGE_MODE_MULIPLE)

	app.Log("Tattoo DB", "Init DB: Tag Index DB")
	db.TagIndexDB.Init("storage/tag_index/", webapp.FILE_STORAGE_MODE_MULIPLE)

	app.Log("Tattoo DB", "Rebuild Article Timeline")
	db.RebuildTimeline()
	app.Log("Tattoo DB", "Rebuild Comment Timeline")
	db.RebuildCommentTimeline()
}
Example #3
0
func main() {
	flag.Parse()
	if err := GetConfig().Load(); err != nil {
		fmt.Println("Failed to load configure file")
		return
	}
	cfg := GetConfig()
	startUpTime = time.Now().Unix()
	rootPath, _ := os.Getwd()
	rootURL := path.Join(cfg.Path, "/")
	systemStaticPath := path.Join(rootPath, "/sys/static")
	systemStaticURL := path.Join(cfg.Path, "/sys/static")

	themePath := path.Join(rootPath, "theme")
	themeURL := path.Join(cfg.Path, "/theme")

	app := webapp.App{}
	app.Log("App Starts", "OK")
	app.SetStaticPath(systemStaticURL, systemStaticPath)
	app.SetStaticPath(themeURL, themePath)
	app.SetHandler(rootURL, HandleRoot)

	// Load DB
	app.Log("Tattoo DB", "Load DB")
	TattooDB.Load(&app)

	TattooDB.SetVar("RootURL", rootURL)
	TattooDB.SetVar("SystemStaticURL", systemStaticURL)

	// load templates
	if err := LoadSystemTemplates(); err != nil {
		app.Log("Error", fmt.Sprintf("Failed to load system templates: %v", err))
		return
	}
	if err := LoadTheme(&app, GetConfig().ThemeName); err != nil {
		app.Log("Error", fmt.Sprintf("Failed to load theme: %v", err))
	}

	// Start Server.
	if *useFCGI {
		log.Printf("Server Starts(FastCGI): Listen on port %d\n", GetConfig().Port)
		app.RunCGI(GetConfig().Port)
	} else {
		log.Printf("Server Starts: Listen on port %d\n", GetConfig().Port)
		app.Run(GetConfig().Port)
	}
}
Example #4
0
func (db *BlahdyStorage) Load(app *webapp.App) {
	app.Log("DB", "Init DB: Blah DB")
	db.BlahDB.Init("storage/blah/", webapp.FILE_STORAGE_MODE_MULIPLE)
	app.Log("DB", "Init DB: User DB")
	db.UserDB.Init("storage/user/", webapp.FILE_STORAGE_MODE_MULIPLE)
	app.Log("DB", "Init DB: Certification DB")
	db.CertDB.Init("storage/cert/", webapp.FILE_STORAGE_MODE_MULIPLE)
	app.Log("DB", "Init DB: Message DB")
	db.MessageDB.Init("storage/message/", webapp.FILE_STORAGE_MODE_MULIPLE)
	app.Log("DB", "Init DB: Message Index DB")
	db.MessageIndexDB.Init("storage/message_index/", webapp.FILE_STORAGE_MODE_MULIPLE)
	app.Log("DB", "Init DB: Vars DB")
	db.VarDB.Init("storage/var/", webapp.FILE_STORAGE_MODE_MULIPLE)
}
Example #5
0
func main() {
	flag.Parse()

	rootPath, _ := os.Getwd()
	rootPath += ""
	app := webapp.App{}
	app.Log("App Starts", "OK")
	app.SetStaticPath("/static", path.Join(rootPath, "/static"))
	app.SetHandler("/api/", HandleRoot)

	BlahdyDB.Load(&app)
	LoadSamples()

	// Start Server.
	if *useFCGI {
		log.Printf("Server Starts(FastCGI): Listen on port %d\n", 4321)
		app.RunCGI(4321)
	} else {
		log.Printf("Server Starts: Listen on port %d\n", 8888)
		app.Run(8888)
	}
}