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

Implement a way to open a libretexts page as a jupyter notebook on the LIbreTexts jupyterhub #82

Open
moorepants opened this issue Nov 4, 2019 · 6 comments

Comments

@moorepants
Copy link
Member

A button "Open in JupyterHub" should be on each Jupyter enabled LIbretexts page. When a user presses it a new tab should open at jupyter.libretexts.org, they log in, and then the hub uploads the page to their home directory and opens it for execution.

@sandertyu
Copy link
Contributor

There's a way we can basically do this using nbgitpuller. You can simply add nbgitpuller link anywhere on the page, and then when clicked on, it redirects the user to our jupyter.libretexts.org and then they choose a Jupyter Environment to spawn and it will contain the files we want them to be able to run. The problems are that 1. Users need to have an account with us 2. They have to manually choose an environment (it doesn't matter which) so it isn't a smooth process of "click link then immediatly open a JupyterLab hosted by us" and 3. we need to setup a github repo in order to do this. I've added this type of link to our sandbox on the Chem LibreText library if you want to test.

Another way is to use our binder URL, but I don't see a way other than just visiting the binder page, clicking run, and then launching the notebook we want them to run. Not sure if we can prepopulate the repo field with the one we want them to build anyways.

We'd have to discuss other ways to do it if you want a more smooth and continuous process.

@moorepants
Copy link
Member Author

But doesn't the libretexts page have to be converted to ipynb somewhere in the process?

@sandertyu
Copy link
Contributor

sandertyu commented Sep 16, 2020

But doesn't the libretexts page have to be converted to ipynb somewhere in the process?

You're right, I misread the title. I figured it just meant importing all the code cells, but if you want the texts and everything too, that's a bit more involved. Something along these lines could be useful then, where we scrape the <body> of the html, and dictate what type of cell it is based on the containing div (all Thebe cells are contained in a <div class="thebelab-widget">). Since notebooks accept code, markdown, and raw types of data, we would need to convert all the html to markdown as well. There's things like html parser we can use to do the HTML -> markdown conversion if we make some stylistic choices I bet. I'm not sure how high of a priority this is still, but the email you sent recently does mention this type of functionality.

@moorepants
Copy link
Member Author

Yes, I think we have to take the HTML in the LibreTexts page and convert it to the IPYNB format. A custom parser may be needed, but we should also see if someone else has solved this already. I suspect there may be a solution of some variety. Also be aware that there is the command line tool nbconvert, which converts IPYNB to different formats. It is possible that is used to go the other way too. If we have to write something our selves, I think using pandoc might be best. You can write a custom plugin for pandoc that does the conversion.

@moorepants
Copy link
Member Author

Since notebooks accept code, markdown, and raw types of data, we would need to convert all the html to markdown as well.

pandoc does this nicely already.

@moorepants
Copy link
Member Author

This will probably require #81 to be solved first.

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

No branches or pull requests

2 participants