From b1e80d440ef268aebad3cb0ed4de1b7a687fdf6d Mon Sep 17 00:00:00 2001
From: Adrian Stoica <george.a.stoica@ntnu.no>
Date: Tue, 22 Oct 2019 15:10:29 +0200
Subject: [PATCH] work on support for windows

---
 lectures/build.gradle   | 54 +++++++++++++++++++++++++++++------------
 lectures/pdfslides.bat  | 14 +++++++++++
 lectures/pdfslides.sh   | 14 +++++------
 lectures/pdfslides2.bat | 14 +++++++++++
 4 files changed, 73 insertions(+), 23 deletions(-)
 create mode 100644 lectures/pdfslides.bat
 create mode 100644 lectures/pdfslides2.bat

diff --git a/lectures/build.gradle b/lectures/build.gradle
index bb10025..7a24ddc 100644
--- a/lectures/build.gradle
+++ b/lectures/build.gradle
@@ -120,22 +120,21 @@ task checkDocker {
  	doLast{
  	 	def result = 1
 	    if (Os.isFamily(Os.FAMILY_WINDOWS)) {
-	        	println "windows os"
-	            result = exec{
-		            def command = "/c docker --version"
-		            ignoreExitValue = true
-		            executable "cmd" args command
-		        }
-	        
+	    	println "windows os"
+	      result = exec{
+	          def command = "/c docker --version"
+	          ignoreExitValue = true
+	          executable "cmd" args command
+	      }
 	    } else { 
-	    		//we assume linux/mac with bash if not having windows - 
-	    		//more fine tuned testing can be done if needed
-		        println "linux / unix os"
-		        result = exec{
-		            def command = "command -v docker"
-		            ignoreExitValue = true
-		            executable "bash" args "-l", "-c", command
-		        }
+	  		//we assume linux/mac with bash if not having windows - 
+	  		//more fine tuned testing can be done if needed
+        println "linux / unix os"
+        result = exec{
+            def command = "command -v docker"
+            ignoreExitValue = true
+            executable "bash" args "-l", "-c", command
+        }
 	    }
 	    
 	    if(result.getExitValue()==0){
@@ -149,15 +148,38 @@ task checkDocker {
 }
 
 task pdfSlides {
+	doLast{
 	if (dockerAvailable){
 	    if (Os.isFamily(Os.FAMILY_WINDOWS)) {
-	        println "run windows script"
+	       def result = exec{
+	       		workingDir = '.'
+	          ignoreExitValue = true
+	          commandLine 'cmd','/c','pdfslides.bat'
+	      } 
+	      
+	      if(result.getExitValue()==0){
+            println "export successful"
+	    	} else {
+	        	print "export to pdf failed"
+	    	}
 	    } else {
+	    	def result = exec{
+            def command = "pdfslides.sh"
+            ignoreExitValue = true
+            executable "bash" args "-l", "-c", command
+        }
+        
+	    	if(result.getExitValue()==0){
+            println "export successful"
+	    	} else {
+	        	print "export to pdf failed"
+	    	}
 	    	println "run linux / unix script"
 	    }
     } else {
     	println "docker is not available on this machine"
     }
+   }
 }
 
 build.dependsOn 'asciidoctorRevealJs'
diff --git a/lectures/pdfslides.bat b/lectures/pdfslides.bat
new file mode 100644
index 0000000..a9b3e34
--- /dev/null
+++ b/lectures/pdfslides.bat
@@ -0,0 +1,14 @@
+SETLOCAL ENABLEEXTENSIONS
+SETLOCAL ENABLEDELAYEDEXPANSION
+
+SET CURRENT_PATH=%~dp0
+SET "URL_SLIDES=https://gitlab.stud.idi.ntnu.no/it1901/course-material/-/jobs/artifacts/master/file/lectures/build/docs/revealjs/"
+rem using 2.9 as the latest vesion is not working properly in our case
+SET "DOCKER_PARAMS=run --rm -t -v ^"%CURRENT_PATH%build\docs\pdf^":/slides astefanutti/decktape:2.9 --size=1280x1000"
+
+docker %DOCKER_PARAMS% %URL_SLIDES%course-intro.html?job=build 01.a.course-intro-slides.pdf
+docker %DOCKER_PARAMS% %URL_SLIDES%02-software-development.html?job=build 02.a.software-development-slides.pdf
+docker %DOCKER_PARAMS% %URL_SLIDES%scm.html?job=build 02.b.source-code-management.pdf
+docker %DOCKER_PARAMS% %URL_SLIDES%03-build-tools-and-some-testing.html?job=build 03-build-tools-and-some-testing.pdf
+docker %DOCKER_PARAMS% %URL_SLIDES%07-documentation.html?job=build 07.b.-documentation.pdf
+docker %DOCKER_PARAMS% %URL_SLIDES%08-workflow-example.html?job=build 08.workflow-example.pdf
\ No newline at end of file
diff --git a/lectures/pdfslides.sh b/lectures/pdfslides.sh
index 084315a..aec0ff2 100644
--- a/lectures/pdfslides.sh
+++ b/lectures/pdfslides.sh
@@ -2,12 +2,12 @@
 
 URL_SLIDES="https://gitlab.stud.idi.ntnu.no/it1901/course-material/-/jobs/artifacts/master/file/lectures/build/docs/revealjs/"
 #using 2.9 as the latest vesion is not working properly in our case
-DOCKER_PARAMS="run --rm -t -v `pwd`:/slides astefanutti/decktape:2.9"
+DOCKER_PARAMS="run --rm -t -v `pwd`:/slides astefanutti/decktape:2.9  --size=1280x1000"
 
 
-docker ${DOCKER_PARAMS} --size=1280x1000 ${URL_SLIDES}course-intro.html?job=build 01.a.course-intro-slides.pdf
-docker ${DOCKER_PARAMS} --size=1280x1000 ${URL_SLIDES}02-software-development.html?job=build 02.a.software-development-slides.pdf
-docker ${DOCKER_PARAMS} --size=1280x1000 ${URL_SLIDES}scm.html?job=build 02.b.source-code-management.pdf
-docker ${DOCKER_PARAMS} --size=1280x1000 ${URL_SLIDES}03-build-tools-and-some-testing.html?job=build 03-build-tools-and-some-testing.pdf
-docker ${DOCKER_PARAMS} --size=1280x1000 ${URL_SLIDES}07-documentation.html?job=build 07.b.-documentation.pdf
-docker ${DOCKER_PARAMS} --size=1280x1000 ${URL_SLIDES}08-workflow-example.html?job=build 08.workflow-example.pdf
+docker ${DOCKER_PARAMS} ${URL_SLIDES}course-intro.html?job=build 01.a.course-intro-slides.pdf
+docker ${DOCKER_PARAMS} ${URL_SLIDES}02-software-development.html?job=build 02.a.software-development-slides.pdf
+docker ${DOCKER_PARAMS} ${URL_SLIDES}scm.html?job=build 02.b.source-code-management.pdf
+docker ${DOCKER_PARAMS} ${URL_SLIDES}03-build-tools-and-some-testing.html?job=build 03-build-tools-and-some-testing.pdf
+docker ${DOCKER_PARAMS} ${URL_SLIDES}07-documentation.html?job=build 07.b.-documentation.pdf
+docker ${DOCKER_PARAMS} ${URL_SLIDES}08-workflow-example.html?job=build 08.workflow-example.pdf
diff --git a/lectures/pdfslides2.bat b/lectures/pdfslides2.bat
new file mode 100644
index 0000000..f2e8370
--- /dev/null
+++ b/lectures/pdfslides2.bat
@@ -0,0 +1,14 @@
+SETLOCAL ENABLEEXTENSIONS
+SETLOCAL ENABLEDELAYEDEXPANSION
+
+SET CURRENT_PATH=%~dp0
+SET "URL_SLIDES=/revealjs/"
+rem using 2.9 as the latest vesion is not working properly in our case
+SET "DOCKER_PARAMS=run --rm -t -v ^"%CURRENT_PATH%build\docs\pdf^":/slides -v ^"%CURRENT_PATH%build\docs\revealjs^":/revealjs astefanutti/decktape:2.9 --size=1280x1000 --chrome-arg=--allow-file-access-from-files"
+
+docker %DOCKER_PARAMS% "%URL_SLIDES%course-intro.html" 01.a.course-intro-slides.pdf
+docker %DOCKER_PARAMS% %URL_SLIDES%02-software-development.html 02.a.software-development-slides.pdf
+docker %DOCKER_PARAMS% %URL_SLIDES%scm.html 02.b.source-code-management.pdf
+docker %DOCKER_PARAMS% %URL_SLIDES%03-build-tools-and-some-testing.html 03-build-tools-and-some-testing.pdf
+docker %DOCKER_PARAMS% %URL_SLIDES%07-documentation.html 07.b.-documentation.pdf
+docker %DOCKER_PARAMS% %URL_SLIDES%08-workflow-example.html 08.workflow-example.pdf
\ No newline at end of file
-- 
GitLab