瀏覽代碼

Finish department generator prototype

Andrea Fazzi 5 年之前
父節點
當前提交
655eefb9ef

+ 15 - 21
generator/funcmap/funcmap.go

@@ -2,6 +2,8 @@ package funcmap
 
 import (
 	"fmt"
+	"log"
+	"reflect"
 	"sort"
 	"strings"
 	"text/template"
@@ -10,10 +12,6 @@ import (
 	"gogs.carducci-dante.gov.it/karmen/core/orm"
 )
 
-type Stringer interface {
-	String() string
-}
-
 var FuncMap template.FuncMap = template.FuncMap{
 	"comma":        comma,
 	"groupClasses": groupClasses,
@@ -32,23 +30,19 @@ func order(items []string) []string {
 }
 
 func stringSlice(items interface{}) []string {
-	// var (
-	// 	interfaces []interface{}
-	// 	result     []string
-	// )
-
-	// val := reflect.ValueOf(items)
-	// interfaces = make([]interface{}, val.Len())
-
-	// for i := 0; i < val.Len(); i++ {
-	// 	interfaces = append(interfaces, items[i])
-	// }
-	// for _, i := range interfaces {
-	// 	result = append(result, i.(Stringer).String())
-	// }
-
-	//	return result
-	return []string{}
+	var result []string
+
+	switch reflect.TypeOf(items).Kind() {
+	case reflect.Slice:
+		s := reflect.ValueOf(items)
+		for i := 0; i < s.Len(); i++ {
+			result = append(result, fmt.Sprintf("%s", s.Index(i)))
+		}
+	default:
+		log.Println("Unknown type")
+	}
+
+	return result
 }
 
 func toUpper(content string) string {

+ 2 - 0
generator/generators/department/example_1/.gitignore

@@ -0,0 +1,2 @@
+example_1
+output

二進制
generator/generators/department/example_1/example_1


+ 0 - 11
generator/generators/department/example_1/output/Dipartimento di LINGUE STRANIERE.md

@@ -1,11 +0,0 @@
-# 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
-
-## Dipartimento di LINGUE STRANIERE
-
-### Materie afferenti al dipartimento
-
-* FRANCESE

二進制
generator/generators/department/example_1/output/Dipartimento di LINGUE STRANIERE.odt


二進制
generator/generators/department/example_1/output/Dipartimento di LINGUE STRANIERE.pdf


+ 0 - 11
generator/generators/department/example_1/output/Dipartimento di SOSTEGNO.md

@@ -1,11 +0,0 @@
-# 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
-
-## Dipartimento di SOSTEGNO
-
-### Materie afferenti al dipartimento
-
-* SOSTEGNO

二進制
generator/generators/department/example_1/output/Dipartimento di SOSTEGNO.odt


二進制
generator/generators/department/example_1/output/Dipartimento di SOSTEGNO.pdf


二進制
generator/generators/department/example_1/output/reference.odt


+ 0 - 0
generator/generators/department/example_1/reference.odt


二進制
generator/generators/department/example_1/resources/reference.odt


+ 3 - 1
generator/generators/department/example_1/resources/template.md

@@ -6,7 +6,7 @@
 
 ## Dipartimento di {{.Name}}
 
-### Materie afferenti al dipartimento
+### Materie e docenti afferenti al dipartimento
 
 {{range $subject := .Subjects -}}
 * {{$subject.Name}}
@@ -15,5 +15,7 @@
 {{end}}
 {{- end}}
 
+### Coordinatore del Dipartimento
+
 Il coordinatore del Dipartimento è il/la prof./prof.ssa **{{.Coordinator.CompleteName}}**.