Running the GTN website online using GitPod
OverviewQuestions:Objectives:
How can I get a preview of the GTN website using GitPod?
Preview the GTN website online via GitPod
Make changes to the GTN website and preview those changes
Time estimation: 15 minutesSupporting Materials:Published: Jun 24, 2021Last modification: Nov 8, 2024License: Tutorial Content is licensed under Creative Commons Attribution 4.0 International License. The GTN Framework is licensed under MITpurl PURL: https://gxy.io/GTN:T00066rating Rating: 3.0 (1 recent ratings, 6 all time)version Revision: 12
If you are working on your own training materials and want preview them online without installing anything on your computer, you can do this using GitPod!
AgendaIn this tutorial, you will learn how to run a local instance of the GTN website:
Setting up Gitpod
Hands-on: Setting up GitPod
- Create a fork of the GTN GitHub repository
- Go on the GitHub repository: github.com/galaxyproject/training-material
- Click on th Fork button (top-right corner of the page)
If you already have a fork, fantastic! But a common issue is that the
main
branch gets outdated, or your fork was from before we renamed themaster
branch tomain
.
- Start by browsing to your fork in GitHub
- Check the default branch that is shown.
- Does it say
master
? Then you need to update it, following the instructions below
- Go to your fork’s settings (Click on the gear icon called “Settings”)
- Find “Branches” on the left
- If it says master you can click on the ⇆ icon to switch branches.
- Select
main
(it may not be present).- If it isn’t present, use the pencil icon to rename
master
tomain
.- Now you can update it in the next step
Click the Sync Fork button on your fork to update it to the latest version
- Open your browser and navigate to gitpod.io/login
- Note: don’t leave the
/login
part of the URL off, it will lead you to a different flavour of GitPod. We are using Gitpod classic- Log in with GitHub
- Click on Configure your own repository under the Workspaces menu
- Under Select a repository choose your fork, e.g.
https://github.com/shiltemann/training-material
- Click continue
- This will create an enviroment where you can make changes to the GTN and preview them
- Note: It can take quite some time to start up the first time (15-30 minutes)
- We can make future starts a lot faster using prebuilds (see tip box below), you can configure this now while you wait
Prebuilds can speed up the launch of your GitPod workspace after the first time. When this is enabled, starting a workspace will check if there is a previous build to reuse. This should bring startup times down to 3-5 minutes.
Enable Prebuilds
- On the GitPod website, click on your name in the top left of the screen
- Select Repositories
- Add your fork as a repository
- On the left, click Prebuild settings
- Click the slider in front of Prebuilds are disabled to toggle the setting
- Set Branch Filter to Default Branch
Run a prebuild now
- In GitPod, click on your name in the top left of the screen
- Select Prebuilds
- Click Run a Prebuild
- Select a Repository: your fork
- Click Run Prebuild
- This will also take a bit of time to complete
- In the future, it will automatically refresh this prebuild every 20 commits, so you only have to do this once
Note: Prebuilds expire if you haven’t used them in 7 days, so if you have taken a longer break from GTN you might have to wait longer again the first time. But otherwise it should bring the launch time down to around 3-5 minutes.
Once the setup is finished, you should see a page something like this:
The GitPod Workspace
Let’s have a closer look at the GitPod workspace:
- Left: Here you see all the files in the GTN repository
- Top: This is the main window where you can view and edit files
- Bottom: Terminal window. Here you can type commands (e.g. to build the website preview) and read output and error messages.
Build and preview the GTN website
Before we start making any changes, let’s build the website and get a live preview.
Hands-on: Setting up GitPod
In the terminal window (bottom), type the following command:
make serve-gitpod
- The first time you run this command, it will install some dependencies, so it may take a little bit of time (a few minutes)
- Next times will be a lot faster! (~30 seconds)
- When the build process is finished, the terminal will show you a link, and a window should popup with a preview on the right.
You may have to click the “Try Again” button if the preview was generated before the site building completed
Click on the link in the terminal to see the GTN in full-screen:
Server address: http://127.0.0.1:4000/training-material/
Some browsers block popups by default, you may need to allow GitPod to show popups in order to click links.
- This will take you to a preview of the GTN website
- Note: It will take you the 404 page because GitPod doesn’t know the location of the GTN homepage, but from here you can just click the homepage button.
Editing Training Materials on GitPod
Now that you have the GitPod environment working and we have a live preview up, let’s make some changes to the GTN materials and get an instant preview.
Scenario: You have spotted a typo in one of the tutorials, and would like to fix this and see the resulting GTN webpage.
Hands-on: Make and view changes
- In the preview of the GTN website, open the following tutorial:
- Topic: “Introduction to Galaxy Analyses” topic
- Tutorial: “A Short Introduction to Galaxy””
- We will edit this tutorial and watch the live preview window for the effects
On the file browser on the left, open the following file:
topics/introduction/tutorials/galaxy-intro-short/tutorial.md
You can use the key combination ctrl-p to launch the file search dialog and simply enter the text
topics/introduction/tutorials/galaxy-intro-short/tutorial.md
- Change the title of the tutorial
- From: “A Short Introduction to Galaxy”
- To: “A Short and Cool Introduction to Galaxy”
- You should immediately see a message in the terminal saying “regenerating”. GitPod has detected your changes and is rebuilding the website.
- Move to the top right panel where the GTN is previewed and refresh the frame
- galaxy-refresh Refresh button in front of the address bar of the preview panel
- You can also open the preview in it’s own brower tab, using the galaxy_instance button at the top-right corner of the preview window. Then you can reload the page the regular way (e.g. F5 or ctrl + r or the reload button in the browser)
- You should see the change you made:
In this way you can edit files in the text editor, and see the effects in the website preview.
Saving your changes back to GitHub
When you have finished your changes, it all looks good in the preview, you want to save your changes back to GitHub so that you can either continue later, or make a Pull Request to the GTN to contribute your changes.
Hands-on: Save changes
- Option 1: via the terminal
- Hit ctrl+c if your preview was still running to stop it
- Create a new branch, commit your changes, push changes:
git checkout -b fix-title git commit -m "update tutorial title" topics/introduction/tutorials/galaxy-intro-short/tutorial.md git push origin fix-title
- Option 2: via the web interface
- Your changes are now saved to your fork, and you can make a PR via the GitHub interface.
If this is your first time using GitPod, you may need to grant permissions to let GitPod push to your GitHub fork This will take you through a process to authorize GitPod, and set permissions If it doesn’t take you to GitPod’s permission page because your browser blocks popups, you can set them on this page.
Closing your GitPod Workspace
Everybody gets 50 hours per month for free on GitPod, so it is wise to close your GitPod workspace when you are finished with it, to conserve your quotum.
Hands-on: Shutting down your GitPod workspace