diff --git a/app/endpoints/delete_event.js b/app/endpoints/delete_event.js index f8bad740..7ebd1084 100644 --- a/app/endpoints/delete_event.js +++ b/app/endpoints/delete_event.js @@ -11,7 +11,7 @@ * } * * If there was an error ( for example, if the id was missing or the event wasn't found ) - * returns http 400 "Bad Request" and a json error response (see errors.php) + * returns http 400 "Bad Request" and a json error response (see util/errors.js) * */ const config = require("../config"); diff --git a/app/endpoints/events.js b/app/endpoints/events.js index 4f1fd933..be271eb8 100644 --- a/app/endpoints/events.js +++ b/app/endpoints/events.js @@ -103,13 +103,11 @@ function getSummaries(dailies) { } exports.getSummaries = getSummaries; -// the php version had each daily query for its event -// and then tacked the end time to the end of the daily json -// relying on flourish to ( presumably ) filter out the redundant event queries. -// this pools the events to avoid multiple queries: -// so to keep the endtime after each daily, we have to tack it on manually. +// pool the events so each daily doesn't separately query for its (shared) event. +// the end time lives on the event, but needs to appear after each daily's json, +// so it's tacked on manually below. function specialSummary(evt) { - // an invalid duration generates a null here; just like the php. + // an invalid duration generates a null here. const endTime = to24HourString(evt.getEndTime()); return [ evt.getJSON(), endTime ]; } diff --git a/app/endpoints/retrieve_event.js b/app/endpoints/retrieve_event.js index 847cc882..da809012 100644 --- a/app/endpoints/retrieve_event.js +++ b/app/endpoints/retrieve_event.js @@ -9,7 +9,7 @@ * * On success, returns a json summary of event. * If there was an error ( for example, if the id was missing or the event wasn't found ) - * returns http 400 "Bad Request" with a json error response ( see errors.php ) + * returns http 400 "Bad Request" with a json error response ( see util/errors.js ) * * See also: * https://github.com/shift-org/shift-docs/blob/main/docs/CALENDAR_API.md#retrieving-public-event-data diff --git a/app/models/calDaily.js b/app/models/calDaily.js index 476ff2f1..a1487449 100644 --- a/app/models/calDaily.js +++ b/app/models/calDaily.js @@ -37,7 +37,7 @@ const methods = { // store the status and newflash if they changed. // promises this after storing the change. - // note: flourish stored empty strings as null; so we do the same. + // note: empty strings are stored as null, to stay consistent with existing data. _updateStatus(dateStatus) { let changed = false; const newStatus = dateStatus.status || null; @@ -328,7 +328,7 @@ class CalDaily { * @param statusMap a js Map containing {YYYY-MM-DD: dateStatus } * @return the promise of valid CalDaily(s) * - * @see: DateStatus.php, manage_event.php + * @see: dateStatus.js, manage_event.js */ static reconcile(evt, statusMap, softDelete = true) { return CalDaily.getByEventID(evt.id).then((dailies) => { diff --git a/app/models/calEventValidator.js b/app/models/calEventValidator.js index b14816dc..23980ae0 100644 --- a/app/models/calEventValidator.js +++ b/app/models/calEventValidator.js @@ -76,11 +76,9 @@ function makeValidator(input, errors) { requiredTime(field) { // interestingly: the upload is in AM/PM style // but the server stores and reports in 24 hour style. - // and flourish stores communicates 'time' fields as an fTime - // while mysql stores as a 'hh:mm:ss' with no meridian - // so flourish must automatically transform to 24 time. + // mysql stores 'time' fields as 'hh:mm:ss' with no meridian, + // so we convert to 24 hour here. // https://dev.mysql.com/doc/refman/8.0/en/time.html - // https://flourishlib.com/docs/fTime.html const str = getString(field); if (validator.isEmpty(str)) { errors.addError('time'); @@ -96,8 +94,7 @@ function makeValidator(input, errors) { } } }, - // to mimic php/flourish empty strings are converted to null. - // https://flourishlib.com/docs/fActiveRecord.html#ColumnOperations + // empty strings are converted to null, to stay consistent with existing data. nullString(field, maxLen = 255) { const str = getString(field); if (validator.isEmpty(str)) { diff --git a/docs/TABLES.md b/docs/TABLES.md index 44e14180..4315a0f9 100644 --- a/docs/TABLES.md +++ b/docs/TABLES.md @@ -45,7 +45,7 @@ See also: - **tinytitle** string event string used for the printed calendar. - if not specified, manage_event.php slices the first 24 characters of the long title. + if not specified, the manage_event endpoint slices the first 24 characters of the long title. - **audience** char @@ -59,13 +59,11 @@ See also: - **image** string - server location is configured via config.php: - $IMAGEDIR = "/opt/backend/eventimages"; - $IMAGEURL = "/eventimages"; - - mange_event.php accepts gif, jpeg, pjpeg, png, up to 2 megs. - https://flourishlib.com/docs/fValidation.html - https://flourishlib.com/docs/fUpload.html + the storage location and url path are configured in `app/config.js` + ( `config.image.dir` and `config.image.path` ). + + the `manage_event` endpoint accepts gif, jpeg, pjpeg, png images, + up to `config.image.maxFileSize`. - **tinytitle** string diff --git a/docs/cache_busting.md b/docs/cache_busting.md index 7763bebd..869b9513 100644 --- a/docs/cache_busting.md +++ b/docs/cache_busting.md @@ -7,7 +7,7 @@ use cases 4. uploading a new image -in the legacy case ( 3 ), say, for example, there is an old event with id `666` and an image called `legacy.png`. The php renames the file ( even during a GET ) to match its id ( ie. `666.png` ) and this becomes the stable case ( 2 ) thereafter. +in the legacy case ( 3 ), an old event might have an image stored under a name unrelated to its id ( ex. `legacy.png` ). these files are served directly by their stored name. calevent image field examples -------------------- @@ -16,15 +16,14 @@ calevent image field examples 5. **legacy name** -- i have no idea if any of these actually exist, but some images used to have a format different than the "base format". ( maybe some `legacy.png` ) 3. **base format** -- the db record matches the file on disk. its name follows from the event id. for example, for event `123` the image field is `123.png` 4. **extended format** -- for cache busting, appends the calevent sequence number to the base format. for example, the image field might be `123-44.png` -2. **upload finalized** -- in `manage_event.php` `upload_attached_file()`, after the upload has completed but before event management has finished, the event image field gets updated to match the name of the uploaded file. This name is determined by the flourish file uploader. It is temporary, and will become the base ( or extended ) format after `updateImageUrl()` is called. +2. **upload finalized** -- when an image is uploaded, `manage_event` ( `app/endpoints/manage_event.js` ) saves the file via `app/uploader.js` and sets the image field to the extended format, `-`. the sequence number comes from the event's `changes` counter. filenames on disk ------------------ 1. **pre-upload**, the image has whatever name the user has assigned: ex. `/my/local/computer/puppet.png` -2. **upload in progress**, flourish appears to upload files to a temp directory on the server with a randomly assigned temporary name: ex, maybe, `/tmp/tmphhh` -2. **upload finalized**, flourish assigns a unique, non conflicting name based on the user's original file. For example: `/opt/backend/eventimages/puppet.png` or if there is already some `puppet.png` on the server, `/opt/backend/eventimages/puppet_copy_1.png`. This name is not stored to the db, only set in memory. -3. any time **updateImageUrl()** is called, the php code may rename the image file. It uses a name based on the event id. For example, for event 123, `/opt/backend/eventimages/123.png`. **Note:** this is the same as the "base format", it's never the "extended format". +2. **uploaded**, the upload is received in memory by [multer](https://github.com/expressjs/multer) ( see `app/uploader.js` ), so no temporary file is left on disk. +3. **stored**, `uploader.write()` writes the file under a name based on the event id, in the directory set by `config.image.dir`. for event 123, that's ex. `/opt/backend/eventimages/123.png`. **Note:** this is always the "base format", never the "extended format"; the sequence number only appears in the db image field and the url. image urls diff --git a/site/themes/s2b_hugo_theme/assets/js/cal/addevent.js b/site/themes/s2b_hugo_theme/assets/js/cal/addevent.js index 6223b082..4b60473b 100644 --- a/site/themes/s2b_hugo_theme/assets/js/cal/addevent.js +++ b/site/themes/s2b_hugo_theme/assets/js/cal/addevent.js @@ -235,7 +235,7 @@ err = returnVal.responseJSON.error; } else if (returnVal.status === 413) { // 413 - "Request Entity Too Large" gets sent by nginx above its client_max_body_size; - // so the error message sent by flourish. + // nginx (not the backend) sends it, so we construct the error message here. err = { message: 'There were errors in your fields', fields: {