From 6d19fb8c7ccdffedd8b48af855ff82f307d5e866 Mon Sep 17 00:00:00 2001 From: Steve Greenberg Date: Sat, 9 Jun 2018 08:35:08 -0600 Subject: [PATCH 1/4] update chapter name to match current hugo --- fixtures/target/01-A/{index.md => _index.md} | 0 fixtures/target/02-D/{index.md => _index.md} | 0 main.go | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename fixtures/target/01-A/{index.md => _index.md} (100%) rename fixtures/target/02-D/{index.md => _index.md} (100%) diff --git a/fixtures/target/01-A/index.md b/fixtures/target/01-A/_index.md similarity index 100% rename from fixtures/target/01-A/index.md rename to fixtures/target/01-A/_index.md diff --git a/fixtures/target/02-D/index.md b/fixtures/target/02-D/_index.md similarity index 100% rename from fixtures/target/02-D/index.md rename to fixtures/target/02-D/_index.md diff --git a/main.go b/main.go index 7556d05..ec7e273 100644 --- a/main.go +++ b/main.go @@ -75,7 +75,7 @@ func main() { index := fmt.Sprintf("%02d", i+1) fullSrc := learningPath + "/" + mapping.Name + "/index.md" fullTgtDir := targetDir + "/" + index + "-" + mapping.Name - fullTgt := fullTgtDir + "/index.md" + fullTgt := fullTgtDir + "/_index.md" if !exists(fullTgtDir) { os.MkdirAll(fullTgtDir, mode) } From 2b0c9426e66b379aae0e98b7059d532ec1a9d999 Mon Sep 17 00:00:00 2001 From: Steve Greenberg Date: Mon, 11 Jun 2018 08:21:06 -0600 Subject: [PATCH 2/4] prefix exercises with index for ordering --- fixtures/hugo-structure.yml | 2 +- fixtures/target/01-A/{C.md => 01-C.md} | 0 fixtures/target/01-A/{B.md => 02-B.md} | 0 fixtures/target/02-D/{E.md => 01-E.md} | 0 main.go | 5 +++-- main_test.go | 2 +- 6 files changed, 5 insertions(+), 4 deletions(-) rename fixtures/target/01-A/{C.md => 01-C.md} (100%) rename fixtures/target/01-A/{B.md => 02-B.md} (100%) rename fixtures/target/02-D/{E.md => 01-E.md} (100%) diff --git a/fixtures/hugo-structure.yml b/fixtures/hugo-structure.yml index 8f98145..0f958a0 100644 --- a/fixtures/hugo-structure.yml +++ b/fixtures/hugo-structure.yml @@ -1,8 +1,8 @@ mappings: - name: A exercises: - - B - C + - B - name: D exercises: - E diff --git a/fixtures/target/01-A/C.md b/fixtures/target/01-A/01-C.md similarity index 100% rename from fixtures/target/01-A/C.md rename to fixtures/target/01-A/01-C.md diff --git a/fixtures/target/01-A/B.md b/fixtures/target/01-A/02-B.md similarity index 100% rename from fixtures/target/01-A/B.md rename to fixtures/target/01-A/02-B.md diff --git a/fixtures/target/02-D/E.md b/fixtures/target/02-D/01-E.md similarity index 100% rename from fixtures/target/02-D/E.md rename to fixtures/target/02-D/01-E.md diff --git a/main.go b/main.go index ec7e273..807c7b5 100644 --- a/main.go +++ b/main.go @@ -84,9 +84,10 @@ func main() { err = shutil.CopyFile(fullSrc, fullTgt, false) check(err) - for _, exercise := range mapping.Exercises { + for j, exercise := range mapping.Exercises { + subIndex := fmt.Sprintf("%02d", j+1) fullSrc := exercisePath + "/" + exercise + "/README.md" - fullTgt := targetDir + "/" + index + "-" + mapping.Name + "/" + exercise + ".md" + fullTgt := targetDir + "/" + index + "-" + mapping.Name + "/" + subIndex + "-" + exercise + ".md" fmt.Println(fullSrc + " to " + fullTgt) err = shutil.CopyFile(fullSrc, fullTgt, false) check(err) diff --git a/main_test.go b/main_test.go index d41491a..1cb6f17 100644 --- a/main_test.go +++ b/main_test.go @@ -66,8 +66,8 @@ var _ = Describe("hugo-parser", func() { result := `mappings: - name: A exercises: - - B - C + - B - name: D exercises: - E` From 8c3f92c161433f573864124be41b32e858eba403 Mon Sep 17 00:00:00 2001 From: Steve Greenberg Date: Mon, 18 Jun 2018 19:12:57 -0600 Subject: [PATCH 3/4] copy exercise images --- fixtures/source/exercises/C/images/image1.png | 0 fixtures/source/exercises/C/images/image2.png | 0 fixtures/target/01-A/images/image1.png | 0 fixtures/target/01-A/images/image2.png | 0 main.go | 6 ++++++ 5 files changed, 6 insertions(+) create mode 100644 fixtures/source/exercises/C/images/image1.png create mode 100644 fixtures/source/exercises/C/images/image2.png create mode 100644 fixtures/target/01-A/images/image1.png create mode 100644 fixtures/target/01-A/images/image2.png diff --git a/fixtures/source/exercises/C/images/image1.png b/fixtures/source/exercises/C/images/image1.png new file mode 100644 index 0000000..e69de29 diff --git a/fixtures/source/exercises/C/images/image2.png b/fixtures/source/exercises/C/images/image2.png new file mode 100644 index 0000000..e69de29 diff --git a/fixtures/target/01-A/images/image1.png b/fixtures/target/01-A/images/image1.png new file mode 100644 index 0000000..e69de29 diff --git a/fixtures/target/01-A/images/image2.png b/fixtures/target/01-A/images/image2.png new file mode 100644 index 0000000..e69de29 diff --git a/main.go b/main.go index 807c7b5..438249c 100644 --- a/main.go +++ b/main.go @@ -91,6 +91,12 @@ func main() { fmt.Println(fullSrc + " to " + fullTgt) err = shutil.CopyFile(fullSrc, fullTgt, false) check(err) + fullSrcImages := exercisePath + "/" + exercise + "/images" + if _, err := os.Stat(fullSrcImages); err == nil { + fullTgtImages := targetDir + "/" + index + "-" + mapping.Name + "/images" + err = shutil.CopyTree(fullSrcImages, fullTgtImages, nil) + check(err) + } } } From 7e8a82841036ad8925660f0df14bf93bbd0e1655 Mon Sep 17 00:00:00 2001 From: Steve Greenberg Date: Mon, 18 Jun 2018 19:30:30 -0600 Subject: [PATCH 4/4] put images in exericse directory --- .../exercises/{C/images/image1.png => B/images/bimage1.png} | 0 fixtures/source/exercises/C/images/{image2.png => cimage1.png} | 0 .../images/image1.png => source/exercises/C/images/cimage2.png} | 0 .../target/01-A/{images/image2.png => 01-C/images/cimage1.png} | 0 fixtures/target/01-A/01-C/images/cimage2.png | 0 fixtures/target/01-A/02-B/images/bimage1.png | 0 main.go | 2 +- 7 files changed, 1 insertion(+), 1 deletion(-) rename fixtures/source/exercises/{C/images/image1.png => B/images/bimage1.png} (100%) rename fixtures/source/exercises/C/images/{image2.png => cimage1.png} (100%) rename fixtures/{target/01-A/images/image1.png => source/exercises/C/images/cimage2.png} (100%) rename fixtures/target/01-A/{images/image2.png => 01-C/images/cimage1.png} (100%) create mode 100644 fixtures/target/01-A/01-C/images/cimage2.png create mode 100644 fixtures/target/01-A/02-B/images/bimage1.png diff --git a/fixtures/source/exercises/C/images/image1.png b/fixtures/source/exercises/B/images/bimage1.png similarity index 100% rename from fixtures/source/exercises/C/images/image1.png rename to fixtures/source/exercises/B/images/bimage1.png diff --git a/fixtures/source/exercises/C/images/image2.png b/fixtures/source/exercises/C/images/cimage1.png similarity index 100% rename from fixtures/source/exercises/C/images/image2.png rename to fixtures/source/exercises/C/images/cimage1.png diff --git a/fixtures/target/01-A/images/image1.png b/fixtures/source/exercises/C/images/cimage2.png similarity index 100% rename from fixtures/target/01-A/images/image1.png rename to fixtures/source/exercises/C/images/cimage2.png diff --git a/fixtures/target/01-A/images/image2.png b/fixtures/target/01-A/01-C/images/cimage1.png similarity index 100% rename from fixtures/target/01-A/images/image2.png rename to fixtures/target/01-A/01-C/images/cimage1.png diff --git a/fixtures/target/01-A/01-C/images/cimage2.png b/fixtures/target/01-A/01-C/images/cimage2.png new file mode 100644 index 0000000..e69de29 diff --git a/fixtures/target/01-A/02-B/images/bimage1.png b/fixtures/target/01-A/02-B/images/bimage1.png new file mode 100644 index 0000000..e69de29 diff --git a/main.go b/main.go index 438249c..159dee5 100644 --- a/main.go +++ b/main.go @@ -93,7 +93,7 @@ func main() { check(err) fullSrcImages := exercisePath + "/" + exercise + "/images" if _, err := os.Stat(fullSrcImages); err == nil { - fullTgtImages := targetDir + "/" + index + "-" + mapping.Name + "/images" + fullTgtImages := targetDir + "/" + index + "-" + mapping.Name + "/" + subIndex + "-" + exercise + "/images" err = shutil.CopyTree(fullSrcImages, fullTgtImages, nil) check(err) }