qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [qemu-web PATCH v2 03/16] make all links be relative to the root
Date: Tue, 27 Oct 2020 13:20:02 +0000	[thread overview]
Message-ID: <20201027132015.621733-4-berrange@redhat.com> (raw)
In-Reply-To: <20201027132015.621733-1-berrange@redhat.com>

This enables the site to be hosted at URLs with different base
directories. This is useful when viewing the site after being
published as GitLab CI artifacts.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 _includes/assets.html        | 28 ++++++++++++++--------------
 _includes/copyright.html     |  2 +-
 _includes/footer.html        | 12 ++++++------
 _includes/nav.html           | 12 ++++++------
 _includes/relative_root.html | 12 ++++++++++++
 _includes/sidebar.html       |  6 +++---
 _layouts/archive.html        |  4 ++--
 _layouts/blog.html           |  3 ++-
 _layouts/home.html           |  1 +
 _layouts/page.html           |  1 +
 blog/index.html              |  4 ++--
 index.html                   |  5 +++--
 12 files changed, 53 insertions(+), 37 deletions(-)
 create mode 100644 _includes/relative_root.html

diff --git a/_includes/assets.html b/_includes/assets.html
index 826a50f..411a1ac 100644
--- a/_includes/assets.html
+++ b/_includes/assets.html
@@ -4,23 +4,23 @@
 	<meta name="viewport" content="width=device-width">
 	<link href='https://fonts.googleapis.com/css?family=Roboto+Mono:300,400%7cRoboto:300,400,500' rel='stylesheet' type='text/css'>
 
-	<link rel="apple-touch-icon" sizes="180x180" href="/assets/favicons/apple-touch-icon.png">
-	<link rel="icon" type="image/png" sizes="32x32" href="/assets/favicons/favicon-32x32.png">
-	<link rel="icon" type="image/png" sizes="16x16" href="/assets/favicons/favicon-16x16.png">
-	<link rel="manifest" href="/assets/favicons/manifest.json">
-	<link rel="mask-icon" href="/assets/favicons/safari-pinned-tab.svg" color="#5bbad5">
-	<meta name="msapplication-config" content="/assets/favicons/browserconfig.xml">
+	<link rel="apple-touch-icon" sizes="180x180" href="{{ relative_root }}/assets/favicons/apple-touch-icon.png">
+	<link rel="icon" type="image/png" sizes="32x32" href="{{ relative_root }}/assets/favicons/favicon-32x32.png">
+	<link rel="icon" type="image/png" sizes="16x16" href="{{ relative_root }}/assets/favicons/favicon-16x16.png">
+	<link rel="manifest" href="{{ relative_root }}/assets/favicons/manifest.json">
+	<link rel="mask-icon" href="{{ relative_root }}/assets/favicons/safari-pinned-tab.svg" color="#5bbad5">
+	<meta name="msapplication-config" content="{{ relative_root }}/assets/favicons/browserconfig.xml">
 	<meta name="theme-color" content="#ffffff">
 
-	<link rel="stylesheet" href="/assets/css/normalize.css" />
+	<link rel="stylesheet" href="{{ relative_root }}/assets/css/normalize.css" />
 	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" />
-	<link rel="stylesheet" href="/assets/css/skel-noscript.css" />
-	<link rel="stylesheet" href="/assets/css/style.css" />
-	<link rel="stylesheet" href="/assets/css/style-mobile.css" media="(max-width:699px)"/>
-	<link rel="stylesheet" href="/assets/css/style-desktop.css" media="(min-width:700px)" />
-	<link rel="alternate" title="QEMU Blog (Atom feed)" href="/feed.xml" type="application/atom+xml" />
+	<link rel="stylesheet" href="{{ relative_root }}/assets/css/skel-noscript.css" />
+	<link rel="stylesheet" href="{{ relative_root }}/assets/css/style.css" />
+	<link rel="stylesheet" href="{{ relative_root }}/assets/css/style-mobile.css" media="(max-width:699px)"/>
+	<link rel="stylesheet" href="{{ relative_root }}/assets/css/style-desktop.css" media="(min-width:700px)" />
+	<link rel="alternate" title="QEMU Blog (Atom feed)" href="{{ relative_root }}/feed.xml" type="application/atom+xml" />
 	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
 	{% if page.colorbox %}
-	<script src="/assets/js/jquery.colorbox.js"></script>
-	<link rel="stylesheet" href="/assets/css/colorbox.css" />
+	<script src="{{ relative_root }}/assets/js/jquery.colorbox.js"></script>
+	<link rel="stylesheet" href="{{ relative_root }}/assets/css/colorbox.css" />
 	{% endif %}
