From 6838a2ded4ad5937dff9294a06d765b0184a2e91 Mon Sep 17 00:00:00 2001 From: Yanislav Igonin Date: Sun, 12 Sep 2021 00:30:48 +0300 Subject: [PATCH] posts design wip --- static/post.css | 20 ++++++++++++++++++ templates/thread.html | 48 ++++++++++++++++++++++++++++--------------- utils/utils.go | 4 +++- 3 files changed, 54 insertions(+), 18 deletions(-) create mode 100644 static/post.css diff --git a/static/post.css b/static/post.css new file mode 100644 index 0000000..df678d0 --- /dev/null +++ b/static/post.css @@ -0,0 +1,20 @@ +.post-container { + border: 1px solid rgba(0,0,0,.125); + border-radius: .25rem; + display: flex; +} + +.files-container { + display: flex; +} + +.file-container { + max-width: 5rem; +} + +.file { + width: 100%; +} + +.data-container { +} \ No newline at end of file diff --git a/templates/thread.html b/templates/thread.html index dd16646..85d4011 100644 --- a/templates/thread.html +++ b/templates/thread.html @@ -4,36 +4,50 @@ {{ template "static" }} {{ template "meta" $FirstPost }} + -

Welcome to Micrach

+

+ {{ if ne $FirstPost.Title "" }} + {{$FirstPost.Title}} + {{ else }} + Welcome to Micrach + {{ end }} +

{{ template "post-form" $FirstPost.ID }} -
+
{{range $Post := .}} -
-
+
- {{ $length := len $Post.Files }} {{ if gt $length 0 }} - {{$FirstFile := index $Post.Files 0}} - Uploaded picture - {{end}} - -
- {{ if ne $Post.Title "" }} -
{{$Post.Title}}
+ {{ $filesLength := len $Post.Files }} + {{ if gt $filesLength 0 }} +
+ {{ range $File := $Post.Files }} +
+ + Uploaded picture + +
{{ end }} +
+ {{ end }} + +

{{$Post.Text}}

+
-
{{end}}
diff --git a/utils/utils.go b/utils/utils.go index 96cd941..0e1da55 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -48,5 +48,7 @@ func CreateThreadFolder(postID int) error { } func ValidatePost(title, text string) bool { - return (title == "" && text != "") || (title != "" && text == "") + return (title == "" && text != "") || + (title != "" && text == "") || + (title != "" && text != "") }