diff options
author | Darius Kazemi <darius.kazemi@gmail.com> | 2020-01-24 16:16:27 -0800 |
---|---|---|
committer | Darius Kazemi <darius.kazemi@gmail.com> | 2020-01-24 16:16:27 -0800 |
commit | a390b02416777b045f03a286bfbb02ac369571e6 (patch) | |
tree | 8e690cf7a80635685b258eb6a4b2a1ca3f79ab36 | |
parent | 111406040ec9f7f48b28077c8eea95a792b14cc7 (diff) |
Converting all tabs to two-spaces
-rw-r--r-- | activitypub.js | 8 | ||||
-rw-r--r-- | helpers.js | 14 | ||||
-rwxr-xr-x | models/Event.js | 376 | ||||
-rwxr-xr-x | models/EventGroup.js | 86 | ||||
-rwxr-xr-x | models/Log.js | 16 | ||||
-rwxr-xr-x | public/css/style.css | 318 | ||||
-rwxr-xr-x | routes.js | 1764 | ||||
-rwxr-xr-x | views/event.handlebars | 748 | ||||
-rwxr-xr-x | views/eventgroup.handlebars | 216 | ||||
-rwxr-xr-x | views/home.handlebars | 2 | ||||
-rwxr-xr-x | views/layouts/main.handlebars | 124 | ||||
-rwxr-xr-x | views/login.handlebars | 44 | ||||
-rwxr-xr-x | views/newevent.handlebars | 38 | ||||
-rwxr-xr-x | views/optionsform.handlebars | 86 | ||||
-rw-r--r-- | views/partials/editeventgroupmodal.handlebars | 54 | ||||
-rw-r--r-- | views/partials/editeventmodal.handlebars | 300 | ||||
-rwxr-xr-x | views/partials/neweventform.handlebars | 104 | ||||
-rwxr-xr-x | views/partials/neweventgroupform.handlebars | 36 |
18 files changed, 2166 insertions, 2168 deletions
diff --git a/activitypub.js b/activitypub.js index 2a7c18a..765bee1 100644 --- a/activitypub.js +++ b/activitypub.js @@ -124,10 +124,10 @@ function signAndSend(message, eventID, targetDomain, inbox, callback) { if (!isFederated) return; let inboxFragment = inbox.replace('https://'+targetDomain,''); // get the private key - Event.findOne({ - id: eventID - }) - .then((event) => { + Event.findOne({ + id: eventID + }) + .then((event) => { if (event) { const privateKey = event.privateKey; const signer = crypto.createSign('sha256'); @@ -5,13 +5,13 @@ var moment = require('moment-timezone'); // LOGGING function addToLog(process, status, message) { - let logEntry = new Log({ - status: status, - process: process, - message: message, - timestamp: moment() - }); - logEntry.save().catch(() => { console.log("Error saving log entry!") }); + let logEntry = new Log({ + status: status, + process: process, + message: message, + timestamp: moment() + }); + logEntry.save().catch(() => { console.log("Error saving log entry!") }); } module.exports = { diff --git a/models/Event.js b/models/Event.js index 07f0b70..64cf398 100755 --- a/models/Event.js +++ b/models/Event.js @@ -1,225 +1,225 @@ const mongoose = require('mongoose'); const Attendees = new mongoose.Schema({ - name: { - type: String, - trim: true - }, - status: { - type: String, - trim: true - }, - email: { - type: String, - trim: true - }, - removalPassword: { - type: String, - trim: true - }, + name: { + type: String, + trim: true + }, + status: { + type: String, + trim: true + }, + email: { + type: String, + trim: true + }, + removalPassword: { + type: String, + trim: true + }, id: { - type: String, - trim: true + type: String, + trim: true } }) const Followers = new mongoose.Schema({ // this is the id of the original follow *request*, which we use to validate Undo events followId: { - type: String, - trim: true + type: String, + trim: true }, // this is the actual remote user profile id - actorId: { - type: String, - trim: true - }, + actorId: { + type: String, + trim: true + }, // this is the stringified JSON of the entire user profile - actorJson: { - type: String, - trim: true - }, + actorJson: { + type: String, + trim: true + }, name: { - type: String, - trim: true + type: String, + trim: true }, }, {_id: false}) const ReplySchema = new mongoose.Schema({ - id: { - type: String, - required: true, - unique: true, - sparse: true - }, - author: { - type: String, - trim: true, - required: true - }, - content: { - type: String, - trim: true, - required: true - }, - timestamp: { - type: Date, - trim: true, - required: true - } + id: { + type: String, + required: true, + unique: true, + sparse: true + }, + author: { + type: String, + trim: true, + required: true + }, + content: { + type: String, + trim: true, + required: true + }, + timestamp: { + type: Date, + trim: true, + required: true + } }) const ActivityPubMessages = new mongoose.Schema({ - id: { - type: String, - required: true, - unique: true, - sparse: true - }, - content: { - type: String, - trim: true, - required: true - } + id: { + type: String, + required: true, + unique: true, + sparse: true + }, + content: { + type: String, + trim: true, + required: true + } }) const CommentSchema = new mongoose.Schema({ - id: { - type: String, - required: true, - unique: true, - sparse: true - }, - author: { - type: String, - trim: true, - required: true - }, - content: { - type: String, - trim: true, - required: true - }, - timestamp: { - type: Date, - trim: true, - required: true - }, + id: { + type: String, + required: true, + unique: true, + sparse: true + }, + author: { + type: String, + trim: true, + required: true + }, + content: { + type: String, + trim: true, + required: true + }, + timestamp: { + type: Date, + trim: true, + required: true + }, activityJson: { - type: String, - trim: true + type: String, + trim: true }, actorJson: { - type: String, - trim: true + type: String, + trim: true }, activityId: { - type: String, - trim: true + type: String, + trim: true }, actorId: { - type: String, - trim: true + type: String, + trim: true }, - replies: [ReplySchema] + replies: [ReplySchema] }) const EventSchema = new mongoose.Schema({ - id: { - type: String, - required: true, - unique: true - }, - type: { - type: String, - trim: true, - required: true - }, - name: { - type: String, - trim: true, - required: true - }, - location: { - type: String, - trim: true, - required: true - }, - start: { // Stored as a UTC timestamp - type: Date, - trim: true, - required: true - }, - end: { // Stored as a UTC timestamp - type: Date, - trim: true, - required: true - }, - timezone: { - type: String, - default: 'Etc/UTC' - }, - description: { - type: String, - trim: true, - required: true - }, - image: { - type: String, - trim: true - }, - url: { - type: String, - trim: true - }, - creatorEmail: { - type: String, - trim: true - }, - hostName: { - type: String, - trim: true - }, - viewPassword: { - type: String, - trim: true - }, - editPassword: { - type: String, - trim: true - }, - editToken: { - type: String, - trim: true, - minlength: 32, - maxlength: 32 - }, - eventGroup: { type: mongoose.Schema.Types.ObjectId, ref: 'EventGroup' }, - usersCanAttend: { - type: Boolean, - trim: true, - default: false - }, - showUsersList: { - type: Boolean, - trim: true, - default: false - }, - usersCanComment: { - type: Boolean, - trim: true, - default: false - }, - firstLoad: { - type: Boolean, - trim: true, - default: true - }, - attendees: [Attendees], - maxAttendees: { - type: Number - }, - comments: [CommentSchema], + id: { + type: String, + required: true, + unique: true + }, + type: { + type: String, + trim: true, + required: true + }, + name: { + type: String, + trim: true, + required: true + }, + location: { + type: String, + trim: true, + required: true + }, + start: { // Stored as a UTC timestamp + type: Date, + trim: true, + required: true + }, + end: { // Stored as a UTC timestamp + type: Date, + trim: true, + required: true + }, + timezone: { + type: String, + default: 'Etc/UTC' + }, + description: { + type: String, + trim: true, + required: true + }, + image: { + type: String, + trim: true + }, + url: { + type: String, + trim: true + }, + creatorEmail: { + type: String, + trim: true + }, + hostName: { + type: String, + trim: true + }, + viewPassword: { + type: String, + trim: true + }, + editPassword: { + type: String, + trim: true + }, + editToken: { + type: String, + trim: true, + minlength: 32, + maxlength: 32 + }, + eventGroup: { type: mongoose.Schema.Types.ObjectId, ref: 'EventGroup' }, + usersCanAttend: { + type: Boolean, + trim: true, + default: false + }, + showUsersList: { + type: Boolean, + trim: true, + default: false + }, + usersCanComment: { + type: Boolean, + trim: true, + default: false + }, + firstLoad: { + type: Boolean, + trim: true, + default: true + }, + attendees: [Attendees], + maxAttendees: { + type: Number + }, + comments: [CommentSchema], activityPubActor: { type: String, trim: true @@ -236,7 +236,7 @@ const EventSchema = new mongoose.Schema({ type: String, trim: true }, - followers: [Followers], + followers: [Followers], activityPubMessages: [ActivityPubMessages] }); diff --git a/models/EventGroup.js b/models/EventGroup.js index 336074c..6d2893b 100755 --- a/models/EventGroup.js +++ b/models/EventGroup.js @@ -1,49 +1,49 @@ const mongoose = require('mongoose'); const EventGroupSchema = new mongoose.Schema({ - id: { - type: String, - required: true, - unique: true - }, - name: { - type: String, - trim: true, - required: true - }, - description: { - type: String, - trim: true, - required: true - }, - image: { - type: String, - trim: true - }, - url: { - type: String, - trim: true - }, - creatorEmail: { - type: String, - trim: true - }, - hostName: { - type: String, - trim: true - }, - editToken: { - type: String, - trim: true, - minlength: 32, - maxlength: 32 - }, - firstLoad: { - type: Boolean, - trim: true, - default: true - }, - events: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Event' }] + id: { + type: String, + required: true, + unique: true + }, + name: { + type: String, + trim: true, + required: true + }, + description: { + type: String, + trim: true, + required: true + }, + image: { + type: String, + trim: true + }, + url: { + type: String, + trim: true + }, + creatorEmail: { + type: String, + trim: true + }, + hostName: { + type: String, + trim: true + }, + editToken: { + type: String, + trim: true, + minlength: 32, + maxlength: 32 + }, + firstLoad: { + type: Boolean, + trim: true, + default: true + }, + events: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Event' }] }); module.exports = mongoose.model('EventGroup', EventGroupSchema); diff --git a/models/Log.js b/models/Log.js index 6ed474b..95a3ab3 100755 --- a/models/Log.js +++ b/models/Log.js @@ -1,26 +1,26 @@ const mongoose = require('mongoose'); const LogSchema = new mongoose.Schema({ - status: { + status: { type: String, trim: true, - required: true + required: true }, - process: { + process: { type: String, trim: true, - required: true + required: true }, message: { type: String, trim: true, - required: true + required: true }, - timestamp: { + timestamp: { type: Date, trim: true, - required: true + required: true } }); -module.exports = mongoose.model('Log', LogSchema);
\ No newline at end of file +module.exports = mongoose.model('Log', LogSchema); diff --git a/public/css/style.css b/public/css/style.css index 6c5de7f..93789b7 100755 --- a/public/css/style.css +++ b/public/css/style.css @@ -7,24 +7,24 @@ body, html { /* FONTS */ @font-face { - font-family: 'Fredoka One'; - font-style: normal; - font-weight: 400; - src: url('../fonts/fredoka-one-v7-latin-regular.eot'); /* IE9 Compat Modes */ - src: local('Fredoka One'), local('FredokaOne-Regular'), - url('../fonts/fredoka-one-v7-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ - url('../fonts/fredoka-one-v7-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */ - url('../fonts/fredoka-one-v7-latin-regular.woff') format('woff'), /* Modern Browsers */ - url('../fonts/fredoka-one-v7-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */ - url('../fonts/fredoka-one-v7-latin-regular.svg#FredokaOne') format('svg'); /* Legacy iOS */ + font-family: 'Fredoka One'; + font-style: normal; + font-weight: 400; + src: url('../fonts/fredoka-one-v7-latin-regular.eot'); /* IE9 Compat Modes */ + src: local('Fredoka One'), local('FredokaOne-Regular'), + url('../fonts/fredoka-one-v7-latin-regular.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ + url('../fonts/fredoka-one-v7-latin-regular.woff2') format('woff2'), /* Super Modern Browsers */ + url('../fonts/fredoka-one-v7-latin-regular.woff') format('woff'), /* Modern Browsers */ + url('../fonts/fredoka-one-v7-latin-regular.ttf') format('truetype'), /* Safari, Android, iOS */ + url('../fonts/fredoka-one-v7-latin-regular.svg#FredokaOne') format('svg'); /* Legacy iOS */ } @media (max-width: 576px) { - #container { - height: auto !important; - overflow-x: hidden; - } + #container { + height: auto !important; + overflow-x: hidden; + } } #content { @@ -37,86 +37,86 @@ body, html { } #fixedContainer { - position: sticky; - top: 0; + position: sticky; + top: 0; } #footerContainer { - border-top: 1px solid #e0e0e0; - text-align: center; - padding: 5px 0; + border-top: 1px solid #e0e0e0; + text-align: center; + padding: 5px 0; } #sidebar { - background: #f5f5f5; - border-bottom: 2px solid #e0e0e0; + background: #f5f5f5; + border-bottom: 2px solid #e0e0e0; } #sidebar h1 { - font-family: "Fredoka One", sans-serif; - font-weight: 700; - text-align: center; - letter-spacing: -0.5px; - font-size: 3rem; - color: transparent !important; - margin-bottom: 0; + font-family: "Fredoka One", sans-serif; + font-weight: 700; + text-align: center; + letter-spacing: -0.5px; + font-size: 3rem; + color: transparent !important; + margin-bottom: 0; } #sidebar h1 a { - background: rgb(33, 37, 41); - background-clip: text; - -webkit-background-clip: text; - color: transparent !important; + background: rgb(33, 37, 41); + background-clip: text; + -webkit-background-clip: text; + color: transparent !important; } #sidebar h1 a:hover { - text-decoration: none; - background: linear-gradient(to right, #27aa45, #7fe0c8, #5d26c1); - background-size: 100% 100%; - background-clip: text; - -webkit-background-clip: text; - color: transparent !important; + text-decoration: none; + background: linear-gradient(to right, #27aa45, #7fe0c8, #5d26c1); + background-size: 100% 100%; + background-clip: text; + -webkit-background-clip: text; + color: transparent !important; } #content { - background: #ffffff; - box-shadow: -8px 0 6px -6px rgba(0,0,0,0.3); + background: #ffffff; + box-shadow: -8px 0 6px -6px rgba(0,0,0,0.3); } #genericEventImageContainer { - height:150px; - border-radius: 5px; + height:150px; + border-radius: 5px; } #genericEventImageContainer:before { - content: ''; - background: linear-gradient(to bottom, rgba(30,87,153,0) 0%,rgba(242,245,249,0) 75%,rgba(255,255,255,1) 95%,rgba(255,255,255,1) 100%); - position: absolute; - width: 97%; - height: 150px; + content: ''; + background: linear-gradient(to bottom, rgba(30,87,153,0) 0%,rgba(242,245,249,0) 75%,rgba(255,255,255,1) 95%,rgba(255,255,255,1) 100%); + position: absolute; + width: 97%; + height: 150px; } #eventImageContainer { - height:300px; - background-size: cover; - background-repeat: no-repeat; - background-position: center; - border-radius: 5px; + height:300px; + background-size: cover; + background-repeat: no-repeat; + background-position: center; + border-radius: 5px; } #eventImageContainer:before { - content: ''; - background: linear-gradient(to bottom, rgba(30,87,153,0) 0%,rgba(242,245,249,0) 85%,rgba(255,255,255,1) 95%,rgba(255,255,255,1) 100%); - position: absolute; - width: 100%; - height: 300px; + content: ''; + background: linear-gradient(to bottom, rgba(30,87,153,0) 0%,rgba(242,245,249,0) 85%,rgba(255,255,255,1) 95%,rgba(255,255,255,1) 100%); + position: absolute; + width: 100%; + height: 300px; } #eventName { - padding: 0 0 0 10px; - width: 100%; - display: flex; - justify-content: space-between; + padding: 0 0 0 10px; + width: 100%; + display: flex; + justify-content: space-between; } #eventPrivacy { @@ -124,88 +124,88 @@ body, html { } #eventFromNow { - padding-left: 25px; + padding-left: 25px; } #eventFromNow::first-letter { - text-transform:capitalize; + text-transform:capitalize; } #eventActions { - padding-left: 0; - margin-top: 1rem; + padding-left: 0; + margin-top: 1rem; } /* .location, .eventLink { - display: flex; - width: 100%; - justify-content: space-between; + display: flex; + width: 100%; + justify-content: space-between; } */ .attendeesList { - margin: 0; - padding: 0; - list-style-type: none; - display: flex; - flex-wrap: wrap; + margin: 0; + padding: 0; + list-style-type: none; + display: flex; + flex-wrap: wrap; } .attendeesList > li { - border: 4px solid #0ea130; - border-radius: 2em; - padding: .5em 1em; - margin-right: 5px; - margin-bottom: 10px; - background: #57b76d; - color: white; - font-size: 0.95em; - font-weight: bold; + border: 4px solid #0ea130; + border-radius: 2em; + padding: .5em 1em; + margin-right: 5px; + margin-bottom: 10px; + background: #57b76d; + color: white; + font-size: 0.95em; + font-weight: bold; } .expand { - -webkit-transition: height 0.2s; - -moz-transition: height 0.2s; - transition: height 0.2s; + -webkit-transition: height 0.2s; + -moz-transition: height 0.2s; + transition: height 0.2s; } .eventInformation { - margin-left: 1.6em; + margin-left: 1.6em; } .eventInformation > li { /* line-height: 2.1em;*/ - margin-bottom: 0.8em; + margin-bottom: 0.8em; } #copyEventLink { - margin-left: 5px; + margin-left: 5px; } .commentContainer { - background: #fafafa; - border-radius: 5px; - padding: 10px; - margin-bottom: 10px; - border: 1px solid #dfdfdf; + background: #fafafa; + border-radius: 5px; + padding: 10px; + margin-bottom: 10px; + border: 1px solid #dfdfdf; } .replyContainer { - display: none; - background: #efefef; - padding: 10px; - border-radius: 0 0 5px 5px; - border-bottom: 1px solid #d2d2d2; - border-left: 1px solid #d2d2d2; - border-right: 1px solid #d2d2d2; - width: 95%; - margin: -10px auto 10px auto; + display: none; + background: #efefef; + padding: 10px; + border-radius: 0 0 5px 5px; + border-bottom: 1px solid #d2d2d2; + border-left: 1px solid #d2d2d2; + border-right: 1px solid #d2d2d2; + width: 95%; + margin: -10px auto 10px auto; } .repliesContainer { - font-size: smaller; - padding-left:20px; + font-size: smaller; + padding-left:20px; } /* IMAGE UPLOAD FORM */ @@ -218,8 +218,8 @@ body, html { overflow: hidden; background-color: #ffffff; color: #ecf0f1; - border-radius: 5px; - border: 1px dashed #ced4da; + border-radius: 5px; + border: 1px dashed #ced4da; } .image-preview input { line-height: 200px; @@ -234,7 +234,7 @@ body, html { opacity: 0.8; cursor: pointer; background-color: #ced4da; - color: #555; + color: #555; width: 200px; height: 50px; font-size: 20px; @@ -246,28 +246,28 @@ body, html { bottom: 0; margin: auto; text-align: center; - border-radius: 5px; + border-radius: 5px; } .datepickers-container { - z-index: 1600 !important; /* has to be larger than 1050 */ + z-index: 1600 !important; /* has to be larger than 1050 */ } #newEventFormContainer, #importEventFormContainer, #newEventGroupFormContainer { - display: none; + display: none; } #icsImportLabel { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - color: #6c757d; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + color: #6c757d; } .select2-container { - width: 100% !important; + width: 100% !important; } .select2-selection__rendered { line-height: 2.25rem !important; @@ -280,86 +280,86 @@ body, html { } .attendee-name { - white-space: nowrap; - overflow: hidden; - text-overflow: ""; - overflow: hidden; - max-width: 62px; + white-space: nowrap; + overflow: hidden; + text-overflow: ""; + overflow: hidden; + max-width: 62px; color: #fff; } .remove-attendee { - color: #fff; + color: #fff; } .remove-attendee:hover { - color: #016418; + color: #016418; } #eventAttendees h5 { - display: flex; - flex-direction: column; - align-items: flex-start; + display: flex; + flex-direction: column; + align-items: flex-start; } #eventAttendees h5 .btn-group { - margin-top: 0.5rem; + margin-top: 0.5rem; } #maxAttendeesContainer { - display: none; + display: none; } /* #maxAttendeesCheckboxContainer { - display: none; + display: none; } */ #eventGroupData { - display: none; + display: none; } .edit-buttons { - text-align: right; + text-align: right; } @media (max-width: 1199.98px) { - .edit-buttons { - text-align: left; - } + .edit-buttons { + text-align: left; + } } @media (min-width: 1120px) { - #eventActions { - margin-top: 0; - padding-left: 1rem; - } + #eventActions { + margin-top: 0; + padding-left: 1rem; + } } @media (min-width: 577px) { - #sidebar { - border-right: 2px solid #e0e0e0; - min-height: 100vh; - } - body { - background: #f5f5f5; /* Old browsers */ - background: -moz-linear-gradient(left, #f5f5f5 0%, #f5f5f5 50%, #ffffff 51%, #ffffff 100%); /* FF3.6-15 */ - background: -webkit-linear-gradient(left, #f5f5f5 0%,#f5f5f5 50%,#ffffff 51%,#ffffff 100%); /* Chrome10-25,Safari5.1-6 */ - background: linear-gradient(to right, #f5f5f5 0%,#f5f5f5 50%,#ffffff 51%,#ffffff 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f5f5', endColorstr='#ffffff',GradientType=1 ); /* IE6-9 */ - } - #eventAttendees h5 { - flex-direction: row; - justify-content: space-between; - align-items: center; - } - #eventAttendees h5 .btn-group { - margin-top: 0; - } + #sidebar { + border-right: 2px solid #e0e0e0; + min-height: 100vh; + } + body { + background: #f5f5f5; /* Old browsers */ + background: -moz-linear-gradient(left, #f5f5f5 0%, #f5f5f5 50%, #ffffff 51%, #ffffff 100%); /* FF3.6-15 */ + background: -webkit-linear-gradient(left, #f5f5f5 0%,#f5f5f5 50%,#ffffff 51%,#ffffff 100%); /* Chrome10-25,Safari5.1-6 */ + background: linear-gradient(to right, #f5f5f5 0%,#f5f5f5 50%,#ffffff 51%,#ffffff 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f5f5', endColorstr='#ffffff',GradientType=1 ); /* IE6-9 */ + } + #eventAttendees h5 { + flex-direction: row; + justify-content: space-between; + align-items: center; + } + #eventAttendees h5 .btn-group { + margin-top: 0; + } } .list-group-item-action:hover { - background-color: #d4edda; + background-color: #d4edda; } .code { - font-family: 'Courier New', Courier, monospace; - overflow-wrap: anywhere; + font-family: 'Courier New', Courier, monospace; + overflow-wrap: anywhere; } @@ -70,17 +70,17 @@ function render_plain () { render.image = function (href, title, text) { return ''; }; - render.br = function () { + render.br = function () { return ''; - }; + }; return render; } const ical = require('ical'); const icalGenerator = require('ical-generator'); const cal = icalGenerator({ - domain: domain, - name: siteName + domain: domain, + name: siteName }); const sgMail = require('@sendgrid/mail'); @@ -89,8 +89,8 @@ const apiCredentials = require('./config/api.js'); let sendEmails = false; if (apiCredentials.sendgrid) { // Only set up Sendgrid if an API key is set - sgMail.setApiKey(apiCredentials.sendgrid); - sendEmails = true; + sgMail.setApiKey(apiCredentials.sendgrid); + sendEmails = true; } const fileUpload = require('express-fileupload'); @@ -103,20 +103,20 @@ router.use(fileUpload()); const schedule = require('node-schedule'); const deleteOldEvents = schedule.scheduleJob('59 23 * * *', function(fireDate){ - const too_old = moment.tz('Etc/UTC').subtract(7, 'days').toDate(); - console.log("Old event deletion running! Deleting all events concluding before ", too_old); - - Event.find({ end: { $lte: too_old } }).then((oldEvents) => { - oldEvents.forEach(event => { - if (event.image){ - fs.unlink(global.appRoot + '/public/events/' + event.image, (err) => { - if (err) { - addToLog("deleteOldEvents", "error", "Attempt to delete event image for old event "+event.id+" failed with error: " + err); - } - // Image removed - addToLog("deleteOldEvents", "error", "Image deleted for old event "+event.id); - }) - } + const too_old = moment.tz('Etc/UTC').subtract(7, 'days').toDate(); + console.log("Old event deletion running! Deleting all events concluding before ", too_old); + + Event.find({ end: { $lte: too_old } }).then((oldEvents) => { + oldEvents.forEach(event => { + if (event.image){ + fs.unlink(global.appRoot + '/public/events/' + event.image, (err) => { + if (err) { + addToLog("deleteOldEvents", "error", "Attempt to delete event image for old event "+event.id+" failed with error: " + err); + } + // Image removed + addToLog("deleteOldEvents", "error", "Image deleted for old event "+event.id); + }) + } // broadcast a Delete profile message to all followers so that at least Mastodon servers will delete their local profile information const guidUpdateObject = crypto.randomBytes(16).toString('hex'); const jsonUpdateObject = JSON.parse(event.activityPubActor); @@ -132,10 +132,10 @@ const deleteOldEvents = schedule.scheduleJob('59 23 * * *', function(fireDate){ }); }); }); - }) - }).catch((err) => { - addToLog("deleteOldEvents", "error", "Attempt to delete old event "+event.id+" failed with error: " + err); - }); + }) + }).catch((err) => { + addToLog("deleteOldEvents", "error", "Attempt to delete old event "+event.id+" failed with error: " + err); + }); }); // FRONTEND ROUTES @@ -149,57 +149,57 @@ router.get('/', (req, res) => { }); router.get('/new', (req, res) => { - res.render('home'); + res.render('home'); }); //router.get('/login', (req, res) => { -// res.render('admin'); +// res.render('admin'); //}) //router.get('/login', (req, res) => { -// res.render('login'); +// res.render('login'); //}); // //router.get('/register', (req, res) => { -// res.render('register'); +// res.render('register'); //}); router.get('/new/event', (req, res) => { - res.render('newevent', { + res.render('newevent', { domain: domain, email: contactEmail, siteName: siteName, }); }); router.get('/new/event/public', (req, res) => { - let isPrivate = false; - let isPublic = true; - let isOrganisation = false; - let isUnknownType = false; -// let eventType = req.params.eventType; -// if (eventType == "private"){ -// isPrivate = true; -// } -// else if (eventType == "public"){ -// isPublic = true; -// } -// else if (eventType == "organisation"){ -// isOrganisation = true; -// } -// else { -// isUnknownType = true; -// } - res.render('newevent', { - title: 'New event', - isPrivate: isPrivate, - isPublic: isPublic, - isOrganisation: isOrganisation, - isUnknownType: isUnknownType, - eventType: 'public', + let isPrivate = false; + let isPublic = true; + let isOrganisation = false; + let isUnknownType = false; +// let eventType = req.params.eventType; +// if (eventType == "private"){ +// isPrivate = true; +// } +// else if (eventType == "public"){ +// isPublic = true; +// } +// else if (eventType == "organisation"){ +// isOrganisation = true; +// } +// else { +// isUnknownType = true; +// } + res.render('newevent', { + title: 'New event', + isPrivate: isPrivate, + isPublic: isPublic, + isOrganisation: isOrganisation, + isUnknownType: isUnknownType, + eventType: 'public', domain: domain, email: contactEmail, siteName: siteName, - }); + }); }) // return the JSON for the featured/pinned post for this event @@ -285,78 +285,78 @@ router.get('/.well-known/webfinger', (req, res) => { }); router.get('/:eventID', (req, res) => { - Event.findOne({ - id: req.params.eventID - }) - .populate('eventGroup') - .then((event) => { - if (event) { - const parsedLocation = event.location.replace(/\s+/g, '+'); - let displayDate; - if (moment.tz(event.end, event.timezone).isSame(event.start, 'day')){ - // Happening during one day - displayDate = moment.tz(event.start, event.timezone).format('dddd D MMMM YYYY [<span class="text-muted">from</span>] h:mm a') + moment.tz(event.end, event.timezone).format(' [<span class="text-muted">to</span>] h:mm a [<span class="text-muted">](z)[</span>]'); - } - else { - displayDate = moment.tz(event.start, event.timezone).format('dddd D MMMM YYYY [<span class="text-muted">at</span>] h:mm a') + moment.tz(event.end, event.timezone).format(' [<span class="text-muted">–</span>] dddd D MMMM YYYY [<span class="text-muted">at</span>] h:mm a [<span class="text-muted">](z)[</span>]'); - } - let eventStartISO = moment.tz(event.start, "Etc/UTC").toISOString(); - let eventEndISO = moment.tz(event.end, "Etc/UTC").toISOString(); - let parsedStart = moment.tz(event.start, event.timezone).format('YYYYMMDD[T]HHmmss'); - let parsedEnd = moment.tz(event.end, event.timezone).format('YYYYMMDD[T]HHmmss'); - let eventHasConcluded = false; - if (moment.tz(event.end, event.timezone).isBefore(moment.tz(event.timezone))){ - eventHasConcluded = true; - } - let eventHasBegun = false; - if (moment.tz(event.start, event.timezone).isBefore(moment.tz(event.timezone))){ - eventHasBegun = true; - } - let fromNow = moment.tz(event.start, event.timezone).fromNow(); - let parsedDescription = marked(event.description); - let eventEditToken = event.editToken; - - let escapedName = event.name.replace(/\s+/g, '+'); - - let eventHasCoverImage = false; - if( event.image ) { - eventHasCoverImage = true; - } - else { - eventHasCoverImage = false; - } - let eventHasHost = false; - if( event.hostName ) { - eventHasHost = true; - } - else { - eventHasHost = false; - } - let firstLoad = false; - if (event.firstLoad === true) { - firstLoad = true; - Event.findOneAndUpdate({id: req.params.eventID}, {firstLoad: false}, function(err, raw) { - if (err) { - res.send(err); - } - }); - } - let editingEnabled = false; - if (Object.keys(req.query).length !== 0) { - if (!req.query.e) { - editingEnabled = false; - console.log("No edit token set"); - } - else { - if (req.query.e === eventEditToken){ - editingEnabled = true; - } - else { - editingEnabled = false; - } - } - } - let eventAttendees = event.attendees.sort((a,b) => (a.name > b.name) ? 1 : ((b.name > a.name) ? -1 : 0)) + Event.findOne({ + id: req.params.eventID + }) + .populate('eventGroup') + .then((event) => { + if (event) { + const parsedLocation = event.location.replace(/\s+/g, '+'); + let displayDate; + if (moment.tz(event.end, event.timezone).isSame(event.start, 'day')){ + // Happening during one day + displayDate = moment.tz(event.start, event.timezone).format('dddd D MMMM YYYY [<span class="text-muted">from</span>] h:mm a') + moment.tz(event.end, event.timezone).format(' [<span class="text-muted">to</span>] h:mm a [<span class="text-muted">](z)[</span>]'); + } + else { + displayDate = moment.tz(event.start, event.timezone).format('dddd D MMMM YYYY [<span class="text-muted">at</span>] h:mm a') + moment.tz(event.end, event.timezone).format(' [<span class="text-muted">–</span>] dddd D MMMM YYYY [<span class="text-muted">at</span>] h:mm a [<span class="text-muted">](z)[</span>]'); + } + let eventStartISO = moment.tz(event.start, "Etc/UTC").toISOString(); + let eventEndISO = moment.tz(event.end, "Etc/UTC").toISOString(); + let parsedStart = moment.tz(event.start, event.timezone).format('YYYYMMDD[T]HHmmss'); + let parsedEnd = moment.tz(event.end, event.timezone).format('YYYYMMDD[T]HHmmss'); + let eventHasConcluded = false; + if (moment.tz(event.end, event.timezone).isBefore(moment.tz(event.timezone))){ + eventHasConcluded = true; + } + let eventHasBegun = false; + if (moment.tz(event.start, event.timezone).isBefore(moment.tz(event.timezone))){ + eventHasBegun = true; + } + let fromNow = moment.tz(event.start, event.timezone).fromNow(); + let parsedDescription = marked(event.description); + let eventEditToken = event.editToken; + + let escapedName = event.name.replace(/\s+/g, '+'); + + let eventHasCoverImage = false; + if( event.image ) { + eventHasCoverImage = true; + } + else { + eventHasCoverImage = false; + } + let eventHasHost = false; + if( event.hostName ) { + eventHasHost = true; + } + else { + eventHasHost = false; + } + let firstLoad = false; + if (event.firstLoad === true) { + firstLoad = true; + Event.findOneAndUpdate({id: req.params.eventID}, {firstLoad: false}, function(err, raw) { + if (err) { + res.send(err); + } + }); + } + let editingEnabled = false; + if (Object.keys(req.query).length !== 0) { + if (!req.query.e) { + editingEnabled = false; + console.log("No edit token set"); + } + else { + if (req.query.e === eventEditToken){ + editingEnabled = true; + } + else { + editingEnabled = false; + } + } + } + let eventAttendees = event.attendees.sort((a,b) => (a.name > b.name) ? 1 : ((b.name > a.name) ? -1 : 0)) .map(el => { if (!el.id) { el.id = el._id; @@ -373,13 +373,13 @@ router.get('/:eventID', (req, res) => { if (spotsRemaining <= 0) { noMoreSpots = true; } - } - let metadata = { - title: event.name, - description: marked(event.description, { renderer: render_plain()}).split(" ").splice(0,40).join(" ").trim(), - image: (eventHasCoverImage ? `https://${domain}/events/` + event.image : null), - url: `https://${domain}/` + req.params.eventID - }; + } + let metadata = { + title: event.name, + description: marked(event.description, { renderer: render_plain()}).split(" ").splice(0,40).join(" ").trim(), + image: (eventHasCoverImage ? `https://${domain}/events/` + event.image : null), + url: `https://${domain}/` + req.params.eventID + }; if (req.headers.accept && (req.headers.accept.includes('application/activity+json') || req.headers.accept.includes('application/json') || req.headers.accept.includes('application/json+ld'))) { res.json(JSON.parse(event.activityPubActor)); } @@ -393,8 +393,8 @@ router.get('/:eventID', (req, res) => { escapedName: escapedName, eventData: event, eventAttendees: eventAttendees, - spotsRemaining: spotsRemaining, - noMoreSpots: noMoreSpots, + spotsRemaining: spotsRemaining, + noMoreSpots: noMoreSpots, eventStartISO: eventStartISO, eventEndISO: eventEndISO, parsedLocation: parsedLocation, @@ -414,30 +414,30 @@ router.get('/:eventID', (req, res) => { siteName: siteName }) } - } - else { - res.status(404); - res.render('404', { url: req.url }); - } - - }) - .catch((err) => { - addToLog("displayEvent", "error", "Attempt to display event " + req.params.eventID + " failed with error: " + err); - console.log(err) - res.status(404); - res.render('404', { url: req.url }); - return; - }); + } + else { + res.status(404); + res.render('404', { url: req.url }); + } + + }) + .catch((err) => { + addToLog("displayEvent", "error", "Attempt to display event " + req.params.eventID + " failed with error: " + err); + console.log(err) + res.status(404); + res.render('404', { url: req.url }); + return; + }); }) router.get('/:eventID/followers', (req, res) => { if (!isFederated) return res.sendStatus(404); const eventID = req.params.eventID; - Event.findOne({ - id: eventID - }) - .then((event) => { - if (event) { + Event.findOne({ + id: eventID + }) + .then((event) => { + if (event) { const followers = event.followers.map(el => el.actorId); let followersCollection = { "type": "OrderedCollection", @@ -461,148 +461,148 @@ router.get('/:eventID/followers', (req, res) => { }) router.get('/group/:eventGroupID', (req, res) => { - EventGroup.findOne({ - id: req.params.eventGroupID - }) - .then(async (eventGroup) => { - if (eventGroup) { - let parsedDescription = marked(eventGroup.description); - let eventGroupEditToken = eventGroup.editToken; - - let escapedName = eventGroup.name.replace(/\s+/g, '+'); - - let eventGroupHasCoverImage = false; - if( eventGroup.image ) { - eventGroupHasCoverImage = true; - } - else { - eventGroupHasCoverImage = false; - } - let eventGroupHasHost = false; - if( eventGroup.hostName ) { - eventGroupHasHost = true; - } - else { - eventGroupHasHost = false; - } - - let events = await Event.find({eventGroup: eventGroup._id}).sort('start') - - events.forEach(event => { - if (moment.tz(event.end, event.timezone).isSame(event.start, 'day')){ - // Happening during one day - event.displayDate = moment.tz(event.start, event.timezone).format('D MMM YYYY'); - } - else { - event.displayDate = moment.tz(event.start, event.timezone).format('D MMM YYYY') + moment.tz(event.end, event.timezone).format(' - D MMM YYYY'); - } - if (moment.tz(event.end, event.timezone).isBefore(moment.tz(event.timezone))){ - event.eventHasConcluded = true; - } else { - event.eventHasConcluded = false; - } - }) - - let upcomingEventsExist = false; - if (events.some(e => e.eventHasConcluded === false)) { - upcomingEventsExist = true; - } - - let firstLoad = false; - if (eventGroup.firstLoad === true) { - firstLoad = true; - EventGroup.findOneAndUpdate({id: req.params.eventGroupID}, {firstLoad: false}, function(err, raw) { - if (err) { - res.send(err); - } - }); - } - let editingEnabled = false; - if (Object.keys(req.query).length !== 0) { - if (!req.query.e) { - editingEnabled = false; - console.log("No edit token set"); - } - else { - if (req.query.e === eventGroupEditToken){ - editingEnabled = true; - } - else { - editingEnabled = false; - } - } - } - let metadata = { - title: eventGroup.name, - description: marked(eventGroup.description, { renderer: render_plain()}).split(" ").splice(0,40).join(" ").trim(), - image: (eventGroupHasCoverImage ? `https://${domain}/events/` + eventGroup.image : null), - url: `https://${domain}/` + req.params.eventID - }; - res.set("X-Robots-Tag", "noindex"); - res.render('eventgroup', { + EventGroup.findOne({ + id: req.params.eventGroupID + }) + .then(async (eventGroup) => { + if (eventGroup) { + let parsedDescription = marked(eventGroup.description); + let eventGroupEditToken = eventGroup.editToken; + + let escapedName = eventGroup.name.replace(/\s+/g, '+'); + + let eventGroupHasCoverImage = false; + if( eventGroup.image ) { + eventGroupHasCoverImage = true; + } + else { + eventGroupHasCoverImage = false; + } + let eventGroupHasHost = false; + if( eventGroup.hostName ) { + eventGroupHasHost = true; + } + else { + eventGroupHasHost = false; + } + + let events = await Event.find({eventGroup: eventGroup._id}).sort('start') + + events.forEach(event => { + if (moment.tz(event.end, event.timezone).isSame(event.start, 'day')){ + // Happening during one day + event.displayDate = moment.tz(event.start, event.timezone).format('D MMM YYYY'); + } + else { + event.displayDate = moment.tz(event.start, event.timezone).format('D MMM YYYY') + moment.tz(event.end, event.timezone).format(' - D MMM YYYY'); + } + if (moment.tz(event.end, event.timezone).isBefore(moment.tz(event.timezone))){ + event.eventHasConcluded = true; + } else { + event.eventHasConcluded = false; + } + }) + + let upcomingEventsExist = false; + if (events.some(e => e.eventHasConcluded === false)) { + upcomingEventsExist = true; + } + + let firstLoad = false; + if (eventGroup.firstLoad === true) { + firstLoad = true; + EventGroup.findOneAndUpdate({id: req.params.eventGroupID}, {firstLoad: false}, function(err, raw) { + if (err) { + res.send(err); + } + }); + } + let editingEnabled = false; + if (Object.keys(req.query).length !== 0) { + if (!req.query.e) { + editingEnabled = false; + console.log("No edit token set"); + } + else { + if (req.query.e === eventGroupEditToken){ + editingEnabled = true; + } + else { + editingEnabled = false; + } + } + } + let metadata = { + title: eventGroup.name, + description: marked(eventGroup.description, { renderer: render_plain()}).split(" ").splice(0,40).join(" ").trim(), + image: (eventGroupHasCoverImage ? `https://${domain}/events/` + eventGroup.image : null), + url: `https://${domain}/` + req.params.eventID + }; + res.set("X-Robots-Tag", "noindex"); + res.render('eventgroup', { domain: domain, - title: eventGroup.name, - eventGroupData: eventGroup, - escapedName: escapedName, - events: events, - upcomingEventsExist: upcomingEventsExist, - parsedDescription: parsedDescription, - editingEnabled: editingEnabled, - eventGroupHasCoverImage: eventGroupHasCoverImage, - eventGroupHasHost: eventGroupHasHost, - firstLoad: firstLoad, - metadata: metadata - }) - } - else { - res.status(404); - res.render('404', { url: req.url }); - } - - }) - .catch((err) => { - addToLog("displayEventGroup", "error", "Attempt to display event group " + req.params.eventGroupID + " failed with error: " + err); - console.log(err) - res.status(404); - res.render('404', { url: req.url }); - return; - }); + title: eventGroup.name, + eventGroupData: eventGroup, + escapedName: escapedName, + events: events, + upcomingEventsExist: upcomingEventsExist, + parsedDescription: parsedDescription, + editingEnabled: editingEnabled, + eventGroupHasCoverImage: eventGroupHasCoverImage, + eventGroupHasHost: eventGroupHasHost, + firstLoad: firstLoad, + metadata: metadata + }) + } + else { + res.status(404); + res.render('404', { url: req.url }); + } + + }) + .catch((err) => { + addToLog("displayEventGroup", "error", "Attempt to display event group " + req.params.eventGroupID + " failed with error: " + err); + console.log(err) + res.status(404); + res.render('404', { url: req.url }); + return; + }); }) router.get('/exportevent/:eventID', (req, res) => { - Event.findOne({ - id: req.params.eventID - }) - .populate('eventGroup') - .then((event) => { - if (event) { - const icalEvent = cal.createEvent({ - start: moment.tz(event.start, event.timezone), - end: moment.tz(event.start, event.timezone), - timezone: event.timezone, - timestamp: moment(), - summary: event.name, - description: event.description, - organizer: { - name: event.hostName ? event.hostName : "Anonymous", - email: event.creatorEmail - }, - location: event.location, - url: 'https://gath.io/' + event.id - }); - - let string = cal.toString(); - console.log(string) - res.send(string); - } - }) - .catch((err) => { - addToLog("exportEvent", "error", "Attempt to export event " + req.params.eventID + " failed with error: " + err); - console.log(err) - res.status(404); - res.render('404', { url: req.url }); - return; - }); + Event.findOne({ + id: req.params.eventID + }) + .populate('eventGroup') + .then((event) => { + if (event) { + const icalEvent = cal.createEvent({ + start: moment.tz(event.start, event.timezone), + end: moment.tz(event.start, event.timezone), + timezone: event.timezone, + timestamp: moment(), + summary: event.name, + description: event.description, + organizer: { + name: event.hostName ? event.hostName : "Anonymous", + email: event.creatorEmail + }, + location: event.location, + url: 'https://gath.io/' + event.id + }); + + let string = cal.toString(); + console.log(string) + res.send(string); + } + }) + .catch((err) => { + addToLog("exportEvent", "error", "Attempt to export event " + req.params.eventID + " failed with error: " + err); + console.log(err) + res.status(404); + res.render('404', { url: req.url }); + return; + }); }) // BACKEND ROUTES @@ -615,73 +615,73 @@ router.get('/exportevent/:eventID', (req, res) => { router.post('/newevent', async (req, res) => { - let eventID = shortid.generate(); + let eventID = shortid.generate(); // this is a hack, activitypub does not like "-" in ids so we are essentially going // to have a 63-character alphabet instead of a 64-character one eventID = eventID.replace(/-/g,'_'); - let editToken = randomstring.generate(); - let eventImageFilename = ""; - let isPartOfEventGroup = false; - if (req.files && Object.keys(req.files).length !== 0) { - let eventImageBuffer = req.files.imageUpload.data; - Jimp.read(eventImageBuffer, (err, img) => { - if (err) addToLog("Jimp", "error", "Attempt to edit image failed with error: " + err); - img - .resize(920, Jimp.AUTO) // resize - .quality(80) // set JPEG quality - .write('./public/events/' + eventID + '.jpg'); // save - }); - eventImageFilename = eventID + '.jpg'; - } - let startUTC = moment.tz(req.body.eventStart, 'D MMMM YYYY, hh:mm a', req.body.timezone); - let endUTC = moment.tz(req.body.eventEnd, 'D MMMM YYYY, hh:mm a', req.body.timezone); - let eventGroup; - if (req.body.eventGroupCheckbox) { - eventGroup = await EventGroup.findOne({ - id: req.body.eventGroupID, - editToken: req.body.eventGroupEditToken - }) - if (eventGroup) { - isPartOfEventGroup = true; - } - } + let editToken = randomstring.generate(); + let eventImageFilename = ""; + let isPartOfEventGroup = false; + if (req.files && Object.keys(req.files).length !== 0) { + let eventImageBuffer = req.files.imageUpload.data; + Jimp.read(eventImageBuffer, (err, img) => { + if (err) addToLog("Jimp", "error", "Attempt to edit image failed with error: " + err); + img + .resize(920, Jimp.AUTO) // resize + .quality(80) // set JPEG quality + .write('./public/events/' + eventID + '.jpg'); // save + }); + eventImageFilename = eventID + '.jpg'; + } + let startUTC = moment.tz(req.body.eventStart, 'D MMMM YYYY, hh:mm a', req.body.timezone); + let endUTC = moment.tz(req.body.eventEnd, 'D MMMM YYYY, hh:mm a', req.body.timezone); + let eventGroup; + if (req.body.eventGroupCheckbox) { + eventGroup = await EventGroup.findOne({ + id: req.body.eventGroupID, + editToken: req.body.eventGroupEditToken + }) + if (eventGroup) { + isPartOfEventGroup = true; + } + } // generate RSA keypair for ActivityPub let pair = generateRSAKeypair(); - const event = new Event({ - id: eventID, - type: req.body.eventType, - name: req.body.eventName, - location: req.body.eventLocation, - start: startUTC, - end: endUTC, - timezone: req.body.timezone, - description: req.body.eventDescription, - image: eventImageFilename, - creatorEmail: req.body.creatorEmail, - url: req.body.eventURL, - hostName: req.body.hostName, - viewPassword: req.body.viewPassword, - editPassword: req.body.editPassword, - editToken: editToken, - eventGroup: isPartOfEventGroup ? eventGroup._id : null, - usersCanAttend: req.body.joinCheckbox ? true : false, - showUsersList: req.body.guestlistCheckbox ? true : false, - usersCanComment: req.body.interactionCheckbox ? true : false, - maxAttendees: req.body.maxAttendees, - firstLoad: true, + const event = new Event({ + id: eventID, + type: req.body.eventType, + name: req.body.eventName, + location: req.body.eventLocation, + start: startUTC, + end: endUTC, + timezone: req.body.timezone, + description: req.body.eventDescription, + image: eventImageFilename, + creatorEmail: req.body.creatorEmail, + url: req.body.eventURL, + hostName: req.body.hostName, + viewPassword: req.body.viewPassword, + editPassword: req.body.editPassword, + editToken: editToken, + eventGroup: isPartOfEventGroup ? eventGroup._id : null, + usersCanAttend: req.body.joinCheckbox ? true : false, + showUsersList: req.body.guestlistCheckbox ? true : false, + usersCanComment: req.body.interactionCheckbox ? true : false, + maxAttendees: req.body.maxAttendees, + firstLoad: true, activityPubActor: ap.createActivityPubActor(eventID, domain, pair.public, marked(req.body.eventDescription), req.body.eventName, req.body.eventLocation, eventImageFilename, startUTC, endUTC, req.body.timezone), activityPubEvent: ap.createActivityPubEvent(req.body.eventName, startUTC, endUTC, req.body.timezone, req.body.eventDescription, req.body.eventLocation), activityPubMessages: [ { id: `https://${domain}/${eventID}/m/featuredPost`, content: JSON.stringify(ap.createFeaturedPost(eventID, req.body.eventName, startUTC, endUTC, req.body.timezone, req.body.eventDescription, req.body.eventLocation)) } ], publicKey: pair.public, privateKey: pair.private - }); - event.save() - .then((event) => { - addToLog("createEvent", "success", "Event " + eventID + "created"); - // Send email with edit link - if (sendEmails) { + }); + event.save() + .then((event) => { + addToLog("createEvent", "success", "Event " + eventID + "created"); + // Send email with edit link + if (sendEmails) { req.app.get('hbsInstance').renderView('./views/emails/createevent.handlebars', {eventID, editToken, siteName, siteLogo, domain, cache: true, layout: 'email.handlebars'}, function(err, html) { const msg = { to: req.body.creatorEmail, @@ -697,117 +697,117 @@ router.post('/newevent', async (req, res) => { res.status(500).end(); }); }); - } - res.writeHead(302, { - 'Location': '/' + eventID + '?e=' + editToken - }); - res.end(); - }) - .catch((err) => { res.status(500).send('Database error, please try again :( - ' + err); addToLog("createEvent", "error", "Attempt to create event failed with error: " + err);}); + } + res.writeHead(302, { + 'Location': '/' + eventID + '?e=' + editToken + }); + res.end(); + }) + .catch((err) => { res.status(500).send('Database error, please try again :( - ' + err); addToLog("createEvent", "error", "Attempt to create event failed with error: " + err);}); }); router.post('/importevent', (req, res) => { - let eventID = shortid.generate(); - let editToken = randomstring.generate(); - if (req.files && Object.keys(req.files).length !== 0) { - let iCalObject = ical.parseICS(req.files.icsImportControl.data.toString('utf8')); - let importedEventData = iCalObject[Object.keys(iCalObject)]; - - let creatorEmail; - if (req.body.creatorEmail) { - creatorEmail = req.body.creatorEmail - } else if (importedEventData.organizer) { - creatorEmail = importedEventData.organizer.val.replace("MAILTO:", ""); - } else { - res.status(500).send("Please supply an email address on the previous page."); - } - - const event = new Event({ - id: eventID, - type: 'public', - name: importedEventData.summary, - location: importedEventData.location, - start: importedEventData.start, - end: importedEventData.end, - timezone: typeof importedEventData.start.tz !== 'undefined' ? importedEventData.start.tz : "Etc/UTC", - description: importedEventData.description, - image: '', - creatorEmail: creatorEmail, - url: '', - hostName: importedEventData.organizer ? importedEventData.organizer.params.CN.replace(/["]+/g, '') : "", - viewPassword: '', - editPassword: '', - editToken: editToken, - usersCanAttend: false, - showUsersList: false, - usersCanComment: false, - firstLoad: true - }); - event.save() - .then(() => { - addToLog("createEvent", "success", "Event " + eventID + " created"); - // Send email with edit link - if (sendEmails) { - req.app.get('hbsInstance').renderView('./views/emails/createevent.handlebars', {eventID, editToken, siteName, siteLogo, domain, cache: true, layout: 'email.handlebars'}, function(err, html) { - const msg = { - to: req.body.creatorEmail, - from: { - name: siteName, - email: contactEmail, - }, - subject: `${siteName}: ${importedEventData.summary}`, - html, - }; - sgMail.send(msg).catch(e => { - console.error(e.toString()); - res.status(500).end(); - }); - }); - } - res.writeHead(302, { - 'Location': '/' + eventID + '?e=' + editToken - }); - res.end(); - }) - .catch((err) => { res.send('Database error, please try again :('); addToLog("createEvent", "error", "Attempt to create event failed with error: " + err);}); - } - else { - console.log("Files array is empty!") - res.status(500).end(); - } + let eventID = shortid.generate(); + let editToken = randomstring.generate(); + if (req.files && Object.keys(req.files).length !== 0) { + let iCalObject = ical.parseICS(req.files.icsImportControl.data.toString('utf8')); + let importedEventData = iCalObject[Object.keys(iCalObject)]; + + let creatorEmail; + if (req.body.creatorEmail) { + creatorEmail = req.body.creatorEmail + } else if (importedEventData.organizer) { + creatorEmail = importedEventData.organizer.val.replace("MAILTO:", ""); + } else { + res.status(500).send("Please supply an email address on the previous page."); + } + + const event = new Event({ + id: eventID, + type: 'public', + name: importedEventData.summary, + location: importedEventData.location, + start: importedEventData.start, + end: importedEventData.end, + timezone: typeof importedEventData.start.tz !== 'undefined' ? importedEventData.start.tz : "Etc/UTC", + description: importedEventData.description, + image: '', + creatorEmail: creatorEmail, + url: '', + hostName: importedEventData.organizer ? importedEventData.organizer.params.CN.replace(/["]+/g, '') : "", + viewPassword: '', + editPassword: '', + editToken: editToken, + usersCanAttend: false, + showUsersList: false, + usersCanComment: false, + firstLoad: true + }); + event.save() + .then(() => { + addToLog("createEvent", "success", "Event " + eventID + " created"); + // Send email with edit link + if (sendEmails) { + req.app.get('hbsInstance').renderView('./views/emails/createevent.handlebars', {eventID, editToken, siteName, siteLogo, domain, cache: true, layout: 'email.handlebars'}, function(err, html) { + const msg = { + to: req.body.creatorEmail, + from: { + name: siteName, + email: contactEmail, + }, + subject: `${siteName}: ${importedEventData.summary}`, + html, + }; + sgMail.send(msg).catch(e => { + console.error(e.toString()); + res.status(500).end(); + }); + }); + } + res.writeHead(302, { + 'Location': '/' + eventID + '?e=' + editToken + }); + res.end(); + }) + .catch((err) => { res.send('Database error, please try again :('); addToLog("createEvent", "error", "Attempt to create event failed with error: " + err);}); + } + else { + console.log("Files array is empty!") + res.status(500).end(); + } }); router.post('/neweventgroup', (req, res) => { - let eventGroupID = shortid.generate(); - let editToken = randomstring.generate(); - let eventGroupImageFilename = ""; - if (req.files && Object.keys(req.files).length !== 0) { - let eventImageBuffer = req.files.imageUpload.data; - Jimp.read(eventImageBuffer, (err, img) => { - if (err) addToLog("Jimp", "error", "Attempt to edit image failed with error: " + err); - img - .resize(920, Jimp.AUTO) // resize - .quality(80) // set JPEG quality - .write('./public/events/' + eventGroupID + '.jpg'); // save - }); - eventGroupImageFilename = eventGroupID + '.jpg'; - } - const eventGroup = new EventGroup({ - id: eventGroupID, - name: req.body.eventGroupName, - description: req.body.eventGroupDescription, - image: eventGroupImageFilename, - creatorEmail: req.body.creatorEmail, - url: req.body.eventGroupURL, - hostName: req.body.hostName, - editToken: editToken, - firstLoad: true - }); - eventGroup.save() - .then(() => { - addToLog("createEventGroup", "success", "Event group " + eventGroupID + " created"); - // Send email with edit link - if (sendEmails) { + let eventGroupID = shortid.generate(); + let editToken = randomstring.generate(); + let eventGroupImageFilename = ""; + if (req.files && Object.keys(req.files).length !== 0) { + let eventImageBuffer = req.files.imageUpload.data; + Jimp.read(eventImageBuffer, (err, img) => { + if (err) addToLog("Jimp", "error", "Attempt to edit image failed with error: " + err); + img + .resize(920, Jimp.AUTO) // resize + .quality(80) // set JPEG quality + .write('./public/events/' + eventGroupID + '.jpg'); // save + }); + eventGroupImageFilename = eventGroupID + '.jpg'; + } + const eventGroup = new EventGroup({ + id: eventGroupID, + name: req.body.eventGroupName, + description: req.body.eventGroupDescription, + image: eventGroupImageFilename, + creatorEmail: req.body.creatorEmail, + url: req.body.eventGroupURL, + hostName: req.body.hostName, + editToken: editToken, + firstLoad: true + }); + eventGroup.save() + .then(() => { + addToLog("createEventGroup", "success", "Event group " + eventGroupID + " created"); + // Send email with edit link + if (sendEmails) { req.app.get('hbsInstance').renderView('./views/emails/createeventgroup.handlebars', {eventGroupID, editToken, siteName, siteLogo, domain, cache: true, layout: 'email.handlebars'}, function(err, html) { const msg = { to: req.body.creatorEmail, @@ -823,71 +823,71 @@ router.post('/neweventgroup', (req, res) => { res.status(500).end(); }); }); - } - res.writeHead(302, { - 'Location': '/group/' + eventGroupID + '?e=' + editToken - }); - res.end(); - }) - .catch((err) => { res.send('Database error, please try again :( - ' + err); addToLog("createEvent", "error", "Attempt to create event failed with error: " + err);}); + } + res.writeHead(302, { + 'Location': '/group/' + eventGroupID + '?e=' + editToken + }); + res.end(); + }) + .catch((err) => { res.send('Database error, please try again :( - ' + err); addToLog("createEvent", "error", "Attempt to create event failed with error: " + err);}); }); router.post('/editevent/:eventID/:editToken', (req, res) => { - console.log(req.body); - let submittedEditToken = req.params.editToken; - Event.findOne(({ - id: req.params.eventID, - })) - .then(async (event) => { - if (event.editToken === submittedEditToken) { - // Token matches - - // If there is a new image, upload that first - let eventID = req.params.eventID; - let eventImageFilename = event.image; - if (req.files && Object.keys(req.files).length !== 0) { - let eventImageBuffer = req.files.imageUpload.data; - Jimp.read(eventImageBuffer, (err, img) => { - if (err) throw err; - img - .resize(920, Jimp.AUTO) // resize - .quality(80) // set JPEG - .write('./public/events/' + eventID + '.jpg'); // save - }); - eventImageFilename = eventID + '.jpg'; - } - let startUTC = moment.tz(req.body.eventStart, 'D MMMM YYYY, hh:mm a', req.body.timezone); - let endUTC = moment.tz(req.body.eventEnd, 'D MMMM YYYY, hh:mm a', req.body.timezone); - - let isPartOfEventGroup = false; + console.log(req.body); + let submittedEditToken = req.params.editToken; + Event.findOne(({ + id: req.params.eventID, + })) + .then(async (event) => { + if (event.editToken === submittedEditToken) { + // Token matches + + // If there is a new image, upload that first + let eventID = req.params.eventID; + let eventImageFilename = event.image; + if (req.files && Object.keys(req.files).length !== 0) { + let eventImageBuffer = req.files.imageUpload.data; + Jimp.read(eventImageBuffer, (err, img) => { + if (err) throw err; + img + .resize(920, Jimp.AUTO) // resize + .quality(80) // set JPEG + .write('./public/events/' + eventID + '.jpg'); // save + }); + eventImageFilename = eventID + '.jpg'; + } + let startUTC = moment.tz(req.body.eventStart, 'D MMMM YYYY, hh:mm a', req.body.timezone); + let endUTC = moment.tz(req.body.eventEnd, 'D MMMM YYYY, hh:mm a', req.body.timezone); + + let isPartOfEventGroup = false; let eventGroup; - if (req.body.eventGroupCheckbox) { - eventGroup = await EventGroup.findOne({ - id: req.body.eventGroupID, - editToken: req.body.eventGroupEditToken - }) - if (eventGroup) { - isPartOfEventGroup = true; - } - } - const updatedEvent = { - name: req.body.eventName, - location: req.body.eventLocation, - start: startUTC, - end: endUTC, - timezone: req.body.timezone, - description: req.body.eventDescription, - url: req.body.eventURL, - hostName: req.body.hostName, - image: eventImageFilename, - usersCanAttend: req.body.joinCheckbox ? true : false, - showUsersList: req.body.guestlistCheckbox ? true : false, - usersCanComment: req.body.interactionCheckbox ? true : false, - maxAttendees: req.body.maxAttendeesCheckbox ? req.body.maxAttendees : null, - eventGroup: isPartOfEventGroup ? eventGroup._id : null, + if (req.body.eventGroupCheckbox) { + eventGroup = await EventGroup.findOne({ + id: req.body.eventGroupID, + editToken: req.body.eventGroupEditToken + }) + if (eventGroup) { + isPartOfEventGroup = true; + } + } + const updatedEvent = { + name: req.body.eventName, + location: req.body.eventLocation, + start: startUTC, + end: endUTC, + timezone: req.body.timezone, + description: req.body.eventDescription, + url: req.body.eventURL, + hostName: req.body.hostName, + image: eventImageFilename, + usersCanAttend: req.body.joinCheckbox ? true : false, + showUsersList: req.body.guestlistCheckbox ? true : false, + usersCanComment: req.body.interactionCheckbox ? true : false, + maxAttendees: req.body.maxAttendeesCheckbox ? req.body.maxAttendees : null, + eventGroup: isPartOfEventGroup ? eventGroup._id : null, activityPubActor: ap.updateActivityPubActor(JSON.parse(event.activityPubActor), req.body.eventDescription, req.body.eventName, req.body.eventLocation, eventImageFilename, startUTC, endUTC, req.body.timezone), activityPubEvent: ap.updateActivityPubEvent(JSON.parse(event.activityPubEvent), req.body.eventName, req.body.startUTC, req.body.endUTC, req.body.timezone), - } + } let diffText = '<p>This event was just updated with new information.</p><ul>'; let displayDate; if (event.name !== updatedEvent.name) { @@ -912,14 +912,14 @@ router.post('/editevent/:eventID/:editToken', (req, res) => { diffText += `<li>the event description changed</li>`; } diffText += `</ul>`; - Event.findOneAndUpdate({id: req.params.eventID}, updatedEvent, function(err, raw) { - if (err) { - addToLog("editEvent", "error", "Attempt to edit event " + req.params.eventID + " failed with error: " + err); - res.send(err); - } - }) - .then(() => { - addToLog("editEvent", "success", "Event " + req.params.eventID + " edited"); + Event.findOneAndUpdate({id: req.params.eventID}, updatedEvent, function(err, raw) { + if (err) { + addToLog("editEvent", "error", "Attempt to edit event " + req.params.eventID + " failed with error: " + err); + res.send(err); + } + }) + .then(() => { + addToLog("editEvent", "success", "Event " + req.params.eventID + " edited"); // send update to ActivityPub subscribers Event.findOne({id: req.params.eventID}, function(err,event) { if (!event) return; @@ -957,11 +957,11 @@ router.post('/editevent/:eventID/:editToken', (req, res) => { } } }) - if (sendEmails) { - Event.findOne({id: req.params.eventID}).distinct('attendees.email', function(error, ids) { - let attendeeEmails = ids; - if (!error && attendeeEmails !== ""){ - console.log("Sending emails to: " + attendeeEmails); + if (sendEmails) { + Event.findOne({id: req.params.eventID}).distinct('attendees.email', function(error, ids) { + let attendeeEmails = ids; + if (!error && attendeeEmails !== ""){ + console.log("Sending emails to: " + attendeeEmails); req.app.get('hbsInstance').renderView('./views/emails/editevent.handlebars', {diffText, eventID: req.params.eventID, siteName, siteLogo, domain, cache: true, layout: 'email.handlebars'}, function(err, html) { const msg = { to: attendeeEmails, @@ -977,130 +977,130 @@ router.post('/editevent/:eventID/:editToken', (req, res) => { res.status(500).end(); }); }); - } - else { - console.log("Nothing to send!"); - } - }) - } - res.writeHead(302, { - 'Location': '/' + req.params.eventID + '?e=' + req.params.editToken - }); - res.end(); - }) - .catch((err) => { console.error(err); res.send('Sorry! Something went wrong!'); addToLog("editEvent", "error", "Attempt to edit event " + req.params.eventID + " failed with error: " + err);}); - } - else { - // Token doesn't match - res.send('Sorry! Something went wrong'); - addToLog("editEvent", "error", "Attempt to edit event " + req.params.eventID + " failed with error: token does not match"); - } - }) - .catch((err) => { console.error(err); res.send('Sorry! Something went wrong!'); addToLog("editEvent", "error", "Attempt to edit event " + req.params.eventID + " failed with error: " + err);}); + } + else { + console.log("Nothing to send!"); + } + }) + } + res.writeHead(302, { + 'Location': '/' + req.params.eventID + '?e=' + req.params.editToken + }); + res.end(); + }) + .catch((err) => { console.error(err); res.send('Sorry! Something went wrong!'); addToLog("editEvent", "error", "Attempt to edit event " + req.params.eventID + " failed with error: " + err);}); + } + else { + // Token doesn't match + res.send('Sorry! Something went wrong'); + addToLog("editEvent", "error", "Attempt to edit event " + req.params.eventID + " failed with error: token does not match"); + } + }) + .catch((err) => { console.error(err); res.send('Sorry! Something went wrong!'); addToLog("editEvent", "error", "Attempt to edit event " + req.params.eventID + " failed with error: " + err);}); }); router.post('/editeventgroup/:eventGroupID/:editToken', (req, res) => { - let submittedEditToken = req.params.editToken; - EventGroup.findOne(({ - id: req.params.eventGroupID, - })) - .then((eventGroup) => { - if (eventGroup.editToken === submittedEditToken) { - // Token matches - - // If there is a new image, upload that first - let eventGroupID = req.params.eventGroupID; - let eventGroupImageFilename = eventGroup.image; - if (req.files && Object.keys(req.files).length !== 0) { - let eventImageBuffer = req.files.eventGroupImageUpload.data; - Jimp.read(eventImageBuffer, (err, img) => { - if (err) throw err; - img - .resize(920, Jimp.AUTO) // resize - .quality(80) // set JPEG - .write('./public/events/' + eventGroupID + '.jpg'); // save - }); - eventGroupImageFilename = eventGroupID + '.jpg'; - } - const updatedEventGroup = { - name: req.body.eventGroupName, - description: req.body.eventGroupDescription, - url: req.body.eventGroupURL, - hostName: req.body.hostName, - image: eventGroupImageFilename - } - EventGroup.findOneAndUpdate({id: req.params.eventGroupID}, updatedEventGroup, function(err, raw) { - if (err) { - addToLog("editEventGroup", "error", "Attempt to edit event group " + req.params.eventGroupID + " failed with error: " + err); - res.send(err); - } - }) - .then(() => { - addToLog("editEventGroup", "success", "Event group " + req.params.eventGroupID + " edited"); - res.writeHead(302, { - 'Location': '/group/' + req.params.eventGroupID + '?e=' + req.params.editToken - }); - res.end(); - }) - .catch((err) => { console.error(err); res.send('Sorry! Something went wrong!'); addToLog("editEventGroup", "error", "Attempt to edit event group " + req.params.eventGroupID + " failed with error: " + err);}); - } - else { - // Token doesn't match - res.send('Sorry! Something went wrong'); - addToLog("editEventGroup", "error", "Attempt to edit event group " + req.params.eventGroupID + " failed with error: token does not match"); - } - }) - .catch((err) => { console.error(err); res.send('Sorry! Something went wrong!'); addToLog("editEventGroup", "error", "Attempt to edit event group " + req.params.eventGroupID + " failed with error: " + err);}); + let submittedEditToken = req.params.editToken; + EventGroup.findOne(({ + id: req.params.eventGroupID, + })) + .then((eventGroup) => { + if (eventGroup.editToken === submittedEditToken) { + // Token matches + + // If there is a new image, upload that first + let eventGroupID = req.params.eventGroupID; + let eventGroupImageFilename = eventGroup.image; + if (req.files && Object.keys(req.files).length !== 0) { + let eventImageBuffer = req.files.eventGroupImageUpload.data; + Jimp.read(eventImageBuffer, (err, img) => { + if (err) throw err; + img + .resize(920, Jimp.AUTO) // resize + .quality(80) // set JPEG + .write('./public/events/' + eventGroupID + '.jpg'); // save + }); + eventGroupImageFilename = eventGroupID + '.jpg'; + } + const updatedEventGroup = { + name: req.body.eventGroupName, + description: req.body.eventGroupDescription, + url: req.body.eventGroupURL, + hostName: req.body.hostName, + image: eventGroupImageFilename + } + EventGroup.findOneAndUpdate({id: req.params.eventGroupID}, updatedEventGroup, function(err, raw) { + if (err) { + addToLog("editEventGroup", "error", "Attempt to edit event group " + req.params.eventGroupID + " failed with error: " + err); + res.send(err); + } + }) + .then(() => { + addToLog("editEventGroup", "success", "Event group " + req.params.eventGroupID + " edited"); + res.writeHead(302, { + 'Location': '/group/' + req.params.eventGroupID + '?e=' + req.params.editToken + }); + res.end(); + }) + .catch((err) => { console.error(err); res.send('Sorry! Something went wrong!'); addToLog("editEventGroup", "error", "Attempt to edit event group " + req.params.eventGroupID + " failed with error: " + err);}); + } + else { + // Token doesn't match + res.send('Sorry! Something went wrong'); + addToLog("editEventGroup", "error", "Attempt to edit event group " + req.params.eventGroupID + " failed with error: token does not match"); + } + }) + .catch((err) => { console.error(err); res.send('Sorry! Something went wrong!'); addToLog("editEventGroup", "error", "Attempt to edit event group " + req.params.eventGroupID + " failed with error: " + err);}); }); router.post('/deleteimage/:eventID/:editToken', (req, res) => { - let submittedEditToken = req.params.editToken; - Event.findOne(({ - id: req.params.eventID, - })) - .then((event) => { - if (event.editToken === submittedEditToken) { - // Token matches - if (event.image){ - eventImage = event.image; - } else { - res.status(500).send('This event doesn\'t have a linked image. What are you even doing'); - } - fs.unlink(global.appRoot + '/public/events/' + eventImage, (err) => { - if (err) { - res.status(500).send(err); - addToLog("deleteEventImage", "error", "Attempt to delete event image for event " + req.params.eventID + " failed with error: " + err); - } - // Image removed - addToLog("deleteEventImage", "success", "Image for event " + req.params.eventID + " deleted"); - event.image = ""; - event.save() - .then(response => { - res.status(200).send('Success'); - }) - .catch(err => { - res.status(500).send(err); - addToLog("deleteEventImage", "error", "Attempt to delete event image for event " + req.params.eventID + " failed with error: " + err); - }) - }); - } - }); + let submittedEditToken = req.params.editToken; + Event.findOne(({ + id: req.params.eventID, + })) + .then((event) => { + if (event.editToken === submittedEditToken) { + // Token matches + if (event.image){ + eventImage = event.image; + } else { + res.status(500).send('This event doesn\'t have a linked image. What are you even doing'); + } + fs.unlink(global.appRoot + '/public/events/' + eventImage, (err) => { + if (err) { + res.status(500).send(err); + addToLog("deleteEventImage", "error", "Attempt to delete event image for event " + req.params.eventID + " failed with error: " + err); + } + // Image removed + addToLog("deleteEventImage", "success", "Image for event " + req.params.eventID + " deleted"); + event.image = ""; + event.save() + .then(response => { + res.status(200).send('Success'); + }) + .catch(err => { + res.status(500).send(err); + addToLog("deleteEventImage", "error", "Attempt to delete event image for event " + req.params.eventID + " failed with error: " + err); + }) + }); + } + }); }); router.post('/deleteevent/:eventID/:editToken', (req, res) => { - let submittedEditToken = req.params.editToken; - let eventImage; - Event.findOne(({ - id: req.params.eventID, - })) - .then((event) => { - if (event.editToken === submittedEditToken) { - // Token matches + let submittedEditToken = req.params.editToken; + let eventImage; + Event.findOne(({ + id: req.params.eventID, + })) + .then((event) => { + if (event.editToken === submittedEditToken) { + // Token matches let eventImage; - if (event.image){ - eventImage = event.image; - } + if (event.image){ + eventImage = event.image; + } // broadcast a Delete profile message to all followers so that at least Mastodon servers will delete their local profile information const guidUpdateObject = crypto.randomBytes(16).toString('hex'); @@ -1132,12 +1132,12 @@ router.post('/deleteevent/:eventID/:editToken', (req, res) => { }) .catch((err) => { res.send('Sorry! Something went wrong (error deleting): ' + err); addToLog("deleteEvent", "error", "Attempt to delete event " + req.params.eventID + " failed with error: " + err);}); }); - // Send emails here otherwise they don't exist lol - if (sendEmails) { - Event.findOne({id: req.params.eventID}).distinct('attendees.email', function(error, ids) { - attendeeEmails = ids; - if (!error){ - console.log("Sending emails to: " + attendeeEmails); + // Send emails here otherwise they don't exist lol + if (sendEmails) { + Event.findOne({id: req.params.eventID}).distinct('attendees.email', function(error, ids) { + attendeeEmails = ids; + if (!error){ + console.log("Sending emails to: " + attendeeEmails); req.app.get('hbsInstance').renderView('./views/emails/deleteevent.handlebars', {siteName, siteLogo, domain, eventName: event.name, cache: true, layout: 'email.handlebars'}, function(err, html) { const msg = { to: attendeeEmails, @@ -1159,89 +1159,89 @@ router.post('/deleteevent/:eventID/:editToken', (req, res) => { } }); } - } - else { - // Token doesn't match - res.send('Sorry! Something went wrong'); - addToLog("deleteEvent", "error", "Attempt to delete event " + req.params.eventID + " failed with error: token does not match"); - } - }) - .catch((err) => { res.send('Sorry! Something went wrong: ' + err); addToLog("deleteEvent", "error", "Attempt to delete event " + req.params.eventID + " failed with error: " + err);}); + } + else { + // Token doesn't match + res.send('Sorry! Something went wrong'); + addToLog("deleteEvent", "error", "Attempt to delete event " + req.params.eventID + " failed with error: token does not match"); + } + }) + .catch((err) => { res.send('Sorry! Something went wrong: ' + err); addToLog("deleteEvent", "error", "Attempt to delete event " + req.params.eventID + " failed with error: " + err);}); }); router.post('/deleteeventgroup/:eventGroupID/:editToken', (req, res) => { - let submittedEditToken = req.params.editToken; - EventGroup.findOne(({ - id: req.params.eventGroupID, - })) - .then(async (eventGroup) => { - if (eventGroup.editToken === submittedEditToken) { - // Token matches - - let linkedEvents = await Event.find({eventGroup: eventGroup._id}); - - let linkedEventIDs = linkedEvents.map(event => event._id); - let eventGroupImage = false; - if (eventGroup.image){ - eventGroupImage = eventGroup.image; - } - - EventGroup.deleteOne({id: req.params.eventGroupID}, function(err, raw) { - if (err) { - res.send(err); - addToLog("deleteEventGroup", "error", "Attempt to delete event group " + req.params.eventGroupID + " failed with error: " + err); - } - }) - .then(() => { - // Delete image - if (eventGroupImage){ - fs.unlink(global.appRoot + '/public/events/' + eventGroupImage, (err) => { - if (err) { - res.send(err); - addToLog("deleteEventGroup", "error", "Attempt to delete event image for event group " + req.params.eventGroupID + " failed with error: " + err); - } - }) - } - Event.update({_id: {$in: linkedEventIDs}}, { $set: { eventGroup: null } }, { multi: true }) - .then(response => { - console.log(response); - addToLog("deleteEventGroup", "success", "Event group " + req.params.eventGroupID + " deleted"); - res.writeHead(302, { - 'Location': '/' - }); - res.end(); - }) - .catch((err) => { res.send('Sorry! Something went wrong (error deleting): ' + err); addToLog("deleteEventGroup", "error", "Attempt to delete event group " + req.params.eventGroupID + " failed with error: " + err);}); - }) - .catch((err) => { res.send('Sorry! Something went wrong (error deleting): ' + err); addToLog("deleteEventGroup", "error", "Attempt to delete event group " + req.params.eventGroupID + " failed with error: " + err);}); - } - else { - // Token doesn't match - res.send('Sorry! Something went wrong'); - addToLog("deleteEventGroup", "error", "Attempt to delete event group " + req.params.eventGroupID + " failed with error: token does not match"); - } - }) - .catch((err) => { res.send('Sorry! Something went wrong: ' + err); addToLog("deleteEventGroup", "error", "Attempt to delete event group " + req.params.eventGroupID + " failed with error: " + err);}); + let submittedEditToken = req.params.editToken; + EventGroup.findOne(({ + id: req.params.eventGroupID, + })) + .then(async (eventGroup) => { + if (eventGroup.editToken === submittedEditToken) { + // Token matches + + let linkedEvents = await Event.find({eventGroup: eventGroup._id}); + + let linkedEventIDs = linkedEvents.map(event => event._id); + let eventGroupImage = false; + if (eventGroup.image){ + eventGroupImage = eventGroup.image; + } + + EventGroup.deleteOne({id: req.params.eventGroupID}, function(err, raw) { + if (err) { + res.send(err); + addToLog("deleteEventGroup", "error", "Attempt to delete event group " + req.params.eventGroupID + " failed with error: " + err); + } + }) + .then(() => { + // Delete image + if (eventGroupImage){ + fs.unlink(global.appRoot + '/public/events/' + eventGroupImage, (err) => { + if (err) { + res.send(err); + addToLog("deleteEventGroup", "error", "Attempt to delete event image for event group " + req.params.eventGroupID + " failed with error: " + err); + } + }) + } + Event.update({_id: {$in: linkedEventIDs}}, { $set: { eventGroup: null } }, { multi: true }) + .then(response => { + console.log(response); + addToLog("deleteEventGroup", "success", "Event group " + req.params.eventGroupID + " deleted"); + res.writeHead(302, { + 'Location': '/' + }); + res.end(); + }) + .catch((err) => { res.send('Sorry! Something went wrong (error deleting): ' + err); addToLog("deleteEventGroup", "error", "Attempt to delete event group " + req.params.eventGroupID + " failed with error: " + err);}); + }) + .catch((err) => { res.send('Sorry! Something went wrong (error deleting): ' + err); addToLog("deleteEventGroup", "error", "Attempt to delete event group " + req.params.eventGroupID + " failed with error: " + err);}); + } + else { + // Token doesn't match + res.send('Sorry! Something went wrong'); + addToLog("deleteEventGroup", "error", "Attempt to delete event group " + req.params.eventGroupID + " failed with error: token does not match"); + } + }) + .catch((err) => { res.send('Sorry! Something went wrong: ' + err); addToLog("deleteEventGroup", "error", "Attempt to delete event group " + req.params.eventGroupID + " failed with error: " + err);}); }); router.post('/attendevent/:eventID', (req, res) => { - const newAttendee = { - name: req.body.attendeeName, - status: 'attending', - email: req.body.attendeeEmail, - removalPassword: req.body.removeAttendancePassword - }; - - Event.findOne({ - id: req.params.eventID, - }, function(err,event) { + const newAttendee = { + name: req.body.attendeeName, + status: 'attending', + email: req.body.attendeeEmail, + removalPassword: req.body.removeAttendancePassword + }; + + Event.findOne({ + id: req.params.eventID, + }, function(err,event) { if (!event) return; - event.attendees.push(newAttendee); - event.save() - .then(() => { - addToLog("addEventAttendee", "success", "Attendee added to event " + req.params.eventID); - if (sendEmails) { - if (req.body.attendeeEmail){ + event.attendees.push(newAttendee); + event.save() + .then(() => { + addToLog("addEventAttendee", "success", "Attendee added to event " + req.params.eventID); + if (sendEmails) { + if (req.body.attendeeEmail){ req.app.get('hbsInstance').renderView('./views/emails/addeventattendee.handlebars', {eventID: req.params.eventID, siteName, siteLogo, domain, cache: true, layout: 'email.handlebars'}, function(err, html) { const msg = { to: req.body.attendeeEmail, @@ -1257,34 +1257,34 @@ router.post('/attendevent/:eventID', (req, res) => { res.status(500).end(); }); }); - } - } - res.writeHead(302, { - 'Location': '/' + req.params.eventID - }); - res.end(); - }) - .catch((err) => { res.send('Database error, please try again :('); addToLog("addEventAttendee", "error", "Attempt to add attendee to event " + req.params.eventID + " failed with error: " + err); }); - }); + } + } + res.writeHead(302, { + 'Location': '/' + req.params.eventID + }); + res.end(); + }) + .catch((err) => { res.send('Database error, please try again :('); addToLog("addEventAttendee", "error", "Attempt to add attendee to event " + req.params.eventID + " failed with error: " + err); }); + }); }); router.post('/unattendevent/:eventID', (req, res) => { - Event.update( - { id: req.params.eventID }, - { $pull: { attendees: { removalPassword: req.body.removeAttendancePassword } } } - ) - .then(response => { - console.log(response) - addToLog("unattendEvent", "success", "Attendee removed self from event " + req.params.eventID); - if (sendEmails) { - if (req.body.attendeeEmail){ + Event.update( + { id: req.params.eventID }, + { $pull: { attendees: { removalPassword: req.body.removeAttendancePassword } } } + ) + .then(response => { + console.log(response) + addToLog("unattendEvent", "success", "Attendee removed self from event " + req.params.eventID); + if (sendEmails) { + if (req.body.attendeeEmail){ req.app.get('hbsInstance').renderView('./views/emails/unattendevent.handlebars', {eventID: req.params.eventID, siteName, siteLogo, domain, cache: true, layout: 'email.handlebars'}, function(err, html) { const msg = { to: req.body.attendeeEmail, from: { name: siteName, email: contactEmail, }, - subject: `${siteName}: You have been removed from an event`, + subject: `${siteName}: You have been removed from an event`, html, }; sgMail.send(msg).catch(e => { @@ -1292,16 +1292,16 @@ router.post('/unattendevent/:eventID', (req, res) => { res.status(500).end(); }); }); - } - } - res.writeHead(302, { - 'Location': '/' + req.params.eventID - }); - res.end(); - }) - .catch((err) => { - res.send('Database error, please try again :('); addToLog("removeEventAttendee", "error", "Attempt to remove attendee from event " + req.params.eventID + " failed with error: " + err); - }); + } + } + res.writeHead(302, { + 'Location': '/' + req.params.eventID + }); + res.end(); + }) + .catch((err) => { + res.send('Database error, please try again :('); addToLog("removeEventAttendee", "error", "Attempt to remove attendee from event " + req.params.eventID + " failed with error: " + err); + }); }); // this is a one-click unattend that requires a secret URL that only the person who RSVPed over @@ -1312,22 +1312,22 @@ router.get('/oneclickunattendevent/:eventID/:attendeeID', (req, res) => { if (req.headers['user-agent'] && req.headers['user-agent'].includes('Mastodon')) { return res.sendStatus(200); } - Event.update( - { id: req.params.eventID }, - { $pull: { attendees: { _id: req.params.attendeeID } } } - ) - .then(response => { - addToLog("oneClickUnattend", "success", "Attendee removed via one click unattend " + req.params.eventID); - if (sendEmails) { + Event.update( + { id: req.params.eventID }, + { $pull: { attendees: { _id: req.params.attendeeID } } } + ) + .then(response => { + addToLog("oneClickUnattend", "success", "Attendee removed via one click unattend " + req.params.eventID); + if (sendEmails) { // currently this is never called because we don't have the email address - if (req.body.attendeeEmail){ + if (req.body.attendeeEmail){ req.app.get('hbsInstance').renderView('./views/emails/removeeventattendee.handlebars', {eventName: req.params.eventName, siteName, domain, cache: true, layout: 'email.handlebars'}, function(err, html) { const msg = { to: req.body.attendeeEmail, from: { name: siteName, email: contactEmail, }, - subject: `${siteName}: You have been removed from an event`, + subject: `${siteName}: You have been removed from an event`, html, }; sgMail.send(msg).catch(e => { @@ -1335,36 +1335,36 @@ router.get('/oneclickunattendevent/:eventID/:attendeeID', (req, res) => { res.status(500).end(); }); }); - } - } - res.writeHead(302, { - 'Location': '/' + req.params.eventID - }); - res.end(); - }) - .catch((err) => { - res.send('Database error, please try again :('); addToLog("removeEventAttendee", "error", "Attempt to remove attendee by admin from event " + req.params.eventID + " failed with error: " + err); - }); + } + } + res.writeHead(302, { + 'Location': '/' + req.params.eventID + }); + res.end(); + }) + .catch((err) => { + res.send('Database error, please try again :('); addToLog("removeEventAttendee", "error", "Attempt to remove attendee by admin from event " + req.params.eventID + " failed with error: " + err); + }); }); router.post('/removeattendee/:eventID/:attendeeID', (req, res) => { - Event.update( - { id: req.params.eventID }, - { $pull: { attendees: { _id: req.params.attendeeID } } } - ) - .then(response => { - console.log(response) - addToLog("removeEventAttendee", "success", "Attendee removed by admin from event " + req.params.eventID); - if (sendEmails) { + Event.update( + { id: req.params.eventID }, + { $pull: { attendees: { _id: req.params.attendeeID } } } + ) + .then(response => { + console.log(response) + addToLog("removeEventAttendee", "success", "Attendee removed by admin from event " + req.params.eventID); + if (sendEmails) { // currently this is never called because we don't have the email address - if (req.body.attendeeEmail){ + if (req.body.attendeeEmail){ req.app.get('hbsInstance').renderView('./views/emails/removeeventattendee.handlebars', {eventName: req.params.eventName, siteName, siteLogo, domain, cache: true, layout: 'email.handlebars'}, function(err, html) { const msg = { to: req.body.attendeeEmail, from: { name: siteName, email: contactEmail, }, - subject: `${siteName}: You have been removed from an event`, + subject: `${siteName}: You have been removed from an event`, html, }; sgMail.send(msg).catch(e => { @@ -1372,35 +1372,35 @@ router.post('/removeattendee/:eventID/:attendeeID', (req, res) => { res.status(500).end(); }); }); - } - } - res.writeHead(302, { - 'Location': '/' + req.params.eventID - }); - res.end(); - }) - .catch((err) => { - res.send('Database error, please try again :('); addToLog("removeEventAttendee", "error", "Attempt to remove attendee by admin from event " + req.params.eventID + " failed with error: " + err); - }); + } + } + res.writeHead(302, { + 'Location': '/' + req.params.eventID + }); + res.end(); + }) + .catch((err) => { + res.send('Database error, please try again :('); addToLog("removeEventAttendee", "error", "Attempt to remove attendee by admin from event " + req.params.eventID + " failed with error: " + err); + }); }); router.post('/post/comment/:eventID', (req, res) => { - let commentID = shortid.generate(); - const newComment = { - id: commentID, - author: req.body.commentAuthor, - content: req.body.commentContent, - timestamp: moment() - }; - - Event.findOne({ - id: req.params.eventID, - }, function(err,event) { + let commentID = shortid.generate(); + const newComment = { + id: commentID, + author: req.body.commentAuthor, + content: req.body.commentContent, + timestamp: moment() + }; + + Event.findOne({ + id: req.params.eventID, + }, function(err,event) { if (!event) return; - event.comments.push(newComment); - event.save() - .then(() => { - addToLog("addEventComment", "success", "Comment added to event " + req.params.eventID); + event.comments.push(newComment); + event.save() + .then(() => { + addToLog("addEventComment", "success", "Comment added to event " + req.params.eventID); // broadcast an identical message to all followers, will show in their home timeline // and in the home timeline of the event const guidObject = crypto.randomBytes(16).toString('hex'); @@ -1413,11 +1413,11 @@ router.post('/post/comment/:eventID', (req, res) => { "content": `<p>${req.body.commentAuthor} commented: ${req.body.commentContent}.</p><p><a href="https://${domain}/${req.params.eventID}/">See the full conversation here.</a></p>`, } ap.broadcastCreateMessage(jsonObject, event.followers, req.params.eventID) - if (sendEmails) { - Event.findOne({id: req.params.eventID}).distinct('attendees.email', function(error, ids) { - let attendeeEmails = ids; - if (!error){ - console.log("Sending emails to: " + attendeeEmails); + if (sendEmails) { + Event.findOne({id: req.params.eventID}).distinct('attendees.email', function(error, ids) { + let attendeeEmails = ids; + if (!error){ + console.log("Sending emails to: " + attendeeEmails); req.app.get('hbsInstance').renderView('./views/emails/addeventcomment.handlebars', {siteName, siteLogo, domain, eventID: req.params.eventID, commentAuthor: req.body.commentAuthor, cache: true, layout: 'email.handlebars'}, function(err, html) { const msg = { to: attendeeEmails, @@ -1433,39 +1433,39 @@ router.post('/post/comment/:eventID', (req, res) => { res.status(500).end(); }); }); - } - else { - console.log("Nothing to send!"); - } - }); - } - res.writeHead(302, { - 'Location': '/' + req.params.eventID - }); - res.end(); - }) - .catch((err) => { res.send('Database error, please try again :(' + err); addToLog("addEventComment", "error", "Attempt to add comment to event " + req.params.eventID + " failed with error: " + err); }); - }); + } + else { + console.log("Nothing to send!"); + } + }); + } + res.writeHead(302, { + 'Location': '/' + req.params.eventID + }); + res.end(); + }) + .catch((err) => { res.send('Database error, please try again :(' + err); addToLog("addEventComment", "error", "Attempt to add comment to event " + req.params.eventID + " failed with error: " + err); }); + }); }); router.post('/post/reply/:eventID/:commentID', (req, res) => { - let replyID = shortid.generate(); - let commentID = req.params.commentID; - const newReply = { - id: replyID, - author: req.body.replyAuthor, - content: req.body.replyContent, - timestamp: moment() - }; - Event.findOne({ - id: req.params.eventID, - }, function(err,event) { + let replyID = shortid.generate(); + let commentID = req.params.commentID; + const newReply = { + id: replyID, + author: req.body.replyAuthor, + content: req.body.replyContent, + timestamp: moment() + }; + Event.findOne({ + id: req.params.eventID, + }, function(err,event) { if (!event) return; - var parentComment = event.comments.id(commentID); - parentComment.replies.push(newReply); - event.save() - .then(() => { - addToLog("addEventReply", "success", "Reply added to comment " + commentID + " in event " + req.params.eventID); + var parentComment = event.comments.id(commentID); + parentComment.replies.push(newReply); + event.save() + .then(() => { + addToLog("addEventReply", "success", "Reply added to comment " + commentID + " in event " + req.params.eventID); // broadcast an identical message to all followers, will show in their home timeline const guidObject = crypto.randomBytes(16).toString('hex'); const jsonObject = { @@ -1477,11 +1477,11 @@ router.post('/post/reply/:eventID/:commentID', (req, res) => { "content": `<p>${req.body.replyAuthor} commented: ${req.body.replyContent}</p><p><a href="https://${domain}/${req.params.eventID}/">See the full conversation here.</a></p>`, } ap.broadcastCreateMessage(jsonObject, event.followers, req.params.eventID) - if (sendEmails) { - Event.findOne({id: req.params.eventID}).distinct('attendees.email', function(error, ids) { - let attendeeEmails = ids; - if (!error){ - console.log("Sending emails to: " + attendeeEmails); + if (sendEmails) { + Event.findOne({id: req.params.eventID}).distinct('attendees.email', function(error, ids) { + let attendeeEmails = ids; + if (!error){ + console.log("Sending emails to: " + attendeeEmails); req.app.get('hbsInstance').renderView('./views/emails/addeventcomment.handlebars', {siteName, siteLogo, domain, eventID: req.params.eventID, commentAuthor: req.body.replyAuthor, cache: true, layout: 'email.handlebars'}, function(err, html) { const msg = { to: attendeeEmails, @@ -1497,47 +1497,47 @@ router.post('/post/reply/:eventID/:commentID', (req, res) => { res.status(500).end(); }); }); - } - else { - console.log("Nothing to send!"); - } - }); - } - res.writeHead(302, { - 'Location': '/' + req.params.eventID - }); - res.end(); - }) - .catch((err) => { res.send('Database error, please try again :('); addToLog("addEventReply", "error", "Attempt to add reply to comment " + commentID + " in event " + req.params.eventID + " failed with error: " + err); }); - }); + } + else { + console.log("Nothing to send!"); + } + }); + } + res.writeHead(302, { + 'Location': '/' + req.params.eventID + }); + res.end(); + }) + .catch((err) => { res.send('Database error, please try again :('); addToLog("addEventReply", "error", "Attempt to add reply to comment " + commentID + " in event " + req.params.eventID + " failed with error: " + err); }); + }); }); router.post('/deletecomment/:eventID/:commentID/:editToken', (req, res) => { - let submittedEditToken = req.params.editToken; - Event.findOne(({ - id: req.params.eventID, - })) - .then((event) => { - if (event.editToken === submittedEditToken) { - // Token matches - event.comments.id(req.params.commentID).remove(); - event.save() - .then(() => { - addToLog("deleteComment", "success", "Comment deleted from event " + req.params.eventID); - res.writeHead(302, { - 'Location': '/' + req.params.eventID + '?e=' + req.params.editToken - }); - res.end(); - }) - .catch((err) => { res.send('Sorry! Something went wrong (error deleting): ' + err); addToLog("deleteComment", "error", "Attempt to delete comment " + req.params.commentID + "from event " + req.params.eventID + " failed with error: " + err);}); - } - else { - // Token doesn't match - res.send('Sorry! Something went wrong'); - addToLog("deleteComment", "error", "Attempt to delete comment " + req.params.commentID + "from event " + req.params.eventID + " failed with error: token does not match"); - } - }) - .catch((err) => { res.send('Sorry! Something went wrong: ' + err); addToLog("deleteComment", "error", "Attempt to delete comment " + req.params.commentID + "from event " + req.params.eventID + " failed with error: " + err);}); + let submittedEditToken = req.params.editToken; + Event.findOne(({ + id: req.params.eventID, + })) + .then((event) => { + if (event.editToken === submittedEditToken) { + // Token matches + event.comments.id(req.params.commentID).remove(); + event.save() + .then(() => { + addToLog("deleteComment", "success", "Comment deleted from event " + req.params.eventID); + res.writeHead(302, { + 'Location': '/' + req.params.eventID + '?e=' + req.params.editToken + }); + res.end(); + }) + .catch((err) => { res.send('Sorry! Something went wrong (error deleting): ' + err); addToLog("deleteComment", "error", "Attempt to delete comment " + req.params.commentID + "from event " + req.params.eventID + " failed with error: " + err);}); + } + else { + // Token doesn't match + res.send('Sorry! Something went wrong'); + addToLog("deleteComment", "error", "Attempt to delete comment " + req.params.commentID + "from event " + req.params.eventID + " failed with error: token does not match"); + } + }) + .catch((err) => { res.send('Sorry! Something went wrong: ' + err); addToLog("deleteComment", "error", "Attempt to delete comment " + req.params.commentID + "from event " + req.params.eventID + " failed with error: " + err);}); }); router.post('/activitypub/inbox', (req, res) => { @@ -1602,9 +1602,9 @@ router.post('/activitypub/inbox', (req, res) => { }); router.use(function(req, res, next){ - res.status(404); - res.render('404', { url: req.url }); - return; + res.status(404); + res.render('404', { url: req.url }); + return; }); addToLog("startup", "success", "Started up successfully"); diff --git a/views/event.handlebars b/views/event.handlebars index 52a68bc..c931bb6 100755 --- a/views/event.handlebars +++ b/views/event.handlebars @@ -1,77 +1,77 @@ {{#if eventHasCoverImage}} - <div id="eventImageContainer" style="background-image: url(/events/{{eventData.image}});"></div> + <div id="eventImageContainer" style="background-image: url(/events/{{eventData.image}});"></div> {{else}} - <div id="genericEventImageContainer" style="background-image: url(/images/seigaiha.png);"></div> + <div id="genericEventImageContainer" style="background-image: url(/images/seigaiha.png);"></div> {{/if}} <div class="row"> - <div class="col-lg"> - <h3 id="eventName">{{eventData.name}}</h3> - </div> - {{#if editingEnabled}} - <div class="col-lg-3 ml-2 edit-buttons"> - <div class="btn-group" role="group" aria-label="Event controls"> - <button type="button" id="editEvent" class="btn btn-success" data-toggle="modal" data-target="#editModal" {{#if eventHasConcluded}}disabled{{/if}}><i class="fas fa-edit"></i> Edit</button> - <button type="button" id="deleteEvent" class="btn btn-danger" data-toggle="modal" data-target="#deleteModal"><i class="fas fa-trash"></i> Delete</button> - </div> - </div> - {{/if}} + <div class="col-lg"> + <h3 id="eventName">{{eventData.name}}</h3> + </div> + {{#if editingEnabled}} + <div class="col-lg-3 ml-2 edit-buttons"> + <div class="btn-group" role="group" aria-label="Event controls"> + <button type="button" id="editEvent" class="btn btn-success" data-toggle="modal" data-target="#editModal" {{#if eventHasConcluded}}disabled{{/if}}><i class="fas fa-edit"></i> Edit</button> + <button type="button" id="deleteEvent" class="btn btn-danger" data-toggle="modal" data-target="#deleteModal"><i class="fas fa-trash"></i> Delete</button> + </div> + </div> + {{/if}} </div> <div class="container my-4 pr-0"> - <div class="row"> - <div class="col-lg-9 card p-0"> - <div class="card-body"> - <ul class="fa-ul eventInformation"> - <li> - <span class="fa-li"> - <i class="fas fa-map-marker-alt"></i> - </span> - {{eventData.location}} - </li> - <li> - <span class="fa-li"> - <i class="fas fa-fw fa-calendar-day"></i> - </span> - {{{displayDate}}} - <br> - <span class="text-muted"> - {{#if eventHasBegun}}{{#unless eventHasConcluded}}Started {{else}}Ended {{/unless}}{{/if}}{{fromNow}} - </span> - </li> - {{#if eventHasHost}} - <li> - <span class="fa-li"> - <i class="fas fa-fw fa-user-circle"></i> - </span> - <span class="text-muted">Hosted by</span> {{eventData.hostName}} - </li> - {{/if}} - {{#if eventData.eventGroup}} - <li> - <span class="fa-li"> - <i class="fas fa-fw fa-calendar-alt"></i> - </span> - <span class="text-muted">Part of</span> <a href="/group/{{eventData.eventGroup.id}}">{{eventData.eventGroup.name}}</a> - </li> - {{/if}} - {{#if eventData.url}} - <li> - <span class="fa-li"> - <i class="fas fa-fw fa-link"></i> - </span> - <a href="{{eventData.url}}"> - {{eventData.url}} - </a> - </li> - {{/if}} - <li> - <span class="fa-li"> - <i class="fas fa-fw fa-share-square"></i> - </span> - <a href="https://{{domain}}/{{eventData.id}}">{{domain}}/{{eventData.id}}</a> - <button type="button" id="copyEventLink" class="eventInformationAction btn btn-outline-secondary btn-sm" data-clipboard-text="https://{{domain}}/{{eventData.id}}"> - <i class="fas fa-copy"></i> Copy - </button> - </li> + <div class="row"> + <div class="col-lg-9 card p-0"> + <div class="card-body"> + <ul class="fa-ul eventInformation"> + <li> + <span class="fa-li"> + <i class="fas fa-map-marker-alt"></i> + </span> + {{eventData.location}} + </li> + <li> + <span class="fa-li"> + <i class="fas fa-fw fa-calendar-day"></i> + </span> + {{{displayDate}}} + <br> + <span class="text-muted"> + {{#if eventHasBegun}}{{#unless eventHasConcluded}}Started {{else}}Ended {{/unless}}{{/if}}{{fromNow}} + </span> + </li> + {{#if eventHasHost}} + <li> + <span class="fa-li"> + <i class="fas fa-fw fa-user-circle"></i> + </span> + <span class="text-muted">Hosted by</span> {{eventData.hostName}} + </li> + {{/if}} + {{#if eventData.eventGroup}} + <li> + <span class="fa-li"> + <i class="fas fa-fw fa-calendar-alt"></i> + </span> + <span class="text-muted">Part of</span> <a href="/group/{{eventData.eventGroup.id}}">{{eventData.eventGroup.name}}</a> + </li> + {{/if}} + {{#if eventData.url}} + <li> + <span class="fa-li"> + <i class="fas fa-fw fa-link"></i> + </span> + <a href="{{eventData.url}}"> + {{eventData.url}} + </a> + </li> + {{/if}} + <li> + <span class="fa-li"> + <i class="fas fa-fw fa-share-square"></i> + </span> + <a href="https://{{domain}}/{{eventData.id}}">{{domain}}/{{eventData.id}}</a> + <button type="button" id="copyEventLink" class="eventInformationAction btn btn-outline-secondary btn-sm" data-clipboard-text="https://{{domain}}/{{eventData.id}}"> + <i class="fas fa-copy"></i> Copy + </button> + </li> {{#if isFederated}} <li> <span class="fa-li"> @@ -83,26 +83,26 @@ </button> </li> {{/if}} - </ul> - </div> - </div> - <div class="col-lg-3" id="eventActions"> - <aside class="btn-group-vertical d-flex" role="group" aria-label="Event actions"> - <a href="http://www.google.com/calendar/event?action=TEMPLATE&dates={{parsedStart}}%2F{{parsedEnd}}&text={{escapedName}}&location={{parsedLocation}}&ctz={{timezone}}" class="btn btn-outline-secondary btn-sm"> - <i class="far fa-calendar-plus"></i> Add to Google Calendar - </a> - <button type="button" id="exportICS" class="btn btn-outline-secondary btn-sm" data-event-id="{{eventData.id}}"> - <i class="fas fa-download"></i> Export as ICS - </button> - <a target="_blank" href="http://maps.google.com/?q={{parsedLocation}}" class="btn btn-outline-secondary btn-sm"> - <i class="fas fa-map-marked"></i> Show on Google Maps - </a> - <a target="_blank" href="https://www.openstreetmap.org/search?query={{parsedLocation}}" class="btn btn-outline-secondary btn-sm"> - <i class="fas fa-map-marked"></i> Show on OpenStreetMap - </a> - </aside> - </div> - </div> + </ul> + </div> + </div> + <div class="col-lg-3" id="eventActions"> + <aside class="btn-group-vertical d-flex" role="group" aria-label="Event actions"> + <a href="http://www.google.com/calendar/event?action=TEMPLATE&dates={{parsedStart}}%2F{{parsedEnd}}&text={{escapedName}}&location={{parsedLocation}}&ctz={{timezone}}" class="btn btn-outline-secondary btn-sm"> + <i class="far fa-calendar-plus"></i> Add to Google Calendar + </a> + <button type="button" id="exportICS" class="btn btn-outline-secondary btn-sm" data-event-id="{{eventData.id}}"> + <i class="fas fa-download"></i> Export as ICS + </button> + <a target="_blank" href="http://maps.google.com/?q={{parsedLocation}}" class="btn btn-outline-secondary btn-sm"> + <i class="fas fa-map-marked"></i> Show on Google Maps + </a> + <a target="_blank" href="https://www.openstreetmap.org/search?query={{parsedLocation}}" class="btn btn-outline-secondary btn-sm"> + <i class="fas fa-map-marked"></i> Show on OpenStreetMap + </a> + </aside> + </div> + </div> </div> {{#if eventHasConcluded}} @@ -112,47 +112,47 @@ {{/if}} {{#if firstLoad}} <div class="alert alert-success alert-dismissible fade show" role="alert"> - <button type="button" class="close" data-dismiss="alert" aria-label="Close"> + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span> </button> - Welcome to your event! We've just sent you an email with your secret editing link, which you can also see in the address bar above. Haven't got the email? Check your spam or junk folder. To share your event, use the link you can see just above this message - that way your attendees won't be able to edit or delete your event! + Welcome to your event! We've just sent you an email with your secret editing link, which you can also see in the address bar above. Haven't got the email? Check your spam or junk folder. To share your event, use the link you can see just above this message - that way your attendees won't be able to edit or delete your event! </div> {{/if}} <div class="card mb-4" id="eventDescription"> - <h5 class="card-header">About</h5> - <div class="card-body"> - {{{parsedDescription}}} - </div> + <h5 class="card-header">About</h5> + <div class="card-body"> + {{{parsedDescription}}} + </div> </div> {{#if eventData.usersCanAttend}} <div class="card mb-4" id="eventAttendees"> - <h5 class="card-header">Attendees {{#if eventAttendees}}({{eventAttendees.length}}){{/if}} - <div class="btn-group" role="group" aria-label="Attendance controls"> - {{#unless noMoreSpots}} - <button type="button" id="attendEvent" class="btn btn-success" data-toggle="modal" data-target="#attendModal"><i class="fas fa-user-plus"></i> Add me</button> - {{/unless}} - <button type="button" id="unattendEvent" class="btn btn-secondary" data-toggle="modal" data-target="#unattendModal"><i class="fas fa-user-times"></i> Remove me</button> - </div> - </h5> - <div class="card-body"> - {{#if eventData.maxAttendees}} - {{#if noMoreSpots}} - <div class="alert alert-warning text-center">This event is at capacity.</div> - {{else}} - <div class="alert alert-warning text-center">{{spotsRemaining}} {{plural spotsRemaining "spot(s)"}} remaining - add yourself now!</div> - {{/if}} - {{/if}} - {{#if eventAttendees}} - <ul class="attendeesList"> - {{#each eventAttendees}} - <li{{#if ../editingEnabled}} data-attendee-name="{{this.name}}" data-attendee-id="{{this._id}}"{{/if}}>{{#if this.email}}<span class="attendee-name">{{this.name}}</span>{{else}}<a href="{{this.id}}"><span class="attendee-name">{{this.name}}</span></a>{{/if}}{{#if ../editingEnabled}} <a href="#" class="remove-attendee" data-toggle="modal" data-target="#removeAttendeeModal" title="Remove user from event"><i class="fas fa-user-times"></i></a>{{/if}}</li> - {{/each}} - </ul> - {{else}} - <p class="text-center text-muted mb-0">No attendees yet!</p> - {{/if}} - </div> + <h5 class="card-header">Attendees {{#if eventAttendees}}({{eventAttendees.length}}){{/if}} + <div class="btn-group" role="group" aria-label="Attendance controls"> + {{#unless noMoreSpots}} + <button type="button" id="attendEvent" class="btn btn-success" data-toggle="modal" data-target="#attendModal"><i class="fas fa-user-plus"></i> Add me</button> + {{/unless}} + <button type="button" id="unattendEvent" class="btn btn-secondary" data-toggle="modal" data-target="#unattendModal"><i class="fas fa-user-times"></i> Remove me</button> + </div> + </h5> + <div class="card-body"> + {{#if eventData.maxAttendees}} + {{#if noMoreSpots}} + <div class="alert alert-warning text-center">This event is at capacity.</div> + {{else}} + <div class="alert alert-warning text-center">{{spotsRemaining}} {{plural spotsRemaining "spot(s)"}} remaining - add yourself now!</div> + {{/if}} + {{/if}} + {{#if eventAttendees}} + <ul class="attendeesList"> + {{#each eventAttendees}} + <li{{#if ../editingEnabled}} data-attendee-name="{{this.name}}" data-attendee-id="{{this._id}}"{{/if}}>{{#if this.email}}<span class="attendee-name">{{this.name}}</span>{{else}}<a href="{{this.id}}"><span class="attendee-name">{{this.name}}</span></a>{{/if}}{{#if ../editingEnabled}} <a href="#" class="remove-attendee" data-toggle="modal" data-target="#removeAttendeeModal" title="Remove user from event"><i class="fas fa-user-times"></i></a>{{/if}}</li> + {{/each}} + </ul> + {{else}} + <p class="text-center text-muted mb-0">No attendees yet!</p> + {{/if}} + </div> </div> <div class="modal fade" id="attendModal" tabindex="-1" role="dialog" aria-labelledby="attendModalLabel" aria-hidden="true"> @@ -165,26 +165,26 @@ </button> </div> <form id="attendEventForm" action="/attendevent/{{eventData.id}}" method="post"> - <div class="modal-body"> - <div class="form-group"> - <label for="attendeeName">Your name</label> - <div class="form-group"> - <input type="text" class="form-control" id="attendeeName" name="attendeeName" placeholder="Or an alias, perhaps..." data-validation="required length" data-validation-length="3-30"> - </div> - </div> - <div class="form-group"> - <label for="attendeeEmail">Your email (optional)</label> - <p class="form-text small">If you provide your email, you will receive updates to the event.</p> - <div class="form-group"> - <input type="email" class="form-control" id="attendeeEmail" name="attendeeEmail" placeholder="We won't spam you <3" data-validation="email" data-validation-optional="true"> - </div> - </div> - <div class="form-group"> - <label for="removeAttendancePassword">Deletion password</label> - <p class="form-text small">You will need this password if you want to remove yourself from the list of event attendees. Write it down now because it will <strong>not be shown again</strong>.</p> - <input type="text" class="form-control" readonly id="removeAttendancePassword" name="removeAttendancePassword"> - </div> - </div> + <div class="modal-body"> + <div class="form-group"> + <label for="attendeeName">Your name</label> + <div class="form-group"> + <input type="text" class="form-control" id="attendeeName" name="attendeeName" placeholder="Or an alias, perhaps..." data-validation="required length" data-validation-length="3-30"> + </div> + </div> + <div class="form-group"> + <label for="attendeeEmail">Your email (optional)</label> + <p class="form-text small">If you provide your email, you will receive updates to the event.</p> + <div class="form-group"> + <input type="email" class="form-control" id="attendeeEmail" name="attendeeEmail" placeholder="We won't spam you <3" data-validation="email" data-validation-optional="true"> + </div> + </div> + <div class="form-group"> + <label for="removeAttendancePassword">Deletion password</label> + <p class="form-text small">You will need this password if you want to remove yourself from the list of event attendees. Write it down now because it will <strong>not be shown again</strong>.</p> + <input type="text" class="form-control" readonly id="removeAttendancePassword" name="removeAttendancePassword"> + </div> + </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> <button type="submit" class="btn btn-primary">Add myself</button> @@ -204,12 +204,12 @@ </button> </div> <form id="unattendEventForm" action="/unattendevent/{{eventData.id}}" method="post"> - <div class="modal-body"> - <div class="form-group"> - <label for="removeAttendancePassword" class="form-label">Your deletion password</label> - <p class="form-text small">Lost your password? Get in touch with the event organiser.</p> - <input type="text" class="form-control" id="removeAttendancePassword" name="removeAttendancePassword"> - </div> + <div class="modal-body"> + <div class="form-group"> + <label for="removeAttendancePassword" class="form-label">Your deletion password</label> + <p class="form-text small">Lost your password? Get in touch with the event organiser.</p> + <input type="text" class="form-control" id="removeAttendancePassword" name="removeAttendancePassword"> + </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> @@ -220,107 +220,107 @@ </div> </div> - {{#if editingEnabled}} - <div class="modal fade" id="removeAttendeeModal" tabindex="-1" role="dialog" aria-labelledby="removeAttendeeModalLabel" aria-hidden="true"> - <div class="modal-dialog" role="document"> - <div class="modal-content"> - <div class="modal-header"> - <h5 class="modal-title" id="removeAttendeeModalLabel">Remove attendee from '{{eventData.name}}'</h5> - <button type="button" class="close" data-dismiss="modal" aria-label="Close"> - <span aria-hidden="true">×</span> - </button> - </div> - <form id="removeAttendeeForm" action="/removeattendee/{{eventData.id}}/" method="post"> - <div class="modal-body"> - <p>Are you sure you want to remove this attendee from the event? This action cannot be undone.</p> - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> - <button type="submit" class="btn btn-danger">Remove attendee</button> - </div> - </form> - </div> - </div> - </div> - {{/if}} + {{#if editingEnabled}} + <div class="modal fade" id="removeAttendeeModal" tabindex="-1" role="dialog" aria-labelledby="removeAttendeeModalLabel" aria-hidden="true"> + <div class="modal-dialog" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <h5 class="modal-title" id="removeAttendeeModalLabel">Remove attendee from '{{eventData.name}}'</h5> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> + <span aria-hidden="true">×</span> + </button> + </div> + <form id="removeAttendeeForm" action="/removeattendee/{{eventData.id}}/" method="post"> + <div class="modal-body"> + <p>Are you sure you want to remove this attendee from the event? This action cannot be undone.</p> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> + <button type="submit" class="btn btn-danger">Remove attendee</button> + </div> + </form> + </div> + </div> + </div> + {{/if}} {{/if}} {{#if eventData.usersCanComment}} <div class="card mb-4" id="eventComments"> - <h5 class="card-header">Discussion</h5> - <div class="card-body"> - <form id="commentForm" action="/post/comment/{{eventData.id}}/" method="post"> - <div class="form-group"> - <input type="text" class="form-control" id="commentAuthor" name="commentAuthor" placeholder="Your name" data-validation="required length" data-validation-length="3-60"> - </div> - <div class="form-group"> - <div class="input-group"> - <textarea class="form-control" id="commentContent" name="commentContent" style="resize: none;" placeholder="What would you like to ask?" data-validation="required length" data-validation-length="3-280"></textarea> - <div class="input-group-append"> - <button type="submit" class="btn btn-primary btn-block h-100" id="postComment">Send <i class="fas fa-chevron-right"></i></button> - </div> - </div> - </div> - </form> - {{#if eventData.comments}} - <hr style="border-style:dashed;"> - <div class="container commentsList"> - {{#each eventData.comments}} - <div class="comment"> - <div class="row commentContainer"> - <div class="col-lg commentText"> + <h5 class="card-header">Discussion</h5> + <div class="card-body"> + <form id="commentForm" action="/post/comment/{{eventData.id}}/" method="post"> + <div class="form-group"> + <input type="text" class="form-control" id="commentAuthor" name="commentAuthor" placeholder="Your name" data-validation="required length" data-validation-length="3-60"> + </div> + <div class="form-group"> + <div class="input-group"> + <textarea class="form-control" id="commentContent" name="commentContent" style="resize: none;" placeholder="What would you like to ask?" data-validation="required length" data-validation-length="3-280"></textarea> + <div class="input-group-append"> + <button type="submit" class="btn btn-primary btn-block h-100" id="postComment">Send <i class="fas fa-chevron-right"></i></button> + </div> + </div> + </div> + </form> + {{#if eventData.comments}} + <hr style="border-style:dashed;"> + <div class="container commentsList"> + {{#each eventData.comments}} + <div class="comment"> + <div class="row commentContainer"> + <div class="col-lg commentText"> {{#if this.actorId}} <p class="mb-0"><a href="{{this.actorId}}"><strong>{{this.author}}</strong></a> <a href="{{this.activityId}}"><small class="commentTimestamp text-muted">{{this.timestamp}}</small></a></p> {{else}} <p class="mb-0"><strong>{{this.author}}</strong> <small class="commentTimestamp text-muted">{{this.timestamp}}</small></p> {{/if}} - <p>{{this.content}}</p> - {{#if this.replies}} - <hr> - <div class="repliesContainer"> - {{#each this.replies}} - <p class="mb-0"><strong><i class="fas fa-reply text-muted"></i> {{this.author}}</strong> <small class="commentTimestamp text-muted">{{this.timestamp}}</small></p> - <p>{{this.content}}</p> - {{/each}} - </div> - {{/if}} - </div> - <div class="col-lg-3 commentMetadata text-right"> - <button type="button" class="btn btn-outline-primary btn-sm openReplyBox"> - <i class="fas fa-comment"></i> Reply - </button> - {{#if ../editingEnabled}} - <form class="d-inline" action="/deletecomment/{{../eventData.id}}/{{this._id}}/{{../eventData.editToken}}" method="post"> - <button type="submit" class="btn btn-outline-danger btn-sm deleteComment"> - <i class="fas fa-trash"></i> Delete - </button> - </form> - {{/if}} - </div> - </div> - <div class="row replyContainer"> - <div class="col-md"> - <form id="replyForm" action="/post/reply/{{../eventData.id}}/{{this._id}}" method="post"> - <div class="form-group"> - <input type="text" class="form-control form-control-sm" id="replyAuthor" name="replyAuthor" placeholder="Your name" data-validation="required length" data-validation-length="3-60"> - </div> - <div class="form-group"> - <div class="input-group"> - <textarea class="form-control form-control-sm" id="replyContent" name="replyContent" style="resize: none;" placeholder="What would you like to reply?" data-validation="required length" data-validation-length="3-280"></textarea> - <div class="input-group-append"> - <button type="submit" class="btn btn-primary btn-block h-100 btn-sm" id="postReply">Reply <i class="fas fa-chevron-right"></i></button> - </div> - </div> - </div> - </form> - </div> - </div> - </div> - {{/each}} - </div> - {{/if}} - </div> + <p>{{this.content}}</p> + {{#if this.replies}} + <hr> + <div class="repliesContainer"> + {{#each this.replies}} + <p class="mb-0"><strong><i class="fas fa-reply text-muted"></i> {{this.author}}</strong> <small class="commentTimestamp text-muted">{{this.timestamp}}</small></p> + <p>{{this.content}}</p> + {{/each}} + </div> + {{/if}} + </div> + <div class="col-lg-3 commentMetadata text-right"> + <button type="button" class="btn btn-outline-primary btn-sm openReplyBox"> + <i class="fas fa-comment"></i> Reply + </button> + {{#if ../editingEnabled}} + <form class="d-inline" action="/deletecomment/{{../eventData.id}}/{{this._id}}/{{../eventData.editToken}}" method="post"> + <button type="submit" class="btn btn-outline-danger btn-sm deleteComment"> + <i class="fas fa-trash"></i> Delete + </button> + </form> + {{/if}} + </div> + </div> + <div class="row replyContainer"> + <div class="col-md"> + <form id="replyForm" action="/post/reply/{{../eventData.id}}/{{this._id}}" method="post"> + <div class="form-group"> + <input type="text" class="form-control form-control-sm" id="replyAuthor" name="replyAuthor" placeholder="Your name" data-validation="required length" data-validation-length="3-60"> + </div> + <div class="form-group"> + <div class="input-group"> + <textarea class="form-control form-control-sm" id="replyContent" name="replyContent" style="resize: none;" placeholder="What would you like to reply?" data-validation="required length" data-validation-length="3-280"></textarea> + <div class="input-group-append"> + <button type="submit" class="btn btn-primary btn-block h-100 btn-sm" id="postReply">Reply <i class="fas fa-chevron-right"></i></button> + </div> + </div> + </div> + </form> + </div> + </div> + </div> + {{/each}} + </div> + {{/if}} + </div> </div> {{/if}} @@ -339,8 +339,8 @@ </button> </div> <form id="editEventForm" action="/deleteevent/{{eventData.id}}/{{eventData.editToken}}" method="post"> - <div class="modal-body"> - <p>Are you sure you want to delete this event? This action cannot be undone.</p> + <div class="modal-body"> + <p>Are you sure you want to delete this event? This action cannot be undone.</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> @@ -358,150 +358,150 @@ <script src='/js/niceware.js'></script> {{/unless}} <script> - $.validate({ + $.validate({ lang: 'en', - errorElementClass: "is-invalid", - errorMessageClass: "text-danger", - successElementClass: "is-valid" + errorElementClass: "is-invalid", + errorMessageClass: "text-danger", + successElementClass: "is-valid" }); - {{#if editingEnabled}} + {{#if editingEnabled}} - $('#removeAttendeeModal').on('show.bs.modal', function (event) { - var listItem = $(event.relatedTarget).closest('li'); // List element enclosing button - var attendeeName = listItem.data('attendee-name'); - var attendeeID = listItem.data('attendee-id'); - var modal = $(this); - modal.find('.modal-title').text('Remove ' + attendeeName + ' from {{eventData.name}}') - modal.find('#removeAttendeeForm').attr('action', '/removeattendee/{{eventData.id}}/' + attendeeID); - }) - {{#unless eventHasConcluded}} - $('#eventStart').datepicker({ + $('#removeAttendeeModal').on('show.bs.modal', function (event) { + var listItem = $(event.relatedTarget).closest('li'); // List element enclosing button + var attendeeName = listItem.data('attendee-name'); + var attendeeID = listItem.data('attendee-id'); + var modal = $(this); + modal.find('.modal-title').text('Remove ' + attendeeName + ' from {{eventData.name}}') + modal.find('#removeAttendeeForm').attr('action', '/removeattendee/{{eventData.id}}/' + attendeeID); + }) + {{#unless eventHasConcluded}} + $('#eventStart').datepicker({ language: 'en', - timepicker: true, - dateFormat: 'd MM yyyy', - dateTimeSeparator: ', ', - onSelect: function(formattedDate, rawDate){ - $('#eventEnd').datepicker().data('datepicker').update('minDate', rawDate).clear(); - } - }); - $('#eventEnd').datepicker({ + timepicker: true, + dateFormat: 'd MM yyyy', + dateTimeSeparator: ', ', + onSelect: function(formattedDate, rawDate){ + $('#eventEnd').datepicker().data('datepicker').update('minDate', rawDate).clear(); + } + }); + $('#eventEnd').datepicker({ language: 'en', - timepicker: true, - dateFormat: 'd MM yyyy', - dateTimeSeparator: ', ' - }); - $("#timezone").val('{{eventData.timezone}}').trigger('change'); - {{/unless}} - {{/if}} - $(".commentTimestamp").html(function(){ - parsedDate = moment($(this).html()).fromNow(); - return parsedDate; - }); - $(".openReplyBox").click(function(){ -// let replyID = $(this).attr("data-id"); - $(this).closest(".comment").find(".replyContainer").slideToggle(); - }) - $(document).ready(function() { + timepicker: true, + dateFormat: 'd MM yyyy', + dateTimeSeparator: ', ' + }); + $("#timezone").val('{{eventData.timezone}}').trigger('change'); + {{/unless}} + {{/if}} + $(".commentTimestamp").html(function(){ + parsedDate = moment($(this).html()).fromNow(); + return parsedDate; + }); + $(".openReplyBox").click(function(){ +// let replyID = $(this).attr("data-id"); + $(this).closest(".comment").find(".replyContainer").slideToggle(); + }) + $(document).ready(function() { - // From https://davidwalsh.name/javascript-download - function downloadFile(data, fileName, type="text/plain") { - // Create an invisible A element - const a = document.createElement("a"); - a.style.display = "none"; - document.body.appendChild(a); + // From https://davidwalsh.name/javascript-download + function downloadFile(data, fileName, type="text/plain") { + // Create an invisible A element + const a = document.createElement("a"); + a.style.display = "none"; + document.body.appendChild(a); - // Set the HREF to a Blob representation of the data to be downloaded - a.href = window.URL.createObjectURL( - new Blob([data], { type }) - ); + // Set the HREF to a Blob representation of the data to be downloaded + a.href = window.URL.createObjectURL( + new Blob([data], { type }) + ); - // Use download attribute to set set desired file name - a.setAttribute("download", fileName); + // Use download attribute to set set desired file name + a.setAttribute("download", fileName); - // Trigger the download by simulating click - a.click(); + // Trigger the download by simulating click + a.click(); - // Cleanup - window.URL.revokeObjectURL(a.href); - document.body.removeChild(a); - } + // Cleanup + window.URL.revokeObjectURL(a.href); + document.body.removeChild(a); + } - $.uploadPreview({ - input_field: "#image-upload", - preview_box: "#image-preview", - label_field: "#image-label", - label_default: "Choose file", - label_selected: "Change file", - no_label: false - }); - $("#image-preview").css("background-image", "url('/events/{{eventData.image}}')"); - $("#image-preview").css("background-size", "cover"); - $("#image-preview").css("background-position", "center center"); - {{#if editingEnabled}} - {{#unless eventHasConcluded}} - $('#eventStart').datepicker().data('datepicker').selectDate(moment('{{parsedStart}}', 'YYYYMMDD[T]HHmmss').toDate()); - $('#eventEnd').datepicker().data('datepicker').selectDate(moment('{{parsedEnd}}', 'YYYYMMDD[T]HHmmss').toDate()); - {{/unless}} - {{/if}} - new ClipboardJS('#copyEventLink'); - autosize($('textarea')); - $("#exportICS").click(function(){ - let eventID = $(this).attr('data-event-id'); - $.get('/exportevent/' + eventID, function(response) { - downloadFile(response, eventID + '.ics'); - }) - }) - $("#copyEventLink").click(function(){ - $(this).html('<i class="fas fa-copy"></i> Copied!'); - setTimeout(function(){ $("#copyEventLink").html('<i class="fas fa-copy"></i> Copy');}, 5000); - }) - new ClipboardJS('#copyAPLink'); - $("#copyAPLink").click(function(){ - $(this).html('<i class="fas fa-copy"></i> Copied!'); - setTimeout(function(){ $("#copyAPLink").html('<i class="fas fa-copy"></i> Copy');}, 5000); - }) - $(".daysToDeletion").html(moment("{{eventEndISO}}").add(7, 'days').fromNow()); - if ($("#joinCheckbox").is(':checked')){ - $("#maxAttendeesCheckboxContainer").css("display","flex"); - } - $("#maxAttendeesCheckbox").on("click", function() { - if ($(this).is(':checked')) { - $("#maxAttendeesContainer").slideDown('fast').css("display","flex"); - $("#maxAttendees").attr("data-validation-optional","false"); - } - else { - $("#maxAttendeesContainer").slideUp('fast'); - $("#maxAttendees").attr("data-validation-optional","true").val("").removeClass('is-valid is-invalid'); - } - }); - $("#joinCheckbox").on("click", function() { - if ($(this).is(':checked')) { - $("#maxAttendeesCheckboxContainer").slideDown('fast').css("display","flex"); - } - else { - $("#maxAttendeesCheckboxContainer").slideUp('fast'); - $("#maxAttendeesCheckbox").prop("checked",false); - $("#maxAttendeesContainer").slideUp('fast'); - $("#maxAttendees").attr("data-validation-optional","true").val("").removeClass('is-valid is-invalid'); - } - }); - $("#eventGroupCheckbox").on("click", function() { - if ($(this).is(':checked')) { - $("#eventGroupData").slideDown('fast'); - $("#eventGroupID").removeAttr("data-validation-optional").attr("data-validation","required"); - $("#eventGroupEditToken").removeAttr("data-validation-optional").attr("data-validation","required"); - } - else { - $("#eventGroupData").slideUp('fast'); - $("#eventGroupID").removeAttr("data-validation").attr("data-validation-optional","true").val(""); - $("#eventGroupEditToken").removeAttr("data-validation").attr("data-validation-optional","true").val(""); - } - }); - $('#attendModal').on('show.bs.modal', function (event) { - var modal = $(this); - const passphrase = window.niceware.generatePassphrase(6).join('-'); - modal.find('#removeAttendancePassword').val(passphrase); - }); - }); + $.uploadPreview({ + input_field: "#image-upload", + preview_box: "#image-preview", + label_field: "#image-label", + label_default: "Choose file", + label_selected: "Change file", + no_label: false + }); + $("#image-preview").css("background-image", "url('/events/{{eventData.image}}')"); + $("#image-preview").css("background-size", "cover"); + $("#image-preview").css("background-position", "center center"); + {{#if editingEnabled}} + {{#unless eventHasConcluded}} + $('#eventStart').datepicker().data('datepicker').selectDate(moment('{{parsedStart}}', 'YYYYMMDD[T]HHmmss').toDate()); + $('#eventEnd').datepicker().data('datepicker').selectDate(moment('{{parsedEnd}}', 'YYYYMMDD[T]HHmmss').toDate()); + {{/unless}} + {{/if}} + new ClipboardJS('#copyEventLink'); + autosize($('textarea')); + $("#exportICS").click(function(){ + let eventID = $(this).attr('data-event-id'); + $.get('/exportevent/' + eventID, function(response) { + downloadFile(response, eventID + '.ics'); + }) + }) + $("#copyEventLink").click(function(){ + $(this).html('<i class="fas fa-copy"></i> Copied!'); + setTimeout(function(){ $("#copyEventLink").html('<i class="fas fa-copy"></i> Copy');}, 5000); + }) + new ClipboardJS('#copyAPLink'); + $("#copyAPLink").click(function(){ + $(this).html('<i class="fas fa-copy"></i> Copied!'); + setTimeout(function(){ $("#copyAPLink").html('<i class="fas fa-copy"></i> Copy');}, 5000); + }) + $(".daysToDeletion").html(moment("{{eventEndISO}}").add(7, 'days').fromNow()); + if ($("#joinCheckbox").is(':checked')){ + $("#maxAttendeesCheckboxContainer").css("display","flex"); + } + $("#maxAttendeesCheckbox").on("click", function() { + if ($(this).is(':checked')) { + $("#maxAttendeesContainer").slideDown('fast').css("display","flex"); + $("#maxAttendees").attr("data-validation-optional","false"); + } + else { + $("#maxAttendeesContainer").slideUp('fast'); + $("#maxAttendees").attr("data-validation-optional","true").val("").removeClass('is-valid is-invalid'); + } + }); + $("#joinCheckbox").on("click", function() { + if ($(this).is(':checked')) { + $("#maxAttendeesCheckboxContainer").slideDown('fast').css("display","flex"); + } + else { + $("#maxAttendeesCheckboxContainer").slideUp('fast'); + $("#maxAttendeesCheckbox").prop("checked",false); + $("#maxAttendeesContainer").slideUp('fast'); + $("#maxAttendees").attr("data-validation-optional","true").val("").removeClass('is-valid is-invalid'); + } + }); + $("#eventGroupCheckbox").on("click", function() { + if ($(this).is(':checked')) { + $("#eventGroupData").slideDown('fast'); + $("#eventGroupID").removeAttr("data-validation-optional").attr("data-validation","required"); + $("#eventGroupEditToken").removeAttr("data-validation-optional").attr("data-validation","required"); + } + else { + $("#eventGroupData").slideUp('fast'); + $("#eventGroupID").removeAttr("data-validation").attr("data-validation-optional","true").val(""); + $("#eventGroupEditToken").removeAttr("data-validation").attr("data-validation-optional","true").val(""); + } + }); + $('#attendModal').on('show.bs.modal', function (event) { + var modal = $(this); + const passphrase = window.niceware.generatePassphrase(6).join('-'); + modal.find('#removeAttendancePassword').val(passphrase); + }); + }); - </script> + </script> diff --git a/views/eventgroup.handlebars b/views/eventgroup.handlebars index dffb847..9cbc504 100755 --- a/views/eventgroup.handlebars +++ b/views/eventgroup.handlebars @@ -1,106 +1,106 @@ {{#if eventGroupHasCoverImage}} - <div id="eventImageContainer" style="background-image: url(/events/{{eventGroupData.image}});"></div> + <div id="eventImageContainer" style="background-image: url(/events/{{eventGroupData.image}});"></div> {{else}} - <div id="genericEventImageContainer" style="background-image: url(/images/seigaiha.png);"></div> + <div id="genericEventImageContainer" style="background-image: url(/images/seigaiha.png);"></div> {{/if}} <div class="row"> - <div class="col-lg"> - <h3 id="eventName">{{eventGroupData.name}}</h3> - </div> - {{#if editingEnabled}} - <div class="col-lg-2 ml-2 edit-buttons"> - <div class="btn-group" role="group" aria-label="Event controls"> - <button type="button" id="editEvent" class="btn btn-success" data-toggle="modal" data-target="#editModal" ><i class="fas fa-edit"></i></button> - <button type="button" id="deleteEvent" class="btn btn-danger" data-toggle="modal" data-target="#deleteModal"><i class="fas fa-trash"></i></button> - </div> - </div> - {{/if}} + <div class="col-lg"> + <h3 id="eventName">{{eventGroupData.name}}</h3> + </div> + {{#if editingEnabled}} + <div class="col-lg-2 ml-2 edit-buttons"> + <div class="btn-group" role="group" aria-label="Event controls"> + <button type="button" id="editEvent" class="btn btn-success" data-toggle="modal" data-target="#editModal" ><i class="fas fa-edit"></i></button> + <button type="button" id="deleteEvent" class="btn btn-danger" data-toggle="modal" data-target="#deleteModal"><i class="fas fa-trash"></i></button> + </div> + </div> + {{/if}} </div> {{#if firstLoad}} <div class="alert alert-success alert-dismissible fade show" role="alert"> - <button type="button" class="close" data-dismiss="alert" aria-label="Close"> + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span> </button> - Welcome to your event group! We've just sent you an email with your secret editing link, which you can also see in the address bar above. Haven't got the email? Check your spam or junk folder. To share your event group, use the link you can see just below this message - that way your attendees won't be able to edit or delete your event group! + Welcome to your event group! We've just sent you an email with your secret editing link, which you can also see in the address bar above. Haven't got the email? Check your spam or junk folder. To share your event group, use the link you can see just below this message - that way your attendees won't be able to edit or delete your event group! </div> {{/if}} <div class="card mt-4 mb-4"> <div class="card-body"> - <ul class="fa-ul eventInformation"> - {{#if eventGroupHasHost}} - <li> - <span class="fa-li"> - <i class="fas fa-fw fa-user-circle"></i> - </span> - <span class="text-muted">Hosted by</span> {{eventGroupData.hostName}} - </li> - {{/if}} - {{#if eventGroupData.url}} - <li> - <span class="fa-li"> - <i class="fas fa-link"></i> - </span> - <a href="{{eventGroupData.url}}"> - {{eventGroupData.url}} - </a> - </li> - {{/if}} - <li> - <span class="fa-li"> - <i class="fas fa-share-square"></i> - </span> - <a href="https://{{domain}}/group/{{eventGroupData.id}}"> - {{domain}}/group/{{eventGroupData.id}} - </a> - <button type="button" id="copyEventLink" class="eventInformationAction btn btn-outline-secondary btn-sm" data-clipboard-text="https://{{domain}}/group/{{eventGroupData.id}}"> - <i class="fas fa-copy"></i> Copy - </button> - </li> - </ul> - </div> + <ul class="fa-ul eventInformation"> + {{#if eventGroupHasHost}} + <li> + <span class="fa-li"> + <i class="fas fa-fw fa-user-circle"></i> + </span> + <span class="text-muted">Hosted by</span> {{eventGroupData.hostName}} + </li> + {{/if}} + {{#if eventGroupData.url}} + <li> + <span class="fa-li"> + <i class="fas fa-link"></i> + </span> + <a href="{{eventGroupData.url}}"> + {{eventGroupData.url}} + </a> + </li> + {{/if}} + <li> + <span class="fa-li"> + <i class="fas fa-share-square"></i> + </span> + <a href="https://{{domain}}/group/{{eventGroupData.id}}"> + {{domain}}/group/{{eventGroupData.id}} + </a> + <button type="button" id="copyEventLink" class="eventInformationAction btn btn-outline-secondary btn-sm" data-clipboard-text="https://{{domain}}/group/{{eventGroupData.id}}"> + <i class="fas fa-copy"></i> Copy + </button> + </li> + </ul> + </div> </div> {{#if editingEnabled}} - <div class="alert alert-success"> - <p>To add an event to this group, copy and paste the two codes below into the 'Event Group' box when creating a new event or editing an existing event.</p> - <div class="table-responsive"> - <table style="width:100%"> - <tr style="border-bottom:1px solid rgba(0,0,0,0.2)"> - <td><strong>Event group ID</strong></td> - <td><span class="code">{{eventGroupData.id}}</span></td> - </tr> - <tr> - <td><strong>Event group secret editing code</strong></td> - <td><span class="code">{{eventGroupData.editToken}}</span></td> - </tr> - </table> - </div> - - </div> + <div class="alert alert-success"> + <p>To add an event to this group, copy and paste the two codes below into the 'Event Group' box when creating a new event or editing an existing event.</p> + <div class="table-responsive"> + <table style="width:100%"> + <tr style="border-bottom:1px solid rgba(0,0,0,0.2)"> + <td><strong>Event group ID</strong></td> + <td><span class="code">{{eventGroupData.id}}</span></td> + </tr> + <tr> + <td><strong>Event group secret editing code</strong></td> + <td><span class="code">{{eventGroupData.editToken}}</span></td> + </tr> + </table> + </div> + + </div> {{/if}} <div class="card mb-4" id="eventDescription"> - <h5 class="card-header">About</h5> - <div class="card-body"> - {{{parsedDescription}}} - </div> + <h5 class="card-header">About</h5> + <div class="card-body"> + {{{parsedDescription}}} + </div> </div> <div class="card mt-4 mb-4"> <h5 class="card-header">Upcoming events</h5> <div class="list-group list-group-flush"> - {{#if upcomingEventsExist}} - {{#each events}} - {{#unless this.eventHasConcluded}} - <a href="/{{this.id}}" class="list-group-item list-group-item-action" target="_blank"> - <i class="fas fa-fw fa-calendar-day"></i> - <strong>{{this.name}}</strong> - <span class="ml-2 text-muted">{{this.displayDate}}</span> - </a> - {{/unless}} - {{/each}} - {{else}} - <div class="list-group-item">No events!</div> - {{/if}} + {{#if upcomingEventsExist}} + {{#each events}} + {{#unless this.eventHasConcluded}} + <a href="/{{this.id}}" class="list-group-item list-group-item-action" target="_blank"> + <i class="fas fa-fw fa-calendar-day"></i> + <strong>{{this.name}}</strong> + <span class="ml-2 text-muted">{{this.displayDate}}</span> + </a> + {{/unless}} + {{/each}} + {{else}} + <div class="list-group-item">No events!</div> + {{/if}} </div> </div> @@ -117,9 +117,9 @@ </button> </div> <form action="/deleteeventgroup/{{eventGroupData.id}}/{{eventGroupData.editToken}}" method="post"> - <div class="modal-body"> - <p>Are you sure you want to delete this event group? This action cannot be undone.</p> - <p>This will <strong>not</strong> delete the individual events contained in this group. They can be linked to another group later.</p> + <div class="modal-body"> + <p>Are you sure you want to delete this event group? This action cannot be undone.</p> + <p>This will <strong>not</strong> delete the individual events contained in this group. They can be linked to another group later.</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> @@ -133,32 +133,30 @@ {{/if}} <script> - $.validate({ + $.validate({ lang: 'en', - errorElementClass: "is-invalid", - errorMessageClass: "text-danger", - successElementClass: "is-valid" + errorElementClass: "is-invalid", + errorMessageClass: "text-danger", + successElementClass: "is-valid" }); - $(document).ready(function() { - - $.uploadPreview({ - input_field: "#eventGroupImageUpload", - preview_box: "#eventGroupImagePreview", - label_field: "#eventGroupImageLabel", - label_default: "Choose file", - label_selected: "Change file", - no_label: false - }); - $("#eventGroupImagePreview").css("background-image", "url('/events/{{eventGroupData.image}}')"); - $("#eventGroupImagePreview").css("background-size", "cover"); - $("#eventGroupImagePreview").css("background-position", "center center"); - new ClipboardJS('#copyEventLink'); - autosize($('textarea')); - $("#copyEventLink").click(function(){ - $(this).html('<i class="fas fa-copy"></i> Copied!'); - setTimeout(function(){ $("#copyEventLink").html('<i class="fas fa-copy"></i> Copy');}, 5000); - }) - }); - - </script> + $(document).ready(function() { + $.uploadPreview({ + input_field: "#eventGroupImageUpload", + preview_box: "#eventGroupImagePreview", + label_field: "#eventGroupImageLabel", + label_default: "Choose file", + label_selected: "Change file", + no_label: false + }); + $("#eventGroupImagePreview").css("background-image", "url('/events/{{eventGroupData.image}}')"); + $("#eventGroupImagePreview").css("background-size", "cover"); + $("#eventGroupImagePreview").css("background-position", "center center"); + new ClipboardJS('#copyEventLink'); + autosize($('textarea')); + $("#copyEventLink").click(function(){ + $(this).html('<i class="fas fa-copy"></i> Copied!'); + setTimeout(function(){ $("#copyEventLink").html('<i class="fas fa-copy"></i> Copy');}, 5000); + }) + }); +</script> diff --git a/views/home.handlebars b/views/home.handlebars index 164250c..cc31756 100755 --- a/views/home.handlebars +++ b/views/home.handlebars @@ -19,6 +19,6 @@ <div class="card border-secondary mt-5 mb-3 mx-auto" style="min-width:300px;max-width:50%;"> <div class="card-body text-secondary"> <p>If you find yourself using and enjoying <strong>gath<span class="text-muted">io</span></strong>, consider buying me a coffee. It'll help keep the site running! <i class="far fa-heart"></i></p> - <script type='text/javascript' src='https://ko-fi.com/widgets/widget_2.js'></script><script type='text/javascript'>kofiwidget2.init('Support Me on Ko-fi', '#46b798', 'Q5Q2O7T5');kofiwidget2.draw();</script> + <script type='text/javascript' src='https://ko-fi.com/widgets/widget_2.js'></script><script type='text/javascript'>kofiwidget2.init('Support Me on Ko-fi', '#46b798', 'Q5Q2O7T5');kofiwidget2.draw();</script> </div> </div> diff --git a/views/layouts/main.handlebars b/views/layouts/main.handlebars index 5032974..aafa5de 100755 --- a/views/layouts/main.handlebars +++ b/views/layouts/main.handlebars @@ -1,77 +1,77 @@ <!DOCTYPE html> <html> - <head> - <meta charset="utf-8"> + <head> + <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> - <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"> - <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"> - <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"> - <link rel="manifest" href="/site.webmanifest"> - <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5"> - <meta name="msapplication-TileColor" content="#da532c"> - <meta name="theme-color" content="#ffffff"> + <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"> + <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"> + <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"> + <link rel="manifest" href="/site.webmanifest"> + <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5"> + <meta name="msapplication-TileColor" content="#da532c"> + <meta name="theme-color" content="#ffffff"> - <meta property="og:type" content="website"> - <meta property="og:image:width" content="260"> - <meta property="og:image:height" content="260"> - <meta property="og:description" content="{{#if metadata.description}}{{metadata.description}}{{else}}An easier, quicker, and much less privacy-invading way to make and share events{{/if}}"> - <meta property="og:title" content="{{#if metadata.title}}{{metadata.title}} · {{siteName}}{{else}}{{siteName}}{{/if}}"> - <meta property="og:url" content="{{#if metadata.url}}{{metadata.url}}{{else}}https://{{domain}}/{{/if}}"> - <meta property="og:image" content="{{#if metadata.image}}{{metadata.image}}{{else}}https://{{domain}}/og-image.jpg{{/if}}"> + <meta property="og:type" content="website"> + <meta property="og:image:width" content="260"> + <meta property="og:image:height" content="260"> + <meta property="og:description" content="{{#if metadata.description}}{{metadata.description}}{{else}}An easier, quicker, and much less privacy-invading way to make and share events{{/if}}"> + <meta property="og:title" content="{{#if metadata.title}}{{metadata.title}} · {{siteName}}{{else}}{{siteName}}{{/if}}"> + <meta property="og:url" content="{{#if metadata.url}}{{metadata.url}}{{else}}https://{{domain}}/{{/if}}"> + <meta property="og:image" content="{{#if metadata.image}}{{metadata.image}}{{else}}https://{{domain}}/og-image.jpg{{/if}}"> - <meta name="twitter:card" content="summary"> - <meta name="twitter:title" content="{{#if metadata.title}}{{metadata.title}} · {{siteName}}{{else}}{{siteName}}{{/if}}"> - <meta name="twitter:description" content="{{#if metadata.description}}{{metadata.description}}{{else}}An easier, quicker, and much less privacy-invading way to make and share events{{/if}}"> - <meta name="twitter:image" content="{{#if metadata.image}}{{metadata.image}}{{else}}https://{{domain}}/og-image.jpg{{/if}}"> + <meta name="twitter:card" content="summary"> + <meta name="twitter:title" content="{{#if metadata.title}}{{metadata.title}} · {{siteName}}{{else}}{{siteName}}{{/if}}"> + <meta name="twitter:description" content="{{#if metadata.description}}{{metadata.description}}{{else}}An easier, quicker, and much less privacy-invading way to make and share events{{/if}}"> + <meta name="twitter:image" content="{{#if metadata.image}}{{metadata.image}}{{else}}https://{{domain}}/og-image.jpg{{/if}}"> - <title>{{#if title}}{{title}} · {{/if}}{{siteName}}</title> + <title>{{#if title}}{{title}} · {{/if}}{{siteName}}</title> - <!-- FONTS --> - <link rel="stylesheet" href="/css/fontawesome.css"> + <!-- FONTS --> + <link rel="stylesheet" href="/css/fontawesome.css"> - <!-- CSS --> - <link rel="stylesheet" href="/css/bootstrap.min.css"> - <link href="/css/datepicker.min.css" rel="stylesheet" type="text/css"> - <link rel="stylesheet" href="/css/select2.min.css"> - <link rel="stylesheet" href="/css/style.css"> + <!-- CSS --> + <link rel="stylesheet" href="/css/bootstrap.min.css"> + <link href="/css/datepicker.min.css" rel="stylesheet" type="text/css"> + <link rel="stylesheet" href="/css/select2.min.css"> + <link rel="stylesheet" href="/css/style.css"> - <!-- JS --> - <script src="/js/jquery-3.4.1.min.js"></script> - <script src="/js/popper.min.js"></script> - <script src="/js/jquery.form-validator.js"></script> - <script src="/js/bootstrap.min.js"></script> - <script src="/js/datepicker.min.js"></script> - <script src="/js/moment.js"></script> - <script src="/js/jquery.uploadPreview.min.js"></script> - <script src="/js/clipboard.min.js"></script> - <script src="/js/autosize.min.js"></script> - <script src="/js/i18n/datepicker.en.js"></script> - <script src="/js/select2.min.js"></script> - <script src="/js/moment-timezone.js"></script> + <!-- JS --> + <script src="/js/jquery-3.4.1.min.js"></script> + <script src="/js/popper.min.js"></script> + <script src="/js/jquery.form-validator.js"></script> + <script src="/js/bootstrap.min.js"></script> + <script src="/js/datepicker.min.js"></script> + <script src="/js/moment.js"></script> + <script src="/js/jquery.uploadPreview.min.js"></script> + <script src="/js/clipboard.min.js"></script> + <script src="/js/autosize.min.js"></script> + <script src="/js/i18n/datepicker.en.js"></script> + <script src="/js/select2.min.js"></script> + <script src="/js/moment-timezone.js"></script> - </head> + </head> - <body> - <div class="container h-100"> - <div class="row" id="container"> - <div class="col-lg-2 col-md-3 col-sm-4" id="sidebar"> - {{>sidebar}} - </div> - <div class="col-sm pt-3" id="content"> - <div id="bodyContainer"> - {{{body}}} - </div> - <div id="footerContainer"> - <small class="text-muted"> - <a href="https://github.com/lowercasename/gathio">GitHub</a> · Made with <i class="far fa-heart"></i> by <a href="https://raphaelkabo.com">Raphael</a> · Need help? <a href="mailto:{{email}}">Email us</a>.<br /> - If you like gathio, you might like <strong><a href="https://sweet.sh/" style="color:#ed5e5e;">sweet</a></strong>, my utopian social network. - </small> - </div> - </div> - </div> - </div> - </body> + <body> + <div class="container h-100"> + <div class="row" id="container"> + <div class="col-lg-2 col-md-3 col-sm-4" id="sidebar"> + {{>sidebar}} + </div> + <div class="col-sm pt-3" id="content"> + <div id="bodyContainer"> + {{{body}}} + </div> + <div id="footerContainer"> + <small class="text-muted"> + <a href="https://github.com/lowercasename/gathio">GitHub</a> · Made with <i class="far fa-heart"></i> by <a href="https://raphaelkabo.com">Raphael</a> · Need help? <a href="mailto:{{email}}">Email us</a>.<br /> + If you like gathio, you might like <strong><a href="https://sweet.sh/" style="color:#ed5e5e;">sweet</a></strong>, my utopian social network. + </small> + </div> + </div> + </div> + </div> + </body> </html> diff --git a/views/login.handlebars b/views/login.handlebars index b5907c0..a08f5b4 100755 --- a/views/login.handlebars +++ b/views/login.handlebars @@ -1,32 +1,32 @@ <h2>Log in</h2> <div class="form-group row"> - <div class="col-sm-12"> - {{#if isPublic}} - <p class="form-text">Register or log in to your account to be able to show this event on your profile, edit it, and delete it. <strong>Associating an event with an account is optional, but keep in mind that an unassociated event can not be modified in any way and will be automatically deleted 30 days after it concludes.</strong></p> - {{else if isPrivate}} - <p class="form-text">You must <a href="/register">register</a> or log in to your account to create a private event.</p> - {{else if isOrganisation}} - <p class="form-text">You must <a href="/register">register</a> or log in to an organisation account to create an organisation event.</p> - {{/if}} - </div> + <div class="col-sm-12"> + {{#if isPublic}} + <p class="form-text">Register or log in to your account to be able to show this event on your profile, edit it, and delete it. <strong>Associating an event with an account is optional, but keep in mind that an unassociated event can not be modified in any way and will be automatically deleted 30 days after it concludes.</strong></p> + {{else if isPrivate}} + <p class="form-text">You must <a href="/register">register</a> or log in to your account to create a private event.</p> + {{else if isOrganisation}} + <p class="form-text">You must <a href="/register">register</a> or log in to an organisation account to create an organisation event.</p> + {{/if}} + </div> </div> <div class="form-group row"> - <label for="email" class="col-sm-2 col-form-label">Email address</label> - <div class="form-group col-sm-10"> - <input type="email" class="form-control" id="email" name="email" placeholder="We will never spam you or share your email." value="{{data.email}}" data-validation="{{#unless isPublic}}required{{/unless}} email" {{#if isPublic}}data-validation-optional="true"{{/if}}> - </div> + <label for="email" class="col-sm-2 col-form-label">Email address</label> + <div class="form-group col-sm-10"> + <input type="email" class="form-control" id="email" name="email" placeholder="We will never spam you or share your email." value="{{data.email}}" data-validation="{{#unless isPublic}}required{{/unless}} email" {{#if isPublic}}data-validation-optional="true"{{/if}}> + </div> </div> <div class="form-group row"> - <label for="password" class="col-sm-2 col-form-label">Password</label> - <div class="form-group col-sm-10"> - <input type="password" class="form-control" id="password" name="password" placeholder="Don't forget it!" {{#unless isPublic}}data-validation="required"{{/unless}}> - </div> - <div class="form-group col-sm-10 offset-sm-2"> - <div class="" id="passwordStrengthBar"></div> - </div> + <label for="password" class="col-sm-2 col-form-label">Password</label> + <div class="form-group col-sm-10"> + <input type="password" class="form-control" id="password" name="password" placeholder="Don't forget it!" {{#unless isPublic}}data-validation="required"{{/unless}}> + </div> + <div class="form-group col-sm-10 offset-sm-2"> + <div class="" id="passwordStrengthBar"></div> + </div> </div> <p> - <a href="/register">Register</a> | <a href="/forgotpassword">Forgot password</a> -</p>
\ No newline at end of file + <a href="/register">Register</a> | <a href="/forgotpassword">Forgot password</a> +</p> diff --git a/views/newevent.handlebars b/views/newevent.handlebars index 81d39c5..dccfbcc 100755 --- a/views/newevent.handlebars +++ b/views/newevent.handlebars @@ -1,9 +1,9 @@ {{#if isPublic}} <h2>New public event</h2> <hr> - <div class="alert alert-info mb-4 text-center" role="alert"> - <i class="fas fa-exclamation-circle"></i> A public event is visible to anyone who knows the link. - </div> + <div class="alert alert-info mb-4 text-center" role="alert"> + <i class="fas fa-exclamation-circle"></i> A public event is visible to anyone who knows the link. + </div> {{else if isPrivate}} <h2>New private event</h2> <hr> @@ -14,22 +14,22 @@ <p>An organisation event is linked to an existing <strong>organisation</strong>. It can be made public, in which case it is visible to anyone who has the link, or private, in which case it is only visible to those who know the <strong>event password</strong>. </p> <hr> {{else if isUnknownType}} - <h2>New event</h2> - <hr> - <div class="alert alert-warning" role="alert"> - Event creation error: unknown event type. Please select an event type from the sidebar. - </div> + <h2>New event</h2> + <hr> + <div class="alert alert-warning" role="alert"> + Event creation error: unknown event type. Please select an event type from the sidebar. + </div> {{else}} <h2>New event</h2> <hr> <div class="alert alert-warning" role="alert"> - Event creation error: unknown event type. Please select an event type from the sidebar. - </div> + Event creation error: unknown event type. Please select an event type from the sidebar. + </div> {{/if}} {{#each errors}} - <div class="alert alert-danger" role="alert">{{this.msg}}</div> + <div class="alert alert-danger" role="alert">{{this.msg}}</div> {{/each}} <div class="container mb-4"> @@ -48,11 +48,11 @@ <div id="newEventFormContainer"> {{#if isPublic}} - {{>neweventform}} + {{>neweventform}} {{else if isPrivate}} - {{>neweventform}} + {{>neweventform}} {{else if isOrganisation}} - {{>neweventform}} + {{>neweventform}} {{else}} {{/if}} </div> @@ -65,12 +65,12 @@ {{>neweventgroupform}} </div> - <script> + <script> $.validate({ lang: 'en', - errorElementClass: "is-invalid", - errorMessageClass: "text-danger", - successElementClass: "is-valid" + errorElementClass: "is-invalid", + errorMessageClass: "text-danger", + successElementClass: "is-valid" }); $(document).ready(function(){ if ($('#icsImportControl')[0].files[0] != null){ @@ -138,4 +138,4 @@ $(this).next('label').html('<i class="far fa-file-alt"></i> ' + file); }); }) - </script> + </script> diff --git a/views/optionsform.handlebars b/views/optionsform.handlebars index 4b3e7a3..a844d12 100755 --- a/views/optionsform.handlebars +++ b/views/optionsform.handlebars @@ -1,47 +1,47 @@ <div class="form-group row"> - <div class="col-sm-2">Options</div> - <div class="col-sm-10"> - <div class="form-check"> - <input class="form-check-input" type="checkbox" id="joinCheckbox" name="joinCheckbox" {{#if data.joinCheckbox}}checked{{/if}}> - <label class="form-check-label" for="joinCheckbox"> - Users can mark themselves as attending this event - </label> - </div> - <div class="form-check"> - <input class="form-check-input" type="checkbox" id="guestlistCheckbox" name="guestlistCheckbox" {{#if data.guestlistCheckbox}}checked{{/if}}> - <label class="form-check-label" for="guestlistCheckbox"> - {{#if isPrivate}}Privately display{{else}}Publicly display{{/if}} the list of attendees - </label> - </div> - <div class="form-check"> - <input class="form-check-input" type="checkbox" id="interactionCheckbox" name="interactionCheckbox" {{#if data.interactionCheckbox}}checked{{/if}}> - <label class="form-check-label" for="interactionCheckbox"> - Users can post comments on this event - </label> - </div> + <div class="col-sm-2">Options</div> + <div class="col-sm-10"> + <div class="form-check"> + <input class="form-check-input" type="checkbox" id="joinCheckbox" name="joinCheckbox" {{#if data.joinCheckbox}}checked{{/if}}> + <label class="form-check-label" for="joinCheckbox"> + Users can mark themselves as attending this event + </label> + </div> + <div class="form-check"> + <input class="form-check-input" type="checkbox" id="guestlistCheckbox" name="guestlistCheckbox" {{#if data.guestlistCheckbox}}checked{{/if}}> + <label class="form-check-label" for="guestlistCheckbox"> + {{#if isPrivate}}Privately display{{else}}Publicly display{{/if}} the list of attendees + </label> + </div> + <div class="form-check"> + <input class="form-check-input" type="checkbox" id="interactionCheckbox" name="interactionCheckbox" {{#if data.interactionCheckbox}}checked{{/if}}> + <label class="form-check-label" for="interactionCheckbox"> + Users can post comments on this event + </label> </div> </div> +</div> - <div class="form-group row"> - <div class="col-sm-2">Options</div> - <div class="col-sm-10"> - <div class="form-check"> - <input class="form-check-input" type="checkbox" id="joinCheckbox" name="joinCheckbox" {{#if eventData.usersCanAttend}}checked{{/if}}> - <label class="form-check-label" for="joinCheckbox"> - Users can mark themselves as attending this event - </label> - </div> - <div class="form-check"> - <input class="form-check-input" type="checkbox" id="guestlistCheckbox" name="guestlistCheckbox" {{#if eventData.showUsersList}}checked{{/if}}> - <label class="form-check-label" for="guestlistCheckbox"> - Display the list of attendees - </label> - </div> - <div class="form-check"> - <input class="form-check-input" type="checkbox" id="interactionCheckbox" name="interactionCheckbox" {{#if eventData.usersCanComment}}checked{{/if}}> - <label class="form-check-label" for="interactionCheckbox"> - Users can post comments on this event - </label> - </div> - </div> - </div> +<div class="form-group row"> + <div class="col-sm-2">Options</div> + <div class="col-sm-10"> + <div class="form-check"> + <input class="form-check-input" type="checkbox" id="joinCheckbox" name="joinCheckbox" {{#if eventData.usersCanAttend}}checked{{/if}}> + <label class="form-check-label" for="joinCheckbox"> + Users can mark themselves as attending this event + </label> + </div> + <div class="form-check"> + <input class="form-check-input" type="checkbox" id="guestlistCheckbox" name="guestlistCheckbox" {{#if eventData.showUsersList}}checked{{/if}}> + <label class="form-check-label" for="guestlistCheckbox"> + Display the list of attendees + </label> + </div> + <div class="form-check"> + <input class="form-check-input" type="checkbox" id="interactionCheckbox" name="interactionCheckbox" {{#if eventData.usersCanComment}}checked{{/if}}> + <label class="form-check-label" for="interactionCheckbox"> + Users can post comments on this event + </label> + </div> + </div> +</div> diff --git a/views/partials/editeventgroupmodal.handlebars b/views/partials/editeventgroupmodal.handlebars index 64fba9b..a6102fa 100644 --- a/views/partials/editeventgroupmodal.handlebars +++ b/views/partials/editeventgroupmodal.handlebars @@ -8,33 +8,33 @@ </button> </div> <form id="editEventForm" action="/editeventgroup/{{eventGroupData.id}}/{{eventGroupData.editToken}}" method="post" enctype="multipart/form-data" autocomplete="off"> - <div class="modal-body"> - <div class="form-group"> - <label for="eventGroupName" >Name</label> - <input type="text" class="form-control" id="eventGroupName" name="eventGroupName" placeholder="Make it snappy." value="{{eventGroupData.name}}" data-validation="required length" data-validation-length="3-120"> - </div> - <div class="form-group"> - <label for="eventGroupDescription" >Description</label> - <textarea class="form-control" id="eventGroupDescription" name="eventGroupDescription" data-validation="required">{{eventGroupData.description}}</textarea> - <small class="form-text"><a href="https://commonmark.org/help/">Markdown</a> formatting supported.</small> - </div> - <div class="form-group"> - <label for="eventGroupURL" >Link</label> - <input type="url" class="form-control" id="eventURL" name="eventGroupURL" value="{{eventGroupData.url}}" placeholder="For tickets or a page with more information (optional)." data-validation="url" data-validation-optional="true"> - </div> - <div class="form-group"> - <label for="hostName" >Host or organisation name</label> - <input type="text" class="form-control" id="hostName" name="hostName" placeholder="Will be shown on the event group page (optional)." value="{{eventGroupData.hostName}}" data-validation="length" data-validation-length="3-120" data-validation-optional="true"> - </div> - <div class="form-group"> - <label>Cover image</label> - <div class="image-preview" id="eventGroupImagePreview"> - <label for="eventGroupImageUpload" id="eventGroupImageLabel">Choose file</label> - <input type="file" name="eventGroupImageUpload" id="eventGroupImageUpload" /> - </div> - <small class="form-text">Recommended dimensions (w x h): 920px by 300px.</small> - </div> - </div> + <div class="modal-body"> + <div class="form-group"> + <label for="eventGroupName" >Name</label> + <input type="text" class="form-control" id="eventGroupName" name="eventGroupName" placeholder="Make it snappy." value="{{eventGroupData.name}}" data-validation="required length" data-validation-length="3-120"> + </div> + <div class="form-group"> + <label for="eventGroupDescription" >Description</label> + <textarea class="form-control" id="eventGroupDescription" name="eventGroupDescription" data-validation="required">{{eventGroupData.description}}</textarea> + <small class="form-text"><a href="https://commonmark.org/help/">Markdown</a> formatting supported.</small> + </div> + <div class="form-group"> + <label for="eventGroupURL" >Link</label> + <input type="url" class="form-control" id="eventURL" name="eventGroupURL" value="{{eventGroupData.url}}" placeholder="For tickets or a page with more information (optional)." data-validation="url" data-validation-optional="true"> + </div> + <div class="form-group"> + <label for="hostName" >Host or organisation name</label> + <input type="text" class="form-control" id="hostName" name="hostName" placeholder="Will be shown on the event group page (optional)." value="{{eventGroupData.hostName}}" data-validation="length" data-validation-length="3-120" data-validation-optional="true"> + </div> + <div class="form-group"> + <label>Cover image</label> + <div class="image-preview" id="eventGroupImagePreview"> + <label for="eventGroupImageUpload" id="eventGroupImageLabel">Choose file</label> + <input type="file" name="eventGroupImageUpload" id="eventGroupImageUpload" /> + </div> + <small class="form-text">Recommended dimensions (w x h): 920px by 300px.</small> + </div> + </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> <button type="submit" class="btn btn-primary">Save changes</button> diff --git a/views/partials/editeventmodal.handlebars b/views/partials/editeventmodal.handlebars index 2227473..a1ccd83 100644 --- a/views/partials/editeventmodal.handlebars +++ b/views/partials/editeventmodal.handlebars @@ -1,156 +1,156 @@ <div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="editModalLabel" aria-hidden="true"> - <div class="modal-dialog" role="document"> - <div class="modal-content"> - <div class="modal-header"> - <h5 class="modal-title" id="editModalLabel">Edit '{{eventData.name}}'</h5> - <button type="button" class="close" data-dismiss="modal" aria-label="Close"> - <span aria-hidden="true">×</span> - </button> - </div> - <div class="modal-body"> - <form id="editEventForm" action="/editevent/{{eventData.id}}/{{eventData.editToken}}" method="post" - enctype="multipart/form-data" autocomplete="off"> - <div class="form-group"> - <label for="eventName" class="col-form-label">Event name</label> - <input type="text" class="form-control" id="eventName" name="eventName" - placeholder="Make it snappy." value="{{eventData.name}}" data-validation="required length" - data-validation-length="3-120"> - </div> - <div class="form-group"> - <label for="eventLocation" class="col-form-label">Location</label> - <input type="text" class="form-control" id="eventLocation" name="eventLocation" - placeholder="Be specific." value="{{eventData.location}}" data-validation="required length" - data-validation-length="3-120"> - </div> - <div class="form-group"> - <label for="eventStart" class="col-form-label">Starts</label> - <input readonly type="text" class="form-control" id="eventStart" name="eventStart" value="" - data-validation="required"> - </div> - <div class="form-group"> - <label for="eventEnd" class="col-form-label">Ends</label> - <input readonly type="text" class="form-control" id="eventEnd" name="eventEnd" value="" - data-validation="required"> - </div> - <div class="form-group"> - <label for="timezone" class="col-form-label">Timezone</label> - <select class="select2" id="timezone" name="timezone"></select> - </div> - <div class="form-group"> - <label for="eventDescription" class="col-form-label">Description</label> - <textarea class="form-control" id="eventDescription" name="eventDescription" - data-validation="required">{{eventData.description}}</textarea> - <small class="form-text"><a href="https://commonmark.org/help/">Markdown</a> formatting - supported.</small> - </div> - <div class="form-group"> - <label for="eventURL" class="col-form-label">Link</label> - <input type="url" class="form-control" id="eventURL" name="eventURL" value="{{eventData.url}}" - placeholder="For tickets or another event page (optional)." data-validation="url" - data-validation-optional="true"> - </div> - <div class="form-group"> - <label for="hostName" class="col-form-label">Host name</label> - <input type="text" class="form-control" id="hostName" name="hostName" - placeholder="Will be shown on the event page (optional)." value="{{eventData.hostName}}" - data-validation="length" data-validation-length="3-120" data-validation-optional="true"> - </div> - <div class="form-group"> - <label for="eventImage" class="col-form-label">Cover image</label> - <div class="image-preview" id="image-preview"> - <label for="image-upload" id="image-label">Choose file</label> - <input type="file" name="imageUpload" id="image-upload" /> - </div> - <small class="form-text">Recommended dimensions (w x h): 920px by 300px.</small> - {{#if eventData.image}} - <button type="button" class="btn btn-danger" id="deleteImage">Delete image</button> - {{/if}} - </div> - <div class="form-group"> - <div class="mb-2">Options</div> - <div class="form-check"> - <input class="form-check-input" type="checkbox" id="eventGroupCheckbox" - name="eventGroupCheckbox" {{#if eventData.eventGroup}}checked{{/if}}> - <label class="form-check-label" for="eventGroupCheckbox"> - This event is part of an event group - </label> - </div> - <div class="card text-white bg-secondary my-2" id="eventGroupData" {{#if eventData.eventGroup}}style="display:flex" {{/if}}> - <div class="card-header"> - <strong>Link this event to an event group</strong> - </div> - <div class="card-body"> - <div class="form-group"> - <label for="eventGroupID" class="form-label">Event group ID</label> - <div class="form-group"> - <input type="text" class="form-control" id="eventGroupID" name="eventGroupID" - placeholder="" data-validation-optional="true" value="{{eventData.eventGroup.id}}"> - <small class="form-text">You can find this short string of characters in the - event group's link, in your confirmation email, or on the event group's - page.</small> - </div> - </div> - <div class="form-group"> - <label for="eventGroupEditToken" class="form-label">Event group secret - editing code</label> - <div class="form-group"> - <input type="text" class="form-control" id="eventGroupEditToken" - name="eventGroupEditToken" placeholder="" data-validation-optional="true" value="{{eventData.eventGroup.editToken}}"> - <small class="form-text">You can find this long string of characters in the - confirmation email you received when you created the event group.</small> - </div> - </div> - </div> - </div> - <div class="form-check"> - <input class="form-check-input" type="checkbox" id="interactionCheckbox" - name="interactionCheckbox" {{#if eventData.usersCanComment}}checked{{/if}}> - <label class="form-check-label" for="interactionCheckbox"> - Users can post comments on this event - </label> - </div> - <div class="form-check"> - <input class="form-check-input {{#unless eventData.usersCanAttend}}unchecked{{/unless}}" - type="checkbox" id="joinCheckbox" name="joinCheckbox" - {{#if eventData.usersCanAttend}}checked{{/if}}> - <label class="form-check-label" for="joinCheckbox"> - Users can mark themselves as attending this event - </label> - </div> - <div class="form-check" id="maxAttendeesCheckboxContainer" - {{#if eventData.maxAttendees}}style="display:flex" {{/if}}> - <input class="form-check-input" type="checkbox" id="maxAttendeesCheckbox" - name="maxAttendeesCheckbox" {{#if eventData.maxAttendees}}checked{{/if}}> - <label class="form-check-label" for="maxAttendeesCheckbox"> - Set a limit on the maximum number of attendees - </label> - </div> - </div> - <div class="form-group" id="maxAttendeesContainer" - {{#if eventData.maxAttendees}}style="display:flex" {{/if}}> - <label for="maxAttendees" class="col-form-label">Attendee limit</label> - <input type="number" class="form-control" id="maxAttendees" name="maxAttendees" - placeholder="Enter a number." data-validation="number" data-validation-optional="true" - value="{{eventData.maxAttendees}}"> - </div> - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> - <button type="submit" class="btn btn-primary">Save changes</button> - </form> - </div> - </div> - </div> + <div class="modal-dialog" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <h5 class="modal-title" id="editModalLabel">Edit '{{eventData.name}}'</h5> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> + <span aria-hidden="true">×</span> + </button> + </div> + <div class="modal-body"> + <form id="editEventForm" action="/editevent/{{eventData.id}}/{{eventData.editToken}}" method="post" + enctype="multipart/form-data" autocomplete="off"> + <div class="form-group"> + <label for="eventName" class="col-form-label">Event name</label> + <input type="text" class="form-control" id="eventName" name="eventName" + placeholder="Make it snappy." value="{{eventData.name}}" data-validation="required length" + data-validation-length="3-120"> + </div> + <div class="form-group"> + <label for="eventLocation" class="col-form-label">Location</label> + <input type="text" class="form-control" id="eventLocation" name="eventLocation" + placeholder="Be specific." value="{{eventData.location}}" data-validation="required length" + data-validation-length="3-120"> + </div> + <div class="form-group"> + <label for="eventStart" class="col-form-label">Starts</label> + <input readonly type="text" class="form-control" id="eventStart" name="eventStart" value="" + data-validation="required"> + </div> + <div class="form-group"> + <label for="eventEnd" class="col-form-label">Ends</label> + <input readonly type="text" class="form-control" id="eventEnd" name="eventEnd" value="" + data-validation="required"> + </div> + <div class="form-group"> + <label for="timezone" class="col-form-label">Timezone</label> + <select class="select2" id="timezone" name="timezone"></select> + </div> + <div class="form-group"> + <label for="eventDescription" class="col-form-label">Description</label> + <textarea class="form-control" id="eventDescription" name="eventDescription" + data-validation="required">{{eventData.description}}</textarea> + <small class="form-text"><a href="https://commonmark.org/help/">Markdown</a> formatting + supported.</small> + </div> + <div class="form-group"> + <label for="eventURL" class="col-form-label">Link</label> + <input type="url" class="form-control" id="eventURL" name="eventURL" value="{{eventData.url}}" + placeholder="For tickets or another event page (optional)." data-validation="url" + data-validation-optional="true"> + </div> + <div class="form-group"> + <label for="hostName" class="col-form-label">Host name</label> + <input type="text" class="form-control" id="hostName" name="hostName" + placeholder="Will be shown on the event page (optional)." value="{{eventData.hostName}}" + data-validation="length" data-validation-length="3-120" data-validation-optional="true"> + </div> + <div class="form-group"> + <label for="eventImage" class="col-form-label">Cover image</label> + <div class="image-preview" id="image-preview"> + <label for="image-upload" id="image-label">Choose file</label> + <input type="file" name="imageUpload" id="image-upload" /> + </div> + <small class="form-text">Recommended dimensions (w x h): 920px by 300px.</small> + {{#if eventData.image}} + <button type="button" class="btn btn-danger" id="deleteImage">Delete image</button> + {{/if}} + </div> + <div class="form-group"> + <div class="mb-2">Options</div> + <div class="form-check"> + <input class="form-check-input" type="checkbox" id="eventGroupCheckbox" + name="eventGroupCheckbox" {{#if eventData.eventGroup}}checked{{/if}}> + <label class="form-check-label" for="eventGroupCheckbox"> + This event is part of an event group + </label> + </div> + <div class="card text-white bg-secondary my-2" id="eventGroupData" {{#if eventData.eventGroup}}style="display:flex" {{/if}}> + <div class="card-header"> + <strong>Link this event to an event group</strong> + </div> + <div class="card-body"> + <div class="form-group"> + <label for="eventGroupID" class="form-label">Event group ID</label> + <div class="form-group"> + <input type="text" class="form-control" id="eventGroupID" name="eventGroupID" + placeholder="" data-validation-optional="true" value="{{eventData.eventGroup.id}}"> + <small class="form-text">You can find this short string of characters in the + event group's link, in your confirmation email, or on the event group's + page.</small> + </div> + </div> + <div class="form-group"> + <label for="eventGroupEditToken" class="form-label">Event group secret + editing code</label> + <div class="form-group"> + <input type="text" class="form-control" id="eventGroupEditToken" + name="eventGroupEditToken" placeholder="" data-validation-optional="true" value="{{eventData.eventGroup.editToken}}"> + <small class="form-text">You can find this long string of characters in the + confirmation email you received when you created the event group.</small> + </div> + </div> + </div> + </div> + <div class="form-check"> + <input class="form-check-input" type="checkbox" id="interactionCheckbox" + name="interactionCheckbox" {{#if eventData.usersCanComment}}checked{{/if}}> + <label class="form-check-label" for="interactionCheckbox"> + Users can post comments on this event + </label> + </div> + <div class="form-check"> + <input class="form-check-input {{#unless eventData.usersCanAttend}}unchecked{{/unless}}" + type="checkbox" id="joinCheckbox" name="joinCheckbox" + {{#if eventData.usersCanAttend}}checked{{/if}}> + <label class="form-check-label" for="joinCheckbox"> + Users can mark themselves as attending this event + </label> + </div> + <div class="form-check" id="maxAttendeesCheckboxContainer" + {{#if eventData.maxAttendees}}style="display:flex" {{/if}}> + <input class="form-check-input" type="checkbox" id="maxAttendeesCheckbox" + name="maxAttendeesCheckbox" {{#if eventData.maxAttendees}}checked{{/if}}> + <label class="form-check-label" for="maxAttendeesCheckbox"> + Set a limit on the maximum number of attendees + </label> + </div> + </div> + <div class="form-group" id="maxAttendeesContainer" + {{#if eventData.maxAttendees}}style="display:flex" {{/if}}> + <label for="maxAttendees" class="col-form-label">Attendee limit</label> + <input type="number" class="form-control" id="maxAttendees" name="maxAttendees" + placeholder="Enter a number." data-validation="number" data-validation-optional="true" + value="{{eventData.maxAttendees}}"> + </div> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> + <button type="submit" class="btn btn-primary">Save changes</button> + </form> + </div> + </div> + </div> </div> <script> $('#deleteImage').click(function() { - $.post('/deleteimage/{{eventData.id}}/{{eventData.editToken}}', function(response) { - if (response === "Success") { - location.reload(); - } else { - alert(response); - } - }); + $.post('/deleteimage/{{eventData.id}}/{{eventData.editToken}}', function(response) { + if (response === "Success") { + location.reload(); + } else { + alert(response); + } + }); }) -</script>
\ No newline at end of file +</script> diff --git a/views/partials/neweventform.handlebars b/views/partials/neweventform.handlebars index 82ecfd9..829ec42 100755 --- a/views/partials/neweventform.handlebars +++ b/views/partials/neweventform.handlebars @@ -1,6 +1,6 @@ <h4 class="mb-2">Create an event</h4> <form id="newEventForm" action="/newevent" method="post" enctype="multipart/form-data"> - <input type="text" hidden class="form-control" id="eventType" name="eventType" value="{{eventType}}"> + <input type="text" hidden class="form-control" id="eventType" name="eventType" value="{{eventType}}"> <div class="form-group row"> <label for="eventName" class="col-sm-2 col-form-label">Event name</label> <div class="form-group col-sm-10"> @@ -34,8 +34,8 @@ <div class="form-group row"> <label for="eventDescription" class="col-sm-2 col-form-label">Description</label> <div class="form-group col-sm-10"> - <textarea class="form-control expand" id="eventDescription" name="eventDescription" data-validation="required" placeholder="You can always edit it later."></textarea> - <small class="form-text"><a href="https://commonmark.org/help/">Markdown</a> formatting supported.</small> + <textarea class="form-control expand" id="eventDescription" name="eventDescription" data-validation="required" placeholder="You can always edit it later."></textarea> + <small class="form-text"><a href="https://commonmark.org/help/">Markdown</a> formatting supported.</small> </div> </div> <div class="form-group row"> @@ -47,11 +47,11 @@ <div class="form-group row"> <label for="eventImage" class="col-sm-2 col-form-label">Cover image</label> <div class="form-group col-sm-10"> - <div class="image-preview" id="eventImagePreview"> - <label for="image-upload" id="eventImageLabel">Choose file</label> - <input type="file" name="imageUpload" id="eventImageUpload" /> - </div> - <small class="form-text">Recommended dimensions (w x h): 920px by 300px.</small> + <div class="image-preview" id="eventImagePreview"> + <label for="image-upload" id="eventImageLabel">Choose file</label> + <input type="file" name="imageUpload" id="eventImageUpload" /> + </div> + <small class="form-text">Recommended dimensions (w x h): 920px by 300px.</small> </div> </div> {{#unless isPublic}} @@ -144,48 +144,48 @@ <script type="text/javascript" src="/js/generate-timezones.js"></script> <script> - $(document).ready(function() { - $.uploadPreview({ - input_field: "#eventImageUpload", - preview_box: "#eventImagePreview", - label_field: "#eventImageLabel", - label_default: "Choose file", - label_selected: "Change file", - no_label: false - }); - autosize($('textarea')); - $("#maxAttendeesCheckbox").on("click", function() { - if ($(this).is(':checked')) { - $("#maxAttendeesContainer").slideDown('fast').css("display","flex"); - $("#maxAttendees").attr("data-validation-optional","false"); - } - else { - $("#maxAttendeesContainer").slideUp('fast'); - $("#maxAttendees").attr("data-validation-optional","true").val("").removeClass('is-valid is-invalid'); - } - }); - $("#joinCheckbox").on("click", function() { - if ($(this).is(':checked')) { - $("#maxAttendeesCheckboxContainer").slideDown('fast').css("display","flex"); - } - else { - $("#maxAttendeesCheckboxContainer").slideUp('fast'); - $("#maxAttendeesCheckbox").prop("checked",false); - $("#maxAttendeesContainer").slideUp('fast'); - $("#maxAttendees").attr("data-validation-optional","true").val("").removeClass('is-valid is-invalid'); - } - }); - $("#eventGroupCheckbox").on("click", function() { - if ($(this).is(':checked')) { - $("#eventGroupData").slideDown('fast'); - $("#eventGroupID").removeAttr("data-validation-optional").attr("data-validation","required"); - $("#eventGroupEditToken").removeAttr("data-validation-optional").attr("data-validation","required"); - } - else { - $("#eventGroupData").slideUp('fast'); - $("#eventGroupID").removeAttr("data-validation").attr("data-validation-optional","true").val(""); - $("#eventGroupEditToken").removeAttr("data-validation").attr("data-validation-optional","true").val(""); - } - }); - }); + $(document).ready(function() { + $.uploadPreview({ + input_field: "#eventImageUpload", + preview_box: "#eventImagePreview", + label_field: "#eventImageLabel", + label_default: "Choose file", + label_selected: "Change file", + no_label: false + }); + autosize($('textarea')); + $("#maxAttendeesCheckbox").on("click", function() { + if ($(this).is(':checked')) { + $("#maxAttendeesContainer").slideDown('fast').css("display","flex"); + $("#maxAttendees").attr("data-validation-optional","false"); + } + else { + $("#maxAttendeesContainer").slideUp('fast'); + $("#maxAttendees").attr("data-validation-optional","true").val("").removeClass('is-valid is-invalid'); + } + }); + $("#joinCheckbox").on("click", function() { + if ($(this).is(':checked')) { + $("#maxAttendeesCheckboxContainer").slideDown('fast').css("display","flex"); + } + else { + $("#maxAttendeesCheckboxContainer").slideUp('fast'); + $("#maxAttendeesCheckbox").prop("checked",false); + $("#maxAttendeesContainer").slideUp('fast'); + $("#maxAttendees").attr("data-validation-optional","true").val("").removeClass('is-valid is-invalid'); + } + }); + $("#eventGroupCheckbox").on("click", function() { + if ($(this).is(':checked')) { + $("#eventGroupData").slideDown('fast'); + $("#eventGroupID").removeAttr("data-validation-optional").attr("data-validation","required"); + $("#eventGroupEditToken").removeAttr("data-validation-optional").attr("data-validation","required"); + } + else { + $("#eventGroupData").slideUp('fast'); + $("#eventGroupID").removeAttr("data-validation").attr("data-validation-optional","true").val(""); + $("#eventGroupEditToken").removeAttr("data-validation").attr("data-validation-optional","true").val(""); + } + }); + }); </script> diff --git a/views/partials/neweventgroupform.handlebars b/views/partials/neweventgroupform.handlebars index fddc795..8201c60 100755 --- a/views/partials/neweventgroupform.handlebars +++ b/views/partials/neweventgroupform.handlebars @@ -11,8 +11,8 @@ <div class="form-group row"> <label for="eventGroupDescription" class="col-sm-2 col-form-label">Description</label> <div class="form-group col-sm-10"> - <textarea class="form-control expand" id="eventGroupDescription" name="eventGroupDescription" data-validation="required" placeholder="You can always edit it later."></textarea> - <small class="form-text"><a href="https://commonmark.org/help/">Markdown</a> formatting supported.</small> + <textarea class="form-control expand" id="eventGroupDescription" name="eventGroupDescription" data-validation="required" placeholder="You can always edit it later."></textarea> + <small class="form-text"><a href="https://commonmark.org/help/">Markdown</a> formatting supported.</small> </div> </div> <div class="form-group row"> @@ -24,11 +24,11 @@ <div class="form-group row"> <label for="eventGroupImage" class="col-sm-2 col-form-label">Cover image</label> <div class="form-group col-sm-10"> - <div class="image-preview" id="eventGroupImagePreview"> - <label for="image-upload" id="eventGroupImageLabel">Choose file</label> - <input type="file" name="imageUpload" id="eventGroupImageUpload" /> - </div> - <small class="form-text">Recommended dimensions (w x h): 920px by 300px.</small> + <div class="image-preview" id="eventGroupImagePreview"> + <label for="image-upload" id="eventGroupImageLabel">Choose file</label> + <input type="file" name="imageUpload" id="eventGroupImageUpload" /> + </div> + <small class="form-text">Recommended dimensions (w x h): 920px by 300px.</small> </div> </div> <div class="form-group row"> @@ -52,15 +52,15 @@ </form> <script> - $(document).ready(function() { - $.uploadPreview({ - input_field: "#eventGroupImageUpload", - preview_box: "#eventGroupImagePreview", - label_field: "#eventGroupImageLabel", - label_default: "Choose file", - label_selected: "Change file", - no_label: false - }); - autosize($('textarea')); - }); + $(document).ready(function() { + $.uploadPreview({ + input_field: "#eventGroupImageUpload", + preview_box: "#eventGroupImagePreview", + label_field: "#eventGroupImageLabel", + label_default: "Choose file", + label_selected: "Change file", + no_label: false + }); + autosize($('textarea')); + }); </script> |