예제 #1
0
파일: main.go 프로젝트: Stromausfall/ssmpg
func main() {
	// validate arguments
	configFile, baseHtml, contentFolder, outputPath := input.BasicValidationOfConsoleArguments(os.Args[1:])

	/*
		configFile := "C:/Users/Matthias/OneDrive/GO/ssmpg/input/test.yaml"
		baseHtml := "C:/Users/Matthias/OneDrive/GO/ssmpg/input/base.html"
		contentFolder := "C:/Users/Matthias/OneDrive/GO/ssmpg/input/content"
		outputPath := "C:/xxx/output/"
	*/

	os.Mkdir(filepath.Join(outputPath, "content"), 777)
	os.Mkdir(filepath.Join(outputPath, "categories"), 777)

	configData := input.CreateConfigData(configFile)
	baseHtmlContent := input.LoadBaseHtmlData(baseHtml)
	contentData := input.LoadContentData(contentFolder)

	// create index
	page.CreateIndexPage(outputPath, configData, contentData, baseHtmlContent)

	// create category pages
	categories := sidebar.CollectCategories(contentData)

	// we need to synchronize the go routines
	waitGroup := sync.WaitGroup{}

	createCategories(&waitGroup, categories, outputPath, configData, contentData, baseHtmlContent)
	createContent(&waitGroup, outputPath, configData, contentData, baseHtmlContent)

	// wait until all go routines have finished
	waitGroup.Wait()
}
예제 #2
0
func setupTestEnvironment(id string) (string, input.ConfigData, []input.ContentData) {
	baseDir := filepath.Join(test.GetTestPath(), "pageTest"+id)
	outputDirectory := filepath.Join(baseDir, "output")
	test.CreateTestDirectory(baseDir)
	test.CreateTestDirectory(outputDirectory)

	configDataPath := createConfigFile(baseDir)
	contentPath := createContent(baseDir)

	configData := input.CreateConfigData(configDataPath)
	elements := input.LoadContentData(contentPath)

	return outputDirectory, configData, elements
}