-
Notifications
You must be signed in to change notification settings - Fork 166
bug 760240: provide interactive-examples settings to macros #306
bug 760240: provide interactive-examples settings to macros #306
Conversation
|
By the way, I'm sorry for the lack of camel-case. Python's practices are so embedded that I sometimes forget when I'm writing JavaScript. Feel free to suggest otherwise, and I'd be happy to change. |
|
r+ from my side. One question though, in a situation(and I am not at all certain how regular this would happen) where you wanted to run Kuma, Kumascript and the interactive editor locally. Is there than a way to override the URL using a |
|
Yes, you can change the configuration by setting environment variables. There's a small section in the docs that mentions it. With this change, I think the method would be:
We'd need to update In the worker section: In the kumascript section: If there's going to be a lot of development around these, then we may want to add an interactive examples container to |
|
Thanks @jwhitlock ! |
|
I'm going to try adding a commit updating |
| let surveyClass = "interactive-editor-survey"; | ||
| let surveyLink = "https://www.surveygizmo.com/s3/3780959/MDN-Interactive-Editor"; | ||
| let url = "https://interactive-examples.mdn.mozilla.net/" + $0; | ||
| let url = kuma.url.resolve(env.interactive_examples.base_url, $0); |
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.
I'm getting an error:
Cannot read property 'base_url' of undefined
at eval (eval at compile (/node_modules/ejs/lib/ejs.js:491:12), <anonymous>:21:52)
at returnedFn (/node_modules/ejs/lib/ejs.js:520:17)
at /app/lib/kumascript/templates.js:71:26
Adding some debug statements to see what is going on...
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.
@jwhitlock Do you get this when you run make test-macros? Hmm, my first guess is that you may need to rebuild your kumascript image cd .. && make build-kumascript?
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.
No, the macros tests explictly set env.interactive_examples, so the error doesn't occur. It only occurs when using the value set by server.js
jwhitlock
left a comment
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.
After the change in server.js, this works locally, and allows the iframe source to be http://127.0.0.1:8080. Kuma needs to whitelist this as a domain for iframes as well, or it gets filtered out during sanitizing.
| let surveyClass = "interactive-editor-survey"; | ||
| let surveyLink = "https://www.surveygizmo.com/s3/3780959/MDN-Interactive-Editor"; | ||
| let url = "https://interactive-examples.mdn.mozilla.net/" + $0; | ||
| let url = kuma.url.resolve(env.interactive_examples.base_url, $0); |
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.
No, the macros tests explictly set env.interactive_examples, so the error doesn't occur. It only occurs when using the value set by server.js
lib/kumascript/server.js
Outdated
| } | ||
|
|
||
| // Add a clone of the interactive-examples settings to "env". | ||
| env.interactive_examples = _.clone( |
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.
This should be:
env.interactive_examples = ks_conf.nconf.get('interactive_examples');
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.
Oh man, good catch, sorry about that! Fix coming soon...
stephaniehobson
left a comment
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.
I'm not sure I understand this well enough to review it.
|
Also, I think bug 760240 is the wrong one. Maybe bug 1308630? |
|
@jwhitlock I amended my original commit to address your requested fix. Good catch, I should have tried it manually. 😞 I think it's good to go now? |
|
@jwhitlock Ugh, you're right, that bugzilla issue is not the right one, sorry! I'm not sure where I got that one from now that I think of it. Yes, I think bug 1308630 will work fine, thanks. I'll amend the commit again to use that one. |
* add interactive-examples settings to conf.js * add interactive-examples settings to env object of each macro's APIContext * add tests for EmbedInteractiveExample.ejs
jwhitlock
left a comment
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.
👍 this works now, thanks @escattone!
This PR:
env.interactive_examplesobjectEmbedInteractiveExample.ejsmacro to use the new setting, as well as provides tests for the macro