diff --git a/frontend/pages/newspaper.ejs b/frontend/pages/newspaper.ejs index ad0c2f8..fe0396b 100644 --- a/frontend/pages/newspaper.ejs +++ b/frontend/pages/newspaper.ejs @@ -39,33 +39,33 @@

Unable to display PDF file, you may have Javascript disabled. No worries, you can download the PDF version instead!

<% if (newspaper.articles.length != 0) { %>
- <% for (article of newspaper.articles) { article = cms.articles.find(a => a._id === article._id); %> + <% for (article of newspaper.articles) { article = cms.articles.find(a => a._id === article._id); if (article) { %>

<%= article.title %>

<%- article.content.replaceAll('/.spaces/', vars.asset_url) %>
- <% }%> + <% } } %>
- <% }%> + <% } %> Click here to open the PDF file. <% if (newspaper.articles.length != 0) { %>
- <% for (article of newspaper.articles) { article = cms.articles.find(a => a._id === article._id); %> + <% for (article of newspaper.articles) { article = cms.articles.find(a => a._id === article._id); if (article) { %>

<%= article.title %>

<%- article.content.replaceAll('/.spaces/', vars.asset_url) %>
- <% }%> + <% } } %>
- <% }%> + <% } %> <% } else if (newspaper.articles.length != 0) { %>
- <% for (article of newspaper.articles) { article = cms.articles.find(a => a._id === article._id); %> + <% for (article of newspaper.articles) { article = cms.articles.find(a => a._id === article._id); if (article) { %>

<%= article.title %>

<%- article.content.replaceAll('/.spaces/', vars.asset_url) %>
- <% }%> + <% } } %>
- <% }%> + <% } %>

Comments