diff --git a/_includes/copyright.html b/_includes/copyright.html
index 3e6e6a3..cdcd98f 100644
--- a/_includes/copyright.html
+++ b/_includes/copyright.html
@@ -2,7 +2,7 @@
 	<div id="copyright-inner">
 	  <div class="container">
 	    This site is made available under the terms of
-	    <a href="/license.html">a number of licenses</a>.
+	    <a href="{{ relative_root }}/license.html">a number of licenses</a>.
 	  </div>
 	</div>
 </div>
diff --git a/_includes/footer.html b/_includes/footer.html
index c8f1042..b614795 100644
--- a/_includes/footer.html
+++ b/_includes/footer.html
@@ -1,20 +1,20 @@
 <div id="footer">
 	<div id="footer-inner">
 		<ul class="style">
-			<li><a href="/">Home</a></li>
-			<li><a href="/download">Download</a></li>
-			<li><a href="/conservancy/">Conservancy / Committee</a></li>
+			<li><a href="{{ relative_root }}/">Home</a></li>
+			<li><a href="{{ relative_root }}/download">Download</a></li>
+			<li><a href="{{ relative_root }}/conservancy/">Conservancy / Committee</a></li>
 			<li><a href="http://qemu-advent-calendar.org">QEMU advent calendar</a></li>
 		</ul>
 		<ul class="style">
-			<li><a href="/contribute">Contribute</a></li>
-			<li><a href="/contribute/report-a-bug">Reporting a bug</a></li>
+			<li><a href="{{ relative_root }}/contribute">Contribute</a></li>
+			<li><a href="{{ relative_root }}/contribute/report-a-bug">Reporting a bug</a></li>
 			<li><a href="https://wiki.qemu.org/Documentation/GettingStartedDevelopers">New contributors</a></li>
 			<li><a href="https://wiki.qemu.org/Contribute/SubmitAPatch">Submitting a patch</a></li>
 			<li><a href="https://wiki.qemu.org/Contribute/FAQ">Contributor FAQ</a></li>
 		</ul>
 		<ul class="style">
-			<li><a href="/documentation">Documentation</a></li>
+			<li><a href="{{ relative_root }}/documentation">Documentation</a></li>
 			<li><a href="https://www.qemu.org/docs/master/">Main docs</a></li>
 			<li><a href="https://wiki.qemu.org/Category:Developer_documentation">Developer docs</a></li>
 			<li><a href="https://wiki.qemu.org/">Wiki</a></li>
diff --git a/_includes/nav.html b/_includes/nav.html
index 0c81e24..58b6c5a 100644
--- a/_includes/nav.html
+++ b/_includes/nav.html
@@ -2,12 +2,12 @@
 	<nav id="nav">
 		<ul>
 			{% assign current = page.url | downcase | split: '/' %}
-			<li class='{% if page.url == '/' %}not-desktop {%endif %}home'><a href="/">Home</a>
-			</li><li {% if current[1] == 'download' %}class='current'{% endif %}><a href="/download">Download</a>
-			</li><li {% if current[1] == 'support' %}class='current'{% endif %}><a href="/support">Support</a>
-			</li><li {% if current[1] == 'contribute' %}class='current'{% endif %}><a href="/contribute">Contribute</a>
-			</li><li {% if current[1] == 'documentation' %}class='current'{% endif %}><a href="/documentation">Documentation</a>
-			</li><li {% if current[1] == 'blog' %}class='current'{% endif %}><a href="/blog">Blog</a></li>
+			<li class='{% if page.url == '/' %}not-desktop {%endif %}home'><a href="{{ relative_root }}/">Home</a>
+			</li><li {% if current[1] == 'download' %}class='current'{% endif %}><a href="{{ relative_root }}/download">Download</a>
+			</li><li {% if current[1] == 'support' %}class='current'{% endif %}><a href="{{ relative_root }}/support">Support</a>
+			</li><li {% if current[1] == 'contribute' %}class='current'{% endif %}><a href="{{ relative_root }}/contribute">Contribute</a>
+			</li><li {% if current[1] == 'documentation' %}class='current'{% endif %}><a href="{{ relative_root }}/documentation">Documentation</a>
+			</li><li {% if current[1] == 'blog' %}class='current'{% endif %}><a href="{{ relative_root }}/blog">Blog</a></li>
 		</ul>
 	</nav>
 
