Ejemplo n.º 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
}
Ejemplo n.º 2
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)
	}
}
Ejemplo n.º 3
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/", webapp.FILE_STORAGE_MODE_MULIPLE)
	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()
}