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> <head>
{{ template "static" }} {{ template "static" }}
{{ template "meta" $FirstPost }} {{ template "meta" $FirstPost }}
<link
href="/static/post.css"
rel="stylesheet"
>
</head> </head>
<body> <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"> <div class="container">
{{ template "post-form" $FirstPost.ID }} {{ template "post-form" $FirstPost.ID }}
<div class="row row-cols-auto gy-4 mb-4"> <div id="postsСontainer">
{{range $Post := .}} {{range $Post := .}}
<div class="col col-sm-6 col-md-4 col-lg-3"> <div class="post-container mb-4">
<div class="card">
{{ $length := len $Post.Files }} {{ if gt $length 0 }} {{ $filesLength := len $Post.Files }}
{{$FirstFile := index $Post.Files 0}} {{ 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 <img
src="/uploads/{{$FirstPost.ID}}/{{$FirstFile.ID}}.{{$FirstFile.Ext}}" src="/uploads/{{$FirstPost.ID}}/{{$File.ID}}.{{$File.Ext}}"
class="card-img-top" class="file"
alt="Uploaded picture" alt="Uploaded picture"
> >
{{end}} </a>
</div>
<div class="card-body">
{{ if ne $Post.Title "" }}
<h5 class="card-title">{{$Post.Title}}</h5>
{{ end }} {{ end }}
</div>
{{ end }}
<div class="data-container p-2">
<p class="card-text">{{$Post.Text}}</p> <p class="card-text">{{$Post.Text}}</p>
</div> </div>
</div>
</div> </div>
{{end}} {{end}}
</div> </div>

View File

@ -48,5 +48,7 @@ func CreateThreadFolder(postID int) error {
} }
func ValidatePost(title, text string) bool { func ValidatePost(title, text string) bool {
return (title == "" && text != "") || (title != "" && text == "") return (title == "" && text != "") ||
(title != "" && text == "") ||
(title != "" && text != "")
} }