Skip to content

Parse urls with query params for ^/static - #3394

Merged
dcadams merged 1 commit into
masterfrom
dcadams/parse_query_params
May 28, 2014
Merged

Parse urls with query params for ^/static#3394
dcadams merged 1 commit into
masterfrom
dcadams/parse_query_params

Conversation

@dcadams

@dcadams dcadams commented Apr 18, 2014

Copy link
Copy Markdown
Contributor

Query params with a value that starts with /static should have their values converted to the full location.
Query params with a value that does not start with /static should be left unchanged.

@dcadams

dcadams commented Apr 18, 2014

Copy link
Copy Markdown
Contributor Author

@jbau please.

@jbau

jbau commented Apr 18, 2014

Copy link
Copy Markdown

@dcadams this seems good.

@jbau

jbau commented Apr 18, 2014

Copy link
Copy Markdown

@sarina can you give this a review, or schedule it for review, or bounce it to someone? Let me give you some context. Basically we have things breaking on our instance b/c the "/static" URL expansion happens on the path part of URLs, but not within query parameters. The issue here is that this is inconsistent with the behavior in studio's HTML editor, which will collapse ?query=/c4x/org/course/asset/foo back into ?query=/static/asset, so it breaks things (Flash .swfs -- I know, I know) that depend on query parameters passing in static urls.

tagging @cahrens as an FYI, and she can confirm the studio behavior.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need re.sub here (you can just slice the string), but I don't feel strongly about making this change. Others might though.

Actually, I don't see the subbing out of "/static" in the code above your addition. is it really necessary?

@cahrens

cahrens commented Apr 18, 2014

Copy link
Copy Markdown

Here is a very brief description of what Studio is doing. In the TinyMCE Editor for HTML components, we rewrite /static -> c4x notation when loading in the Editor, and we do the reverse on save. This is necessary so that links and images appear correctly in the WYSIWYG editor (in the code editor accessible from the toolbar, we show only the /static notation, as that is what is actually persisted).

The rewrite code we use is very simplistic, so it converts all c4x links to /static on Save.

We should not be storing absolute links to the courseware in mongo because that is not portable (import into a new course will not work as the links will not refer to the new course).

@sarina

sarina commented Apr 18, 2014

Copy link
Copy Markdown
Contributor

@jbau I'm unfamiliar with this area of the codebase. @singingwolfboy has been triaging PRs, I'm hoping he can help identify a reviewer for this case.

@cahrens

cahrens commented Apr 23, 2014

Copy link
Copy Markdown

@dcadams We are releasing a "raw HTML Editor", most likely tomorrow. It will allow you to have complete control over the HTML (using CodeMirror, not TinyMCE), and will not do any link rewriting. This should give you a workaround until this PR is merged.

See #3449.

@dcadams

dcadams commented Apr 23, 2014

Copy link
Copy Markdown
Contributor Author

Thank you @cahrens I was just looking at the raw HTML editor. We are not in a bind right now as we haven't pulled in the original editor change yet. I believe this PR will still be beneficial in preventing cross-course linking of assets.

@cahrens

cahrens commented Apr 23, 2014

Copy link
Copy Markdown

I agree-- I do think this PR is the right thing to do.

@dcadams

dcadams commented May 1, 2014

Copy link
Copy Markdown
Contributor Author

@singingwolfboy any chance you can schedule a look at this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use a loop like for query_name, query_value in orig_query, and then use query_value instead of query_item[1], which I think would make the operation clearer.

@dcadams

dcadams commented May 23, 2014

Copy link
Copy Markdown
Contributor Author

@dianakhuang could you schedule a review please.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpennington

Copy link
Copy Markdown
Contributor

👍

@flowerhack

Copy link
Copy Markdown
Contributor

🎋 🍊 ⛵ once the indentation style thing is fixed

@jbau

jbau commented May 27, 2014

Copy link
Copy Markdown

FYI @dcadams is on vacation today. He'll be back in tomorrow 5/28

  Query params with a value that starts with /static should have their values converted to the full location.
  Query params with a value that does not start with /static should be left unchanged.
@dcadams

dcadams commented May 28, 2014

Copy link
Copy Markdown
Contributor Author

Indentation fixed, re-based, all tests passing.

dcadams pushed a commit that referenced this pull request May 28, 2014
Parse urls with query params for ^/static
@dcadams
dcadams merged commit 54e1fae into master May 28, 2014
@dcadams
dcadams deleted the dcadams/parse_query_params branch May 28, 2014 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants