@livepreso/api 6.55.2 → 6.56.1
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.
- package/.rush/temp/1aebf46f78ad5c45f82f8147751890adb37bef9d.log +10 -0
- package/.rush/temp/256021b5963b4c0221d3dec247b697b9691a9b2c.log +10 -0
- package/.rush/temp/2a322f00f12cf9d1e64afe81275cc78d01c49050.log +10 -0
- package/.rush/temp/30061f1865447dcbb3f20a305061205f3dbe6091.log +10 -0
- package/.rush/temp/3cdc82c352e8ed90607952873f3aa4c200490874.log +10 -0
- package/.rush/temp/45522aea0dee8cb2be1a53248ba45bd235743b43.log +10 -0
- package/.rush/temp/5489ab737e406518983c16c57fc3e1edc07c0341.log +10 -0
- package/.rush/temp/58fcbb7f15a76326d40e0839ab179755da82a891.log +10 -0
- package/.rush/temp/5bc0bba70b733baa4dd976667ba0a1386e516186.log +10 -0
- package/.rush/temp/64f1bb696f8d7d7e72907b80df316b127f72e23e.log +10 -0
- package/.rush/temp/6f640f951414ea68adb65c17e4ed7527cde54faf.log +10 -0
- package/.rush/temp/7c7b958682d4ab5697530be47d0aac62efe1adf1.log +10 -0
- package/.rush/temp/82bfb987463fbcfebf04022e6ed00015c73879c8.log +10 -0
- package/.rush/temp/844034aa6e542115075e8f3dc5ffc640973e0064.log +10 -0
- package/.rush/temp/8b42957a7c15da1f29cb57bee125f13affa70dca.log +10 -0
- package/.rush/temp/924652444ab5a6063f328a2217123a2227058896.log +10 -0
- package/.rush/temp/9f2030f96d62f3e38052e35201819a216566f14f.log +10 -0
- package/.rush/temp/a769db9d81a23000c0e9b1bf4f1a9a9e721d0d7c.log +10 -0
- package/.rush/temp/a87d3a8b4ece87ec66f27c86226a9f205617681f.log +10 -0
- package/.rush/temp/bb7a5bdcc4af4ad1507f81f33774b31f5b4e4fb7.log +10 -0
- package/.rush/temp/build-cache-tar.log +7 -0
- package/.rush/temp/c20e29ccaaa9231b38a28bb24451b4ce7562cdc0.log +10 -0
- package/.rush/temp/chunked-rush-logs/api.build.chunks.jsonl +15 -5
- package/.rush/temp/chunked-rush-logs/api.test.chunks.jsonl +1 -0
- package/.rush/temp/e21303db8f59b4625fd184c9114377d781fd24f8.log +10 -0
- package/.rush/temp/e6d303862765b6a5f41dd483d0f9ae083a1fae10.log +10 -0
- package/.rush/temp/eaf69fbc059d2f1258d7569136180d4a1d3c7072.log +10 -0
- package/.rush/temp/f85d279e2674966daaec83e1c3986a96f86ef304.log +10 -0
- package/.rush/temp/fc0a332c5b34c6b90006850cf2d93a48fb4b9a6e.log +10 -0
- package/.rush/temp/operation/build/all.log +15 -5
- package/.rush/temp/operation/build/error.log +13 -3
- package/.rush/temp/operation/build/log-chunks.jsonl +15 -5
- package/.rush/temp/operation/build/state.json +1 -1
- package/.rush/temp/operation/test/all.log +21 -0
- package/.rush/temp/operation/test/log-chunks.jsonl +21 -0
- package/.rush/temp/operation/test/state.json +3 -0
- package/.rush/temp/package-deps_build.json +185 -0
- package/.rush/temp/shrinkwrap-deps.json +1013 -1191
- package/CHANGELOG.json +29 -0
- package/CHANGELOG.md +19 -1
- package/api.build.log +9 -0
- package/api.test.cache.log +1 -0
- package/api.test.log +19 -0
- package/cjs/api.js +3 -5
- package/cjs/api.js.map +1 -1
- package/cjs/auth.spec.js +11 -11
- package/cjs/auth.spec.js.map +1 -1
- package/cjs/collections/appointment-tags.js +14 -15
- package/cjs/collections/appointment-tags.js.map +1 -1
- package/cjs/collections/base.spec.js +30 -30
- package/cjs/collections/base.spec.js.map +1 -1
- package/cjs/fixtures.js +1 -2
- package/cjs/fixtures.js.map +1 -1
- package/cjs/models/appointment.js +7 -7
- package/cjs/models/appointment.js.map +1 -1
- package/cjs/models/base.js +30 -12
- package/cjs/models/base.js.map +1 -1
- package/cjs/models/cms-val.spec.js +2 -2
- package/cjs/models/cms-val.spec.js.map +1 -1
- package/cjs/models/deck-version.js +14 -34
- package/cjs/models/deck-version.js.map +1 -1
- package/cjs/models/manifest-json.js +41 -5
- package/cjs/models/manifest-json.js.map +1 -1
- package/cjs/models/pack.js +2 -1
- package/cjs/models/pack.js.map +1 -1
- package/cjs/models/snapshot.spec.js +2 -2
- package/cjs/models/snapshot.spec.js.map +1 -1
- package/cjs/models/template.js +10 -10
- package/cjs/models/template.js.map +1 -1
- package/cjs/models/timing-log.js +17 -17
- package/cjs/models/timing-log.js.map +1 -1
- package/cjs/models/timing-log.spec.js +2 -2
- package/cjs/models/timing-log.spec.js.map +1 -1
- package/cjs/models/user.spec.js +4 -4
- package/cjs/models/user.spec.js.map +1 -1
- package/cjs/presentation/presentation-deck.js +19 -9
- package/cjs/presentation/presentation-deck.js.map +1 -1
- package/cjs/presentation/presentation-deck.spec.js +6 -6
- package/cjs/presentation/presentation-deck.spec.js.map +1 -1
- package/cjs/presentation/presentation-section.js +30 -9
- package/cjs/presentation/presentation-section.js.map +1 -1
- package/cjs/presentation/presentation-section.spec.js +24 -16
- package/cjs/presentation/presentation-section.spec.js.map +1 -1
- package/cjs/presentation/presentation-slide.js +18 -7
- package/cjs/presentation/presentation-slide.js.map +1 -1
- package/cjs/presentation/presentation-slide.spec.js +21 -12
- package/cjs/presentation/presentation-slide.spec.js.map +1 -1
- package/cjs/presentation/presentation-subslide.spec.js +10 -10
- package/cjs/presentation/presentation-subslide.spec.js.map +1 -1
- package/cjs/presentation/presentation.js +26 -26
- package/cjs/presentation/presentation.js.map +1 -1
- package/cjs/sync.js +15 -5
- package/cjs/sync.js.map +1 -1
- package/cjs/utils.js +33 -3
- package/cjs/utils.js.map +1 -1
- package/package.json +3 -3
- package/rush-logs/api.build.error.log +13 -3
- package/rush-logs/api.build.log +15 -5
- package/rush-logs/api.test.cache.log +1 -0
- package/rush-logs/api.test.log +1 -0
- package/src/api.js +3 -5
- package/src/models/base.js +27 -9
- package/src/models/deck-version.js +5 -31
- package/src/models/manifest-json.js +33 -5
- package/src/models/pack.js +1 -0
- package/src/models/timing-log.js +24 -28
- package/src/presentation/presentation-deck.js +9 -9
- package/src/presentation/presentation-section.js +31 -11
- package/src/presentation/presentation-section.spec.js +8 -0
- package/src/presentation/presentation-slide.js +7 -4
- package/src/presentation/presentation-slide.spec.js +9 -0
- package/src/sync.js +15 -5
- package/src/utils.js +31 -2
|
@@ -5,15 +5,12 @@ import "./deck.js";
|
|
|
5
5
|
import "./asset.js";
|
|
6
6
|
import "./manifest-json.js";
|
|
7
7
|
|
|
8
|
-
import { Auth } from "../auth.js";
|
|
9
8
|
import { BaseModel } from "./base.js";
|
|
10
9
|
import { DeckLayoutModel } from "./deck-layout.js";
|
|
11
10
|
import { DeckVersionScreenshotCollection } from "../collections/deck-version-screenshots.js";
|
|
12
11
|
import Promise from "bluebird";
|
|
13
12
|
import { TemplateCollection } from "../collections.js";
|
|
14
|
-
import _ from "lodash";
|
|
15
13
|
import { register } from "../state-register.js";
|
|
16
|
-
import superagent from "superagent";
|
|
17
14
|
|
|
18
15
|
/**
|
|
19
16
|
* @constructor
|
|
@@ -178,29 +175,6 @@ export const DeckVersionModel = BaseModel.extend(
|
|
|
178
175
|
});
|
|
179
176
|
},
|
|
180
177
|
|
|
181
|
-
getFixtures(fixtures = {}, rootAssetUrl = this.getRootAssetUrl()) {
|
|
182
|
-
const fixturePaths = this.manifest_json.fixtures || {};
|
|
183
|
-
|
|
184
|
-
const imports = _.map(fixturePaths, (fixture, key) => {
|
|
185
|
-
const path = `${rootAssetUrl}${fixture}`;
|
|
186
|
-
|
|
187
|
-
return superagent
|
|
188
|
-
.get(path)
|
|
189
|
-
.then((response) => {
|
|
190
|
-
if (response.text) {
|
|
191
|
-
fixtures[key] = JSON.parse(response.text);
|
|
192
|
-
} else {
|
|
193
|
-
fixtures[key] = response.body || {};
|
|
194
|
-
}
|
|
195
|
-
})
|
|
196
|
-
.catch(superagent.SuperagentPromiseError, (e) => {
|
|
197
|
-
throw e;
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
return Promise.all(imports);
|
|
202
|
-
},
|
|
203
|
-
|
|
204
178
|
fetch(opts, ...other) {
|
|
205
179
|
const fetch = BaseModel.prototype.fetch.apply(this, [opts, ...other]);
|
|
206
180
|
const shouldFetchTemplates = opts?.fetchTemplates ?? true;
|
|
@@ -226,17 +200,17 @@ export const DeckVersionModel = BaseModel.extend(
|
|
|
226
200
|
);
|
|
227
201
|
},
|
|
228
202
|
|
|
229
|
-
fetchLayout: async function (
|
|
203
|
+
fetchLayout: async function ({ presetID, scenarioID }) {
|
|
230
204
|
let queryParams = { version: this.version };
|
|
231
|
-
if (
|
|
232
|
-
queryParams.preset_id =
|
|
205
|
+
if (presetID) {
|
|
206
|
+
queryParams.preset_id = presetID;
|
|
233
207
|
}
|
|
234
208
|
if (scenarioID) {
|
|
235
209
|
queryParams.scenario_id = scenarioID;
|
|
236
210
|
}
|
|
237
211
|
|
|
238
|
-
if (!this.id) {
|
|
239
|
-
return Promise.reject(new Error("DeckVersion has no
|
|
212
|
+
if (!this.deck.id) {
|
|
213
|
+
return Promise.reject(new Error("DeckVersion has no deck."));
|
|
240
214
|
}
|
|
241
215
|
|
|
242
216
|
const layout = new DeckLayoutModel(
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import _ from "lodash";
|
|
1
2
|
import "./pack.js";
|
|
2
3
|
|
|
4
|
+
import superagent from "superagent";
|
|
3
5
|
import { BaseModel } from "./base.js";
|
|
4
6
|
import { register } from "../state-register.js";
|
|
5
|
-
import
|
|
7
|
+
import { resolveURL } from "../utils.js";
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* @constructor
|
|
@@ -135,7 +137,7 @@ export const ManifestJSONModel = BaseModel.extend(
|
|
|
135
137
|
getDimensionsByName(name) {
|
|
136
138
|
if (Array.isArray(this.dimensions)) {
|
|
137
139
|
const dimension = this.dimensions.find(
|
|
138
|
-
(d) => d.name?.toLowerCase() === name
|
|
140
|
+
(d) => d.name?.toLowerCase() === name.toLowerCase(),
|
|
139
141
|
);
|
|
140
142
|
if (!dimension) {
|
|
141
143
|
return { width: 1024, height: 767 };
|
|
@@ -166,12 +168,12 @@ export const ManifestJSONModel = BaseModel.extend(
|
|
|
166
168
|
getAssetPath(key = null) {
|
|
167
169
|
if (key) {
|
|
168
170
|
const [sectionKey, slideKey = null] = key.split("/");
|
|
169
|
-
const sectionKeyPath =
|
|
171
|
+
const sectionKeyPath = resolveURL(
|
|
170
172
|
this.url(),
|
|
171
173
|
`sections/${sectionKey}/`,
|
|
172
174
|
);
|
|
173
175
|
if (slideKey) {
|
|
174
|
-
return
|
|
176
|
+
return resolveURL(sectionKeyPath, `slides/${slideKey}/`);
|
|
175
177
|
}
|
|
176
178
|
return sectionKeyPath;
|
|
177
179
|
}
|
|
@@ -185,7 +187,33 @@ export const ManifestJSONModel = BaseModel.extend(
|
|
|
185
187
|
* @returns {?string}
|
|
186
188
|
*/
|
|
187
189
|
getTemplateAssetPath(key) {
|
|
188
|
-
return
|
|
190
|
+
return resolveURL(this.getAssetPath(), `templates/${key}/`);
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
async getFixtures(rootAssetUrl) {
|
|
194
|
+
const fixturePaths = this.fixtures || {};
|
|
195
|
+
const fixtures = {};
|
|
196
|
+
|
|
197
|
+
const imports = _.map(fixturePaths, (fixture, key) => {
|
|
198
|
+
const path = `${rootAssetUrl}${fixture}`;
|
|
199
|
+
|
|
200
|
+
return superagent
|
|
201
|
+
.get(path)
|
|
202
|
+
.then((response) => {
|
|
203
|
+
if (response.text) {
|
|
204
|
+
fixtures[key] = JSON.parse(response.text);
|
|
205
|
+
} else {
|
|
206
|
+
fixtures[key] = response.body || {};
|
|
207
|
+
}
|
|
208
|
+
})
|
|
209
|
+
.catch(superagent.SuperagentPromiseError, (e) => {
|
|
210
|
+
throw e;
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
await Promise.all(imports);
|
|
215
|
+
|
|
216
|
+
return fixtures;
|
|
189
217
|
},
|
|
190
218
|
|
|
191
219
|
url() {
|
package/src/models/pack.js
CHANGED
package/src/models/timing-log.js
CHANGED
|
@@ -5,15 +5,12 @@ import "../collections/users.js";
|
|
|
5
5
|
|
|
6
6
|
import { DATE_FORMAT, DATE_FORMAT_T } from "../utils.js";
|
|
7
7
|
|
|
8
|
-
import { Auth } from "../auth.js";
|
|
9
8
|
import { BaseModel } from "./base.js";
|
|
10
|
-
import _ from "lodash";
|
|
11
9
|
import dedent from "dedent-js";
|
|
12
10
|
import { getShortURL } from "../utils.js";
|
|
13
11
|
import log from "../log.js";
|
|
14
12
|
import moment from "moment";
|
|
15
13
|
import { register } from "../state-register.js";
|
|
16
|
-
import superagent from "superagent";
|
|
17
14
|
|
|
18
15
|
/**
|
|
19
16
|
* @typedef Event
|
|
@@ -104,6 +101,18 @@ export const TimingLogModel = BaseModel.extend(
|
|
|
104
101
|
remote_attendee_set: "UserCollection",
|
|
105
102
|
},
|
|
106
103
|
|
|
104
|
+
ajaxConfig() {
|
|
105
|
+
return {
|
|
106
|
+
headers: {
|
|
107
|
+
"content-type": "application/vnd.salespreso+timinglog",
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
toServer() {
|
|
113
|
+
return this.toCompactFormat();
|
|
114
|
+
},
|
|
115
|
+
|
|
107
116
|
/**
|
|
108
117
|
* Returns the current timing log model in expected compact format.
|
|
109
118
|
* @see http://doc.dev.salespreso.com/api/tracking.html#compact-representation
|
|
@@ -198,7 +207,9 @@ export const TimingLogModel = BaseModel.extend(
|
|
|
198
207
|
* timingLog.addEvent("http://client.salespreso.com/api/sections/28/", moment());
|
|
199
208
|
* timingLog.addEvent("http://client.salespreso.com/api/slides/100/", "2016-10-27T00:42:47.045186Z");
|
|
200
209
|
*/
|
|
201
|
-
addEvent(
|
|
210
|
+
addEvent(_path, timestamp) {
|
|
211
|
+
let path = _path;
|
|
212
|
+
|
|
202
213
|
if (!path) {
|
|
203
214
|
throw new Error("A path is required");
|
|
204
215
|
}
|
|
@@ -280,33 +291,18 @@ export const TimingLogModel = BaseModel.extend(
|
|
|
280
291
|
return Promise.resolve(this.toJSON());
|
|
281
292
|
}
|
|
282
293
|
|
|
283
|
-
if (options && options.patch) {
|
|
284
|
-
return BaseModel.prototype.save.call(this, data, options);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
294
|
this.checkEventsAscending();
|
|
288
295
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
return superagent[method](this.url())
|
|
292
|
-
.set(Auth.headers)
|
|
293
|
-
.type("application/vnd.salespreso+timinglog")
|
|
294
|
-
.send(this.toCompactFormat())
|
|
295
|
-
.then(({ body }) => {
|
|
296
|
-
this.set(_.omit(body, ["events"]));
|
|
297
|
-
return body;
|
|
298
|
-
})
|
|
299
|
-
.catch(superagent.SuperagentPromiseError, (e) => {
|
|
300
|
-
if (e.status === 405 && e.res.body.detail.indexOf("end") > -1) {
|
|
301
|
-
// Don't send timing log events if the tracking is ended.
|
|
302
|
-
throw e;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
if ((e.status >= 400 && e.status <= 499) || e.status === 503) {
|
|
306
|
-
e.message += `\nBody: ${JSON.stringify(e.res.body)}`;
|
|
307
|
-
}
|
|
296
|
+
return BaseModel.prototype.save.call(this, data, options).catch((e) => {
|
|
297
|
+
if (e.status === 405 && e.response?.body?.detail?.indexOf("end") > -1) {
|
|
308
298
|
throw e;
|
|
309
|
-
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if ((e.status >= 400 && e.status <= 499) || e.status === 503) {
|
|
302
|
+
e.message += `\nBody: ${JSON.stringify(e.response?.body)}`;
|
|
303
|
+
}
|
|
304
|
+
throw e;
|
|
305
|
+
});
|
|
310
306
|
},
|
|
311
307
|
},
|
|
312
308
|
);
|
|
@@ -17,7 +17,7 @@ import _ from "lodash";
|
|
|
17
17
|
import { getAssetRoot } from "../index.js";
|
|
18
18
|
import log from "../log.js";
|
|
19
19
|
import { register } from "../state-register";
|
|
20
|
-
import
|
|
20
|
+
import { resolveURL } from "../utils.js";
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* @constructor
|
|
@@ -67,6 +67,9 @@ export const PresentationDeck = BasePresentationModel.extend(
|
|
|
67
67
|
version: "number",
|
|
68
68
|
namespacedKey: "string",
|
|
69
69
|
cmsvalkey_set: "array",
|
|
70
|
+
isWelcome: { type: "boolean", default: true },
|
|
71
|
+
isSlide: { type: "boolean", default: false },
|
|
72
|
+
isSection: { type: "boolean", default: false },
|
|
70
73
|
},
|
|
71
74
|
|
|
72
75
|
/**
|
|
@@ -406,8 +409,8 @@ PresentationDeck.createFromManifestJSON = function (manifestJSON, project) {
|
|
|
406
409
|
index: 0,
|
|
407
410
|
visible: true,
|
|
408
411
|
key: manifestJSON.key || "manifest_deck",
|
|
409
|
-
html:
|
|
410
|
-
css:
|
|
412
|
+
html: resolveURL(manifestJSON.getAssetPath(), "index.html"),
|
|
413
|
+
css: resolveURL(manifestJSON.getAssetPath(), "slide.css"),
|
|
411
414
|
common: manifestJSON.common,
|
|
412
415
|
thumbnail: null,
|
|
413
416
|
deckID: 1,
|
|
@@ -434,8 +437,8 @@ PresentationDeck.createFromManifestJSON = function (manifestJSON, project) {
|
|
|
434
437
|
return {
|
|
435
438
|
key: newKey,
|
|
436
439
|
sequence,
|
|
437
|
-
html:
|
|
438
|
-
css:
|
|
440
|
+
html: resolveURL(manifestJSON.getAssetPath(key), "index.html"),
|
|
441
|
+
css: resolveURL(manifestJSON.getAssetPath(key), "slide.css"),
|
|
439
442
|
title: manifestJSON.titles[key],
|
|
440
443
|
tags: manifestJSON.tags[key] || [],
|
|
441
444
|
cmsvalkey_set: [],
|
|
@@ -500,10 +503,7 @@ PresentationDeck.createFromManifestJSON = function (manifestJSON, project) {
|
|
|
500
503
|
key,
|
|
501
504
|
sequence: manifestJSON.templates[key].ordering,
|
|
502
505
|
index_asset: {
|
|
503
|
-
url:
|
|
504
|
-
manifestJSON.getTemplateAssetPath(key),
|
|
505
|
-
"index.html",
|
|
506
|
-
),
|
|
506
|
+
url: resolveURL(manifestJSON.getTemplateAssetPath(key), "index.html"),
|
|
507
507
|
},
|
|
508
508
|
cmsvalkey_set: cmsvals,
|
|
509
509
|
};
|
|
@@ -17,7 +17,7 @@ import { PresentationSlide } from "./presentation-slide.js";
|
|
|
17
17
|
import _ from "lodash";
|
|
18
18
|
import { getAssetRoot } from "../index.js";
|
|
19
19
|
import { register } from "../state-register.js";
|
|
20
|
-
import
|
|
20
|
+
import { resolveURL } from "../utils.js";
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* @constructor
|
|
@@ -102,11 +102,10 @@ export const PresentationSection = BasePresentationModel.extend(
|
|
|
102
102
|
tagsEditable: "boolean",
|
|
103
103
|
tags: "array",
|
|
104
104
|
impostor: "boolean",
|
|
105
|
-
isWelcome: {
|
|
106
|
-
type: "boolean",
|
|
107
|
-
default: false,
|
|
108
|
-
},
|
|
109
105
|
cmsvalkey_set: "array",
|
|
106
|
+
isWelcome: { type: "boolean", default: false },
|
|
107
|
+
isSlide: { type: "boolean", default: false },
|
|
108
|
+
isSection: { type: "boolean", default: true },
|
|
110
109
|
},
|
|
111
110
|
|
|
112
111
|
/**
|
|
@@ -445,8 +444,8 @@ PresentationSection.createFromManifestJSON = function (
|
|
|
445
444
|
id: parseInt(_.uniqueId(), 10),
|
|
446
445
|
index,
|
|
447
446
|
title: manifestJSON.titles[sectionKey],
|
|
448
|
-
html:
|
|
449
|
-
css:
|
|
447
|
+
html: resolveURL(manifestJSON.getAssetPath(sectionKey), "index.html"),
|
|
448
|
+
css: resolveURL(manifestJSON.getAssetPath(sectionKey), "slide.css"),
|
|
450
449
|
key: sectionKey,
|
|
451
450
|
sequence: manifestJSON.ordering[sectionKey] - 1,
|
|
452
451
|
thumbnail: null,
|
|
@@ -605,11 +604,32 @@ PresentationSection.createFromAutoAdjunct = function (model, opts = {}) {
|
|
|
605
604
|
return autoAdjunctSection;
|
|
606
605
|
};
|
|
607
606
|
|
|
608
|
-
PresentationSection.createFromTemplate = function (
|
|
607
|
+
PresentationSection.createFromTemplate = function (
|
|
608
|
+
template,
|
|
609
|
+
index,
|
|
610
|
+
minID = 0,
|
|
611
|
+
options = {},
|
|
612
|
+
) {
|
|
609
613
|
const templateModel = new TemplateModel(template);
|
|
610
614
|
|
|
615
|
+
_.defaults(options, {
|
|
616
|
+
rootAssetPath: null,
|
|
617
|
+
});
|
|
618
|
+
|
|
611
619
|
const deckversion = new DeckVersionModel(templateModel.deckversion);
|
|
612
|
-
|
|
620
|
+
|
|
621
|
+
let html;
|
|
622
|
+
let css;
|
|
623
|
+
|
|
624
|
+
if (options.rootAssetPath) {
|
|
625
|
+
const origPath = templateModel.index_asset.orig_path;
|
|
626
|
+
html = `${options.rootAssetPath}${origPath}/index.html`;
|
|
627
|
+
css = `${options.rootAssetPath}${origPath}/slide.css`;
|
|
628
|
+
} else {
|
|
629
|
+
const templateAssetRoot = getAssetRoot(templateModel.index_asset.url());
|
|
630
|
+
html = `${templateAssetRoot}index.html`;
|
|
631
|
+
css = `${templateAssetRoot}slide.css`;
|
|
632
|
+
}
|
|
613
633
|
|
|
614
634
|
const presentationSection = new PresentationSection({
|
|
615
635
|
id: minID + parseInt(_.uniqueId(), 10),
|
|
@@ -617,8 +637,8 @@ PresentationSection.createFromTemplate = function (template, index, minID = 0) {
|
|
|
617
637
|
template: templateModel,
|
|
618
638
|
key: `template-${templateModel.key}`,
|
|
619
639
|
title: templateModel.title,
|
|
620
|
-
html
|
|
621
|
-
css
|
|
640
|
+
html,
|
|
641
|
+
css,
|
|
622
642
|
custom: false,
|
|
623
643
|
visible: true,
|
|
624
644
|
thumbnail: templateModel.image_256,
|
|
@@ -63,6 +63,8 @@ describe("#createFromSection", () => {
|
|
|
63
63
|
id: 1728,
|
|
64
64
|
impostor: false,
|
|
65
65
|
index: 0,
|
|
66
|
+
isSection: true,
|
|
67
|
+
isSlide: false,
|
|
66
68
|
isWelcome: false,
|
|
67
69
|
key: "agenda",
|
|
68
70
|
namespacedKey: "agenda",
|
|
@@ -192,6 +194,8 @@ describe("#createFromAdjunctSection", () => {
|
|
|
192
194
|
"https://staging-test-cdn.salespreso.com/media/autoadjunct/123.png",
|
|
193
195
|
impostor: false,
|
|
194
196
|
index: 1,
|
|
197
|
+
isSection: true,
|
|
198
|
+
isSlide: false,
|
|
195
199
|
isWelcome: false,
|
|
196
200
|
key: "adjunct-1737",
|
|
197
201
|
sequence: 1,
|
|
@@ -325,6 +329,8 @@ describe("#createFromImpostorSection", () => {
|
|
|
325
329
|
id: 23898,
|
|
326
330
|
impostor: true,
|
|
327
331
|
index: 0,
|
|
332
|
+
isSection: true,
|
|
333
|
+
isSlide: false,
|
|
328
334
|
isWelcome: false,
|
|
329
335
|
key: "agenda",
|
|
330
336
|
namespacedKey: "test-deck/agenda",
|
|
@@ -437,6 +443,8 @@ describe("#createFromAutoAdjunct", () => {
|
|
|
437
443
|
"https://staging-test-cdn.salespreso.com/media/autoadjunct/123.png",
|
|
438
444
|
impostor: false,
|
|
439
445
|
index: 3,
|
|
446
|
+
isSection: true,
|
|
447
|
+
isSlide: false,
|
|
440
448
|
isWelcome: false,
|
|
441
449
|
key: "autoadjunct-five",
|
|
442
450
|
sequence: 3,
|
|
@@ -9,7 +9,7 @@ import { PresentationSubSlide } from "./presentation-subslide.js";
|
|
|
9
9
|
import _ from "lodash";
|
|
10
10
|
import { getAssetRoot } from "../index.js";
|
|
11
11
|
import { register } from "../state-register.js";
|
|
12
|
-
import
|
|
12
|
+
import { resolveURL } from "../utils.js";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* @constructor
|
|
@@ -88,6 +88,9 @@ export const PresentationSlide = BasePresentationModel.extend(
|
|
|
88
88
|
tagsEditable: "boolean",
|
|
89
89
|
tags: "array",
|
|
90
90
|
cmsvalkey_set: "array",
|
|
91
|
+
isWelcome: { type: "boolean", default: false },
|
|
92
|
+
isSlide: { type: "boolean", default: true },
|
|
93
|
+
isSection: { type: "boolean", default: false },
|
|
91
94
|
},
|
|
92
95
|
|
|
93
96
|
/**
|
|
@@ -365,8 +368,8 @@ PresentationSlide.createFromManifestJSON = function (
|
|
|
365
368
|
id: parseInt(_.uniqueId(), 10),
|
|
366
369
|
title: manifestJSON.titles[key],
|
|
367
370
|
index,
|
|
368
|
-
html:
|
|
369
|
-
css:
|
|
371
|
+
html: resolveURL(manifestJSON.getAssetPath(key), "index.html"),
|
|
372
|
+
css: resolveURL(manifestJSON.getAssetPath(key), "slide.css"),
|
|
370
373
|
key: slideKey,
|
|
371
374
|
editable: false,
|
|
372
375
|
titleEditable: false,
|
|
@@ -429,9 +432,9 @@ PresentationSlide.createFromTemplate = function (
|
|
|
429
432
|
titleEditable: false,
|
|
430
433
|
notesEditable: false,
|
|
431
434
|
tagsEditable: false,
|
|
432
|
-
thumbnail: null,
|
|
433
435
|
custom: false,
|
|
434
436
|
visible: true,
|
|
437
|
+
thumbnail: template.image_256,
|
|
435
438
|
section: sectionID,
|
|
436
439
|
// Makes sure templates are rendered with unique IDs
|
|
437
440
|
autoAdjunctID: Number(_.uniqueId()),
|
|
@@ -52,6 +52,9 @@ describe("#createFromSlide", () => {
|
|
|
52
52
|
html: "https://staging-test-cdn.salespreso.com/media/pack/410/assets/sections/test-deck/slides/slide-key/index.html",
|
|
53
53
|
id: 23219,
|
|
54
54
|
index: 13,
|
|
55
|
+
isSection: false,
|
|
56
|
+
isSlide: true,
|
|
57
|
+
isWelcome: false,
|
|
55
58
|
key: "slide-key",
|
|
56
59
|
namespacedKey: "test-deck/slide-key",
|
|
57
60
|
section: 1738,
|
|
@@ -166,6 +169,9 @@ describe("#createFromAdjunctSlide", () => {
|
|
|
166
169
|
image:
|
|
167
170
|
"https://staging-test-cdn.salespreso.com/media/autoadjunct/123.png",
|
|
168
171
|
index: 3,
|
|
172
|
+
isSection: false,
|
|
173
|
+
isSlide: true,
|
|
174
|
+
isWelcome: false,
|
|
169
175
|
key: "adjunct-10529",
|
|
170
176
|
section: null,
|
|
171
177
|
sequence: 3,
|
|
@@ -284,6 +290,9 @@ describe("#createFromAutoAdjunct", () => {
|
|
|
284
290
|
image:
|
|
285
291
|
"https://staging-test-cdn.salespreso.com/media/autoadjunct/123.png",
|
|
286
292
|
index: 3,
|
|
293
|
+
isSection: false,
|
|
294
|
+
isSlide: true,
|
|
295
|
+
isWelcome: false,
|
|
287
296
|
key: "autoadjunct-three",
|
|
288
297
|
sectionKey: "",
|
|
289
298
|
sequence: 3,
|
package/src/sync.js
CHANGED
|
@@ -4,7 +4,6 @@ import _ from "lodash";
|
|
|
4
4
|
import log from "./log.js";
|
|
5
5
|
import { middlewares } from "./middleware.js";
|
|
6
6
|
import superagent from "superagent";
|
|
7
|
-
import url2 from "url";
|
|
8
7
|
|
|
9
8
|
const defaults = _.defaults;
|
|
10
9
|
const assign = _.assign;
|
|
@@ -30,11 +29,10 @@ export const defaultFetchURL = function ({ model }) {
|
|
|
30
29
|
|
|
31
30
|
export const buildURL = function ({ method, model }) {
|
|
32
31
|
const url = model.url();
|
|
33
|
-
const urlParse = url2.parse(url);
|
|
34
32
|
|
|
35
33
|
// If not a GET request, strip the query params from the url
|
|
36
34
|
if (method !== "read") {
|
|
37
|
-
return url.
|
|
35
|
+
return url.split("?")[0];
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
return url;
|
|
@@ -144,13 +142,25 @@ export const ajaxSync = function (method, model, options) {
|
|
|
144
142
|
// Combine generated headers with user's headers.
|
|
145
143
|
if (ajaxConfig.headers) {
|
|
146
144
|
for (const key in ajaxConfig.headers) {
|
|
147
|
-
|
|
145
|
+
const lowerKey = key.toLowerCase();
|
|
146
|
+
// Use superagent's .type() method to explicitly set content-type
|
|
147
|
+
// This ensures superagent respects the content-type and doesn't override it
|
|
148
|
+
if (lowerKey === "content-type") {
|
|
149
|
+
request.type(ajaxConfig.headers[key].split(";")[0]);
|
|
150
|
+
} else {
|
|
151
|
+
request.header[lowerKey] = ajaxConfig.headers[key];
|
|
152
|
+
}
|
|
148
153
|
}
|
|
149
154
|
}
|
|
150
155
|
|
|
151
156
|
if (options.headers) {
|
|
152
157
|
for (const key in options.headers) {
|
|
153
|
-
|
|
158
|
+
const lowerKey = key.toLowerCase();
|
|
159
|
+
if (lowerKey === "content-type") {
|
|
160
|
+
request.type(options.headers[key].split(";")[0]);
|
|
161
|
+
} else {
|
|
162
|
+
request.header[lowerKey] = options.headers[key];
|
|
163
|
+
}
|
|
154
164
|
}
|
|
155
165
|
}
|
|
156
166
|
|
package/src/utils.js
CHANGED
|
@@ -1,12 +1,41 @@
|
|
|
1
1
|
import _ from "lodash";
|
|
2
2
|
/* eslint-disable no-control-regex */
|
|
3
|
-
import url2 from "url";
|
|
4
3
|
|
|
5
4
|
export const DATE_FORMAT = "YYYY-MM-DD HH:mm:ss.SSSSSS[Z]";
|
|
6
5
|
export const DATE_FORMAT_T = "YYYY-MM-DDTHH:mm:ss.SSSSSS[Z]";
|
|
7
6
|
|
|
8
7
|
export function getShortURL(url) {
|
|
9
|
-
|
|
8
|
+
if (!url) return url;
|
|
9
|
+
if (typeof url !== "string") return url;
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
return new URL(url, "http://a.b").pathname;
|
|
13
|
+
} catch (e) {
|
|
14
|
+
return url;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Resolves a target URL relative to a base URL in a manner similar to a Web browser resolving an anchor tag.
|
|
20
|
+
* Matches url.resolve() behavior but handles relative bases.
|
|
21
|
+
*/
|
|
22
|
+
export function resolveURL(base, relative) {
|
|
23
|
+
if (!base) return relative;
|
|
24
|
+
if (!relative) return base;
|
|
25
|
+
|
|
26
|
+
const dummyBase = "http://a.b";
|
|
27
|
+
try {
|
|
28
|
+
// Try resolving normally (if base is absolute)
|
|
29
|
+
return new URL(relative, base).href;
|
|
30
|
+
} catch (e) {
|
|
31
|
+
try {
|
|
32
|
+
// If base is relative, resolve it against a dummy base, then strip it
|
|
33
|
+
const resolved = new URL(relative, new URL(base, dummyBase));
|
|
34
|
+
return resolved.href.replace(dummyBase, "");
|
|
35
|
+
} catch (e2) {
|
|
36
|
+
return relative;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
10
39
|
}
|
|
11
40
|
|
|
12
41
|
/**
|