Beispiel #1
0
func create(arguments map[string]interface{}) {
	dir := arguments["<dir>"].(string)

	blogRepo := adapters.NewFSBlogRepository(repoDir(dir))
	authors := application.NewAuthors(blogRepo)

	err := authors.CreateBlog(blogID(dir))
	if err != nil {
		log.Errorf("Failed to create blog: %s\n", err)
		return
	}

	if arguments["--skeleton"].(int) == 1 {
		tmplDir := filepath.Join(dir, templatesDir)
		os.MkdirAll(tmplDir, 0700)

		for _, template := range templates {
			ioutil.WriteFile(filepath.Join(tmplDir, template), nil, 0600)
		}
	} else {
		RestoreAssets(dir, "templates")
		RestoreAssets(dir, "posts")
	}
	log.Infof("Created blog: %s\n", dir)
}
Beispiel #2
0
func build(arguments map[string]interface{}) {
	dir := arguments["<dir>"].(string)

	blogRepo := adapters.NewFSBlogRepository(repoDir(dir))
	readers := application.NewReaders(blogRepo)

	gen, err := adapters.NewStaticBlogGeneratorWithProgress(blogID(dir),
		filepath.Join(dir, templatesDir), filepath.Join(dir, outputDir),
		printProgress, readers)
	if err != nil {
		log.Errorf("Failed to create generator: %s\n", err)
		return
	}

	err = gen.Generate()
	if err != nil {
		log.Errorf("Failed to generate blog: %s\n", err)
	}
}