Hello!
I have the following use case:
- User selects pages to export within XWiki.
- User presses a button to generate a DOCX with custom template (need to apply custom styles).
- XWiki exports selected pages in xwiki/2.1 syntax
- System passes pages to pandoc.
- Pandoc creates a DOCX file using custom LUA filter and template from user.
For first step I need to create zip with selected pages in xwiki/2.1 syntax.
And I XML format is not suitable for me;
This variant is working for me
{{groovy}}
import org.xwiki.environment.*
import org.xwiki.model.reference.*
if (request.confirm == '1') {
services.query.xwql("select distinct doc.fullName from Document doc where doc.space like 'Sandbox' or doc.space like 'Sandbox.%'").execute().each() {
print "* Converting ${it} to MD..."
def itemDoc = xwiki.getDocument(it)
def newContent = itemDoc.getContent()
def tmpDir = new File(services.component.getInstance(Environment.class).temporaryDirectory, 'md-export')
def pathSerializer = services.component.getInstance(EntityReferenceSerializer.TYPE_STRING, 'fspath')
def outputFile = new File(tmpDir, pathSerializer.serialize(itemDoc.documentReference))
outputFile.parentFile.mkdirs()
outputFile << newContent
println "Saved in ${outputFile.toString()}"
}
}
println "[[Export>>||queryString='confirm=1']]"
{{/groovy}}