Skip to content
This repository was archived by the owner on Apr 21, 2026. It is now read-only.

Commit 6e07a20

Browse files
authored
Merge pull request #300 from wheels-dev/fix/blogs-timezone
Fix: Avatar Fallback Display Using Bootstrap d-none Class
2 parents aa0445d + 6d92bbe commit 6e07a20

5 files changed

Lines changed: 25 additions & 25 deletions

File tree

app/controllers/Controller.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ component extends="wheels.Controller" {
102102
// Shared business logic across multiple controllers
103103
public function getBlogBySlug(required string slug) {
104104
return model("Blog").findOne(
105-
where="blog_posts.slug = '#arguments.slug#' AND blog_posts.status = 'Approved' AND blog_posts.publishedAt IS NOT NULL AND blog_posts.publishedAt <= CURRENT_TIMESTAMP",
105+
where="blog_posts.slug = '#arguments.slug#' AND blog_posts.status = 'Approved' AND blog_posts.publishedAt IS NOT NULL AND blog_posts.publishedAt <= '#now()#'",
106106
include="User,PostStatus",
107107
cache=10
108108
);

app/controllers/web/HomeController.cfc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ component extends="app.Controllers.Controller" {
216216
});
217217

218218
// Add blog posts
219-
var blogPosts = model("Blog").findAll(where="blog_posts.statusId <> 1 AND blog_posts.status = 'Approved' AND blog_posts.publishedAt IS NOT NULL AND blog_posts.publishedAt <= CURRENT_TIMESTAMP ");
219+
var blogPosts = model("Blog").findAll(where="blog_posts.statusId <> 1 AND blog_posts.status = 'Approved' AND blog_posts.publishedAt IS NOT NULL AND blog_posts.publishedAt <= '#now()#' ");
220220
for (var post in blogPosts) {
221221
arrayAppend(urls, {
222222
loc: getBaseUrl() & "/blog/" & post.slug,
@@ -231,7 +231,7 @@ component extends="app.Controllers.Controller" {
231231
select="username",
232232
include="User",
233233
distinct="true",
234-
where="blog_posts.statusId <> 1 AND blog_posts.status = 'Approved' AND blog_posts.publishedAt IS NOT NULL AND blog_posts.publishedAt <= CURRENT_TIMESTAMP AND blog_posts.createdBy IS NOT NULL"
234+
where="blog_posts.statusId <> 1 AND blog_posts.status = 'Approved' AND blog_posts.publishedAt IS NOT NULL AND blog_posts.publishedAt <= '#now()#' AND blog_posts.createdBy IS NOT NULL"
235235
);
236236
for (var author in authors) {
237237
arrayAppend(urls, {

app/controllers/web/NewsController.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ component extends="app.Controllers.Controller" {
4343
try {
4444
var blogQuery = model("Blog").findAll(
4545
select = "title, slug, content, postDate",
46-
where = "blog_posts.statusId <> 1 AND blog_posts.status = 'Approved' AND blog_posts.publishedAt IS NOT NULL AND blog_posts.publishedAt <= CURRENT_TIMESTAMP ",
46+
where = "blog_posts.statusId <> 1 AND blog_posts.status = 'Approved' AND blog_posts.publishedAt IS NOT NULL AND blog_posts.publishedAt <= '#now()#' ",
4747
order = "createdAt DESC",
4848
cache = 10
4949
);

app/views/web/BlogController/partials/_blogList.cfm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
<cfset blogUrl = "/blog/#blogs.slug#">
1414
<cfset authorHxGet = "/blog/list/author/#blogs.createdby#?page=1&perPage=6&infiniteScroll=true">
1515
<cfset formattedDate = dateformat(blogs.postDate, 'MMMM DD, YYYY')>
16-
<cfset profileImageTag = '<img src="#gravatarUrl(blogs.email, 80)#"
16+
<cfset profileImageTag = '<img src="#gravatarUrl(blogs.email, 80)#&d=404"
1717
class="rounded-circle"
1818
style="width:2.5rem; height:2.5rem;"
19-
onerror="this.style.display=''none'';this.nextElementSibling.style.display=''flex'';"
19+
onerror="this.classList.add(''d-none'');this.nextElementSibling.classList.remove(''d-none'');"
2020
alt="avatar">
21-
<div style="display:none;width:2.5rem;height:2.5rem;"
22-
class="d-flex align-items-center justify-content-center #getAvatarColorByLetter(ucase(left(listLast(blogs.fullname, " "), 1)))# text-white rounded-circle fw-bold text-uppercase">
21+
<div class="d-none d-flex align-items-center justify-content-center #getAvatarColorByLetter(ucase(left(listLast(blogs.fullname, " "), 1)))# text-white rounded-circle fw-bold text-uppercase"
22+
style="width:2.5rem;height:2.5rem;">
2323
#ucase(left(listLast(blogs.fullName, " "), 1))#
2424
</div>'>
2525

app/views/web/BlogController/show.cfm

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,16 @@
129129
<cfif commentParentId eq '' or commentParentId eq 0>
130130
<div class="d-flex align-items-start gap-3">
131131
<div>
132-
<img src="#gravatarUrl(email, 96)#"
132+
<img src="#gravatarUrl(email, 96)#&d=404"
133133
class="rounded-circle"
134134
style="width:3rem; height:3rem;"
135-
onerror="this.style.display='none';this.nextElementSibling.style.display='flex';"
135+
onerror="this.classList.add('d-none');this.nextElementSibling.classList.remove('d-none');"
136136
alt="avatar">
137-
<div style="display:none;width:3rem;height:3rem;"
138-
class="d-flex align-items-center justify-content-center #getAvatarColorByLetter(ucase(left(listLast(fullName, ' '), 1)))# text-white rounded-circle fw-bold text-uppercase">
137+
<div class="d-none d-flex align-items-center justify-content-center #getAvatarColorByLetter(ucase(left(listLast(fullName, ' '), 1)))# text-white rounded-circle fw-bold text-uppercase"
138+
style="width:3rem;height:3rem;">
139139
#ucase(left(listLast(fullName, " "), 1))#
140140
</div>
141-
</div>
141+
</div>
142142
<div class="p-3 rounded-4 flex-grow-1 bg-light">
143143
<h6 class="fs-16 fw-bold">#fullName#</h6>
144144
<cfif findNoCase("```", content) OR findNoCase("##", content) OR findNoCase("**", content) OR findNoCase("__", content) OR findNoCase(">", content)>
@@ -186,18 +186,18 @@
186186
<div class="mt-4">
187187
<div class="d-flex align-items-start gap-3 position-relative" style="margin-left: 70px;">
188188
<div>
189-
<img src="#gravatarUrl(email, 96)#"
189+
<img src="#gravatarUrl(session.email, 96)#&d=404"
190190
class="rounded-circle"
191191
style="width:3rem; height:3rem;"
192-
onerror="this.style.display='none';this.nextElementSibling.style.display='flex';"
192+
onerror="this.classList.add('d-none');this.nextElementSibling.classList.remove('d-none');"
193193
alt="avatar">
194-
<div style="display:none;width:3rem;height:3rem;"
195-
class="d-flex align-items-center justify-content-center #getAvatarColorByLetter(ucase(left(listLast(fullName, ' '), 1)))# text-white rounded-circle fw-bold text-uppercase">
196-
#ucase(left(listLast(fullName, " "), 1))#
194+
<div class="d-none d-flex align-items-center justify-content-center #getAvatarColorByLetter(ucase(left(listLast(session.username, ' '), 1)))# text-white rounded-circle fw-bold text-uppercase"
195+
style="width:3rem;height:3rem;">
196+
#ucase(left(listLast(session.username, " "), 1))#
197197
</div>
198-
</div>
198+
</div>
199199
<div class="p-3 rounded-4 flex-grow-1 bg-light">
200-
<h6 class="fs-16 fw-bold">#fullName#</h6>
200+
<h6 class="fs-16 fw-bold">#session.username#</h6>
201201

202202
<cfif findNoCase("```", content) OR findNoCase("##", content) OR findNoCase("**", content) OR findNoCase("__", content) OR findNoCase(">", content)>
203203
<p class="fs-14 fw-normal text-dark markdown-content">#encodeForHTML(content)#</p>
@@ -220,14 +220,14 @@
220220
<cfif isLoggedInUser() AND canUserComment()>
221221
<form hx-target="##comment" hx-on:htmx:after-request="handleClear()" hx-swap="beforeend" id="commentForm" hx-post="/blog/comment" class="pt-3 px-1 needs-validation" novalidate hx-validate="true">
222222
<div class="d-flex gap-3 align-items-start">
223-
<img src="#gravatarUrl(session.email, 96)#"
223+
<img src="#gravatarUrl(session.email, 96)#&d=404"
224224
class="rounded-circle"
225225
style="width:3rem; height:3rem;"
226-
onerror="this.style.display='none';this.nextElementSibling.style.display='flex';"
226+
onerror="this.classList.add('d-none');this.nextElementSibling.classList.remove('d-none');"
227227
alt="avatar">
228-
<div style="display:none;width:3rem;height:3rem;"
229-
class="d-flex align-items-center justify-content-center #getAvatarColorByLetter(ucase(left(listLast(session.USERNAME, ' '), 1)))# text-white rounded-circle fw-bold text-uppercase">
230-
#ucase(left(listLast(session.USERNAME, " "), 1))#
228+
<div class="d-none d-flex align-items-center justify-content-center #getAvatarColorByLetter(ucase(left(listLast(session.username, ' '), 1)))# text-white rounded-circle fw-bold text-uppercase"
229+
style="width:3rem;height:3rem;">
230+
#ucase(left(listLast(session.username, " "), 1))#
231231
</div>
232232
<div class="flex-grow-1 gap-2 d-flex justify-content-between align-items-center">
233233
<input class="form-control" type="hidden" name="blogId" id="blogId" value="#blog.Id#">

0 commit comments

Comments
 (0)