From 6cb2de0a1f583ef8d018e430181a7414fa7faff1 Mon Sep 17 00:00:00 2001 From: rtz12 Date: Sun, 17 Jan 2016 21:31:26 +0100 Subject: Ordnung in die Templates gebracht diff --git a/frontend/renderer.go b/frontend/renderer.go index eeff58e..d39dfe1 100644 --- a/frontend/renderer.go +++ b/frontend/renderer.go @@ -3,6 +3,9 @@ package frontend import ( "html/template" "net/http" + "os" + "path/filepath" + "strings" ) // Action ist die Aktion auf einer Card. @@ -70,8 +73,17 @@ func New(path string) *Renderer { }, } + files := make([]string, 0) + filepath.Walk(path, func(path string, info os.FileInfo, err error) error { + if info.IsDir() || !strings.HasSuffix(path, ".html") { + return nil + } + files = append(files, path) + return nil + }) + r := &Renderer{ - template.Must(template.New("").Funcs(funcMap).ParseGlob(path + "/*")), + template.Must(template.New("").Funcs(funcMap).ParseFiles(files...)), make(map[string]interface{}), } diff --git a/views/card.html b/views/card.html deleted file mode 100644 index be28272..0000000 --- a/views/card.html +++ /dev/null @@ -1,20 +0,0 @@ -{{ define "card" }} -{{ $card := . }} -
-
-
- {{ $card.Title | html }} -

{{ $card.Description | html }}

-
-
- {{ range $action := $card.Actions }} - {{ if $action.Disabled }} - {{ $action.Name | html }} - {{ else }} - {{ $action.Name | html }} - {{ end }} - {{ end }} -
-
-
-{{ end }} diff --git a/views/create_list.html b/views/create_list.html deleted file mode 100644 index ead61dd..0000000 --- a/views/create_list.html +++ /dev/null @@ -1,46 +0,0 @@ -{{ define "create_list" }} - - - {{ template "materialize" }} - grilist - - - - {{ template "navbar" . }} -
-
-
- {{ if .error }} -
-
-
- Fehler -

Es gab einen Fehler: {{ .error }}

-
-
-
- {{ end }} - -
-
- list - -
-
- - -
-
-
- -
-
-
-
-
-
- - -{{ end }} diff --git a/views/dashboard.html b/views/dashboard.html deleted file mode 100644 index 045d4ab..0000000 --- a/views/dashboard.html +++ /dev/null @@ -1,24 +0,0 @@ -{{ define "dashboard" }} - - - {{ template "materialize" }} - grilist - - - - {{ template "navbar" . }} -
-
- {{ range $category := .categories }} -

{{ $category.Title }}

-
- {{ range $category.Cards }} - {{ template "card" . }} - {{ end }} -
- {{ end }} -
-
- - -{{ end }} diff --git a/views/gril.html b/views/gril.html deleted file mode 100644 index 776f14f..0000000 --- a/views/gril.html +++ /dev/null @@ -1,77 +0,0 @@ -{{ define "gril" }} -{{ $gril := .gril }} - - - {{ template "materialize" }} - grilist - - - - - {{ template "navbar" . }} -
-

{{ $gril.RomajiName }}{{ $gril.KanjiName }}

- {{ if $gril.OtherNames }} -

Auch bekannt als: - {{ range $i, $alias := $gril.OtherNames }}{{ if $i }},{{ end }} - {{ $alias }}{{ end }} -

- {{ end }} -
- -
- {{ range $tag := $gril.Tags }} - -
- {{ $tag }} -
-
- {{ end }} -
-
-
- {{ if $gril.Birthday.Valid }} -
-
-
- {{ $gril.Birthday.Value}} -

Geburtstag

-
-
-
- {{ else if $gril.Age.Valid }} -
-
-
- {{ $gril.Age.Value }} -

Jahre alt

-
-
-
- {{ end }} - {{ if $gril.Lists }} -
-
-
-

in

- {{ len $gril.Lists}} -

Liste{{ if ne (len $gril.Lists) 1 }}n{{ end }}

-
-
-
- {{ end }} -
-
-
- {{ $gril.UpdatedAt.Format "Jan 02, 2006" }} -

aktualisiert

-
-
-
-
-
- - -{{ end }} diff --git a/views/includes/card.html b/views/includes/card.html new file mode 100644 index 0000000..be28272 --- /dev/null +++ b/views/includes/card.html @@ -0,0 +1,20 @@ +{{ define "card" }} +{{ $card := . }} +
+
+
+ {{ $card.Title | html }} +

{{ $card.Description | html }}

+
+
+ {{ range $action := $card.Actions }} + {{ if $action.Disabled }} + {{ $action.Name | html }} + {{ else }} + {{ $action.Name | html }} + {{ end }} + {{ end }} +
+
+
+{{ end }} diff --git a/views/includes/instant_search_results.html b/views/includes/instant_search_results.html new file mode 100644 index 0000000..0dd445c --- /dev/null +++ b/views/includes/instant_search_results.html @@ -0,0 +1,8 @@ +{{ define "instant_search_results" }} +{{ range .results }} +
  • + + { {{ .Name }} } +
  • +{{ end }} +{{ end }} \ No newline at end of file diff --git a/views/includes/list_gril.html b/views/includes/list_gril.html new file mode 100644 index 0000000..f719dae --- /dev/null +++ b/views/includes/list_gril.html @@ -0,0 +1,38 @@ +{{ define "list_gril" }} +
  • +
    +
    +
    +
    +
    +
    + {{ .Value.Gril.Gril.RomajiName }}
    + {{ .Value.Gril.Gril.KanjiName }} +
    +
    + {{ if .Value.IsListOwner }} +
    +
    +
    +
    + keyboard_arrow_up + keyboard_arrow_down +
    +
    + delete +
    +
    +
    +
    +
    + keyboard_arrow_up + keyboard_arrow_down + delete +
    +
    +
    + {{ end }} +
    +
    +
  • +{{ end }} \ No newline at end of file diff --git a/views/includes/materialize.html b/views/includes/materialize.html new file mode 100644 index 0000000..7c40c0d --- /dev/null +++ b/views/includes/materialize.html @@ -0,0 +1,6 @@ +{{define "materialize"}} + + + + +{{end}} \ No newline at end of file diff --git a/views/includes/navbar.html b/views/includes/navbar.html new file mode 100644 index 0000000..a0db664 --- /dev/null +++ b/views/includes/navbar.html @@ -0,0 +1,17 @@ +{{ define "navbar" }} + +{{ end }} \ No newline at end of file diff --git a/views/instant_search_results.html b/views/instant_search_results.html deleted file mode 100644 index 0dd445c..0000000 --- a/views/instant_search_results.html +++ /dev/null @@ -1,8 +0,0 @@ -{{ define "instant_search_results" }} -{{ range .results }} -
  • - - { {{ .Name }} } -
  • -{{ end }} -{{ end }} \ No newline at end of file diff --git a/views/list.html b/views/list.html deleted file mode 100644 index c85e147..0000000 --- a/views/list.html +++ /dev/null @@ -1,55 +0,0 @@ -{{ define "list" }} -{{ $list := .list }} -{{ $user := .user }} - - - {{ template "materialize" }} - grilist - - - - - - - - {{ template "navbar" . }} -
    -

    {{ $list.Name }}von {{ $list.Owner.GetName }}

    -
    {{ $list.Description }}

    -
    -
    -
      - {{ range $index, $lg := $list.Grils }} - {{ if $user }} - {{ template "list_gril" makeRangePair $index (makeObject "Gril" $lg "IsListOwner" (eq $user.ID $list.Owner.ID)) }} - {{ else }} - {{ template "list_gril" makeRangePair $index (makeObject "Gril" $lg "IsListOwner" false) }} - {{ end }} - {{ end }} -
    -
    - {{ if $user}} - {{ if eq $user.ID $list.Owner.ID }} -
    -
    - Gril hinzufügen
    -
    -
    - - - close -
    -
    -
    -
    -
      -
    -
    -
    - {{ end }} - {{ end }} -
    -
    - - -{{ end }} diff --git a/views/list_gril.html b/views/list_gril.html deleted file mode 100644 index f719dae..0000000 --- a/views/list_gril.html +++ /dev/null @@ -1,38 +0,0 @@ -{{ define "list_gril" }} -
  • -
    -
    -
    -
    -
    -
    - {{ .Value.Gril.Gril.RomajiName }}
    - {{ .Value.Gril.Gril.KanjiName }} -
    -
    - {{ if .Value.IsListOwner }} -
    -
    -
    -
    - keyboard_arrow_up - keyboard_arrow_down -
    -
    - delete -
    -
    -
    -
    -
    - keyboard_arrow_up - keyboard_arrow_down - delete -
    -
    -
    - {{ end }} -
    -
    -
  • -{{ end }} \ No newline at end of file diff --git a/views/login.html b/views/login.html deleted file mode 100644 index 65c4857..0000000 --- a/views/login.html +++ /dev/null @@ -1,48 +0,0 @@ -{{ define "login" }} - - - Grilist - Login - {{ template "materialize" }} - - -
    -
    -
    -

    grilist

    - {{ if .error }} -
    -
    -
    - Fehler -

    Es gab einen Fehler: {{ .error }}

    -
    -
    -
    - {{ end }} - -
    -
    - perm_identity - -
    -
    - lock_outline - -
    -
    - -
    - -
    -
    -
    -
    -
    -
    - - -{{ end }} diff --git a/views/materialize.html b/views/materialize.html deleted file mode 100644 index 7c40c0d..0000000 --- a/views/materialize.html +++ /dev/null @@ -1,6 +0,0 @@ -{{define "materialize"}} - - - - -{{end}} \ No newline at end of file diff --git a/views/navbar.html b/views/navbar.html deleted file mode 100644 index a0db664..0000000 --- a/views/navbar.html +++ /dev/null @@ -1,17 +0,0 @@ -{{ define "navbar" }} - -{{ end }} \ No newline at end of file diff --git a/views/pages/create_list.html b/views/pages/create_list.html new file mode 100644 index 0000000..ead61dd --- /dev/null +++ b/views/pages/create_list.html @@ -0,0 +1,46 @@ +{{ define "create_list" }} + + + {{ template "materialize" }} + grilist + + + + {{ template "navbar" . }} +
    +
    +
    + {{ if .error }} +
    +
    +
    + Fehler +

    Es gab einen Fehler: {{ .error }}

    +
    +
    +
    + {{ end }} + +
    +
    + list + +
    +
    + + +
    +
    +
    + +
    +
    +
    +
    +
    +
    + + +{{ end }} diff --git a/views/pages/dashboard.html b/views/pages/dashboard.html new file mode 100644 index 0000000..045d4ab --- /dev/null +++ b/views/pages/dashboard.html @@ -0,0 +1,24 @@ +{{ define "dashboard" }} + + + {{ template "materialize" }} + grilist + + + + {{ template "navbar" . }} +
    +
    + {{ range $category := .categories }} +

    {{ $category.Title }}

    +
    + {{ range $category.Cards }} + {{ template "card" . }} + {{ end }} +
    + {{ end }} +
    +
    + + +{{ end }} diff --git a/views/pages/gril.html b/views/pages/gril.html new file mode 100644 index 0000000..776f14f --- /dev/null +++ b/views/pages/gril.html @@ -0,0 +1,77 @@ +{{ define "gril" }} +{{ $gril := .gril }} + + + {{ template "materialize" }} + grilist + + + + + {{ template "navbar" . }} +
    +

    {{ $gril.RomajiName }}{{ $gril.KanjiName }}

    + {{ if $gril.OtherNames }} +

    Auch bekannt als: + {{ range $i, $alias := $gril.OtherNames }}{{ if $i }},{{ end }} + {{ $alias }}{{ end }} +

    + {{ end }} +
    + +
    + {{ range $tag := $gril.Tags }} + +
    + {{ $tag }} +
    +
    + {{ end }} +
    +
    +
    + {{ if $gril.Birthday.Valid }} +
    +
    +
    + {{ $gril.Birthday.Value}} +

    Geburtstag

    +
    +
    +
    + {{ else if $gril.Age.Valid }} +
    +
    +
    + {{ $gril.Age.Value }} +

    Jahre alt

    +
    +
    +
    + {{ end }} + {{ if $gril.Lists }} +
    +
    +
    +

    in

    + {{ len $gril.Lists}} +

    Liste{{ if ne (len $gril.Lists) 1 }}n{{ end }}

    +
    +
    +
    + {{ end }} +
    +
    +
    + {{ $gril.UpdatedAt.Format "Jan 02, 2006" }} +

    aktualisiert

    +
    +
    +
    +
    +
    + + +{{ end }} diff --git a/views/pages/list.html b/views/pages/list.html new file mode 100644 index 0000000..c85e147 --- /dev/null +++ b/views/pages/list.html @@ -0,0 +1,55 @@ +{{ define "list" }} +{{ $list := .list }} +{{ $user := .user }} + + + {{ template "materialize" }} + grilist + + + + + + + + {{ template "navbar" . }} +
    +

    {{ $list.Name }}von {{ $list.Owner.GetName }}

    +
    {{ $list.Description }}

    +
    +
    +
      + {{ range $index, $lg := $list.Grils }} + {{ if $user }} + {{ template "list_gril" makeRangePair $index (makeObject "Gril" $lg "IsListOwner" (eq $user.ID $list.Owner.ID)) }} + {{ else }} + {{ template "list_gril" makeRangePair $index (makeObject "Gril" $lg "IsListOwner" false) }} + {{ end }} + {{ end }} +
    +
    + {{ if $user}} + {{ if eq $user.ID $list.Owner.ID }} +
    +
    + Gril hinzufügen
    +
    +
    + + + close +
    +
    +
    +
    +
      +
    +
    +
    + {{ end }} + {{ end }} +
    +
    + + +{{ end }} diff --git a/views/pages/login.html b/views/pages/login.html new file mode 100644 index 0000000..65c4857 --- /dev/null +++ b/views/pages/login.html @@ -0,0 +1,48 @@ +{{ define "login" }} + + + Grilist - Login + {{ template "materialize" }} + + +
    +
    +
    +

    grilist

    + {{ if .error }} +
    +
    +
    + Fehler +

    Es gab einen Fehler: {{ .error }}

    +
    +
    +
    + {{ end }} + +
    +
    + perm_identity + +
    +
    + lock_outline + +
    +
    + +
    + +
    +
    +
    +
    +
    +
    + + +{{ end }} diff --git a/views/pages/register.html b/views/pages/register.html new file mode 100644 index 0000000..b946518 --- /dev/null +++ b/views/pages/register.html @@ -0,0 +1,52 @@ +{{ define "register" }} + + + Grilist - Registration + {{ template "materialize" }} + + +
    +
    +
    +

    grilist

    + {{ if .error }} +
    +
    +
    + Fehler +

    Es gab einen Fehler: {{ .error }}

    +
    +
    +
    + {{ end }} + +
    +
    + perm_identity + +
    +
    + lock_outline + +
    +
    + email + +
    +
    +
    + Cancel +
    +
    + +
    +
    +
    +
    +
    +
    + + +{{ end }} \ No newline at end of file diff --git a/views/pages/tag.html b/views/pages/tag.html new file mode 100644 index 0000000..d0d4180 --- /dev/null +++ b/views/pages/tag.html @@ -0,0 +1,34 @@ +{{ define "tag" }} +{{ $tagBaseURI := printf "/tag/%s/" .tag }} + + + {{ template "materialize" }} + grilist + + + + {{ template "navbar" . }} +
    +
    +

    Grils mit dem Tag "{{ .tag }}":

    +
    + {{ range .cards }} + {{ template "card" . }} + {{ end }} +
    + +
    +
    + + +{{ end }} diff --git a/views/pages/user.html b/views/pages/user.html new file mode 100644 index 0000000..2cf9c54 --- /dev/null +++ b/views/pages/user.html @@ -0,0 +1,29 @@ +{{ define "user" }} + + + {{ template "materialize" }} + {{ .DisplayUser.Name }} - grilist + + + + {{ template "navbar" . }} +
    +
    + {{ .DisplayUser.GetName }} + {{ if .user }} + {{ if eq .DisplayUser.ID .user.ID }} +   Einstellungen + {{ end }} + {{ end }} +
    +
    zuletzt gesehen: {{ .DisplayUser.LastActivity.Format "Mon Jan _2 15:04:05 2006" }}

    +
    +

    Listen von {{ .DisplayUser.GetName }}

    + {{ range .Lists }} + {{ template "card" . }} + {{ end }} +
    +
    + + +{{ end }} diff --git a/views/pages/user_settings.html b/views/pages/user_settings.html new file mode 100644 index 0000000..cf350a5 --- /dev/null +++ b/views/pages/user_settings.html @@ -0,0 +1,62 @@ +{{ define "user_settings" }} + + + {{ template "materialize" }} + {{ .user.Name }} - grilist + + + + {{ template "navbar" . }} +
    +

    {{ .user.Name }}

    +
    +
    + {{ if .error }} +
    +
    +
    + Fehler +

    Es gab einen Fehler: {{ .error }}

    +
    +
    +
    + {{ end }} +
    +
    +
    Standardmäßig wird dein Benutzername angezeigt. Das Ändern des Anzeigenamen erlaubt dir, dass dich andere Nutzer unter einem anderen Namen sehen.
    + perm_identity + +
    +

    +

    Passwort ändern

    +
    Dein Passwort muss eine Länge von mindestens benis Zeichen haben.
    +
    + lock_outline + +
    +
    + lock + +
    +
    + lock + +
    +
    + +

    +
    +
    +
    + +
    +
    +
    +
    + + +{{ end }} diff --git a/views/register.html b/views/register.html deleted file mode 100644 index b946518..0000000 --- a/views/register.html +++ /dev/null @@ -1,52 +0,0 @@ -{{ define "register" }} - - - Grilist - Registration - {{ template "materialize" }} - - -
    -
    -
    -

    grilist

    - {{ if .error }} -
    -
    -
    - Fehler -

    Es gab einen Fehler: {{ .error }}

    -
    -
    -
    - {{ end }} - -
    -
    - perm_identity - -
    -
    - lock_outline - -
    -
    - email - -
    -
    -
    - Cancel -
    -
    - -
    -
    -
    -
    -
    -
    - - -{{ end }} \ No newline at end of file diff --git a/views/tag.html b/views/tag.html deleted file mode 100644 index d0d4180..0000000 --- a/views/tag.html +++ /dev/null @@ -1,34 +0,0 @@ -{{ define "tag" }} -{{ $tagBaseURI := printf "/tag/%s/" .tag }} - - - {{ template "materialize" }} - grilist - - - - {{ template "navbar" . }} -
    -
    -

    Grils mit dem Tag "{{ .tag }}":

    -
    - {{ range .cards }} - {{ template "card" . }} - {{ end }} -
    - -
    -
    - - -{{ end }} diff --git a/views/user.html b/views/user.html deleted file mode 100644 index 2cf9c54..0000000 --- a/views/user.html +++ /dev/null @@ -1,29 +0,0 @@ -{{ define "user" }} - - - {{ template "materialize" }} - {{ .DisplayUser.Name }} - grilist - - - - {{ template "navbar" . }} -
    -
    - {{ .DisplayUser.GetName }} - {{ if .user }} - {{ if eq .DisplayUser.ID .user.ID }} -   Einstellungen - {{ end }} - {{ end }} -
    -
    zuletzt gesehen: {{ .DisplayUser.LastActivity.Format "Mon Jan _2 15:04:05 2006" }}

    -
    -

    Listen von {{ .DisplayUser.GetName }}

    - {{ range .Lists }} - {{ template "card" . }} - {{ end }} -
    -
    - - -{{ end }} diff --git a/views/user_settings.html b/views/user_settings.html deleted file mode 100644 index cf350a5..0000000 --- a/views/user_settings.html +++ /dev/null @@ -1,62 +0,0 @@ -{{ define "user_settings" }} - - - {{ template "materialize" }} - {{ .user.Name }} - grilist - - - - {{ template "navbar" . }} -
    -

    {{ .user.Name }}

    -
    -
    - {{ if .error }} -
    -
    -
    - Fehler -

    Es gab einen Fehler: {{ .error }}

    -
    -
    -
    - {{ end }} -
    -
    -
    Standardmäßig wird dein Benutzername angezeigt. Das Ändern des Anzeigenamen erlaubt dir, dass dich andere Nutzer unter einem anderen Namen sehen.
    - perm_identity - -
    -

    -

    Passwort ändern

    -
    Dein Passwort muss eine Länge von mindestens benis Zeichen haben.
    -
    - lock_outline - -
    -
    - lock - -
    -
    - lock - -
    -
    - -

    -
    -
    -
    - -
    -
    -
    -
    - - -{{ end }} -- cgit v0.10.1