Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Faisal N committed Oct 10, 2023
1 parent 26d6dcf commit 2e4e075
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 15 deletions.
4 changes: 2 additions & 2 deletions frontend/pages/article.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div class="left">
<div class="info">
<h1><%= article.title %></h1>
<h3><%= article.description %></h3>
<% if (article.description != null) { %><h3><%= article.description.slice(0, 97) %>...</h3><% } %>
<h5><%= pageviews %> Views</h5>
<p>Tags: <% for (tag of article.tags) { %><a href="<%- vars.domain %>/tags/<%= tag %>"><%= toTitleCase(tag) %></a> <% } %></p>
</div>
Expand All @@ -47,7 +47,7 @@
<% } %>
</div>
<% } %>
<style>.article-i .content:before { content: '(<% if ((article.author != "") && (article.author != null)) { %><%= article.author %><% } else { %><%= cms.siteDetails[0].title %> Writers<% } %>) — ' }</style>
<style>.article-i .content:before { content: '(<% if ((article.author != "") && (article.author != null)) { %><%- article.author %><% } else { %><%= cms.siteDetails[0].title %> Writers<% } %>) — ' }</style>
<div class="content"><%- article.content.replaceAll('/.spaces/', vars.asset_url) %></div>
<div class="comments">
<h1>Comments</h1>
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/articles.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<a href="<%- vars.domain %>/articles/<%= new Date(article.date).getFullYear() %>/<%= article.slug %>">
<h3><%= article.title %></h3>
</a>
<h4><%= article.description %></h4>
<% if (article.description != null) { %><h4><%= article.description.slice(0, 97) %>...</h4><% } %>
<p><a href="<%- vars.domain %>/tags/<%= article.tags[0].toLowerCase() %>"><%= article.tags[0] %></a> / <% var date = new Date(article.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((article.author != "") && (article.author != null)) { %> / <%= article.author %><% } %></p>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions frontend/pages/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
<h2>Latest Articles</h2>
<hr>
<div class="grid">
<% for (article of cms.articles.sort((a, b) => new Date(b.date) - new Date(a.date))) { %>
<% for (let i = 0; i < 3 && i < cms.articles.length; i++) { const article = cms.articles.sort((a, b) => new Date(b.date) - new Date(a.date))[i]; %>
<div class="article" style="<% if (article.images[0] != null) { %>background-image: url('<%- vars.asset_prefix %><%= article.images[0].path %>')<% } else { %>padding-top: unset !important; justify-content: center; height: 100%;<% } %>">
<div class="inner">
<a href="<%- vars.domain %>/articles/<%= new Date(article.date).getFullYear() %>/<%= article.slug %>">
<h3><%= article.title %></h3>
</a>
<h4><%= article.description %></h4>
<% if (article.description != null) { %><h4><%= article.description.slice(0, 97) %>...</h4><% } %>
<p><a href="<%- vars.domain %>/tags/<%= article.tags[0].toLowerCase() %>"><%= article.tags[0] %></a> / <% var date = new Date(article.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((article.author != "") && (article.author != null)) { %> / <%= article.author %><% } %></p>
</div>
</div>
Expand All @@ -54,13 +54,13 @@
<h2>Latest Artwork</h2>
<hr>
<div class="grid">
<% for (artwork of cms.artworks.sort((a, b) => new Date(b.date) - new Date(a.date))) { %>
<% for (let i = 0; i < 3 && i < cms.artworks.length; i++) { const artwork = cms.artworks.sort((a, b) => new Date(b.date) - new Date(a.date))[i]; %>
<div class="article" style="background-image: url('<%- vars.asset_prefix %><%= artwork.artwork.path %>'); padding-top: 300px;">
<div class="inner">
<a href="<%- vars.domain %>/artworks/<%= artwork.slug %>">
<h3><%= artwork.title %></h3>
</a>
<p><a href="<%- vars.domain %>/tags/<%= article.tags[0].toLowerCase() %>"><%= article.tags[0] %></a> / <% var date = new Date(article.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((article.author != "") && (article.author != null)) { %> / <%= article.author %><% } %></p>
<p><a href="<%- vars.domain %>/tags/<%= artwork.tags[0].toLowerCase() %>"><%= artwork.tags[0] %></a> / <% var date = new Date(artwork.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((artwork.author != "") && (artwork.author != null)) { %> / <%= artwork.author %><% } %></p>
</div>
</div>
<% } %>
Expand Down
3 changes: 3 additions & 0 deletions frontend/pages/newspaper.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<div class="content">
<% for (article of newspaper.articles) { article = cms.articles.find(a => a._id === article._id); if (article) { %>
<h2><%= article.title %></h2>
<style>.article-i .content:before { content: '(<% if ((article.author != "") && (article.author != null)) { %><%- article.author %><% } else { %><%= cms.siteDetails[0].title %> Writers<% } %>) — ' }</style>
<%- article.content.replaceAll('/.spaces/', vars.asset_url) %>
<br />
<% } } %>
Expand All @@ -52,6 +53,7 @@
<div class="content mobileOnly">
<% for (article of newspaper.articles) { article = cms.articles.find(a => a._id === article._id); if (article) { %>
<h2><%= article.title %></h2>
<style>.article-i .content:before { content: '(<% if ((article.author != "") && (article.author != null)) { %><%- article.author %><% } else { %><%= cms.siteDetails[0].title %> Writers<% } %>) — ' }</style>
<%- article.content.replaceAll('/.spaces/', vars.asset_url) %>
<br />
<% } } %>
Expand All @@ -61,6 +63,7 @@
<div class="content">
<% for (article of newspaper.articles) { article = cms.articles.find(a => a._id === article._id); if (article) { %>
<h2><%= article.title %></h2>
<style>.article-i .content:before { content: '(<% if ((article.author != "") && (article.author != null)) { %><%- article.author %><% } else { %><%= cms.siteDetails[0].title %> Writers<% } %>) — ' }</style>
<%- article.content.replaceAll('/.spaces/', vars.asset_url) %>
<br />
<% } } %>
Expand Down
5 changes: 2 additions & 3 deletions frontend/pages/search.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
<%- include('../partials/head.ejs'); %>
<% const filteredArticles = cms.articles.filter(article => {
const title = article.title.toLowerCase();
const description = (article.description || "").toLowerCase();
const content = article.content.toLowerCase();
return title.includes(query) || description.includes(query) || content.includes(query);
return title.includes(query) || content.includes(query);
});
const filteredNewspapers = cms.newspapers.filter(newspaper => newspaper.title.toLowerCase().includes(query));
var tags = {};
Expand Down Expand Up @@ -61,7 +60,7 @@
<a href="<%- vars.domain %>/articles/<%= new Date(article.date).getFullYear() %>/<%= article.slug %>">
<h3>Article: <%= article.title %></h3>
</a>
<h4><%= article.description %></h4>
<% if (article.description != null) { %><h4><%= article.description.slice(0, 97) %>...</h4><% } %>
<p><a href="<%- vars.domain %>/tags/<%= article.tags[0].toLowerCase() %>"><%= article.tags[0] %></a> / <% var date = new Date(article.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((article.author != "") && (article.author != null)) { %> / <%= article.author %><% } %></p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/tag.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<a href="<%- vars.domain %>/articles/<%= new Date(article.date).getFullYear() %>/<%= article.slug %>">
<h3><%= article.title %></h3>
</a>
<h4><%= article.description %></h4>
<h4><%= article.description.slice(0, 97) %>...</h4>
<p><a href="<%- vars.domain %>/tags/<%= article.tags[0].toLowerCase() %>"><%= article.tags[0] %></a> / <% var date = new Date(article._created * 1000); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %></p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/partials/suggested.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function ifYesterday(date) {
<a href="<%- vars.domain %>/articles/<%= new Date(article.date).getFullYear() %>/<%= article.slug %>">
<h3><%= article.title %></h3>
</a>
<h4><%= article.description %></h4>
<% if (article.description != null) { %><h4><%= article.description.slice(0, 97) %>...</h4><% } %>
<p><a href="<%- vars.domain %>/tags/<%= article.tags[0].toLowerCase() %>"><%= article.tags[0] %></a> / <% var date = new Date(article.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((article.author != "") && (article.author != null)) { %> / <%= article.author %><% } %></p>
</div>
</div>
Expand Down
6 changes: 4 additions & 2 deletions frontend/public/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ header .main .search form input::placeholder {
flex-direction: column;
justify-content: flex-end;
background-color: var(--background);
background-size: contain;
background-size: cover;
background-position: bottom;
border-bottom: 4px solid #ececec;
transition: 0.25s;
padding-top: 150px;
Expand Down Expand Up @@ -579,7 +580,8 @@ header .main .search form input::placeholder {
}

.article-i .content * {
margin: 10px 0;
margin: 10px 0;
font-weight: revert !important;
}

.article-i .content b {
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ async function startApp() {
}
],
date: new Date(post.date),
image: `${defaults.asset_prefix}${post.images[0].path}`
image: (post.images[0]) ? `${defaults.asset_prefix}${post.images[0].path}` : ""
});
});
res.set('Content-Type', 'text/xml');
Expand All @@ -440,6 +440,7 @@ async function startApp() {
});

app.use(async (err, req, res, next) => {
console.log(err);
return res.render('error', { error: 'internal server error; check logs' });
});

Expand Down

0 comments on commit 2e4e075

Please sign in to comment.