Explorar el Código

Create examples for list generator

Andrea Fazzi hace 5 años
padre
commit
4f0ee40a00

+ 0 - 0
generator/generators/list/main/.gitignore → generator/generators/list/example_1/.gitignore


+ 0 - 0
generator/generators/list/main/config.yaml → generator/generators/list/example_1/config.yaml


+ 0 - 0
generator/generators/list/main/main.go → generator/generators/list/example_1/main.go


+ 1 - 0
generator/generators/list/example_2/.gitignore

@@ -0,0 +1 @@
+main

+ 17 - 0
generator/generators/list/example_2/config.yaml

@@ -0,0 +1,17 @@
+document_name: "Elenco docenti"
+cloud_path: "Documents/"
+url: "http://localhost:3000"
+domain: "foo.org"
+log_level: 2
+
+admin:
+  username: admin
+  password: admin
+  
+cloud:
+  username: admin
+  password: password
+  url: "http://localhost:8080/remote.php/webdav/"
+  
+documents:
+  output_path: "output"

+ 39 - 0
generator/generators/list/example_2/main.go

@@ -0,0 +1,39 @@
+package main
+
+import (
+	"log"
+
+	"gogs.carducci-dante.gov.it/karmen/core/config"
+	"gogs.carducci-dante.gov.it/karmen/core/generator/generators/list"
+)
+
+type Config struct {
+	config.ConfigT
+
+	DocumentName string `yaml:"document_name"`
+}
+
+func main() {
+	conf := new(Config)
+
+	err := config.ReadFile("config.yaml", &conf.ConfigT)
+	if err != nil {
+		panic(err)
+	}
+
+	// Upload resources on the cloud
+
+	if files, err := cloud.UploadDir("resources/*", "Documents/Example 2"); err != nil {
+		panic(err)
+	} else {
+		for _, file := range files {
+			log.Println(file, " was uploaded.")
+		}
+	}
+
+	gen := list.NewListGenerator(&conf.ConfigT)
+
+	gen.CloudPath = "Documents/Example 2"
+
+	gen.Run()
+}

+ 16 - 0
generator/generators/list/example_2/resources/list.tpl.md

@@ -0,0 +1,16 @@
+# I.S.I.S. “GIOSUE’ CARDUCCI – DANTE ALIGHIERI”
+# Liceo Classico; Liceo Linguistico; Liceo Musicale
+# Liceo delle Scienze Umane; delle Scienze Umane opzione Economico Sociale;
+# 34133 TRIESTE - Via Giustiniano, 3
+# A.S.  2019/2020
+
+## Elenco docenti con classi a.s. 2019/2020
+
+Docente|Classi
+-------|-----------------------------
+{{range $teacher := . -}}
+{{if not $teacher.Exclude -}}
+{{if $teacher.CompleteName|globFilter "[A-M]*"}}{{$teacher.CompleteName|abbrev}}|{{$teacher.Classes|groupClasses}}{{end}}
+{{end}}
+{{- end}}
+

BIN
generator/generators/list/example_2/resources/reference.odt