Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
faisalnjs committed Oct 13, 2023
1 parent ac06605 commit 4fb3cd2
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 18 deletions.
15 changes: 6 additions & 9 deletions frontend/pages/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,12 @@
<hr>
<div class="grid">
<% 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>
<% if (article.description != null) { %><h4><%= article.description.slice(0, 50) %>...</h4><% } %>
<p><% if (article.tags != null) { %><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>
<a class="article" href="<%- vars.domain %>/articles/<%= new Date(article.date).getFullYear() %>/<%= article.slug %>">
<img src="<% if (article.images[0] != null) { %><%- vars.asset_prefix %><%= article.images[0].path %><% } %>" />
<h3><%= article.title %></h3>
<% if (article.description != null) { %><h4><%= article.description.slice(0, 50) %>...</h4><% } %>
<p><% if (article.tags != null) { %><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>
</a>
<% } %>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/partials/footer.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="bottom">
<div class="socials"><%- include('socials.ejs') %></div>
<p>&copy; <%= cms.siteDetails[0].title %> <%= cms.siteDetails[0].est %> - <%= new Date().getFullYear() %> | <a href="<%- vars.domain %>/admin">Admin<a href="https://dangoweb.com/?from=<%= cms.siteDetails[0].title.toLowerCase().replaceAll(' ', '-') %>" style="display: none;"> (Host)</a></a> | <%- vars.environment.replace(/\w\S*/g, function(txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase() }) %> Version | <%= pageviews %> Views</p>
<p>We use cookies for analytics and security.</p>
<p>We use cookies for analytics and security. <a href="<%- vars.domain %>/denycookies">Click here to deny cookies and leave.</a></p>
<!-- We use "Lightbox2" by -->
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/partials/socials.ejs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<% cms.siteDetails[0].socials.sort((a, b) => a._o - b._o); for (item of cms.siteDetails[0].socials) { %>
<% cms.siteDetails[0].socials.sort((a, b) => a._o - b._o); for (item of cms.siteDetails[0].socials.filter(item => { return item.active })) { %>
<a href="<%= item.url %>" title="<%= item.title %>"><i class="fas fa-<%= item.data.icon %>"></i></a>
<% } %>
14 changes: 8 additions & 6 deletions frontend/public/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ header .main .search form input::placeholder {
grid-auto-flow: row;
grid-template-areas: ". . .";
width: 75%;
border-top: 1px solid var(--text);
}

.articles .grid .article {
Expand Down Expand Up @@ -828,6 +829,7 @@ header .main .search form input::placeholder {

footer {
text-align: center;
min-height: calc(100vh - 175px - 80px);
width: 100%;
background-size: cover;
background-position-y: center;
Expand All @@ -841,9 +843,9 @@ footer .inner {
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-end;
justify-content: center;
gap: 20px;
padding: 20px;
padding: 40px 0;
}

footer .inner .top {
Expand All @@ -852,7 +854,7 @@ footer .inner .top {
align-items: center;
gap: 20px;
width: 75%;
padding-bottom: 60px;
padding-bottom: 30px;
border-bottom: 1px solid #5e5e5e;
}

Expand Down Expand Up @@ -885,13 +887,13 @@ footer .inner .bottom {
flex-direction: column;
align-items: center;
width: 75%;
color: var(--text);
color: var(--background);
font-size: 12px;
gap: 15px;
}

footer .inner .bottom a {
color: var(--text);
color: var(--background);
}

footer .inner .bottom p {
Expand All @@ -906,7 +908,7 @@ footer .inner .bottom .socials {
}

footer .inner .bottom .socials i {
border: 1px solid var(--text);
border: 1px solid var(--background);
padding: 15px;
border-radius: 100%;
height: 20px;
Expand Down
22 changes: 21 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@ async function startApp() {

async function allRoutes(req, res) {
cms = (await cmsdata().then(res => res.json())).data;
if (!req.session.cookiesDenied) {
req.session.cookiesDenied = false;
} else if (req.session.cookiesDenied === true) {
res.clearCookie("sessionid");
req.session.destroy();
res.send("You have denied cookies. If you would like to re-enable cookies, click <a href='/enablecookies'>here</a>.");
return false;
} else {
return;
};
};

Date.prototype.isToday = function () {
Expand Down Expand Up @@ -434,6 +444,16 @@ async function startApp() {
res.send(feed.rss2());
});

app.get('/denycookies', async (req, res) => {
req.session.cookiesDenied = true;
res.redirect('/');
});

app.get('/enablecookies', async (req, res) => {
req.session.cookiesDenied = false;
res.redirect('/');
});

app.use(async (req, res, next) => {
await allRoutes(req, res);
return res.render('404', { vars: defaults, title: '404', cms, pageviews: req.pageViews });
Expand All @@ -451,6 +471,6 @@ async function startApp() {
console.log(`Southern Bell listening on port ${port}`);
};
});
}
};

startApp();

0 comments on commit 4fb3cd2

Please sign in to comment.