@@ -76,12 +76,13 @@
- <% if (comments.length > 0) { %>
<% } %> + <% if (comments.length > 0) { %> +
<% } %> <% for (comment of comments.reverse()) { %>

<%= comment.author_name %> -

<% var date = new Date(comment.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %>
-

<%= comment.content %>

+
<% var date = new Date(comment.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %>
+

<%= comment.content %>

<% } %>
diff --git a/frontend/partials/footer.ejs b/frontend/partials/footer.ejs index 95a0cf9..8ac7110 100644 --- a/frontend/partials/footer.ejs +++ b/frontend/partials/footer.ejs @@ -8,6 +8,7 @@
<%- include('socials.ejs') %>

© <%= cms.siteDetails[0].title %> <%= cms.siteDetails[0].est %> - <%= new Date().getFullYear() %> | Admin (Host) | <%- vars.environment.replace(/\w\S*/g, function(txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase() }) %> Version | <%= pageviews %> Views

+

We use cookies for analytics and security.

diff --git a/frontend/public/css/styles.css b/frontend/public/css/styles.css index a44da00..40b0321 100644 --- a/frontend/public/css/styles.css +++ b/frontend/public/css/styles.css @@ -7,12 +7,15 @@ } .hero .newspaper { + height: 25vh; + } + + .hero .newspaper:first-of-type { height: 100%; } .hero .side { width: 100%; - height: 100%; } .articles .grid { @@ -751,7 +754,6 @@ footer .inner .bottom { display: flex; flex-direction: column; align-items: center; - gap: 10px; width: 75%; color: var(--text); font-size: 12px; @@ -775,6 +777,7 @@ footer .inner .bottom a { justify-content: center; opacity: 0; transition: opacity 0.2s ease-in-out; + z-index: 100; } .toTop.visible { diff --git a/index.js b/index.js index ed591cc..91ab2e2 100644 --- a/index.js +++ b/index.js @@ -36,7 +36,10 @@ app.set('trust proxy', true); app.use(cookieParser()); app.use(rateLimit({ windowMs: 60 * 1000, - max: 15 + max: 15, + skip: (req, res) => { + return req.ip !== undefined; + } })); app.use((req, res, next) => { if (req.method === 'GET') { @@ -54,7 +57,7 @@ app.use((req, res, next) => { body: new URLSearchParams(pageviewData), }) .then(() => { - db.query('INSERT INTO pageviews (url, count) VALUES (?, 1) ON DUPLICATE KEY UPDATE count = count + 1', [req.originalUrl], (err, results) => { + db.query('INSERT INTO pageviews (url, count) VALUES (?, 1) ON DUPLICATE KEY UPDATE count = IF(TIMESTAMPDIFF(HOUR, timestamp, NOW()) <= 1, count, count + 1), timestamp = IF(TIMESTAMPDIFF(HOUR, timestamp, NOW()) <= 1, timestamp, NOW());', [req.originalUrl], (err, results) => { if (err) { console.error('Error tracking pageview:', err); }; @@ -184,13 +187,11 @@ async function startApp() { await allRoutes(req, res); var newspaper = cms.newspapers.find(newspaper => newspaper.slug === req.params.newspaper); if (newspaper && req.body.id && (req.body.name.length > 0) && (req.body.email.includes('.')) && (req.body.email.length > 0) && (req.body.content.length > 0)) { - db.prepare("INSERT INTO comments (author_name, author_email, post_id, content) VALUES (?, ?, ?, ?)", (err, statement) => { - statement.execute([req.body.name, req.body.email, req.body.id, req.body.content], function (err, results, fields) { - if (err) { - console.log(err); - }; - res.redirect(`/newspapers/${req.params.newspaper}#${results.insertId}`); - }); + db.query("INSERT INTO comments (author_name, author_email, post_id, content) VALUES (?, ?, ?, ?)", [req.body.name, req.body.email, req.body.id, req.body.content], function (err, results, fields) { + if (err) { + console.log(err); + }; + res.redirect(`/newspapers/${req.params.newspaper}#${results.insertId}`); }); } else { res.redirect('/'); @@ -220,13 +221,11 @@ async function startApp() { await allRoutes(req, res); var article = cms.articles.find(article => article.slug === req.params.article); if (article && req.body.id && (req.body.name.length > 0) && (req.body.email.includes('.')) && (req.body.email.length > 0) && (req.body.content.length > 0)) { - db.prepare("INSERT INTO comments (author_name, author_email, post_id, content) VALUES (?, ?, ?, ?)", (err, statement) => { - statement.execute([req.body.name, req.body.email, req.body.id, req.body.content], function (err, results, fields) { - if (err) { - console.log(err); - }; - res.redirect(`/articles/${req.params.article}#${results.insertId}`); - }); + db.query("INSERT INTO comments (author_name, author_email, post_id, content) VALUES (?, ?, ?, ?)", [req.body.name, req.body.email, req.body.id, req.body.content], function (err, results, fields) { + if (err) { + console.log(err); + }; + res.redirect(`/articles/${req.params.article}#${results.insertId}`); }); } else { res.redirect('/'); @@ -258,7 +257,6 @@ async function startApp() { voteId = uuid.v4(); res.cookie('voteId', voteId); }; - console.log(voteId); var poll = cms.polls.find(poll => poll.slug === req.params.poll); if (poll) { db.query(`SELECT * FROM poll_responses WHERE poll_id = '${poll._id}'`, @@ -308,13 +306,11 @@ async function startApp() { } ); } else if (poll && req.body.id && (req.body.name.length > 0) && (req.body.email.includes('.')) && (req.body.email.length > 0) && (req.body.content.length > 0)) { - db.prepare("INSERT INTO comments (author_name, author_email, post_id, content) VALUES (?, ?, ?, ?)", (err, statement) => { - statement.execute([req.body.name, req.body.email, req.body.id, req.body.content], function (err, results, fields) { - if (err) { - console.log(err); - }; - res.redirect(`/polls/${req.params.poll}#${results.insertId}`); - }); + db.query("INSERT INTO comments (author_name, author_email, post_id, content) VALUES (?, ?, ?, ?)", [req.body.name, req.body.email, req.body.id, req.body.content], function (err, results, fields) { + if (err) { + console.log(err); + }; + res.redirect(`/polls/${req.params.poll}#${results.insertId}`); }); } else { res.redirect('/');