posts design wip

This commit is contained in:
Yanislav Igonin 2021-09-12 00:30:48 +03:00
parent 6243ad9f4c
commit 6838a2ded4
3 changed files with 54 additions and 18 deletions

20
static/post.css Normal file
View File

@ -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 {
}

View File

@ -4,35 +4,49 @@
<head>
{{ template "static" }}
{{ template "meta" $FirstPost }}
<link
href="/static/post.css"
rel="stylesheet"
>
</head>
<body>
<h1 class="display-1 text-center">Welcome to Micrach</h1>
<h1 class="display-1 text-center">
{{ if ne $FirstPost.Title "" }}
{{$FirstPost.Title}}
{{ else }}
Welcome to Micrach
{{ end }}
</h1>
<div class="container">
{{ template "post-form" $FirstPost.ID }}
<div class="row row-cols-auto gy-4 mb-4">
<div id="postsСontainer">
{{range $Post := .}}
<div class="col col-sm-6 col-md-4 col-lg-3">
<div class="card">
<div class="post-container mb-4">
{{ $length := len $Post.Files }} {{ if gt $length 0 }}
{{$FirstFile := index $Post.Files 0}}
{{ $filesLength := len $Post.Files }}
{{ if gt $filesLength 0 }}
<div class="files-container">
{{ range $File := $Post.Files }}
<div class="file-container">
<a href="/uploads/{{$FirstPost.ID}}/{{$File.ID}}.{{$File.Ext}}" target="blank">
<img
src="/uploads/{{$FirstPost.ID}}/{{$FirstFile.ID}}.{{$FirstFile.Ext}}"
class="card-img-top"
src="/uploads/{{$FirstPost.ID}}/{{$File.ID}}.{{$File.Ext}}"
class="file"
alt="Uploaded picture"
>
{{end}}
<div class="card-body">
{{ if ne $Post.Title "" }}
<h5 class="card-title">{{$Post.Title}}</h5>
</a>
</div>
{{ end }}
</div>
{{ end }}
<div class="data-container p-2">
<p class="card-text">{{$Post.Text}}</p>
</div>
</div>
</div>
{{end}}
</div>

View File

@ -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 != "")
}