feat: add simple form for thread creating

This commit is contained in:
Yanislav Igonin 2021-09-04 21:46:27 +03:00
parent 107dd0fa0e
commit 41675a63fc

View File

@ -44,31 +44,36 @@
<h1 class="display-1 text-center">Welcome to Micrach</h1> <h1 class="display-1 text-center">Welcome to Micrach</h1>
<div class="container"> <div class="container">
<div class="row row-cols-auto gy-4"> <form class="row row-cols-auto gy-4" action="/" method="POST" enctype="multipart/form-data">
<input class="form-control" id="postTitle" placeholder="Title" name="title">
{{range $Post := .}} <textarea class="form-control" id="postText" rows="3" placeholder="Text" name="text"></textarea>
<div class="col col-sm-6 col-md-4 col-lg-3"> <input class="form-control" type="file" id="formFileMultiple" multiple name="files">
<div class="card"> </form>
<div class="row row-cols-auto gy-4">
{{range $Post := .}}
<div class="col col-sm-6 col-md-4 col-lg-3">
<div class="card">
{{ $length := len $Post.Files }} {{ if gt $length 0 }} {{ $length := len $Post.Files }} {{ if gt $length 0 }}
{{$FirstFile := index $Post.Files 0}} {{$FirstFile := index $Post.Files 0}}
<img <img
src="{{$FirstFile.Name}}" src="{{$FirstFile.Name}}"
class="card-img-top" class="card-img-top"
alt="Uploaded picture" alt="Uploaded picture"
> >
{{end}} {{end}}
<div class="card-body"> <div class="card-body">
<h5 class="card-title">{{$Post.Title}}</h5> <h5 class="card-title">{{$Post.Title}}</h5>
<p class="card-text">{{$Post.Text}}</p> <p class="card-text">{{$Post.Text}}</p>
<a href="/{{$Post.ID}}" class="btn btn-outline-primary">Open</a> <a href="/{{$Post.ID}}" class="btn btn-outline-primary">Open</a>
</div>
</div> </div>
</div> </div>
</div>
{{end}} {{end}}
</div> </div>
</div> </div>
</body> </body>