mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-20 09:26:23 -07:00
improve OP truncating on board page (check number of lines)
This commit is contained in:
parent
93c62f9753
commit
4c254f98bb
3 changed files with 25 additions and 7 deletions
|
@ -56,12 +56,30 @@ var funcMap = template.FuncMap{
|
|||
"stringNeq": func(a, b string) bool {
|
||||
return a != b
|
||||
},
|
||||
"truncateMessage": func(a string, b int) string {
|
||||
if len(a) < b {
|
||||
return a
|
||||
} else {
|
||||
return a[:b] + "..."
|
||||
"truncateMessage": func(msg string, limit int, max_lines int) string {
|
||||
var truncated bool
|
||||
split := strings.SplitN(msg,"<br />",-1)
|
||||
|
||||
if len(split) > max_lines {
|
||||
split = split[:max_lines]
|
||||
msg = strings.Join(split,"<br />")
|
||||
truncated = true
|
||||
}
|
||||
|
||||
if len(msg) < limit {
|
||||
if truncated {
|
||||
msg = msg + "..."
|
||||
}
|
||||
return msg
|
||||
} else {
|
||||
msg = msg[:limit]
|
||||
truncated = true
|
||||
}
|
||||
|
||||
if truncated {
|
||||
msg = msg + "..."
|
||||
}
|
||||
return msg
|
||||
},
|
||||
"intEq": func(a, b int) bool {
|
||||
return a == b
|
||||
|
|
|
@ -115,7 +115,7 @@
|
|||
</div>
|
||||
<div class="section-body">
|
||||
{{if stringNeq $post.Filename ""}}<img src="{{$post.BoardName}}/thumb/{{getThumbnailFilename $post.Filename}}" alt="post thumbnail"/>{{end}}
|
||||
{{truncateMessage $post.Message 225}}
|
||||
{{truncateMessage $post.Message 225 12}}
|
||||
|
||||
|
||||
</div>
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
<div class="post-text">
|
||||
{{if stringNeq $op.Message ""}}
|
||||
<div class="post-text">
|
||||
{{truncateMessage $op.Message 2222}}
|
||||
{{truncateMessage $op.Message 2222 18}}
|
||||
</div>
|
||||
{{end}}
|
||||
{{if gt $thread.NumReplies 3}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue