1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-09-14 10:06:23 -07:00

Treat recent posts with embed as if they have no thumbnail/upload on front page

This commit is contained in:
Eggbertx 2025-03-29 12:59:16 -07:00
parent a47e03def4
commit 48fb11a199
6 changed files with 22 additions and 7 deletions

View file

@ -46,7 +46,7 @@ col#recent {
}
div#recent-posts {
margin:auto;
margin: auto;
display: block;
width:90%;
}
@ -63,12 +63,17 @@ div.recent-post {
max-height: 320px;
margin-bottom: 10px;
text-align:center;
.file-deleted-box {
margin: auto;
float: none;
}
}
div#frontpage {
overflow: hidden;
width: 80%;
margin:auto;
margin: auto;
}
a.permalink {

View file

@ -346,6 +346,10 @@ div.recent-post {
margin-bottom: 10px;
text-align: center;
}
div.recent-post .file-deleted-box {
margin: auto;
float: none;
}
div#frontpage {
overflow: hidden;

View file

@ -68,11 +68,13 @@ func getFrontPagePosts() ([]frontPagePost, error) {
post = frontPagePost{
Board: boardDir,
URL: config.WebPath(boardDir, "res", topPostID+".html") + "#" + id,
ThumbURL: config.WebPath(boardDir, "thumb", thumbnail),
Filename: filename,
FileDeleted: filename == "deleted",
MessageSample: message,
}
if thumbnail != "" && !strings.HasPrefix(thumbnail, "embed:") {
post.ThumbURL = config.WebPath(boardDir, "thumb", thumbnail)
post.Filename = filename
}
recentPosts = append(recentPosts, post)
}

View file

@ -50,8 +50,12 @@ func SetThumbnailExtension(fileExt, thumbExt string) {
}
// GetThumbnailFilenames returns the regular thumbnail and the catalog thumbnail filenames of the given upload
// filename. It does not check if the catalog actually exists (for example, if it's a reply)
// filename. It does not check if the catalog actually exists (for example, if it's a reply). If the post
// has an embed instead of an upload, it returns empty strings.
func GetThumbnailFilenames(img string) (string, string) {
if strings.HasPrefix(img, "embed:") {
return "", ""
}
ext := GetThumbnailExtension(path.Ext(img))
index := strings.LastIndex(img, ".")
if index < 0 || index > len(img) {

View file

@ -76,7 +76,7 @@ WHERE DBPREFIXposts.is_deleted = FALSE;
CREATE VIEW DBPREFIXv_front_page_posts_with_file AS
SELECT * FROM DBPREFIXv_front_page_posts
WHERE filename IS NOT NULL AND filename <> '' AND filename <> 'deleted';
WHERE filename IS NOT NULL AND filename <> '' AND filename <> 'deleted' and filename not like 'embed:%';
CREATE VIEW DBPREFIXv_upload_info AS
SELECT p1.id as id, (SELECT id FROM DBPREFIXposts p2 WHERE p2.is_top_post AND p1.thread_id = p2.thread_id LIMIT 1) AS op,

View file

@ -36,7 +36,7 @@
{{if and (not $post.FileDeleted) (ne $post.Filename "") -}}
<a href="{{$post.URL}}" class="front-reply" target="_blank"><img src="{{$post.ThumbURL}}" alt="post thumbnail"/></a><br />
{{else}}
<div class="file-deleted-box" style="text-align:center; float:none;"><a href="{{$post.URL}}" class="front-reply" target="_blank">No file</a></div>
<div class="file-deleted-box"><a href="{{$post.URL}}" class="front-reply" target="_blank">No file</a></div>
{{- end}}<br />
<a href="{{webPathDir $post.Board}}">/{{$post.Board}}/</a><hr />
{{$post.MessageSample}}