jupyter-book
jupyter-book copied to clipboard
Example hosting a book with GitLab Pages
Just an example/idea for another section under https://jupyterbook.org/publish/web.html
- Working repository example: NikosAlexandris/jupyter-book-example
- Working site example: nikosalexandris.gitlab.io/jupyter-book-example/intro.html
Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:
I think it's a great idea - though I'm not super familiar with gitlab. Any interest in making a PR following a similar structure to the GitHub section? I'm happy to review
I feel like there is more to supporting gitlab. For example, the github logo in the top right corner should be substituted with a gitlab logo. I currently use a simple script to replace the "fa-github" with "fa-gitlab" icons. jupyter-book also used to replace a gitlab url with a github url but that does no longer seem to be the case.
I think it's a great idea - though I'm not super familiar with gitlab. Any interest in making a PR following a similar structure to the GitHub section? I'm happy to review
I started working on this here: https://github.com/NikosAlexandris/jupyter-book
I feel like there is more to supporting gitlab. For example, the github logo in the top right corner should be substituted with a gitlab logo. I currently use a simple script to replace the "fa-github" with "fa-gitlab" icons.
Would you mind sharing?
jupyter-book also used to replace a gitlab url with a github url but that does no longer seem to be the case.
It is still the case for the suggest edit button.
It is still the case for the suggest edit button.
Interesting.. I didn't enable that button for the project I'm currently working on but now I did and I get the same result. The issues button and repo button both seem to keep the gitlab link though.
Would you mind sharing?
It's a very hacky solution but it did change the icons for me. It's a step in my CI/CD, but I wouldn't recommend on using the code anywhere else :sweat_smile: :
from glob import glob
def change_string_in_file(filename: str, old_string: str, new_string: str):
"""Replaces old_string with new_string from filename and saves the result to that file"""
with open(filename) as f:
content = f.read()
if old_string not in content:
return
with open(filename, 'w') as f:
content = content.replace(old_string, new_string)
f.write(content)
files = glob("./_build/html/**/*html", recursive=True)
for file in files:
change_string_in_file(file, "fa-github", "fa-gitlab")
Best thing would obviously be to look for the place where these links and icons get inserted, but I haven't had the chance to look at that.
edit: I suspect this file needs to be changed: https://github.com/executablebooks/sphinx-book-theme/blob/master/sphinx_book_theme/topbar/repobuttons.html
Now an 'official' example at https://gitlab.com/pages/jupyterbook, in action here: https://pages.gitlab.io/jupyterbook/intro.html.
ah very cool!
I added a script to the makefile that builds the book in pure bash, so maybe a bit more clean than the python script above, if that helps anyone:
# replace the github logo by gitlab's one
# grep -l only prints the filename, we then feed it to sed to replace inplace
grep -rl "fa-github" jupyterbook/_build | xargs sed -i "s/fa-github/fa-gitlab/g"
In the end I reckon it's best to adjust this in the theme. Specifically this part:
if opts.get("use_repository_button"):
repo_buttons.append(
{
"type": "link",
"url": repo_url,
"tooltip": "Source repository",
"text": "repository",
"icon": "fab fa-github",
}
)
in https://github.com/executablebooks/sphinx-book-theme/blob/master/src/sphinx_book_theme/header_buttons/init.py
It would also be good to check the other places where github is mentioned in the code. The URL structure for github/gitlab is interchangable as far as I know though, so nothing should break™.
Yep I agree - I think that this could essentially follow the same config structure as the one proposed for launch buttons here:
- https://github.com/executablebooks/sphinx-book-theme/issues/462
Now an 'official' example at https://gitlab.com/pages/jupyterbook, in action here: https://pages.gitlab.io/jupyterbook/intro.html.
A heads up that the "issues" button on that book still opens a GitHub issue rather than a GitLab issue which is a bit of a surprise.