fleet/website/api/controllers/view-testimonials.js
Jordan Montgomery 2808331296
Add heteronymous reddit testimonial (#27910)
# Checklist for submitter

Adds new Reddit sourced testimonial:
![Screenshot 2025-04-04 at 4 38
25 PM](https://github.com/user-attachments/assets/6c2a62ef-166e-49fe-a7b0-cbc7227cc136)
2025-04-08 10:20:06 -05:00

134 lines
4.2 KiB
JavaScript
Vendored

module.exports = {
friendlyName: 'View testimonials',
description: 'Display "Testimonials" page.',
exits: {
success: {
viewTemplatePath: 'pages/testimonials'
}
},
fn: async function () {
if (!_.isObject(sails.config.builtStaticContent) || !_.isArray(sails.config.builtStaticContent.testimonials) || !sails.config.builtStaticContent.compiledPagePartialsAppPath) {
throw {badConfig: 'builtStaticContent.testimonials'};
}
// Get testimonials for the page contents
let testimonials = _.clone(sails.config.builtStaticContent.testimonials);
// Filter the testimonials by product category
let testimonialOrderForMdm = [
'Scott MacVicar',
'Mike Meyer',
'Tom Larkin',
'Kenny Botelho',
'Erik Gomez',
'Chandra Majumdar',
'Eric Tan',
'Matt Carr',
'Nico Waisman',
'Dan Grzelak',
'u/Heteronymous',
];
let testimonialsForMdm = _.filter(testimonials, (testimonial)=>{
return _.contains(testimonial.productCategories, 'Device management') && _.contains(testimonialOrderForMdm, testimonial.quoteAuthorName);
});
testimonialsForMdm.sort((a, b)=>{
if(testimonialOrderForMdm.indexOf(a.quoteAuthorName) === -1){
return 1;
} else if(testimonialOrderForMdm.indexOf(b.quoteAuthorName) === -1) {
return -1;
}
return testimonialOrderForMdm.indexOf(a.quoteAuthorName) - testimonialOrderForMdm.indexOf(b.quoteAuthorName);
});
let testimonialOrderForSoftwareManagement = [
'Luis Madrigal',
'Arsenio Figueroa',
'Bart Reardon',
'Andre Shields',
'Wes Whetstone',
'Nico Waisman',
'Chandra Majumdar',
'Kenny Botelho',
'Erik Gomez',
'Eric Tan',
'Dan Grzelak',
];
let testimonialsForSoftwareManagement = _.filter(testimonials, (testimonial)=>{
return _.contains(testimonial.productCategories, 'Software management') && _.contains(testimonialOrderForSoftwareManagement, testimonial.quoteAuthorName);
});
testimonialsForSoftwareManagement.sort((a, b)=>{
if(testimonialOrderForSoftwareManagement.indexOf(a.quoteAuthorName) === -1){
return 1;
} else if(testimonialOrderForSoftwareManagement.indexOf(b.quoteAuthorName) === -1) {
return -1;
}
return testimonialOrderForSoftwareManagement.indexOf(a.quoteAuthorName) - testimonialOrderForSoftwareManagement.indexOf(b.quoteAuthorName);
});
let testimonialOrderForObservability = [
'Ahmed Elshaer',
'Brendan Shaklovitz',
'Arsenio Figueroa',
'Luis Madrigal',
'Andre Shields',
'Tom Larkin',
'Eric Tan',
'Charles Zaffery',
'Kenny Botelho',
'Scott MacVicar',
'Erik Gomez',
'Mike Arpaia',
'Chandra Majumdar',
'Justin LaBo',
'tom larkin',
];
let testimonialsForObservability = _.filter(testimonials, (testimonial)=>{
return _.contains(testimonial.productCategories, 'Observability') && _.contains(testimonialOrderForObservability, testimonial.quoteAuthorName);
});
testimonialsForObservability.sort((a, b)=>{
if(testimonialOrderForObservability.indexOf(a.quoteAuthorName) === -1){
return 1;
} else if(testimonialOrderForObservability.indexOf(b.quoteAuthorName) === -1) {
return -1;
}
return testimonialOrderForObservability.indexOf(a.quoteAuthorName) - testimonialOrderForObservability.indexOf(b.quoteAuthorName);
});
let testimonialsWithVideoLinks = _.filter(testimonials, (testimonial)=>{
return testimonial.youtubeVideoUrl;
});
// Get articles with a showOnTestimonialsPageWithEmoji meta tag to display on this page.
let articles = sails.config.builtStaticContent.markdownPages.filter((page)=>{
if(_.startsWith(page.htmlId, 'articles')) {
return page;
}
});
let articlesForThisPage = _.filter(articles, (article)=>{
return article.meta.showOnTestimonialsPageWithEmoji;
});
// Sort the articles by their publish date.
articlesForThisPage = _.sortBy(articlesForThisPage, 'meta.publishedOn');
return {
testimonialsForMdm,
testimonialsForSoftwareManagement,
testimonialsForObservability,
testimonialsWithVideoLinks,
articlesForThisPage,
};
}
};