Skip to content
This repository was archived by the owner on Jun 21, 2022. It is now read-only.

Conversation

@escattone
Copy link
Contributor

This PR:

@escattone
Copy link
Contributor Author

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.

@schalkneethling
Copy link

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 local.conf or something of the sort?

@jwhitlock
Copy link
Contributor

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:

  1. Copy .env-dist.dev to .env, if you haven't already
  2. Add a line:
INTERACTIVE_EXAMPLES_BASE=http://localhost:8003
  1. Restart the services with make up

We'd need to update docker-compose.yml to set the container environment based on that variables.

In the worker section:

  - INTERACTIVE_EXAMPLES_BASE=${INTERACTIVE_EXAMPLES_BASE:-https://interactive-examples.mdn.mozilla.net}

In the kumascript section:

interactive_examples__base_url=${INTERACTIVE_EXAMPLES_BASE:-https://interactive-examples.mdn.mozilla.net}

If there's going to be a lot of development around these, then we may want to add an interactive examples container to docker-compose.yml, or provide an alternate configuration.

@escattone
Copy link
Contributor Author

Thanks @jwhitlock !

@jwhitlock
Copy link
Contributor

I'm going to try adding a commit updating docker-compose.yml, etc to mdn/kuma#4404

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);
Copy link
Contributor

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...

Copy link
Contributor Author

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?

Copy link
Contributor

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

Copy link
Contributor

@jwhitlock jwhitlock left a 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);
Copy link
Contributor

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

}

// Add a clone of the interactive-examples settings to "env".
env.interactive_examples = _.clone(
Copy link
Contributor

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');

Copy link
Contributor Author

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...

Copy link
Contributor

@stephaniehobson stephaniehobson left a 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.

@jwhitlock
Copy link
Contributor

Also, I think bug 760240 is the wrong one. Maybe bug 1308630?

@escattone
Copy link
Contributor Author

@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?

@escattone
Copy link
Contributor Author

@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
Copy link
Contributor

@jwhitlock jwhitlock left a 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!

@jwhitlock jwhitlock merged commit 7bd5390 into mdn:master Sep 6, 2017
@escattone escattone deleted the interactive-settings-in-macros-760240 branch October 31, 2017 17:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants