New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable applab data APIs in exported projects #22522
Changes from 1 commit
3606a6e
508a5cf
19f3cdf
d35cdc4
a8aa02d
6429867
e5f9fe7
36fcc3b
5a8801d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,14 +230,23 @@ function extractCSSFromHTML(el) { | |
const fontAwesomeWOFFRelativeSourcePath = '/assets/fontawesome-webfont.woff2'; | ||
const fontAwesomeWOFFPath = 'applab/fontawesome-webfont.woff2'; | ||
|
||
function getExportConfigPath(baseHref) { | ||
const curHref = window.location.href; | ||
const curHrefWithoutEdit = curHref.slice(0, curHref.lastIndexOf('/') + 1); | ||
baseHref = baseHref || curHrefWithoutEdit; | ||
return `${baseHref}export_config?script_call=setExportConfig`; | ||
} | ||
|
||
export default { | ||
exportAppToZip(appName, code, levelHtml, expoMode) { | ||
const { css, outerHTML } = transformLevelHtml(levelHtml); | ||
|
||
const exportConfigPath = getExportConfigPath(); | ||
const jQueryBaseName = 'jquery-1.12.1.min'; | ||
var html; | ||
if (expoMode) { | ||
html = exportExpoIndexEjs({ | ||
exportConfigPath, | ||
htmlBody: outerHTML, | ||
applabApiPath: "applab-api.j", | ||
jQueryPath: jQueryBaseName + ".j", | ||
|
@@ -250,6 +259,7 @@ export default { | |
}); | ||
} else { | ||
html = exportProjectEjs({ | ||
exportConfigPath, | ||
htmlBody: outerHTML, | ||
fontPath: fontAwesomeWOFFPath, | ||
}); | ||
|
@@ -456,7 +466,10 @@ export default { | |
const appOptionsJs = getAppOptionsFile(); | ||
const { css, outerHTML } = transformLevelHtml(levelHtml); | ||
const fontAwesomeCSS = exportFontAwesomeCssEjs({fontPath: fontAwesomeWOFFPath}); | ||
const exportBaseHref = `https://studio.code.org/projects/applab/${project.getCurrentId()}/`; | ||
const exportConfigPath = getExportConfigPath(exportBaseHref); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I may be misunderstanding, but this looks like it won't work in non-production environments (here and below), making it hard to debug and test. Do you currently need to change all of these urls to point to localhost during development? Ideally, the "origin" (https://studio.code.org/ or http://localhost-studio.code.org:3000/) would be passed from the server via appOptions. That work could be done later, but I'd like to be on the same page about whether there is more work to do here. Also, is this a typo on line 476 below? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the "Try In Expo" scenario results in apps that are published with links back to our production site. We could change this for testing purposes, but the development server URL is unlikely to work from a mobile device already. And no, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated the hardcoded There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for doing this! It looks like this sets us up better for having end-to-end tests ensuring that (a) previously exported projects do not break, and (b) newly exported projects do not break, which are the two tests I'd want to eventually have for this feature. Also the applab-api logic looks like it will do the right thing in test and circle environments. As for local development, I must be missing some context -- are we exporting to a format that can only be run from a phone? or is it just the nature of this feature that viewing from a phone is the main use case? If testing on phone is needed, it seems like the developer's options include either running ios simulator locally (easy on mac, hard on linux) or temporarily setting |
||
const html = exportExpoIndexEjs({ | ||
exportConfigPath, | ||
htmlBody: outerHTML, | ||
commonLocalePath: "https://studio.code.org/blockly/js/en_us/common_locale.js", | ||
applabLocalePath: "https://studio.code.org/blockly/js/en_us/applab_locale.js", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make sure this works when exporting from a script level like https://studio.code.org/s/csp3/stage/9/puzzle/11 . It's possible that
window.dashboard.project.getShareUrl()
will give you what you want.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, much better using
getShareUrl()
!