feat: add line breaks on threads list text

This commit is contained in:
Yanislav Igonin 2022-01-20 21:03:18 +02:00
parent 16d5fa039e
commit 62be228308
5 changed files with 41 additions and 56 deletions

View File

@ -15,11 +15,3 @@
.file {
width: 100%;
}
.line-break {
white-space: pre-line;
}
.word-wrap {
word-break: break-word;
}

3
static/styles/utils.css Normal file
View File

@ -0,0 +1,3 @@
.line-break {
white-space: pre-line;
}

View File

@ -1,11 +1,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
{{ template "static" }}
<link
href="/static/styles/index.css"
rel="stylesheet"
>
<link href="/static/styles/index.css" rel="stylesheet">
{{ template "meta-tags-static" }}
</head>
@ -24,11 +22,8 @@
{{ $length := len $Post.Files }}
{{ if gt $length 0 }}
{{ $FirstFile := index $Post.Files 0 }}
<img
src="/uploads/{{$Post.ID}}/t/{{$FirstFile.ID}}.{{$FirstFile.Ext}}"
class="card-img-top"
alt="Uploaded picture"
>
<img src="/uploads/{{$Post.ID}}/t/{{$FirstFile.ID}}.{{$FirstFile.Ext}}" class="card-img-top"
alt="Uploaded picture">
{{ end }}
<div class="card-body">
@ -38,9 +33,9 @@
{{ $textLength := len $Post.Text }}
{{ if gt $textLength 300 }}
<p class="card-text">{{ slice $Post.Text 0 300 }} ...</p>
<p class="card-text line-break text-break">{{ slice $Post.Text 0 300 }} ...</p>
{{ else }}
<p class="card-text">{{$Post.Text}}</p>
<p class="card-text line-break text-break">{{$Post.Text}}</p>
{{ end }}
<a href="/{{$Post.ID}}" class="btn btn-outline-primary">Open</a>
@ -55,9 +50,9 @@
<ul id="pagesList" class="pagination justify-content-center">
{{ $ActivePage := .Page }}
{{ range $i := Iterate .PagesCount }}
<li class="page-item {{ if (eq $i $ActivePage) }} active {{ end }}">
<a class="page-link" href="/?page={{ $i }}">{{ $i }}</a>
</li>
<li class="page-item {{ if (eq $i $ActivePage) }} active {{ end }}">
<a class="page-link" href="/?page={{ $i }}">{{ $i }}</a>
</li>
{{ end }}
</ul>
</nav>

View File

@ -11,8 +11,6 @@
crossorigin="anonymous">
</script>
<link rel="icon" href="/static/favicon.ico"/>
<link
href="/static/styles/post-form.css"
rel="stylesheet"
>
<link href="/static/styles/utils.css" rel="stylesheet">
<link href="/static/styles/post-form.css" rel="stylesheet">
{{ end }}

View File

@ -2,11 +2,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
{{ template "static" }}
{{ template "meta-tags-dynamic" $FirstPost }}
<link href="/static/styles/thread.css" rel="stylesheet" >
<link href="/static/styles/post.css" rel="stylesheet" >
<link href="/static/styles/thread.css" rel="stylesheet">
<link href="/static/styles/post.css" rel="stylesheet">
</head>
<body>
@ -14,9 +15,9 @@
<h1 class="display-1 text-center thread-title">
{{ if ne $FirstPost.Title "" }}
{{$FirstPost.Title}}
{{$FirstPost.Title}}
{{ else }}
Welcome to Micrach
Welcome to Micrach
{{ end }}
</h1>
</a>
@ -26,30 +27,26 @@
<div id="postsСontainer">
{{ range $Post := .Thread }}
<div class="post-container mb-4">
<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 }}
{{ $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 class="p-2">
<p class="card-text line-break word-wrap">{{$Post.Text}}</p>
</div>
</div>
{{ end }}
<div class="p-2">
<p class="card-text line-break text-break">{{$Post.Text}}</p>
</div>
</div>
{{end}}
</div>
</div>