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

Commit a91d07f

Browse files
authored
Merge pull request #44 from paiindustries/fix/site-issues
Fix/site issues
2 parents bc84c66 + b6d97f9 commit a91d07f

23 files changed

Lines changed: 1203 additions & 257 deletions

.env-testing

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ wheelsdev_connectionlimit=100
1212
wheelsdev_storage=true
1313
wheelsdev_bundleversion=12.6.3.jre11
1414

15+
wheelsdev_storage=true
16+
sessionStorage=wheels.dev
17+
sessionCluster=true
18+
1519
mail_from=noreply@wheels.dev
1620

1721
smtp_host=smtp.postmarkapp.com

app/config/app.cfm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
*/
99
1010
this.name = "wheels.dev";
11+
12+
// Set the session timeout (based on inactivity days,hours,minutes,seconds)
13+
this.sessionManagement = true;
14+
this.sessionTimeout = CreateTimeSpan(0,2,0,0);
15+
this.sessioncookie = {timeout=createTimeSpan(0,2,0,0)};
16+
this.sessionStorage = this.env.sessionStorage;
17+
this.sessionCluster = this.env.sessionCluster;
1118
1219
this.bufferOutput = true;
1320

app/config/routes.cfm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
.get(name = "profile", pattern = "user/profile", to = "web.AuthController##profile")
3131
3232
// Admin Controls
33-
.get(name = "admin-index", pattern = "admin", to = "web.AdminController##index")
33+
// .get(name = "admin-index", pattern = "admin", to = "web.AdminController##index")
3434
.get(name = "admin-blog", pattern = "admin/blog", to = "web.AdminController##blog")
3535
.get(name = "admin-show-blog", pattern = "admin/blog/[slug]", to = "web.AdminController##showBlog")
3636
.get(name = "blog-List", pattern = "admin/blog/list", to = "web.AdminController##blogList")
@@ -85,9 +85,14 @@
8585
.get(name="approve_testimonial", pattern="testimonial/approve/[key]", to="web.testimonials##approve")
8686
.get(name="feature_testimonial", pattern="testimonial/feature/[key]", to="web.testimonials##feature")
8787
.get(name="delete_testimonial", pattern="testimonial/delete/[key]", to="web.testimonials##delete")
88+
.get(name="admin-testimonials", pattern="admin/testimonials", to="web.adminTestimonialController##testimonials")
89+
.get(name = "admin-view-testimonials", pattern = "admin/testimonials/view/[id]", to = "web.adminTestimonialController##testimonialDetails")
90+
.post(name = "admin-approve-testimonials", pattern = "admin/testimonials/approve", to = "web.adminTestimonialController##approve")
91+
.post(name = "admin-reject-testimonials", pattern = "admin/testimonials/reject", to = "web.adminTestimonialController##reject")
8892
8993
.post(name="clear_testimonial_prompt", pattern="testimonial/clear-prompt", to="web.Testimonial##clearPromptFlag") // Use POST to indicate an action
9094
95+
.get(name="admin-dashboard", pattern="admin", to="web.dashboardController##dashboard")
9196
// routes for testimonials
9297
.resources("web.testimonial")
9398
.end()

app/controllers/web/AdminController.cfc

