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

Example hosting a book with GitLab Pages #1416

Open
NikosAlexandris opened this issue Aug 5, 2021 · 12 comments
Open

Example hosting a book with GitLab Pages #1416

NikosAlexandris opened this issue Aug 5, 2021 · 12 comments

Comments

@NikosAlexandris
Copy link

Just an example/idea for another section under https://jupyterbook.org/publish/web.html

@welcome
Copy link

welcome bot commented Aug 5, 2021

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

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! 🎉

@choldgraf
Copy link
Collaborator

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

@sophiedkk
Copy link

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.

@NikosAlexandris
Copy link
Author

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

@NikosAlexandris
Copy link
Author

NikosAlexandris commented Aug 10, 2021

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.

@sophiedkk
Copy link

sophiedkk commented Aug 10, 2021

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 😅 :

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

@NikosAlexandris
Copy link
Author

NikosAlexandris commented Aug 20, 2021

Now an 'official' example at https://gitlab.com/pages/jupyterbook, in action here: https://pages.gitlab.io/jupyterbook/intro.html.

@choldgraf
Copy link
Collaborator

ah very cool!

@FlorianGD
Copy link

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"

@sophiedkk
Copy link

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™.

@choldgraf
Copy link
Collaborator

Yep I agree - I think that this could essentially follow the same config structure as the one proposed for launch buttons here:

@joshmoore
Copy link

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.

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

5 participants