From f07b724e31beaaa48a9f1496fc07d505d28e3a2d Mon Sep 17 00:00:00 2001
From: Ethan Richards <42894274+ezrichards@users.noreply.github.com>
Date: Sun, 11 Aug 2024 21:07:34 -0600
Subject: [PATCH 01/20] add socials footer tab
---
views/layouts/base.ejs | 1 +
views/partials/footer.ejs | 12 ++++++++++++
2 files changed, 13 insertions(+)
diff --git a/views/layouts/base.ejs b/views/layouts/base.ejs
index 728c91d..6aad336 100644
--- a/views/layouts/base.ejs
+++ b/views/layouts/base.ejs
@@ -14,6 +14,7 @@
+
<%- include('../partials/navbar')%>
diff --git a/views/partials/footer.ejs b/views/partials/footer.ejs
index 0cfb1e6..7b756ae 100644
--- a/views/partials/footer.ejs
+++ b/views/partials/footer.ejs
@@ -40,6 +40,18 @@
class="nav-link p-0">Data Analytix @ Mines (DAAM)
+
+
Officers
<% for(let officer of officers) { %>
-
<%= officer.name %> | <%= officer.title %>
+
<%= officer.name %>, <%= officer.title %>
<%= officer.id + "@mines.edu" %>
diff --git a/views/home.ejs b/views/home.ejs
index 0de7fbf..6632ab7 100644
--- a/views/home.ejs
+++ b/views/home.ejs
@@ -29,7 +29,7 @@
<% } else { %>
-
+
<% } %>
<% } %>
<% } else { %>
diff --git a/views/schedule.ejs b/views/schedule.ejs
index 6bbbd8e..f0ad340 100644
--- a/views/schedule.ejs
+++ b/views/schedule.ejs
@@ -14,7 +14,7 @@
<% for(let meeting of upcoming) { %>
-
+
<%= meeting.title %>
From ee5bc7454c8414a00f800ec13a11ad432c4c23a5 Mon Sep 17 00:00:00 2001
From: Ethan Richards <42894274+ezrichards@users.noreply.github.com>
Date: Mon, 12 Aug 2024 17:51:59 -0600
Subject: [PATCH 08/20] update DB for gallery
---
database/init_database.sql | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/database/init_database.sql b/database/init_database.sql
index c4b18d6..23c0612 100644
--- a/database/init_database.sql
+++ b/database/init_database.sql
@@ -56,7 +56,8 @@ CREATE TABLE IF NOT EXISTS rsvps (
CREATE TABLE IF NOT EXISTS images (
"id" TEXT PRIMARY KEY,
- "caption" TEXT
+ "caption" TEXT,
+ "active" BOOLEAN
);
CREATE TABLE IF NOT EXISTS presentations (
From ebc59e40db3cebae7278086730e3cd2919d69167 Mon Sep 17 00:00:00 2001
From: Ethan Richards <42894274+ezrichards@users.noreply.github.com>
Date: Mon, 12 Aug 2024 17:52:13 -0600
Subject: [PATCH 09/20] Update gallery with active image toggle
---
app.js | 8 ++++++++
views/gallery.ejs | 20 ++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/app.js b/app.js
index 738b535..711b605 100644
--- a/app.js
+++ b/app.js
@@ -152,6 +152,14 @@ app.get(
}),
);
+app.post(
+ "/gallery",
+ fallible(async (req, res) => {
+ await db.query("UDPATE images SET active = $1 WHERE id = $2", [req.body.active, req.body.image_id]);
+ res.redirect("/gallery");
+ }),
+);
+
app.get(
"/uploads/:id",
fallible(async (req, res) => {
diff --git a/views/gallery.ejs b/views/gallery.ejs
index ded0a75..24bc459 100644
--- a/views/gallery.ejs
+++ b/views/gallery.ejs
@@ -18,6 +18,26 @@
<%= image.caption %>
+
+
+ <% if(typeof user=='object' && user) { %>
+ <% if(user.is_admin) { %>
+
Admin Actions
+
+ <% } %>
+ <% } %>
From 69d029e4e0689434d3630b3d666da9a2dc96f610 Mon Sep 17 00:00:00 2001
From: Ethan Richards <42894274+ezrichards@users.noreply.github.com>
Date: Mon, 12 Aug 2024 21:51:57 -0600
Subject: [PATCH 10/20] Add gallery updating admin toggle
---
app.js | 3 ++-
middleware.js | 2 ++
views/gallery.ejs | 6 ++++--
3 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/app.js b/app.js
index 711b605..b380207 100644
--- a/app.js
+++ b/app.js
@@ -155,7 +155,8 @@ app.get(
app.post(
"/gallery",
fallible(async (req, res) => {
- await db.query("UDPATE images SET active = $1 WHERE id = $2", [req.body.active, req.body.image_id]);
+ const active = req.body.active === 'true' || req.body.activeHidden === 'false';
+ await db.query("UPDATE images SET active = $1 WHERE id = $2", [active, req.body.image_id]);
res.redirect("/gallery");
}),
);
diff --git a/middleware.js b/middleware.js
index 67e0342..2fa5169 100644
--- a/middleware.js
+++ b/middleware.js
@@ -15,6 +15,8 @@ module.exports.isLoggedIn = (req, res, next) => {
};
module.exports.isAdminAuthenticated = (req, res, next) => {
+ // TODO add debug/dev env check here?
+
if (req.user == undefined || !req.user.is_admin || !req.isAuthenticated()) {
req.session.returnTo = req.originalUrl;
req.user = false;
diff --git a/views/gallery.ejs b/views/gallery.ejs
index 24bc459..5b33712 100644
--- a/views/gallery.ejs
+++ b/views/gallery.ejs
@@ -25,10 +25,12 @@
Admin Actions