mirror of
https://github.com/yanislav-igonin/micrach
synced 2025-04-18 19:00:33 +03:00
feat: separate post
This commit is contained in:
parent
7898323167
commit
b43e1f431e
@ -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
|
||||
|
20
templates/components/post.html
Normal file
20
templates/components/post.html
Normal file
@ -0,0 +1,20 @@
|
||||
{{ define "post" }}
|
||||
<div class="post-container mb-4">
|
||||
{{ $filesLength := len .Files }}
|
||||
{{ if gt $filesLength 0 }}
|
||||
<div class="files-container">
|
||||
{{ range $File := .Files }}
|
||||
<div class="file-container">
|
||||
<a href="/uploads/{{.getThreadID}}/o/{{$File.ID}}.{{$File.Ext}}" target="blank">
|
||||
<img src="/uploads/{{.getThreadID}}/t/{{$File.ID}}.{{$File.Ext}}" class="file" alt="Uploaded picture">
|
||||
</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
<div class="p-2">
|
||||
<p class="card-text line-break text-break">{{.Text}}</p>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
@ -18,26 +18,7 @@
|
||||
|
||||
<div id="postsСontainer">
|
||||
{{ range $Post := .Thread }}
|
||||
<div class="post-container mb-4">
|
||||
|
||||
{{ $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}}/o/{{$File.ID}}.{{$File.Ext}}" target="blank">
|
||||
<img src="/uploads/{{$FirstPost.ID}}/t/{{$File.ID}}.{{$File.Ext}}" class="file" alt="Uploaded picture">
|
||||
</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
<div class="p-2">
|
||||
<p class="card-text line-break text-break">{{$Post.Text}}</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{{ template "post" $Post }}
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user