diff --git a/_includes/relative_root.html b/_includes/relative_root.html
new file mode 100644
index 0000000..87c30e2
--- /dev/null
+++ b/_includes/relative_root.html
@@ -0,0 +1,12 @@
+{% assign relative_root = '' %}
+{% assign tempDepth = page.url | append: 'hackish-solution' | split: '/' | size | minus: 2 %}
+{% for i in (1..tempDepth) %}
+  {% if forloop.last %}
+    {% assign relative_root = relative_root | append: ".." %}
+  {% else %}
+    {% assign relative_root = relative_root | append: "../" %}
+  {% endif %}
+{% endfor %}
+{% if relative_root == '' %}
+    {% assign relative_root = '.' %}
+{% endif %}
diff --git a/_includes/sidebar.html b/_includes/sidebar.html
index 0dc3538..f0cec2a 100644
--- a/_includes/sidebar.html
+++ b/_includes/sidebar.html
@@ -9,7 +9,7 @@
 		<ul class="style">
 		{% for post in site.posts offset: 0 limit: 2 %}
 			<li>
-				<a href="{{ site.prefix }}{{ post.url }}">{{ post.title }}</a><br/>
+				<a href="{{ relative_root }}{{ post.url }}">{{ post.title }}</a><br/>
 				<span class="posted">{{ post.date | date_to_string }}</span>
 			</li>
 		{% endfor %}
@@ -31,12 +31,12 @@
 		{% assign thisurl = post.date | date: "%Y/%m" %}
 		{% assign thisdate = post.date | date: "%B %Y" %}
 		{% if thisurl != prevurl and prevurl != "" %}
-		<li><a href="/blog/{{ prevurl }}/">{{ prevdate }} ({{ counter }})</a></li>
+		<li><a href="{{ relative_root }}/blog/{{ prevurl }}/">{{ prevdate }} ({{ counter }})</a></li>
 		{% assign counter = 0 %}
 		{% endif %}
 		{% assign counter = counter | plus: 1 %}
 		{% endfor %}
-		<li><a href="/blog/{{ thisurl }}/">{{ thisdate }} ({{ counter }})</a></li>
+		<li><a href="{{ relative_root }}/blog/{{ thisurl }}/">{{ thisdate }} ({{ counter }})</a></li>
 		</ul>
 	</section>
 </div>
diff --git a/_layouts/archive.html b/_layouts/archive.html
index 4e67749..a0be7b8 100644
--- a/_layouts/archive.html
+++ b/_layouts/archive.html
@@ -9,13 +9,13 @@ layout: blog
 		{% for post in page.posts %}
 		<article>
 			<header>
-				<h2><a href="{{ site.prefix }}{{ post.url }}">{{ post.title }}</a></h2>
+				<h2><a href="../../..{{ post.url }}">{{ post.title }}</a></h2>
 				<div class="posted">{{ post.date | date_to_string }}{%
 				if post.last_modified_at %} (Updated {{ post.last_modified_at | date_to_string }}) {%
 				endif %}{% if post.author %} &mdash; by {{ post.author }}{% endif %}</div>
 			</header>
 		{{ post.excerpt }}
-		<a href="{{ site.prefix }}{{ post.url }}" class="button button-style1">Read More</a>
+		<a href="../../..{{ post.url }}" class="button button-style1">Read More</a>
 		</article>
 		{% endfor %}
 	</section>
diff --git a/_layouts/blog.html b/_layouts/blog.html
index 2dfb9c8..b300636 100644
--- a/_layouts/blog.html
+++ b/_layouts/blog.html
@@ -3,7 +3,8 @@
 Linear by TEMPLATED
 templated.co @templatedco
 Released for free under the Creative Commons Attribution 3.0 license (templated.co/license)
--->
+  -->
+{% include relative_root.html %}
 <html>
 <head>
 	<title>{{ page.title }} - {{ site.title }}</title>
diff --git a/_layouts/home.html b/_layouts/home.html
index b96e391..d94c9b0 100644
--- a/_layouts/home.html
+++ b/_layouts/home.html
@@ -4,6 +4,7 @@ Linear by TEMPLATED
 templated.co @templatedco
 Released for free under the Creative Commons Attribution 3.0 license (templated.co/license)
 -->
+{% include relative_root.html %}
 <html>
 <head>
 	<title>{{ site.title }}</title>
diff --git a/_layouts/page.html b/_layouts/page.html
index 110ca97..d650054 100644
--- a/_layouts/page.html
+++ b/_layouts/page.html
@@ -4,6 +4,7 @@ Linear by TEMPLATED
 templated.co @templatedco
 Released for free under the Creative Commons Attribution 3.0 license (templated.co/license)
 -->
+{% include relative_root.html %}
 <html>
 <head>
 	<title>{{ page.title }} - {{ site.title }}</title>
diff --git a/blog/index.html b/blog/index.html
index 313b994..c7ceb0a 100644
--- a/blog/index.html
+++ b/blog/index.html
@@ -8,7 +8,7 @@ layout: blog
 	<div class="row">
 		<section>
 			<header>
