dce-reactkit 3.6.25 → 3.6.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,10 +16,12 @@ import LogFunction from '../types/LogFunction';
16
16
  * send (a function that sends a string to the client),
17
17
  * redirect (takes a url and redirects the user to that url),
18
18
  * renderErrorPage (shows a static error page to the user),
19
+ * renderInfoPage (shows a static info page to the user),
19
20
  * and returns the value to send to the client as a JSON API response, or
20
21
  * calls next() or redirect(...) or send(...) or renderErrorPage(...).
21
22
  * Note: params also has userId, userFirstName,
22
- * userLastName, isLearner, isTTM, isAdmin, and any other variables that
23
+ * userLastName, userEmail, userAvatarURL, isLearner, isTTM, isAdmin,
24
+ * and any other variables that
23
25
  * are directly added to the session, if the user does have a session.
24
26
  */
25
27
  declare const genRouteHandler: (opts: {
@@ -41,6 +43,10 @@ declare const genRouteHandler: (opts: {
41
43
  pageTitle?: string;
42
44
  status?: number;
43
45
  }) => void;
46
+ renderInfoPage: (opts: {
47
+ title: string;
48
+ body: string;
49
+ }) => void;
44
50
  logServerEvent: LogFunction;
45
51
  }) => any;
46
52
  skipSessionCheck?: boolean | undefined;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Generate a static info page
