1 minute to read
copyThemes
About This Task
docToolchain provides you with a simple Twitter bootstrap default theme to get you started.
You can use the copyThemes
task to apply a different theme (either jBakeTheme or pdfTheme) to your project.
Feel free to remove all files which should remain as the default and change all others.
When you next run docToolchain, your theme files will be laid over the default theme in order to generate the PDF or site.
Source
Show source code of scripts/copyThemes.gradle
or go directly to GitHub · docToolchain/scripts/copyThemes.gradle.
scripts/copyThemes.gradle
//tag::copyThemes[]
task copyThemes(
description: 'copy some default files to your project for you to modify',
group: 'docToolchain helper'
) {
doFirst {
}
doLast {
def color = { color, text ->
def colors = [black: 30, red: 31, green: 32, yellow: 33, blue: 34, magenta: 35, cyan: 36, white: 37]
return new String((char) 27) + "[${colors[color]}m${text}" + new String((char) 27) + "[0m"
}
def lang = ant.input(message: "${color 'green', 'What do you want me to copy?'}", validargs: 'pdfTheme,jBakeTheme', addproperty: 'what')
switch (ant.what) {
case 'pdfTheme':
def targetDir = new File(pdfThemeDir)
/**
if (targetDir.exists()) {
println "${targetDir.canonicalPath} already exists"
println "in order to re-install the theme, please remove the folder first and re-run the script"
throw new RuntimeException("pdfTheme folder already exists")
}
**/
targetDir.mkdirs()
def source = new File(projectDir, 'template_config/pdfTheme')
println source.canonicalPath
println targetDir.canonicalPath
copy {
from new File(projectDir, 'template_config/pdfTheme')
into targetDir
}
println "pdfTheme copied into ${targetDir}"
break
case 'jBakeTheme':
def targetDir = new File(new File(docDir, inputPath), config.microsite.siteFolder?:'../site')
/**
if (targetDir.exists()) {
println "${targetDir.canonicalPath} already exists"
println "in order to re-install the theme, please remove the folder first and re-run the script"
throw new RuntimeException("jBakeTheme folder already exists")
}
**/
targetDir.mkdirs()
copy {
from new File(projectDir, 'src/site')
into targetDir
}
def siteTheme = System.getenv('DTC_SITETHEME')?:""
def themeFolder = new File(projectDir, "../themes/" + siteTheme.md5())
copy {
from(themeFolder) {}
into targetDir
}
println "jBakeTheme copied into ${targetDir.canonicalPath}"
break
}
}
}
//end::copyThemes[]
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.