-
Notifications
You must be signed in to change notification settings - Fork 670
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
Example hosting a book with GitLab Pages #1416
Comments
Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗 |
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 started working on this here: https://github.com/NikosAlexandris/jupyter-book |
Would you mind sharing?
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.
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 😅 : 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",
}
) 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: |
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. |
Just an example/idea for another section under https://jupyterbook.org/publish/web.html
The text was updated successfully, but these errors were encountered: