diff --git a/repositories/structs.go b/repositories/structs.go index 38ed648..164d677 100644 --- a/repositories/structs.go +++ b/repositories/structs.go @@ -19,6 +19,13 @@ type Post struct { UpdatedAt time.Time `json:"-"` } +func (p *Post) getThreadID() int { + if p.IsParent { + return p.ID + } + return p.ParentID +} + type File struct { ID int `json:"-"` PostID int `json:"-"` @@ -39,6 +46,7 @@ type HtmlFormData struct { IsCaptchaActive bool } +// index.html type HtmlPaginationData struct { PagesCount int Page int diff --git a/templates/components/post.html b/templates/components/post.html new file mode 100644 index 0000000..267f522 --- /dev/null +++ b/templates/components/post.html @@ -0,0 +1,20 @@ +{{ define "post" }} +
+ {{ $filesLength := len .Files }} + {{ if gt $filesLength 0 }} +
+ {{ range $File := .Files }} +
+ + Uploaded picture + +
+ {{ end }} +
+ {{ end }} + +
+

{{.Text}}

+
+
+{{ end }} \ No newline at end of file diff --git a/templates/pages/thread.html b/templates/pages/thread.html index dc38f8f..4671a2f 100644 --- a/templates/pages/thread.html +++ b/templates/pages/thread.html @@ -18,26 +18,7 @@
{{ range $Post := .Thread }} -
- - {{ $filesLength := len $Post.Files }} - {{ if gt $filesLength 0 }} -
- {{ range $File := $Post.Files }} -
- - Uploaded picture - -
- {{ end }} -
- {{ end }} - -
-

{{$Post.Text}}

-
- -
+ {{ template "post" $Post }} {{ end }}