summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Magorsch <arzano@gentoo.org>2020-04-18 02:38:35 +0200
committerMax Magorsch <arzano@gentoo.org>2020-04-18 02:50:54 +0200
commit35a41e63ebd5f6cf9d17419c150eb53a005d2e87 (patch)
treee0bcc21bbb1e7e200857cfbd52acb82b008a3a6d /pkg/app/handler/search/utils.go
parentDisplay version and last update in the footer (diff)
downloadglsamaker-35a41e63ebd5f6cf9d17419c150eb53a005d2e87.tar.gz
glsamaker-35a41e63ebd5f6cf9d17419c150eb53a005d2e87.tar.bz2
glsamaker-35a41e63ebd5f6cf9d17419c150eb53a005d2e87.zip
Add the initial version of the rewritten glsamaker
The glsamaker has been completly rewritten in go. It is using postgres instead of mysql now. The look and feel is based on tyrian. Signed-off-by: Max Magorsch <arzano@gentoo.org>
Diffstat (limited to 'pkg/app/handler/search/utils.go')
-rw-r--r--pkg/app/handler/search/utils.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/pkg/app/handler/search/utils.go b/pkg/app/handler/search/utils.go
new file mode 100644
index 0000000..81e4e88
--- /dev/null
+++ b/pkg/app/handler/search/utils.go
@@ -0,0 +1,38 @@
+// miscellaneous utility functions used for the landing page of the application
+
+package search
+
+import (
+ "glsamaker/pkg/models"
+ "glsamaker/pkg/models/users"
+ "html/template"
+ "net/http"
+)
+
+// renderIndexTemplate renders all templates used for the landing page
+func renderSearchTemplate(w http.ResponseWriter, user *users.User, searchQuery string, searchResults []*models.Glsa) {
+ templates := template.Must(
+ template.Must(
+ template.New("Show").
+ ParseGlob("web/templates/layout/*.tmpl")).
+ ParseGlob("web/templates/search/*.tmpl"))
+
+ templates.ExecuteTemplate(w, "search.tmpl", createPageData("search", user, searchQuery, searchResults))
+}
+
+// createPageData creates the data used in the template of the landing page
+func createPageData(page string, user *users.User, searchQuery string, searchResults []*models.Glsa) interface{} {
+ return struct {
+ Page string
+ Application *models.GlobalSettings
+ User *users.User
+ GLSAs []*models.Glsa
+ SearchQuery string
+ }{
+ Page: page,
+ Application: models.GetDefaultGlobalSettings(),
+ User: user,
+ GLSAs: searchResults,
+ SearchQuery: searchQuery,
+ }
+}