3
+ * @author Gabe Abrams
4
+ * @param opts object containing all arguments
5
+ * @param opts.title title of the info box
6
+ * @param opts.body a human-readable text body for the info alert
7
+ */
8
+ declare const genInfoPage: (opts: {
9
+ title: string;
10
+ body: string;
11
+ }) => string;
12
+ export default genInfoPage;
package/dist/esm/index.js CHANGED
@@ -42040,6 +42040,96 @@ const genErrorPage = (opts = {}) => {
42040
42040
  `;
42041
42041
  };
42042
42042
 
42043
+ /**
42044
+ * Generate a static info page
42045
+ * @author Gabe Abrams
42046
+ * @param opts object containing all arguments
42047
+ * @param opts.title title of the info box
42048
+ * @param opts.body a human-readable text body for the info alert
42049
+ */
42050
+ const genInfoPage = (opts) => {
42051
+ const { title, body, } = opts;
42052
+ return `
42053
+ <head>
42054
+ <!-- Metadata -->
42055
+ <meta
42056
+ name="viewport"
42057
+ content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0"
42058
+ >
42059
+
42060
+ <!-- Title -->
42061
+ <title>${title}</title>
42062
+
42063
+ <!-- Bootstrap -->
42064
+ <link
42065
+ rel="stylesheet"
42066
+ href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.1/css/bootstrap.min.css"
42067
+ integrity="sha512-siwe/oXMhSjGCwLn+scraPOWrJxHlUgMBMZXdPe2Tnk3I0x3ESCoLz7WZ5NTH6SZrywMY+PB1cjyqJ5jAluCOg=="
42068
+ crossorigin="anonymous"
42069
+ referrerpolicy="no-referrer"
42070
+ />
42071
+ <script
42072
+ src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.1/js/bootstrap.min.js"
42073
+ integrity="sha512-vyRAVI0IEm6LI/fVSv/Wq/d0KUfrg3hJq2Qz5FlfER69sf3ZHlOrsLriNm49FxnpUGmhx+TaJKwJ+ByTLKT+Yg=="
42074
+ crossorigin="anonymous"
42075
+ referrerpolicy="no-referrer"
42076
+ ></script>
42077
+
42078
+ <!-- FontAwesome -->
42079
+ <link
42080
+ rel="stylesheet"
42081
+ href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css"
42082
+ integrity="sha512-xh6O/CkQoPOWDdYTDqeRdPCVd1SpvCA9XXcUnZS2FmJNp1coAFzvtCN9BmamE+4aHK8yyUHUSCcJHgXloTyT2A=="
42083
+ crossorigin="anonymous"
42084
+ referrerpolicy="no-referrer"
42085
+ />
42086
+
42087
+ <!-- Style -->
42088
+ <style>
42089
+ .DCEReactKit-pop-in {
42090
+ animation-name: DCEReactKit-pop-in;
42091
+ animation-duration: 0.5s;
42092
+ animation-iteration-count: 1;
42093
+ animation-timing-function: ease-out;
42094
+ animation-fill-mode: both;
42095
+
42096
+ transform-origin: center;
42097
+ }
42098
+
42099
+ @keyframes DCEReactKit-pop-in {
42100
+ 0% {
42101
+ opacity: 0;
42102
+ transform: scale(0.9);
42103
+ }
42104
+ 100% {
42105
+ opacity: 1;
42106
+ transform: scale(1);
42107
+ }
42108
+ }
42109
+ </style>
42110
+ </head>
42111
+
42112
+ <!-- Body -->
42113
+ <body class="bg-dark text-center pt-3 ps-3 pe-3">
42114
+ <!-- Alert -->
42115
+ <div
42116
+ class="DCEReactKit-pop-in alert alert-info d-inline-block"
42117
+ style="width: 50em; max-width: 100%"
42118
+ >
42119
+ <!-- Title -->
42120
+ <h2>
42121
+ <i class="me-1 fa-solid fa-circle-info"></i>
42122
+ ${title}
42123
+ </h2>
42124
+ <!-- Body -->
42125
+ <div>
42126
+ ${body}
42127
+ </div>
42128
+ </div>
42129
+ </body>
42130
+ `;
42131
+ };
42132
+
42043
42133
  /**
42044
42134
  * Perform a rudimentary parsing of the user's browser agent string
42045
42135
  * @author Gabe Abrams
@@ -42161,10 +42251,12 @@ const parseUserAgent = (userAgent) => {
42161
42251
  * send (a function that sends a string to the client),
42162
42252
  * redirect (takes a url and redirects the user to that url),
42163
42253
  * renderErrorPage (shows a static error page to the user),
42254
+ * renderInfoPage (shows a static info page to the user),
42164
42255
  * and returns the value to send to the client as a JSON API response, or
42165
42256
  * calls next() or redirect(...) or send(...) or renderErrorPage(...).
42166
42257
  * Note: params also has userId, userFirstName,
42167
- * userLastName, isLearner, isTTM, isAdmin, and any other variables that
42258
+ * userLastName, userEmail, userAvatarURL, isLearner, isTTM, isAdmin,
42259
+ * and any other variables that
42168
42260
  * are directly added to the session, if the user does have a session.
42169
42261
  */
42170
42262
  const genRouteHandler = (opts) => {
@@ -42414,7 +42506,7 @@ const genRouteHandler = (opts) => {
42414
42506
  }
42415
42507
  });
42416
42508
  /*----------------------------------------*/
42417
- /* Require Course Consistency */
42509
+ /* ----- Require Course Consistency ----- */
42418
42510
  /*----------------------------------------*/
42419
42511
  // Make sure the user actually launched from the appropriate course
42420
42512
  if (output.courseId
@@ -42464,7 +42556,7 @@ const genRouteHandler = (opts) => {
42464
42556
  });
42465
42557
  }
42466
42558
  /*----------------------------------------*/
42467
- /* Log Handler */
42559
+ /* ------------- Log Handler ------------ */
42468
42560
  /*----------------------------------------*/
42469
42561
  // Create a log handler function
42470
42562
  /**
@@ -42660,6 +42752,17 @@ const genRouteHandler = (opts) => {
42660
42752
  },
42661
42753
  });
42662
42754
  };
42755
+ /**
42756
+ * Render an info page
42757
+ * @author Gabe Abrams
42758
+ * @param renderOpts object containing all arguments
42759
+ * @param renderOpts.title title of the info box
42760
+ * @param renderOpts.body a human-readable text body for the info alert
42761
+ */
42762
+ const renderInfoPage = (renderOpts) => {
42763
+ const html = genInfoPage(renderOpts);
42764
+ send(html, 200);
42765
+ };
42663
42766
  // Call the handler
42664
42767
  try {
42665
42768
  const results = yield opts.handler({
@@ -42672,6 +42775,7 @@ const genRouteHandler = (opts) => {
42672
42775
  },
42673
42776
  redirect,
42674
42777
  renderErrorPage,
42778
+ renderInfoPage,
42675
42779
  logServerEvent,
42676
42780
  });
42677
42781
  // Send results to client (only if next wasn't called)