git: 7fe378266a - main - Fix problems with links and CSS in offline mode
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 29 Jan 2022 21:03:11 UTC
The branch main has been updated by carlavilla:
URL: https://cgit.FreeBSD.org/doc/commit/?id=7fe378266af5031be31ccc562b6e0580dc18d51a
commit 7fe378266af5031be31ccc562b6e0580dc18d51a
Author: Sergio Carlavilla Delgado <carlavilla@FreeBSD.org>
AuthorDate: 2022-01-29 21:02:15 +0000
Commit: Sergio Carlavilla Delgado <carlavilla@FreeBSD.org>
CommitDate: 2022-01-29 21:02:15 +0000
Fix problems with links and CSS in offline mode
Reported by: dbaio@
---
documentation/config/offline/config.toml | 13 ++--
.../themes/beastie/layouts/books/list.html | 42 ++++++------
.../themes/beastie/layouts/books/single.html | 42 ++++++------
.../themes/beastie/layouts/partials/menu.html | 23 +++++--
.../beastie/layouts/partials/site-footer.html | 14 ++--
.../themes/beastie/layouts/partials/site-head.html | 79 ++++++++++++----------
.../beastie/layouts/partials/site-header.html | 16 +++--
7 files changed, 132 insertions(+), 97 deletions(-)
diff --git a/documentation/config/offline/config.toml b/documentation/config/offline/config.toml
index f359e2ad7e..653ef5b279 100644
--- a/documentation/config/offline/config.toml
+++ b/documentation/config/offline/config.toml
@@ -1,6 +1,6 @@
# FreeBSD documentation
-baseURL = "localhost"
+baseURL = ""
title = "FreeBSD Documentation Portal"
copyright = "BSD 2-clause 'Simplified' License"
defaultContentLanguage = "en"
@@ -11,6 +11,7 @@ disableKinds = [ "taxonomy", "term", "RSS", "sitemap", "robotsTXT", "404" ]
authors = [ "carlavilla@FreeBSD.org" ]
ignoreFiles = [ "chapter.adoc$", "contrib-386bsd.adoc$", "contrib-additional.adoc$", "contrib-committers.adoc$", "contrib-corealumni.adoc$", "contrib-develalumni.adoc$", "contrib-develinmemoriam.adoc$", "contrib-portmgralumni.adoc$", "books.adoc$", "\\.po$" ]
enableRobotsTXT = true
+relativeURLs = true
[params]
websiteURL = "https://www.FreeBSD.org"
@@ -29,11 +30,11 @@ enableRobotsTXT = true
urls = [".*"]
[markup.asciidocExt]
- extensions = ["man-macro", "inter-document-references-macro", "cross-document-references-macro", "sectnumoffset-treeprocessor", "packages-macro", "git-macro"]
- [markup.asciidocExt.attributes]
- env-beastie = true
- isOnline = false
- skip-front-matter = true
+ extensions = ["man-macro", "inter-document-references-macro", "cross-document-references-macro", "sectnumoffset-treeprocessor", "packages-macro", "git-macro"]
+ [markup.asciidocExt.attributes]
+ env-beastie = true
+ isOnline = false
+ skip-front-matter = true
[outputs]
home = [ "HTML" ]
diff --git a/documentation/themes/beastie/layouts/books/list.html b/documentation/themes/beastie/layouts/books/list.html
index 7b0998acce..d4df934989 100644
--- a/documentation/themes/beastie/layouts/books/list.html
+++ b/documentation/themes/beastie/layouts/books/list.html
@@ -41,15 +41,17 @@
<h3>{{ i18n "toc" }}</h3>
{{ .TableOfContents }}
</div>
- {{ if .Params.add_split_page_link }}
- <div>
- [ <a href="../">{{ i18n "split-html" }}</a> / {{ i18n "single-html" }} ]
- </div>
+ {{ if $.Site.Params.isOnline }}
+ {{ if .Params.add_split_page_link }}
+ <div>
+ [ <a href="../">{{ i18n "split-html" }}</a> / {{ i18n "single-html" }} ]
+ </div>
+ {{ end }}
+ {{ if .Params.add_single_page_link }}
+ <div>
+ [ {{ i18n "split-html" }} / <a href="book/">{{ i18n "single-html" }}</a> ]
+ </div>
{{ end }}
- {{ if .Params.add_single_page_link }}
- <div>
- [ {{ i18n "split-html" }} / <a href="book/">{{ i18n "single-html" }}</a> ]
- </div>
{{ end }}
<div class="book-content">
{{ .Content }}
@@ -61,7 +63,7 @@
<i class="fa fa-angle-left" aria-hidden="true"></i>
<div class="container">
{{ if $.Site.Params.isOnline }}
- <a href={{ .Params.Prev | absLangURL }} class="direction">{{ i18n "prev" }}</a>
+ <a href={{ .Params.Prev | absLangURL }} class="direction">{{ i18n "prev" }}</a>
{{ else }}
{{ $pathSectionsPrev := split .Params.Prev "/" }}
@@ -79,25 +81,25 @@
<div class="home">
<i class="fa fa-home" aria-hidden="true"></i>
<div class="container">
- <a href="../" class="direction">{{ i18n "home" }}</a>
+ {{ if $.Site.Params.isOnline }}
+ <a href="../" class="direction">{{ i18n "home" }}</a>
+ {{ else }}
+ <a href="../index.html" class="direction">{{ i18n "home" }}</a>
+ {{ end }}
</div>
</div>
{{ if .Params.next }}
<div class="next">
<div class="container">
{{ if $.Site.Params.isOnline }}
- <a href={{ .Params.Next | absLangURL }} class="direction">{{ i18n "next" }}</a>
+ <a href={{ .Params.Next | absLangURL }} class="direction">{{ i18n "next" }}</a>
{{ else }}
- {{ $pathSectionsNext := split .Params.Next "/" }}
+ {{ $pathSectionsNext := split .Params.next "/" }}
+
{{if eq (len $pathSectionsNext) 3}}
- {{ if .Params.isIndex }}
- {{ $book := index $pathSectionsNext 1 }}
- {{ $path := index $pathSectionsNext 2 }}
- <a href=../{{ $book }}/{{ $path }}/index.html>{{ i18n "next" }}</a>
- {{ else }}
- {{ $path := index $pathSectionsNext 2 }}
- <a href=../{{ $path }}/index.html>{{ i18n "next" }}</a>
- {{ end }}
+ {{ $book := index $pathSectionsNext 1 }}
+ {{ $chapter := index $pathSectionsNext 2 }}
+ <a href=../{{ $book }}/{{ $chapter }}/index.html>{{ i18n "next" }}</a>
{{ end }}
{{if eq (len $pathSectionsNext) 2}}
<a href=../index.html>{{ i18n "next" }}</a>
diff --git a/documentation/themes/beastie/layouts/books/single.html b/documentation/themes/beastie/layouts/books/single.html
index 7b0998acce..d4df934989 100644
--- a/documentation/themes/beastie/layouts/books/single.html
+++ b/documentation/themes/beastie/layouts/books/single.html
@@ -41,15 +41,17 @@
<h3>{{ i18n "toc" }}</h3>
{{ .TableOfContents }}
</div>
- {{ if .Params.add_split_page_link }}
- <div>
- [ <a href="../">{{ i18n "split-html" }}</a> / {{ i18n "single-html" }} ]
- </div>
+ {{ if $.Site.Params.isOnline }}
+ {{ if .Params.add_split_page_link }}
+ <div>
+ [ <a href="../">{{ i18n "split-html" }}</a> / {{ i18n "single-html" }} ]
+ </div>
+ {{ end }}
+ {{ if .Params.add_single_page_link }}
+ <div>
+ [ {{ i18n "split-html" }} / <a href="book/">{{ i18n "single-html" }}</a> ]
+ </div>
{{ end }}
- {{ if .Params.add_single_page_link }}
- <div>
- [ {{ i18n "split-html" }} / <a href="book/">{{ i18n "single-html" }}</a> ]
- </div>
{{ end }}
<div class="book-content">
{{ .Content }}
@@ -61,7 +63,7 @@
<i class="fa fa-angle-left" aria-hidden="true"></i>
<div class="container">
{{ if $.Site.Params.isOnline }}
- <a href={{ .Params.Prev | absLangURL }} class="direction">{{ i18n "prev" }}</a>
+ <a href={{ .Params.Prev | absLangURL }} class="direction">{{ i18n "prev" }}</a>
{{ else }}
{{ $pathSectionsPrev := split .Params.Prev "/" }}
@@ -79,25 +81,25 @@
<div class="home">
<i class="fa fa-home" aria-hidden="true"></i>
<div class="container">
- <a href="../" class="direction">{{ i18n "home" }}</a>
+ {{ if $.Site.Params.isOnline }}
+ <a href="../" class="direction">{{ i18n "home" }}</a>
+ {{ else }}
+ <a href="../index.html" class="direction">{{ i18n "home" }}</a>
+ {{ end }}
</div>
</div>
{{ if .Params.next }}
<div class="next">
<div class="container">
{{ if $.Site.Params.isOnline }}
- <a href={{ .Params.Next | absLangURL }} class="direction">{{ i18n "next" }}</a>
+ <a href={{ .Params.Next | absLangURL }} class="direction">{{ i18n "next" }}</a>
{{ else }}
- {{ $pathSectionsNext := split .Params.Next "/" }}
+ {{ $pathSectionsNext := split .Params.next "/" }}
+
{{if eq (len $pathSectionsNext) 3}}
- {{ if .Params.isIndex }}
- {{ $book := index $pathSectionsNext 1 }}
- {{ $path := index $pathSectionsNext 2 }}
- <a href=../{{ $book }}/{{ $path }}/index.html>{{ i18n "next" }}</a>
- {{ else }}
- {{ $path := index $pathSectionsNext 2 }}
- <a href=../{{ $path }}/index.html>{{ i18n "next" }}</a>
- {{ end }}
+ {{ $book := index $pathSectionsNext 1 }}
+ {{ $chapter := index $pathSectionsNext 2 }}
+ <a href=../{{ $book }}/{{ $chapter }}/index.html>{{ i18n "next" }}</a>
{{ end }}
{{if eq (len $pathSectionsNext) 2}}
<a href=../index.html>{{ i18n "next" }}</a>
diff --git a/documentation/themes/beastie/layouts/partials/menu.html b/documentation/themes/beastie/layouts/partials/menu.html
index 1d118e85e4..7d82aac764 100644
--- a/documentation/themes/beastie/layouts/partials/menu.html
+++ b/documentation/themes/beastie/layouts/partials/menu.html
@@ -4,19 +4,30 @@
<li>
{{ if ne .Page.File.LogicalName "book.adoc" }}
- {{ $finalPath := printf "%s%s" .Page.Permalink "#" }}
{{ $toc := htmlUnescape .Page.TableOfContents }}
{{ $toc = replace $toc "<nav id=\"TableOfContents\">" "" }}
{{ $toc = replace $toc "</nav>" "" }}
<input type="checkbox" id="chapter-{{ md5 .Page }}" class="toggle" {{ if eq .Page.Permalink $.Permalink }} checked {{ end }} />
<label {{ if gt (len $toc) 0 }} class="icon cursor" {{ end }} for="chapter-{{ md5 .Page }}"><a role="button"></a></label>
- <a href="{{ .Page.Permalink }}">
- {{ .Page.Title }}
- </a>
- {{ $toc = replace $toc "#" $finalPath }}
- {{ $toc | safeHTML }}
+ {{ if $.Site.Params.isOnline }}
+ {{ $finalPath := printf "%s%s" .Page.Permalink "index.html/#" }}
+ <a href="{{ .Page.Permalink }}">
+ {{ .Page.Title }}
+ </a>
+ {{ $toc = replace $toc "#" $finalPath }}
+ {{ $toc | safeHTML }}
+ {{ else }}
+ {{ $chapterPath := printf "%s%s" .Page.Permalink "index.html" }}
+ <a href="{{$chapterPath}}">
+ {{ .Page.Title }}
+ </a>
+ {{ $chapterPath = replace $chapterPath "index.html" "index.html#" }}
+ {{ $toc = replace $toc "#" $chapterPath }}
+ {{ $toc | safeHTML }}
+ {{ end }}
+
{{ end }}
</li>
{{ end }}
diff --git a/documentation/themes/beastie/layouts/partials/site-footer.html b/documentation/themes/beastie/layouts/partials/site-footer.html
index 3b3303ea96..7e00948dd1 100755
--- a/documentation/themes/beastie/layouts/partials/site-footer.html
+++ b/documentation/themes/beastie/layouts/partials/site-footer.html
@@ -4,12 +4,14 @@
{{ i18n "freebsd-project" }}
</h1>
<div class="options-container">
- <div class="language-container">
- <a id="languages" href="{{ "languages" | absLangURL }}">
- <img src="{{ absLangURL ($.Site.BaseURL ) }}images/language.png" class="language-image" alt="{{ i18n "choose-language" }}">
- <span>{{ .Site.Language.LanguageName }}</span>
- </a>
- </div>
+ {{ if $.Site.Params.isOnline }}
+ <div class="language-container">
+ <a id="languages" href="{{ "languages" | absLangURL }}">
+ <img src="{{ absLangURL ($.Site.BaseURL ) }}images/language.png" class="language-image" alt="{{ i18n "choose-language" }}">
+ <span>{{ .Site.Language.LanguageName }}</span>
+ </a>
+ </div>
+ {{ end }}
<div class="theme-container">
<select id="theme-chooser">
<option value="theme-light">{{ i18n "light" }}</option>
diff --git a/documentation/themes/beastie/layouts/partials/site-head.html b/documentation/themes/beastie/layouts/partials/site-head.html
index df073603e6..a9b1d38026 100644
--- a/documentation/themes/beastie/layouts/partials/site-head.html
+++ b/documentation/themes/beastie/layouts/partials/site-head.html
@@ -8,45 +8,56 @@
<title>{{ with .Params.Title }}{{ . }} | {{ end }} {{ block "title" . }}{{ .Site.Title }}{{ end }}</title>
- <!-- FAVICON -->
- <link rel="shortcut icon" href="{{ absLangURL ($.Site.BaseURL) }}favicon.ico">
-
<meta name="theme-color" content="#790000">
<meta name="color-scheme" content="light dark high-contrast">
- <!-- END FAVICON -->
- {{- $styles := resources.Get "styles/main.scss" | resources.ToCSS | resources.Minify }}
- <link rel="stylesheet" href="{{ $styles.Permalink }}">
- <link rel="stylesheet" href="{{ absLangURL ($.Site.BaseURL) }}css/font-awesome-min.css">
+ {{ if $.Site.Params.isOnline }}
+ <link rel="shortcut icon" href="{{ absLangURL ($.Site.BaseURL) }}favicon.ico">
+
+ {{- $styles := resources.Get "styles/main.scss" | resources.ToCSS | resources.Minify }}
+ <link rel="stylesheet" href="{{ $styles.Permalink }}">
+ <link rel="stylesheet" href="{{ absLangURL ($.Site.BaseURL) }}css/font-awesome-min.css">
+
+ {{- $themeChooser := resources.Get "js/theme-chooser.js" | resources.Minify }}
+ <script defer src="{{ $themeChooser.RelPermalink }}"></script>
+ {{ else }}
+ <link rel="shortcut icon" href="/favicon.ico">
+
+ {{- $styles := resources.Get "styles/main.scss" | resources.ToCSS | resources.Minify }}
+ <link rel="stylesheet" href="{{ $styles.RelPermalink }}">
+ <link rel="stylesheet" href="/css/font-awesome-min.css">
- {{- $themeChooser := resources.Get "js/theme-chooser.js" | resources.Minify }}
- <script defer src="{{ $themeChooser.RelPermalink }}"></script>
+ {{- $themeChooser := resources.Get "js/theme-chooser.js" | resources.Minify }}
+ <script defer src="{{ $themeChooser.RelPermalink }}"></script>
+ {{ end }}
<!-- SEO -->
- <meta name="twitter:card" content="summary"/>
- <meta name="twitter:domain" content="docs.FreeBSD.org"/>
- <meta name="twitter:site" content="@freebsd"/>
- <meta name="twitter:url" content="https://twitter.com/freebsd"/>
- <meta property="og:title" content="{{ if .IsHome }}{{ .Site.Params.Title }}{{ else }}{{ .Title }}{{ end }}" />
- <meta property="og:description" content="{{ if .IsHome }}{{ .Site.Params.description }}{{ else }}{{ .Description }}{{ end }}" />
- <meta property="og:type" content="website"/>
- <meta property="og:image" content="{{ absLangURL ($.Site.BaseURL) }}favicon.ico"/>
- <meta property="og:image:alt" content="FreeBSD Logo">
- <meta property="og:locale" content="{{ $.Site.Language.Lang | default "en" }}" />
- <meta property="og:url" content="{{ .Permalink }}" />
- <meta property="og:site_name" content="{{ .Site.Title }}" />
- <script type="application/ld+json">
- {
- "@context": "http://schema.org",
- "@type": "Article",
- "url": "{{ .Permalink }}",
- "name": "{{ .Site.Title }}",
- "headline": "{{ .Site.Title }}",
- "description": "{{ .Site.Params.description }}"
- }
- </script>
- <!-- END SEO -->
-
- {{ template "_internal/google_analytics.html" . }}
+ {{ if $.Site.Params.isOnline }}
+ <meta name="twitter:card" content="summary"/>
+ <meta name="twitter:domain" content="docs.FreeBSD.org"/>
+ <meta name="twitter:site" content="@freebsd"/>
+ <meta name="twitter:url" content="https://twitter.com/freebsd"/>
+ <meta property="og:title" content="{{ if .IsHome }}{{ .Site.Params.Title }}{{ else }}{{ .Title }}{{ end }}" />
+ <meta property="og:description" content="{{ if .IsHome }}{{ .Site.Params.description }}{{ else }}{{ .Description }}{{ end }}" />
+ <meta property="og:type" content="website"/>
+ <meta property="og:image" content="{{ absLangURL ($.Site.BaseURL) }}favicon.ico"/>
+ <meta property="og:image:alt" content="FreeBSD Logo">
+ <meta property="og:locale" content="{{ $.Site.Language.Lang | default "en" }}" />
+ <meta property="og:url" content="{{ .Permalink }}" />
+ <meta property="og:site_name" content="{{ .Site.Title }}" />
+ <script type="application/ld+json">
+ {
+ "@context": "http://schema.org",
+ "@type": "Article",
+ "url": "{{ .Permalink }}",
+ "name": "{{ .Site.Title }}",
+ "headline": "{{ .Site.Title }}",
+ "description": "{{ .Site.Params.description }}"
+ }
+ </script>
+ <!-- END SEO -->
+
+ {{ template "_internal/google_analytics.html" . }}
+ {{ end }}
</head>
diff --git a/documentation/themes/beastie/layouts/partials/site-header.html b/documentation/themes/beastie/layouts/partials/site-header.html
index 5e6af7604a..25e98b01fc 100755
--- a/documentation/themes/beastie/layouts/partials/site-header.html
+++ b/documentation/themes/beastie/layouts/partials/site-header.html
@@ -1,15 +1,21 @@
<header>
<nav>
<a href="{{ $.Site.Params.websiteURL }}" class="logo">
- <img src="{{ absLangURL ($.Site.BaseURL) }}images/freebsd-logo.svg" width="160" height="50" alt="FreeBSD logo" />
+ {{ if $.Site.Params.isOnline }}
+ <img src="{{ absLangURL ($.Site.BaseURL) }}images/freebsd-logo.svg" width="160" height="50" alt="FreeBSD logo" />
+ {{ else }}
+ <img src="/images/freebsd-logo.svg" width="160" height="50" alt="FreeBSD logo" />
+ {{ end }}
</a>
<input class="menu-btn" type="checkbox" id="menu-btn" />
<label class="menu-icon" for="menu-btn"><span class="navicon"></span></label>
<ul class="menu">
- <li class="first-element"><a href="{{ .Site.BaseURL | relLangURL }}">{{ i18n "documentation" }}</a></li>
- <li><a href={{ "books" | absLangURL }}>{{ i18n "books" }}</a></li>
- <li><a href={{ "articles" | absLangURL }}>{{ i18n "articles" }}</a></li>
- <!--<li><a href={{ "communit" | absLangURL }}>{{ i18n "community" }}</a></li>-->
+ {{ if $.Site.Params.isOnline }}
+ <li class="first-element"><a href="{{ .Site.BaseURL | relLangURL }}">{{ i18n "documentation" }}</a></li>
+ <li><a href={{ "books" | absLangURL }}>{{ i18n "books" }}</a></li>
+ <li><a href={{ "articles" | absLangURL }}>{{ i18n "articles" }}</a></li>
+ <!--<li><a href={{ "communit" | absLangURL }}>{{ i18n "community" }}</a></li>-->
+ {{ end }}
</ul>
</nav>
</header>