Lines changed: 172 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ component extends="app.Controllers.Controller" {
1414

1515
function blog() {
1616
blogs = getAllBlogs();
17-
17+
1818
}
1919

2020
function approve() {
@@ -222,11 +222,27 @@ component extends="app.Controllers.Controller" {
222222

223223
private function blogApproval(id){
224224
var blog = model("Blog").findByKey(id);
225-
225+
var user = model("user").findByKey(blog.createdby);
226+
226227
if (!isNull(blog)) {
227228

228229
blog.status = "Approved"; //approved
229230
if (blog.save()) {
231+
siteurl = "http://#cgi.http_host#/blog/#blog.slug#";
232+
emailContent = generateApprovalEmail(siteurl);
233+
cfheader(name="Content-Type" value="text/html; charset=UTF-8");
234+
cfmail(
235+
to = "#user.email#",
236+
from = "#application.env.mail_from#",
237+
subject = "Your blog post has been approved and published",
238+
server = "#application.env.smtp_host#",
239+
port = "#application.env.smtp_port#",
240+
username = "#application.env.smtp_username#",
241+
password = "#application.env.smtp_password#",
242+
type = "html"
243+
) {
244+
writeOutput(emailContent);
245+
};
230246
return {
231247
success = true,
232248
message = "blog status approved successfully"
@@ -248,12 +264,28 @@ component extends="app.Controllers.Controller" {
248264

249265
private function blogReject(id){
250266
var blog = model("Blog").findByKey(id);
251-
267+
var user = model("user").findByKey(blog.createdby);
268+
252269
if (!isNull(blog)) {
253270

254271
blog.status = "Rejected"; //reject
255272

256273
if (blog.save()) {
274+
siteurl = "http://#cgi.http_host#/blog/#blog.slug#";
275+
emailContent = generateRejectEmail(siteurl);
276+
cfheader(name="Content-Type" value="text/html; charset=UTF-8");
277+
cfmail(
278+
to = "#user.email#",
279+
from = "#application.env.mail_from#",
280+
subject = "Your blog post has been Rejected to publish",
281+
server = "#application.env.smtp_host#",
282+
port = "#application.env.smtp_port#",
283+
username = "#application.env.smtp_username#",
284+
password = "#application.env.smtp_password#",
285+
type = "html"
286+
) {
287+
writeOutput(emailContent);
288+
};
257289
return {
258290
success = true,
259291
message = "blog status rejected successfully"
@@ -272,4 +304,141 @@ component extends="app.Controllers.Controller" {
272304
message = "blog not found"
273305
};
274306
}
307+
308+
private string function generateApprovalEmail(required string siteurl) {
309+
return '
310+
<!DOCTYPE html>
311+
<html>
312+
<head>
313+
<meta charset="UTF-8">
314+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
315+
<title>Approve blog post</title>
316+
<style>
317+
body {
318+
font-family: Arial, sans-serif;
319+
background-color: ##f4f4f4;
320+
margin: 0;
321+
padding: 0;
322+
}
323+
.container {
324+
max-width: 600px;
325+
margin: 40px auto;
326+
background: ##ffffff;
327+
padding: 20px;
328+
border-radius: 8px;
329+
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
330+
text-align: center;
331+
}
332+
.logo {
333+
width: 120px;
334+
margin-bottom: 20px;
335+
}
336+
h1 {
337+
color: ##333;
338+
font-size: 24px;
339+
}
340+
p {
341+
color: ##666;
342+
font-size: 16px;
343+
line-height: 1.5;
344+
}
345+
.button {
346+
display: inline-block;
347+
background-color: ##007BFF;
348+
color: ##ffffff;
349+
text-decoration: none;
350+
font-size: 18px;
351+
padding: 12px 20px;
352+
border-radius: 6px;
353+
margin-top: 20px;
354+
}
355+
.footer {
356+
margin-top: 30px;
357+
font-size: 14px;
358+
color: ##999;
359+
}
360+
</style>
361+
</head>
362+
<body>
363+
364+
<div class="container">
365+
<img src="https://avatars.githubusercontent.com/u/159224?s=200&v=4" alt="Bootstrap" width="260">
366+
<h1>Welcome to Wheels.dev!</h1>
367+
<p>Thank you for writing a blog post. Your post has been approved and published on the Wheels website.</p>
368+
<a href="' & siteurl & '" class="button">View Your Post</a>
369+
<p class="footer">If you did not write blog, you can safely ignore this email.</p>
370+
</div>
371+
372+
</body>
373+
</html>
374+
';
375+
}
376+
377+
private string function generateRejectEmail(required string siteurl) {
378+
return '
379+
<!DOCTYPE html>
380+
<html>
381+
<head>
382+
<meta charset="UTF-8">
383+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
384+
<title>Reject blog post</title>
385+
<style>
386+
body {
387+
font-family: Arial, sans-serif;
388+
background-color: ##f4f4f4;
389+
margin: 0;
390+
padding: 0;
391+
}
392+
.container {
393+
max-width: 600px;
394+
margin: 40px auto;
395+
background: ##ffffff;
396+
padding: 20px;
397+
border-radius: 8px;
398+
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
399+
text-align: center;
400+
}
401+
.logo {
402+
width: 120px;
403+
margin-bottom: 20px;
404+
}
405+
h1 {
406+
color: ##333;
407+
font-size: 24px;
408+
}
409+
p {
410+
color: ##666;
411+
font-size: 16px;
412+
line-height: 1.5;
413+
}
414+
.button {
415+
display: inline-block;
416+
background-color: ##007BFF;
417+
color: ##ffffff;
418+
text-decoration: none;
419+
font-size: 18px;
420+
padding: 12px 20px;
421+
border-radius: 6px;
422+
margin-top: 20px;
423+
}
424+
.footer {
425+
margin-top: 30px;
426+
font-size: 14px;
427+
color: ##999;
428+
}
429+
</style>
430+
</head>
431+
<body>
432+
433+
<div class="container">
434+
<img src="https://avatars.githubusercontent.com/u/159224?s=200&v=4" alt="Bootstrap" width="260">
435+
<h1>Welcome to Wheels.dev!</h1>
436+
<p>Thank you for writing a blog post. Your post has been rejected and not published on the Wheels website.</p>
437+
<p class="footer">If you did not write post, you can safely ignore this email.</p>
438+
</div>
439+
440+
</body>
441+
</html>
442+
';
443+
}
275444
}

0 commit comments

Comments
 (0)