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) + +
+
Socials
+ +
From d383e7731180184192e0c5eeecc7aea5977a6698 Mon Sep 17 00:00:00 2001 From: Ethan Richards <42894274+ezrichards@users.noreply.github.com> Date: Mon, 12 Aug 2024 08:49:49 -0600 Subject: [PATCH 02/20] Preliminary gallery page --- app.js | 9 ++++++++- public/stylesheets/styles.scss | 5 +++++ views/gallery.ejs | 8 ++++++++ views/home.ejs | 2 +- 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 views/gallery.ejs diff --git a/app.js b/app.js index 93873f2..657a2bf 100644 --- a/app.js +++ b/app.js @@ -1,6 +1,5 @@ require("dotenv").config(); const express = require("express"); -const http = require("http"); const ejsMate = require("ejs-mate"); const cookieParser = require("cookie-parser"); const session = require("express-session"); @@ -145,6 +144,14 @@ app.get( }), ); +app.get( + "/gallery", + fallible(async (req, res) => { + const images = await db.query("SELECT * FROM images"); + res.render("gallery", { title: "Gallery", images: images.rows }) + }), +); + app.get( "/uploads/:id", fallible(async (req, res) => { diff --git a/public/stylesheets/styles.scss b/public/stylesheets/styles.scss index 69f1cd4..0b7391d 100644 --- a/public/stylesheets/styles.scss +++ b/public/stylesheets/styles.scss @@ -139,6 +139,11 @@ nav .nav-item { } // --- NEW STYLES --- +.gallery-image-caption { + @extend .pt-2, .fs-5; + font-style: italic; +} + .subhead-base { @extend .ps-3, .fs-5; border-left: 4px solid; diff --git a/views/gallery.ejs b/views/gallery.ejs new file mode 100644 index 0000000..bb66d9f --- /dev/null +++ b/views/gallery.ejs @@ -0,0 +1,8 @@ +<% layout('layouts/base')%> + +
+ <% for(let image of images) { %> + <%= image.caption %> + + <% } %> +
\ No newline at end of file diff --git a/views/home.ejs b/views/home.ejs index 77d3a21..0de7fbf 100644 --- a/views/home.ejs +++ b/views/home.ejs @@ -26,7 +26,7 @@ <% if (typeof user === 'object' && user) { %>
- +
<% } else { %> From e2957ec68285662c26e4ec57b0043a1e99a81a14 Mon Sep 17 00:00:00 2001 From: Ethan Richards <42894274+ezrichards@users.noreply.github.com> Date: Mon, 12 Aug 2024 09:33:20 -0600 Subject: [PATCH 03/20] add gallery modal --- views/gallery.ejs | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/views/gallery.ejs b/views/gallery.ejs index bb66d9f..ded0a75 100644 --- a/views/gallery.ejs +++ b/views/gallery.ejs @@ -1,8 +1,26 @@ <% layout('layouts/base')%>
- <% for(let image of images) { %> - <%= image.caption %> - - <% } %> -
\ No newline at end of file +

Gallery

+ + From 405ec81d8ad718879f8c4acbe0cf50ccfd4c2fb9 Mon Sep 17 00:00:00 2001 From: Ethan Richards <42894274+ezrichards@users.noreply.github.com> Date: Mon, 12 Aug 2024 09:33:28 -0600 Subject: [PATCH 04/20] schedule page style fixes --- public/stylesheets/styles.scss | 22 +++++++++++++++++++++- views/schedule.ejs | 29 ++++++++++++++--------------- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/public/stylesheets/styles.scss b/public/stylesheets/styles.scss index 0b7391d..9eb7e82 100644 --- a/public/stylesheets/styles.scss +++ b/public/stylesheets/styles.scss @@ -139,9 +139,29 @@ nav .nav-item { } // --- NEW STYLES --- +.gallery-container { + background-color: white; + border-bottom: 4px solid $primary; + display: flex; + flex-wrap: wrap; + row-gap: 15px; + column-gap: 15px; +} + +.gallery-image { + object-fit: contain; +} + +.thumbnail { + display: flex; + height: 200px; +} + .gallery-image-caption { @extend .pt-2, .fs-5; font-style: italic; + text-align: center; + margin-bottom: 2%; } .subhead-base { @@ -256,6 +276,7 @@ nav .nav-item { @extend .rounded-5; width: 128px; height: 128px; + object-fit: cover; } .project-image { @@ -285,7 +306,6 @@ nav .nav-item { @extend .rounded-5, .w-100, .mb-3; } -// for 'about us' cards styling .row-cols-auto > * { max-width: 20%; } diff --git a/views/schedule.ejs b/views/schedule.ejs index d1c52c7..6bbbd8e 100644 --- a/views/schedule.ejs +++ b/views/schedule.ejs @@ -14,7 +14,7 @@ <% for(let meeting of upcoming) { %>
-
+

<%= meeting.title %>

@@ -37,21 +37,20 @@

Location: <%= meeting.location %>

<% } %> - -
-

Previous Meetings

-
- <% for(let meeting of previous) { %> -
-

<%= meeting.title %>

-

Description: <%= meeting.description %>

-

Date: <%= meeting.date %>,<%= meeting.duration %>

-

Location: <%= meeting.location %>

-
- <% } %> -
-
+
+

Previous Meetings

+
+ <% for(let meeting of previous) { %> +
+

<%= meeting.title %>

+

Description: <%= meeting.description %>

+

Date: <%= meeting.date %>,<%= meeting.duration %>

+

Location: <%= meeting.location %>

+
+ <% } %> +
+
From 0e45ddb7f96b763fa234ad147a147db18c399ac8 Mon Sep 17 00:00:00 2001 From: Ethan Richards <42894274+ezrichards@users.noreply.github.com> Date: Mon, 12 Aug 2024 09:34:54 -0600 Subject: [PATCH 05/20] prettier --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index 657a2bf..738b535 100644 --- a/app.js +++ b/app.js @@ -148,7 +148,7 @@ app.get( "/gallery", fallible(async (req, res) => { const images = await db.query("SELECT * FROM images"); - res.render("gallery", { title: "Gallery", images: images.rows }) + res.render("gallery", { title: "Gallery", images: images.rows }); }), ); From b20cbfa6e757ea925d9ebdb0be3092b68e9e040e Mon Sep 17 00:00:00 2001 From: Ethan Richards <42894274+ezrichards@users.noreply.github.com> Date: Mon, 12 Aug 2024 17:24:24 -0600 Subject: [PATCH 06/20] Update package.json --- package.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index dff0e79..1fca2b7 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,12 @@ { "name": "acm-site", "version": "1.0.0", - "description": "The backend for the Mines ACM website.", + "description": "The Mines ACM club website, acm.mines.edu", "main": "app.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", "start": "sass --style=compressed public/stylesheets/styles.scss public/stylesheets/styles.css; node app.js" }, - "author": "", + "author": "Mines ACM Contributors", "license": "ISC", "dependencies": { "bootstrap": "^5.3.2", From d3fc534ee29916c08c5e510aaa24b466ea6e03e4 Mon Sep 17 00:00:00 2001 From: Ethan Richards <42894274+ezrichards@users.noreply.github.com> Date: Mon, 12 Aug 2024 17:31:16 -0600 Subject: [PATCH 07/20] Fix button styling --- public/stylesheets/styles.scss | 1 + views/admin.ejs | 2 +- views/home.ejs | 2 +- views/schedule.ejs | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/public/stylesheets/styles.scss b/public/stylesheets/styles.scss index 9eb7e82..f1a374b 100644 --- a/public/stylesheets/styles.scss +++ b/public/stylesheets/styles.scss @@ -6,6 +6,7 @@ $alert-border-radius: 0; $modal-inner-padding: 24px; $modal-content-border-radius: 32px; $navbar-active-color: $primary; +$bs-btn-color: white; @import "../../node_modules/bootstrap/scss/bootstrap"; // Light theme colors diff --git a/views/admin.ejs b/views/admin.ejs index 66fa928..eb06a48 100644 --- a/views/admin.ejs +++ b/views/admin.ejs @@ -47,7 +47,7 @@

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

+ +