|
@@ -26,7 +26,8 @@ type ListGenerator struct {
|
|
|
sync.Mutex
|
|
|
Config *config.ConfigT
|
|
|
|
|
|
- JobID uint
|
|
|
+ CloudPath string
|
|
|
+ JobID uint
|
|
|
|
|
|
ncClient *cloud.Client
|
|
|
kaClient *karmen_client.Client
|
|
@@ -39,15 +40,15 @@ var funcMap template.FuncMap = template.FuncMap{
|
|
|
"nbsp": nbsp,
|
|
|
}
|
|
|
|
|
|
-func (generator *ListGenerator) generate(outputPath string, teachers []*orm.Teacher, funcMap template.FuncMap) {
|
|
|
+func (generator *ListGenerator) generate(outputPath string, cloudPath string, teachers []*orm.Teacher, funcMap template.FuncMap) {
|
|
|
filename := filepath.Join(outputPath, "elenco_docenti")
|
|
|
|
|
|
- tplContent, err := generator.ncClient.Download("Karmen/list/list.tpl.md")
|
|
|
+ tplContent, err := generator.ncClient.Download(filepath.Join(cloudPath, "list.tpl.md"))
|
|
|
if err != nil {
|
|
|
panic(err)
|
|
|
}
|
|
|
|
|
|
- refContent, err := generator.ncClient.Download("Karmen/list/reference.odt")
|
|
|
+ refContent, err := generator.ncClient.Download(filepath.Join(cloudPath, "reference.odt"))
|
|
|
if err != nil {
|
|
|
panic(err)
|
|
|
}
|
|
@@ -191,19 +192,24 @@ func (generator *ListGenerator) Run() {
|
|
|
panic(err)
|
|
|
}
|
|
|
|
|
|
- var outputPath string
|
|
|
+ var (
|
|
|
+ outputPath string
|
|
|
+ cloudPath string
|
|
|
+ )
|
|
|
|
|
|
if generator.JobID > 0 {
|
|
|
outputPath = filepath.Join(generator.Config.Documents.OutputPath, fmt.Sprintf("%d/%d", job.DocumentID, job.ID))
|
|
|
+ cloudPath = job.Document.CloudPath
|
|
|
} else {
|
|
|
outputPath = "output"
|
|
|
+ cloudPath = generator.CloudPath
|
|
|
}
|
|
|
|
|
|
if err := os.MkdirAll(outputPath, 0777); err != nil {
|
|
|
panic(err)
|
|
|
}
|
|
|
|
|
|
- generator.generate(outputPath, teachers, funcMap)
|
|
|
+ generator.generate(outputPath, cloudPath, teachers, funcMap)
|
|
|
|
|
|
if generator.JobID > 0 {
|
|
|
job.End = time.Now()
|