-				<h1><a href="{{ site.prefix }}{{ post.url }}">{{ post.title }}</a></h1>
+				<h1><a href="{{ relative_root }}{{ post.url }}">{{ post.title }}</a></h1>
 				<div class="posted">{{ post.date | date_to_string }}{%
 				if post.last_modified_at %} (Updated {{ post.last_modified_at | date_to_string }}) {%
 				endif %}{% if post.author %} &mdash; by {{ post.author }}{% endif %}</div>
@@ -22,7 +22,7 @@ layout: blog
 				</ul>
 			{% else %}
 				{{ post.excerpt }}
-				<a href="{{ site.prefix }}{{ post.url }}" class="button button-style1">Read More</a>
+				<a href="{{ relative_root }}{{ post.url }}" class="button button-style1">Read More</a>
 			{% endif %}
 		</section>
 	</div>
diff --git a/index.html b/index.html
index 4c65101..e52868d 100644
--- a/index.html
+++ b/index.html
@@ -3,6 +3,7 @@ title: QEMU
 layout: home
 colorbox: True
 ---
+{% include relative_root.html %}
 	<!-- Header -->
 	<div id="header">
 		<div class="container">
@@ -38,7 +39,7 @@ colorbox: True
 			{% include screenshot.html offset=3 limit=10 %}
 			</section>
 
-<script src="/assets/js/object-fit.js"></script>
+<script src="{{ relative_root }}/assets/js/object-fit.js"></script>
 <script>
 window.hasColorBox = false;
 $(window).on("load resize", function() {
@@ -62,7 +63,7 @@ $('.colorbox').on("click.random-namespace", function() {
 
 		</div>
 		<hr>
-		<p>QEMU is a member of <a href="/conservancy/">Software Freedom Conservancy</a>.</p>
+		<p>QEMU is a member of <a href="{{ relative_root }}/conservancy/">Software Freedom Conservancy</a>.</p>
 	</div>
 </div>
 
-- 
2.26.2



  parent reply	other threads:[~2020-10-27 13:26 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-27 13:19 [qemu-web PATCH v2 00/16] Re-design the QEMU home page to better present information Daniel P. Berrangé
2020-10-27 13:20 ` [qemu-web PATCH v2 01/16] Convert files to UNIX line endings Daniel P. Berrangé
2020-10-27 17:40   ` Thomas Huth
2020-10-27 13:20 ` [qemu-web PATCH v2 02/16] gitlab: introduce a CI job to publish the site content Daniel P. Berrangé
2020-10-27 13:20 ` Daniel P. Berrangé [this message]
2020-10-27 13:20 ` [qemu-web PATCH v2 04/16] Make page header nav narrower Daniel P. Berrangé
2021-01-19 11:18   ` Thomas Huth
2020-10-27 13:20 ` [qemu-web PATCH v2 05/16] Introduce support for "bxslider" jquery add on Daniel P. Berrangé
2020-10-27 13:20 ` [qemu-web PATCH v2 06/16] Rework display of screenshots to use a carousel slider Daniel P. Berrangé
2020-10-27 16:19   ` Kashyap Chamarthy
2020-10-27 18:45   ` Paolo Bonzini
2020-10-27 13:20 ` [qemu-web PATCH v2 07/16] Compress the two front page headings into one Daniel P. Berrangé
2020-10-27 13:20 ` [qemu-web PATCH v2 08/16] Simplify copyright and integrate into footer Daniel P. Berrangé
2020-10-27 13:20 ` [qemu-web PATCH v2 09/16] Put a full SFC membership blurb in footer of every page Daniel P. Berrangé
2020-10-27 13:20 ` [qemu-web PATCH v2 10/16] Use two column layout to display screenshots and releases Daniel P. Berrangé
2020-10-27 13:20 ` [qemu-web PATCH v2 11/16] Bring contribution links out of the footer into the home page Daniel P. Berrangé
2020-10-27 15:02   ` Kashyap Chamarthy
2020-10-27 13:20 ` [qemu-web PATCH v2 12/16] Add recent blog posts to the front page featured content Daniel P. Berrangé
2020-10-27 13:20 ` [qemu-web PATCH v2 13/16] Move wiki link from footer into the header navbar Daniel P. Berrangé
2020-10-27 13:20 ` [qemu-web PATCH v2 14/16] Simplify and restructure the page footer Daniel P. Berrangé
2020-10-27 13:20 ` [qemu-web PATCH v2 15/16] Add link to "page source" for all pages Daniel P. Berrangé
2020-10-27 13:20 ` [qemu-web PATCH v2 16/16] Add a CONTRIBUTING.md file as guidance for contributors Daniel P. Berrangé
2021-01-13 14:54 ` [qemu-web PATCH v2 00/16] Re-design the QEMU home page to better present information Paolo Bonzini
2021-01-13 14:57   ` Daniel P. Berrangé
2021-01-19 12:03     ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201027132015.621733-4-berrange@redhat.com \
    --to=berrange@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).