示例#1
0
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
}
示例#3
0
func TestCreateContent(t *testing.T) {
	dirPath := test.GetTestPath()
	pathToFolder := filepath.Join(dirPath, "foo66")

	test.CreateTestDirectory(pathToFolder)
	test.CreateTestFile(filepath.Join(pathToFolder, "foo1.md"), test.ContentData)

	files := input.LoadContentData(pathToFolder)
	result := CreateContent(testConfigData, files[0])
	expected := "<p>2015-03-24 22:28</p></br>\n<h3>Old Pages</h3>\n<p>Old unsupported pages :</p>\n"

	if result != expected {
		fmt.Println("expected : '" + expected + "'")
		fmt.Println("result   : '" + result + "'")
		t.Error("incorrect created content")
	}
}
示例#4
0
func TestCreateContentChangeVariousProperties(t *testing.T) {
	alteredCorrectData := strings.Replace(test.ContentData, "2015-03-24 22:28", "2015-03-24 22:29", -1)
	alteredCorrectData = strings.Replace(alteredCorrectData, "Old Pages", "New Pages", -1)
	alteredCorrectData = strings.Replace(alteredCorrectData, "Old unsupported pages :", "New supported pages :", -1)
	alteredTestConfigData := input.ConfigData{TitleType: "h2"}

	dirPath := test.GetTestPath()
	pathToFolder := filepath.Join(dirPath, "foo67")

	test.CreateTestDirectory(pathToFolder)
	test.CreateTestFile(filepath.Join(pathToFolder, "foo1.md"), alteredCorrectData)

	files := input.LoadContentData(pathToFolder)
	result := CreateContent(alteredTestConfigData, files[0])
	expected := "<p>2015-03-24 22:29</p></br>\n<h2>New Pages</h2>\n<p>New supported pages :</p>\n"

	if result != expected {
		fmt.Println("expected : '" + expected + "'")
		fmt.Println("result   : '" + result + "'")
		t.Error("incorrect created content")
	}
}