diff options
Diffstat (limited to 'pkg/app/handler/drafts/utils.go')
-rw-r--r-- | pkg/app/handler/drafts/utils.go | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/pkg/app/handler/drafts/utils.go b/pkg/app/handler/drafts/utils.go new file mode 100644 index 0000000..f7f4f57 --- /dev/null +++ b/pkg/app/handler/drafts/utils.go @@ -0,0 +1,37 @@ +// miscellaneous utility functions used for the landing page of the application + +package drafts + +import ( + "glsamaker/pkg/models" + "glsamaker/pkg/models/users" + "html/template" + "net/http" +) + +// renderIndexTemplate renders all templates used for the landing page +func renderDraftsTemplate(w http.ResponseWriter, user *users.User, drafts []*models.Glsa) { + + templates := template.Must( + template.Must( + template.New("Show"). + ParseGlob("web/templates/layout/*.tmpl")). + ParseGlob("web/templates/drafts/*.tmpl")) + + templates.ExecuteTemplate(w, "drafts.tmpl", createPageData("drafts", user, drafts)) +} + +// createPageData creates the data used in the template of the landing page +func createPageData(page string, user *users.User, drafts []*models.Glsa) interface{} { + return struct { + Page string + Application *models.GlobalSettings + User *users.User + Drafts []*models.Glsa + }{ + Page: page, + Application: models.GetDefaultGlobalSettings(), + User: user, + Drafts: drafts, + } +} |