Skip to content

Commit 33e371c

Browse files
committed
Merge branch 'support-gh-pages-in-forks'
The purpose of this topic branch is to allow development of https://github.com/git/git-scm.com/ to happen in forks and to be tested in those forks' GitHub Pages. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents 60f65c8 + 1ddfb14 commit 33e371c

34 files changed

+203
-184
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ jobs:
2222
- name: run Hugo to build the pages
2323
run: hugo
2424

25+
- name: ensure that there are no absolute URLs
26+
run: |
27+
set -x
28+
if git grep --untracked --no-exclude-standard "\\(href\|src\) *= *[\"']/" \
29+
-- public/ ':^public/js/jquery*' >/tmp/abs-urls.txt
30+
then
31+
cat /tmp/abs-urls.txt
32+
exit 1
33+
fi
34+
2535
- name: run Pagefind ${{ env.PAGEFIND_VERSION }} to build the search index
2636
run: npx -y pagefind@${{ env.PAGEFIND_VERSION }} --site public
2737

assets/js/application.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
popped = 'state' in window.history;
2121
initialURL = location.href;
2222

23+
const baseURLPrefix = (() => {
24+
const scripts = document.getElementsByTagName('script');
25+
const index = scripts.length - 1;
26+
const thisScript = scripts[index];
27+
return thisScript.src.replace(/^.*:\/\/[^/]*(.*\/)js\/[^/]+.js(\?.*)?$/, '$1');
28+
})();
29+
2330
$(document).ready(function() {
2431
BrowserFallbacks.init();
2532
Search.init();
@@ -49,27 +56,27 @@ var DownloadBox = {
4956
var os = window.session.browser.os; // Mac, Win, Linux
5057
if(os == "Mac") {
5158
$(".monitor").addClass("mac");
52-
$("#download-link").text("Download for Mac").attr("href", "/download/mac");
59+
$("#download-link").text("Download for Mac").attr("href", `${baseURLPrefix}download/mac`);
5360
$("#gui-link").removeClass('mac').addClass('gui');
54-
$("#gui-link").text("Mac GUIs").attr("href", "/download/gui/mac");
61+
$("#gui-link").text("Mac GUIs").attr("href", `${baseURLPrefix}download/gui/mac`);
5562
$("#gui-os-filter").attr('data-os', 'mac');
5663
$("#gui-os-filter").text("Only show GUIs for my OS (Mac)")
5764
} else if (os == "Windows") {
5865
$(".monitor").addClass("windows");
59-
$("#download-link").text("Download for Windows").attr("href", "/download/win");
66+
$("#download-link").text("Download for Windows").attr("href", `${baseURLPrefix}download/win`);
6067
$("#gui-link").removeClass('mac').addClass('gui');
61-
$("#gui-link").text("Windows GUIs").attr("href", "/download/gui/windows");
68+
$("#gui-link").text("Windows GUIs").attr("href", `${baseURLPrefix}download/gui/windows`);
6269
$("#alt-link").removeClass("windows").addClass("mac");
63-
$("#alt-link").text("Mac Build").attr("href", "/download/mac");
70+
$("#alt-link").text("Mac Build").attr("href", `${baseURLPrefix}download/mac`);
6471
$("#gui-os-filter").attr('data-os', 'windows');
6572
$("#gui-os-filter").text("Only show GUIs for my OS (Windows)")
6673
} else if (os == "Linux") {
6774
$(".monitor").addClass("linux");
68-
$("#download-link").text("Download for Linux").attr("href", "/download/linux");
75+
$("#download-link").text("Download for Linux").attr("href", `${baseURLPrefix}download/linux`);
6976
$("#gui-link").removeClass('mac').addClass('gui');
70-
$("#gui-link").text("Linux GUIs").attr("href", "/download/gui/linux");
77+
$("#gui-link").text("Linux GUIs").attr("href", `${baseURLPrefix}download/gui/linux`);
7178
$("#alt-link").removeClass("windows").addClass("mac");
72-
$("#alt-link").text("Mac Build").attr("href", "/download/mac");
79+
$("#alt-link").text("Mac Build").attr("href", `${baseURLPrefix}download/mac`);
7380
$("#gui-os-filter").attr('data-os', 'linux');
7481
$("#gui-os-filter").text("Only show GUIs for my OS (Linux)")
7582
} else {
@@ -257,7 +264,7 @@ var Search = {
257264
if(!url) {
258265
const term = $('#search-text').val();
259266
const language = document.querySelector("html")?.getAttribute("lang");
260-
url = `search/results?search=${term}${language && `&language=${language}`}`;
267+
url = `${baseURLPrefix}search/results?search=${term}${language && `&language=${language}`}`;
261268
}
262269
window.location.href = url;
263270
selectedIndex = 0;
@@ -417,8 +424,8 @@ var Downloads = {
417424

418425
if (window.history && window.history.pushState) {
419426
var url = os === ''
420-
? '/downloads/guis/'
421-
: `/download/guis?os=${os}`;
427+
? `${baseURLPrefix}downloads/guis`
428+
: `${baseURLPrefix}download/guis?os=${os}`;
422429
try {
423430
history.pushState(null, $(this).html(), url);
424431
} catch (e) {

content/404.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<div class='inner'>
66
<p>
7-
<img src="/images/[email protected]" alt="404" width="456" height="149" />
7+
<img src="{{< relurl "images/[email protected]" >}}" alt="404" width="456" height="149" />
88
</p>
99
<h1>That page doesn't exist.</h1>
1010
<p>

content/about/branching-and-merging.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ <h2>Branching and Merging</h2>
4242
</ul>
4343

4444
<p class="center">
45-
<img src="/images/about/[email protected]" width="500" height="288" alt="Branches">
45+
<img src="{{< relurl "images/about/[email protected]" >}}" width="500" height="288" alt="Branches">
4646
</p>
4747

4848
<p>
@@ -54,7 +54,7 @@ <h2>Branching and Merging</h2>
5454
</p>
5555

5656
<div class="bottom-nav" style="display: block;">
57-
<a href="/about/small-and-fast" class="next" data-section-id="small-and-fast">Small and Fast →</a>
57+
<a href="{{< relurl "about/small-and-fast" >}}" class="next" data-section-id="small-and-fast">Small and Fast →</a>
5858
</div>
5959

6060
</section>

content/about/data-assurance.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ <h2>Data Assurance</h2>
1717
checksum when checked back out. It's impossible to get anything out of Git
1818
other than the <strong>exact bits you put in</strong>.
1919
</p>
20-
<img height="522" src="/images/[email protected]" width="628">
20+
<img height="522" src="{{< relurl "images/[email protected]" >}}" width="628">
2121
<p>
2222
It is also impossible to change any file, date, commit message, or any other
2323
data in a Git repository without changing the IDs of everything after it.
@@ -29,8 +29,8 @@ <h2>Data Assurance</h2>
2929
Most centralized version control systems provide no such integrity by default.
3030
</p>
3131
<div class="bottom-nav" style="display: block;">
32-
<a href="/about/distributed" class="previous" data-section-id="distributed">← Distributed</a>
33-
<a href="/about/staging-area" class="next" data-section-id="staging-area">Staging Area →</a>
32+
<a href="{{< relurl "about/distributed" >}}" class="previous" data-section-id="distributed">← Distributed</a>
33+
<a href="{{< relurl "about/staging-area" >}}" class="next" data-section-id="staging-area">Staging Area →</a>
3434
</div>
3535
</section>
3636

content/about/distributed.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,25 @@ <h4>Subversion-Style Workflow</h4>
2727
A centralized workflow is very common, especially from people transitioning from a centralized system. Git will not allow you to push if someone has pushed since the last time you fetched, so a centralized model where all developers push to the same server works just fine.
2828
</p>
2929
<p class="center">
30-
<img src="/images/about/[email protected]" width="415" height="209" alt="Workflow A">
30+
<img src="{{< relurl "images/about/[email protected]" >}}" width="415" height="209" alt="Workflow A">
3131
</p>
3232
<h4>Integration Manager Workflow</h4>
3333
<p>
3434
Another common Git workflow involves an integration manager — a single person who commits to the 'blessed' repository. A number of developers then clone from that repository, push to their own independent repositories, and ask the integrator to pull in their changes. This is the type of development model often seen with open source or GitHub repositories.
3535
</p>
3636
<p class="center">
37-
<img src="/images/about/[email protected]" width="407" height="164" alt="Workflow B">
37+
<img src="{{< relurl "images/about/[email protected]" >}}" width="407" height="164" alt="Workflow B">
3838
</p>
3939
<h4>Dictator and Lieutenants Workflow</h4>
4040
<p>
4141
For more massive projects, a development workflow like that of the Linux kernel is often effective.
4242
In this model, some people ('lieutenants') are in charge of a specific subsystem of the project and they merge in all changes related to that subsystem. Another integrator (the 'dictator') can pull changes from only his/her lieutenants and then push to the 'blessed' repository that everyone then clones from again.
4343
</p>
4444
<p class="center">
45-
<img src="/images/about/[email protected]" width="562" height="303" alt="Workflow C">
45+
<img src="{{< relurl "images/about/[email protected]" >}}" width="562" height="303" alt="Workflow C">
4646
</p>
4747
<div class="bottom-nav" style="display: block;">
48-
<a href="/about/small-and-fast" class="previous" data-section-id="small-and-fast">← Small and Fast</a>
49-
<a href="/about/data-assurance" class="next" data-section-id="info-assurance">Data Assurance →</a>
48+
<a href="{{< relurl "about/small-and-fast" >}}" class="previous" data-section-id="small-and-fast">← Small and Fast</a>
49+
<a href="{{< relurl "about/data-assurance" >}}" class="next" data-section-id="info-assurance">Data Assurance →</a>
5050
</div>
5151
</section>

content/about/free-and-open-source.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ <h2>Free and Open Source</h2>
1717
free for all its users.</p>
1818

1919
<p>However, we do restrict the use of the term "Git" and the
20-
<a href="/downloads/logos">logos</a> to avoid confusion. Please
21-
see our <a href="/trademark">trademark</a> policy for
20+
<a href="{{< relurl "downloads/logos" >}}">logos</a> to avoid confusion. Please
21+
see our <a href="{{< relurl "trademark" >}}">trademark</a> policy for
2222
details.</p>
2323

2424
<div class="bottom-nav" style="display: block;">
25-
<a href="/about/staging-area" class="previous" data-section-id="staging-area">← Staging Area</a>
26-
<a href="/about/trademark" class="next" data-section-id="trademark">Trademark →</a>
25+
<a href="{{< relurl "about/staging-area" >}}" class="previous" data-section-id="staging-area">← Staging Area</a>
26+
<a href="{{< relurl "about/trademark" >}}" class="next" data-section-id="trademark">Trademark →</a>
2727
</div>
2828
</section>

content/about/small-and-fast.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ <h3>Benchmarks</h3>
155155
</p>
156156

157157
<div class="bottom-nav" style="display: block;">
158-
<a href="/about/branching-and-merging" class="previous" data-section-id="branching-and-merging">← Branching and Merging</a>
159-
<a href="/about/distributed" class="next" data-section-id="distributed">Distributed →</a>
158+
<a href="{{< relurl "about/branching-and-merging" >}}" class="previous" data-section-id="branching-and-merging">← Branching and Merging</a>
159+
<a href="{{< relurl "about/distributed" >}}" class="next" data-section-id="distributed">Distributed →</a>
160160
</div>
161161

162162
</section>

content/about/staging-area.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ <h2>Staging Area</h2>
1616
One thing that sets Git apart from other tools is that it's possible to quickly stage some of your files and commit them without committing all of the other modified files in your working directory or having to list them on the command line during the commit.
1717
</p>
1818
<p class="center">
19-
<img src="/images/about/[email protected]" width="336" height="194" alt="Index 1">
19+
<img src="{{< relurl "images/about/[email protected]" >}}" width="336" height="194" alt="Index 1">
2020
</p>
2121
<p>
2222
This allows you to stage only portions of a modified file. Gone are the days of making two logically unrelated modifications to a file before you realized that you forgot to commit one of them. Now you can just stage the change you need for the current commit and stage the other change for the next commit. This feature scales up to as many different changes to your file as needed.
@@ -25,11 +25,11 @@ <h2>Staging Area</h2>
2525
Of course, Git also makes it easy to ignore this feature if you don't want that kind of control — just add a '-a' to your commit command in order to add all changes to all files to the staging area.
2626
</p>
2727
<p class="center">
28-
<img src="/images/about/[email protected]" width="338" height="185" alt="Index 2">
28+
<img src="{{< relurl "images/about/[email protected]" >}}" width="338" height="185" alt="Index 2">
2929
</p>
3030
<div class="bottom-nav" style="display: block;">
31-
<a href="/about/data-assurance" class="previous" data-section-id="info-assurance">← Data Assurance</a>
32-
<a href="/about/free-and-open-source" class="next" data-section-id="free-and-open-source">Free and Open Source →</a>
31+
<a href="{{< relurl "about/data-assurance" >}}" class="previous" data-section-id="info-assurance">← Data Assurance</a>
32+
<a href="{{< relurl "about/free-and-open-source" >}}" class="next" data-section-id="free-and-open-source">Free and Open Source →</a>
3333
</div>
3434
</section>
3535

content/about/trademark.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ <h3>4 Questions</h3>
187187
Montague St. Ste 380, Brooklyn, NY 11201-3548.</p>
188188

189189
<div class="bottom-nav" style="display: block;">
190-
<a href="/about/free-and-open-source" class="previous" data-section-id="free-and-open-source">← Free and Open Source</a>
190+
<a href="{{< relurl "about/free-and-open-source" >}}" class="previous" data-section-id="free-and-open-source">← Free and Open Source</a>
191191
</div>
192192

193193
</section>

0 commit comments

Comments
 (0)