Skip to content
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

Interacting with the Sphinx Generated Docs from the Landing Page #216

Closed
thelittlewonder opened this issue Apr 10, 2018 · 5 comments
Closed

Comments

@thelittlewonder
Copy link

I was dabbling with the dynamic search integration of the Sphinx Generated pages with the landing page for the learn astropy website. [Issue #203]

I figured out that we can directly make request to Read the Docs to get search results, corresponding to our query (which is plot, in the example URL stated above). But Read the Docs has disabled CORS. So I can’t make a request directly from the frontend.

There’re 2 possible solutions, I am looking at:

  • Host a Flask Server to make the HTTP Request: Solves the Issue of CORS but since it’s mentioned in org chart of learn astropy that it needs to be hosted on gh-pages, I don’t know how feasible will be the integration of a backend.
  • An uglier solution would be to generate a index (JSON) every time the docs are generated and request that index file to return the query results.

I’d like to have suggestions on how shall I proceed.

@kelle
Copy link
Member

kelle commented Apr 10, 2018

I don't know what CORS is but is it the kind of thing that we could ask RTD to implement for us?

@adrn , thoughts?

@thelittlewonder
Copy link
Author

As far as I know, enabling CORS(Cross-Origin Resource Sharing) is not a good practice since allowing other websites to do HTTP calls from JavaScript (what we call) can be a security issue; so it's possible that RTD may not agree to our request. Maybe we can ask them to whitelist our particular domain, but still, that depends on them.

Let's see what @adrn has to say. Meanwhile I'll brainstorm for better alternatives. Using a simple flask based server can be an option.

@pllim
Copy link
Member

pllim commented Apr 12, 2018

Yeah, let's not get too fancy there with JS lest browser starts blocking it due to suspected security risk...

@thelittlewonder
Copy link
Author

thelittlewonder commented Apr 13, 2018

Problem is If we host a backend(flask or something, to make the HTTP Request), then We will need to deploy it somewhere(Heroku or Digital Ocean). Is that possible?

@thelittlewonder
Copy link
Author

thelittlewonder commented Apr 17, 2018

Demo

Hi @kelle @adrn
I have created a small demo at http://www.thelittlewonder.co/learn-astropy

The Front end makes a call to a flask server hosted by me on Heroku (learn-astropy.herokuapp.com) which in turn makes a call to RTD. CORS issue solved.

Note: It is only for testing purposes, so the filter on the left is not functional. Also I am fetching information from Documentation as of now, not from Tutorials and Examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants