print: add option to print whole chapter #230

This commit is contained in:
Sören Weber 2022-04-02 15:29:34 +02:00
parent 70b4143327
commit 0dd92e332b
No known key found for this signature in database
GPG key ID: 07D17FF580AE7589
53 changed files with 454 additions and 71 deletions

View file

@ -12,6 +12,7 @@ The theme is a fork of the great [Learn theme](https://github.com/matcornic/hugo
- Usable offline, no external dependencies
- Automatic Search
- Print whole chapters or even the complete site
- Multilingual mode for English, Arabic, Simplified Chinese, Dutch, French, German, Hindi, Indonesian, Japanese, Korean, Portuguese, Russian, Spanish, Vietnamese, Turkish
- Unlimited menu levels
- Automatic next/prev buttons to navigate through menu entries

View file

@ -1,3 +1,12 @@
[module]
[module.hugoVersion]
min = "0.93.0"
[outputFormats]
[outputFormats.PRINT]
name= "PRINT"
baseName = "index"
path = "_print"
isHTML = true
mediaType = 'text/html'
permalinkable = false

View file

@ -43,9 +43,13 @@ title = "Hugo Relearn Documentation"
mermaidInitialize = "{ \"securityLevel\": \"loose\" }"
[outputs]
# add JSON to the home page to support lunr search; This is a mandatory setting
# add JSON to the home to support lunr search; This is a mandatory setting
# for the search functionality
home = ["HTML", "RSS", "JSON"]
# add PRINT to home, section and page to activate feature to print whole
# chapters
home = ["HTML", "RSS", "PRINT", "JSON"]
section = ["HTML", "RSS", "PRINT"]
page = ["HTML", "RSS", "PRINT"]
[markup]
[markup.highlight]

View file

@ -18,6 +18,7 @@ See [what's new]({{% relref "basics/migration" %}}) within the latest update.
* Usable offline, no external dependencies
* [Automatic Search]({{%relref "basics/configuration#activate-search" %}})
* [Print]({{%relref "basics/configuration#activate-print-support" %}}) whole chapters or even the complete site
* [Multilingual mode]({{%relref "cont/i18n" %}}) for English, Arabic, Simplified Chinese, Dutch, French, German, Hindi, Indonesian, Japanese, Korean, Portuguese, Russian, Spanish, Vietnamese, Turkish
* Unlimited menu levels
* Automatic next/prev buttons to navigate through menu entries

View file

@ -89,7 +89,7 @@ If not already present, add the follow lines in the same `config.toml` file.
```toml
[outputs]
home = [ "HTML", "RSS", "JSON"]
home = ["HTML", "RSS", "JSON"]
```
Relearn theme uses the last improvement available in hugo version 20+ to generate a json index file ready to be consumed by lunr.js javascript search engine.
@ -97,6 +97,23 @@ Relearn theme uses the last improvement available in hugo version 20+ to generat
> Hugo generate lunrjs index.json at the root of public folder.
> When you build the site with `hugo server`, hugo generates it internally and of course it doesnt show up in the filesystem
## Activate print support
You can activate print support to add the capability to print whole chapters or even the complete site. Just add the `PRINT` output format to your home, section and page in your `config.toml` as seen below:
```toml
[outputs]
home = ["HTML", "RSS", "PRINT", "JSON"]
section = ["HTML", "RSS", "PRINT"]
page = ["HTML", "RSS", "PRINT"]
```
This will add a little printer icon in the top bar. It will switch the page to print preview when clicked. You can then send this page to the printer by using your browser's usual print functionality.
{{% notice note %}}
While colors of your chosen color variant are reset to the theme's light standard values for printing, this does not apply for Mermaid diagrams and Swagger/OpenAPI Specification. Those will still use the colors of your chosen color variant which may cause a non coherent look on paper.
{{% /notice %}}
## Mermaid
The Mermaid configuration parameters can also be set on a specific page. In this case, the global parameter would be overwritten by the local one. See [Mermaid]({{< relref "shortcodes/mermaid.md" >}}) for additional documentation.

View file

@ -18,6 +18,8 @@ This document shows you what's new in the latest release. For a detailed list of
- **Breaking**: If you had previously overwritten the `custom-footer.html` partial to add visual elements below the content of your page, you have to move this content to the new partial `content-footer.html`. `custom-footer.html` was never meant to contain HTML other than additional styles and JavaScript.
- **New**: You can activate [print support]({{%relref "basics/configuration#activate-print-support" %}}) in your `config.toml` to add the capability to print whole chapters or even the complete site.
---
## 3.3.0

View file

@ -1,4 +1,5 @@
+++
description = "Some testing for different styles used in syntax highlightning and preformatted blocks"
title = "Code"
+++

View file

@ -1,4 +1,5 @@
+++
description = "Some test'n fer different styles used 'n rules highlightn'n an' preformatted blocks"
title = "Code"
+++
{{< piratify >}}

View file

@ -0,0 +1,58 @@
+++
description = "Some testing for different styles of image links"
title = "Images"
+++
Some testing for different styles of image links.
## Markdown
### Relative to page
![Magic](images/magic.gif?classes=shadow&height=50px)
### Relative to page up level
![Magic](../images/images/magic.gif?classes=shadow&height=50px)
### Static
![Logo](/images/logo.svg?classes=shadow&height=50px)
### External fully qualified
![Minion](https://octodex.github.com/images/minion.png?classes=shadow&height=50px)
### External without scheme
![Minion](//octodex.github.com/images/minion.png?classes=shadow&height=50px)
### External without scheme and scheme separator
![Minion](octodex.github.com/images/minion.png?classes=shadow&height=50px)
## HTML
### Relative to page
<p><img src="images/magic.gif?classes=shadow&height=50px"></p>
### Relative to page up level
<p><img src="../images/images/magic.gif?classes=shadow&height=50px"></p>
### Static
<p><img src="/images/logo.svg?classes=shadow&height=50px"></p>
### External fully qualified
<p><img src="https://octodex.github.com/images/minion.png?classes=shadow&height=50px"></p>
### External without scheme
<p><img src="//octodex.github.com/images/minion.png?classes=shadow&height=50px"></p>
### External without scheme and scheme separator
<p><img src="octodex.github.com/images/minion.png?classes=shadow&height=50px"></p>

View file

@ -0,0 +1,5 @@
+++
description = "Some test'n fer different styles o' image links"
title = "Images"
+++
{{< piratify >}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

View file

@ -0,0 +1,20 @@
+++
description = "Some testing for different styles of links"
title = "Links"
+++
Some testing for different styles of links.
## Markdown
### Relative to page:
![Magic](images/magic.gif?classes=shadow)
### Relative to page up level:
![Magic](../images/images/magic.gif?classes=shadow)
### Static:
![Logo](/images/logo.svg?classes=shadow)

View file

@ -0,0 +1,5 @@
+++
description = "Some test'n fer different styles o' links"
title = "Links"
+++
{{< piratify >}}

View file

@ -19,6 +19,9 @@ other = "الذهاب إلى الصفحة الرئيسية"
[Edit-this-page]
other = "حرر"
[Print-this-chapter]
other = ""
[Shortcuts-Title]
other = "المزيد"

View file

@ -19,6 +19,9 @@ other = "Gehe zur Homepage"
[Edit-this-page]
other = "Bearbeiten"
[Print-this-chapter]
other = "Ganzes Kapitel drucken"
[Shortcuts-Title]
other = "Mehr"

View file

@ -19,6 +19,9 @@ other = "Go to homepage"
[Edit-this-page]
other = "Edit"
[Print-this-chapter]
other = "Print whole chapter"
[Shortcuts-Title]
other = "More"

View file

@ -19,6 +19,9 @@ other = "Ir al inicio"
[Edit-this-page]
other = "Editar"
[Print-this-chapter]
other = ""
[Shortcuts-Title]
other = "Más"

View file

@ -19,6 +19,9 @@ other = "Vers la page d'accueil"
[Edit-this-page]
other = "Éditer"
[Print-this-chapter]
other = ""
[Shortcuts-Title]
other = "Aller plus loin"

View file

@ -19,6 +19,9 @@ other = "मुख्य पृष्ठ पर जाऐ"
[Edit-this-page]
other = "संपादन करना"
[Print-this-chapter]
other = ""
[Shortcuts-Title]
other = "अधिक सामग्री दिखाएं"

View file

@ -19,6 +19,9 @@ other = "Ke halaman depan"
[Edit-this-page]
other = "Mengedit"
[Print-this-chapter]
other = ""
[Shortcuts-Title]
other = "Lainnya"

View file

@ -19,6 +19,9 @@ other = "ホームページへ行く"
[Edit-this-page]
other = "編集"
[Print-this-chapter]
other = ""
[Shortcuts-Title]
other = "更に"

View file

@ -19,6 +19,9 @@ other = "메인화면"
[Edit-this-page]
other = "편집"
[Print-this-chapter]
other = ""
[Shortcuts-Title]
other = "외부 링크"

View file

@ -19,6 +19,9 @@ other = "Naar startpagina"
[Edit-this-page]
other = "Bewerken"
[Print-this-chapter]
other = ""
[Shortcuts-Title]
other = "Snelkoppelingen"

View file

@ -19,6 +19,9 @@ other = "Go t' homeplank"
[Edit-this-page]
other = "Edit"
[Print-this-chapter]
other = "Prrrint whole chapterrr"
[Shortcuts-Title]
other = "Morrre"

View file

@ -19,6 +19,9 @@ other = "Ir para o início"
[Edit-this-page]
other = "Editar"
[Print-this-chapter]
other = ""
[Shortcuts-Title]
other = "Mais"

View file

@ -19,6 +19,9 @@ other = "Перейти на главную"
[Edit-this-page]
other = "редактировать"
[Print-this-chapter]
other = ""
[Shortcuts-Title]
other = "Еще"

View file

@ -19,6 +19,9 @@ other = "Anasayfaya dön"
[Edit-this-page]
other = "Düzenlemek"
[Print-this-chapter]
other = ""
[Shortcuts-Title]
other = "Dahası Var"

View file

@ -19,6 +19,9 @@ other = "Đi đến trang chủ"
[Edit-this-page]
other = "Biên tập"
[Print-this-chapter]
other = ""
[Shortcuts-Title]
other = "Nội dung khác"

View file

@ -19,6 +19,9 @@ other = "转到主页"
[Edit-this-page]
other = "编辑"
[Print-this-chapter]
other = ""
[Shortcuts-Title]
other = "更多"

View file

@ -1,3 +1,4 @@
{{- .Scratch.Set "relearnOutputFormat" "HTML" }}
<!DOCTYPE html>
<html lang="{{ .Page.Language | default "en" }}" class="js csstransforms3d">
<head>

View file

@ -1,4 +1,4 @@
<div class="mermaid" align="center">
{{- safeHTML .Inner -}}
</div>
{{- .Page.Store.Set "hasMermaid" true }}
{{- .Page.Store.Set "htmlHasMermaid" true }}

View file

@ -1,21 +1,4 @@
{{- .Scratch.Set "relearnOutputFormat" "HTML" }}
{{- partial "header.html" . }}
{{- if eq .Kind "section" }}
{{ partial "content.html" . }}
{{- end }}
{{- if or (eq .Kind "taxonomy") (eq .Kind "term") }}
<ul>
{{- range .Data.Terms.Alphabetical }}
{{- if and .Page.Title (or (ne (.Page.Scratch.Get "relearnIsHiddenStem") true) (ne .Page.Site.Params.disableTagHiddenPages true) ) }}
<li><a href="{{ .Page.RelPermalink }}">{{ .Page.Title }}</a> ({{ len .Pages }})</li>
{{- end }}
{{- else }}
{{- range sort .Pages "Title" }}
{{- if and .Title (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableTagHiddenPages true) ) }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{- end }}
{{- end }}
{{- end }}
</ul>
{{- end }}
{{- partial "content-screen.html" . }}
{{- partial "footer.html" . }}

View file

@ -0,0 +1,4 @@
{{- .Scratch.Set "relearnOutputFormat" "PRINT" }}
{{- partial "header.html" . }}
{{- partial "content-print.html" . }}
{{- partial "footer.html" . }}

View file

@ -1,4 +1,4 @@
{{- .Scratch.Set "relearnOutputFormat" "HTML" }}
{{- partial "header.html" . }}
{{ partial "content.html" . }}
{{- partial "content-screen.html" . }}
{{- partial "footer.html" . }}

View file

@ -0,0 +1,4 @@
{{- .Scratch.Set "relearnOutputFormat" "PRINT" }}
{{- partial "header.html" . }}
{{- partial "content-print.html" . }}
{{- partial "footer.html" . }}

View file

@ -0,0 +1,23 @@
{{- .Scratch.Set "relearnOutputFormat" "HTML" }}
{{- partial "header.html" . }}
<article>
<h1>{{ if eq .Kind "term" }}{{ .Data.Singular | humanize }} {{ default "::" .Site.Params.titleSeparator }} {{ end }}{{ .Title }}</h1>
<ul>
{{- range .Data.Terms.Alphabetical }}
{{- if and .Page.Title (or (ne (.Page.Scratch.Get "relearnIsHiddenStem") true) (ne .Page.Site.Params.disableTagHiddenPages true) ) }}
<li><a href="{{ .Page.RelPermalink }}">{{ .Page.Title }}</a> ({{ len .Pages }})</li>
{{- end }}
{{- else }}
{{- range sort .Pages "Title" }}
{{- if and .Title (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableTagHiddenPages true) ) }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{- end }}
{{- end }}
{{- end }}
</ul>
<footer class="footline">
</footer>
</article>
{{- partial "footer.html" . }}

View file

@ -0,0 +1,23 @@
{{- .Scratch.Set "relearnOutputFormat" "PRINT" }}
{{- partial "header.html" . }}
<article>
<h1>{{ if eq .Kind "term" }}{{ .Data.Singular | humanize }} {{ default "::" .Site.Params.titleSeparator }} {{ end }}{{ .Title }}</h1>
<ul>
{{- range .Data.Terms.Alphabetical }}
{{- if and .Page.Title (or (ne (.Page.Scratch.Get "relearnIsHiddenStem") true) (ne .Page.Site.Params.disableTagHiddenPages true) ) }}
<li><a href="{{ .Page.RelPermalink }}">{{ .Page.Title }}</a> ({{ len .Pages }})</li>
{{- end }}
{{- else }}
{{- range sort .Pages "Title" }}
{{- if and .Title (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableTagHiddenPages true) ) }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
{{- end }}
{{- end }}
{{- end }}
</ul>
<footer class="footline">
</footer>
</article>
{{- partial "footer.html" . }}

View file

@ -1,16 +1,22 @@
{{- .Scratch.Set "relearnOutputFormat" "HTML" }}
{{- partial "header.html" . }}
{{- if .Site.Home.Content }}
{{- partial "content-screen.html" .Site.Home }}
{{- else }}
<article>
{{if .Site.Home.Content }}
{{.Site.Home.Content}}
{{else}}
<h1>Customize your own home page</h1>
<p>
The site is working. Don't forget to customize this page with your own. You typically have 3 choices :
</p>
<ul>
<li><b>1. </b> Create an _index.md document in <b>content</b> folder and fill it with Markdown content</li>
<li><b>2. </b> Create an <b>index.html</b> file in the <b>static</b> folder and fill the file with HTML content</li>
<li><b>3. </b> Configure your server to automatically redirect home page to one your documentation page</li>
</ul>
{{ end }}
<h1>Customize your own home page</h1>
<p>
The site is working. Don't forget to customize this page with your own. You typically have 3 choices :
</p>
<ul>
<li><b>1.</b> Create an _index.md document in <b>content</b> folder and fill it with Markdown content</li>
<li><b>2.</b> Create an <b>index.html</b> file in the <b>static</b> folder and fill the file with HTML content</li>
<li><b>3.</b> Configure your server to automatically redirect home page to one your documentation page</li>
</ul>
<footer class="footline">
</footer>
</article>
{{- end }}
{{- partial "footer.html" . }}

22
layouts/index.print.html Normal file
View file

@ -0,0 +1,22 @@
{{- .Scratch.Set "relearnOutputFormat" "PRINT" }}
{{- partial "header.html" . }}
{{- if .Site.Home.Content }}
{{- partial "content-print.html" .Site.Home }}
{{- else }}
<article>
<h1>Customize your own home page</h1>
<p>
The site is working. Don't forget to customize this page with your own. You typically have 3 choices :
</p>
<ul>
<li><b>1.</b> Create an _index.md document in <b>content</b> folder and fill it with Markdown content</li>
<li><b>2.</b> Create an <b>index.html</b> file in the <b>static</b> folder and fill the file with HTML content</li>
<li><b>3.</b> Configure your server to automatically redirect home page to one your documentation page</li>
</ul>
<footer class="footline">
</footer>
</article>
{{- end }}
{{- partial "footer.html" . }}

View file

@ -0,0 +1,11 @@
{{- $content := .content }}
{{- with .page }}
<article{{if .Params.chapter}} class="chapter"{{end}}>
{{ if and (not .IsHome ) (not .Params.chapter) }}<h1>{{ .Title }}</h1>
{{ end }}{{ $content | safeHTML }}
<footer class="footline">
{{- partial "content-footer.html" . }}
</footer>
</article>
{{- end }}

View file

@ -0,0 +1,83 @@
{{- $isActive := .IsHome }}
{{- $currentNode := . }}
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
{{- $currentOrdersectionsby := .Site.Home.Params.ordersectionsby | default $defaultOrdersectionsby }}
{{- $pages := .Site.Home.Sections }}
{{- if $isActive }}
{{- template "section-print" dict "sect" . "currentnode" $currentNode }}
{{- if or .IsHome .Params.chapter $pages }}
<section>
{{- end }}
{{- end }}
{{- if eq $currentOrdersectionsby "title" }}
{{- range $pages.ByTitle }}
{{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "isActive" $isActive }}
{{- end }}
{{- else }}
{{- range $pages.ByWeight }}
{{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "isActive" $isActive }}
{{- end }}
{{- end }}
{{- if $isActive }}
{{- if or .IsHome .Params.chapter $pages }}
</section>
{{- end }}
{{- end }}
{{- define "section-tree-print" }}
{{- $isActive := .isActive }}
{{- $currentNode := .currentnode }}
{{- $currentFileRelPermalink := .currentnode.RelPermalink }}
{{- with .sect }}
{{- $currentIsActive := eq .RelPermalink $currentFileRelPermalink }}
{{- $isActive = or $currentIsActive $isActive }}
{{- $relearnIsHiddenFrom := index ($currentNode.Scratch.Get "relearnIsHiddenFrom") .RelPermalink }}
{{- $hidden := and $relearnIsHiddenFrom (not $.showhidden) (not (.IsAncestor $currentNode)) }}
{{- if $hidden }}
{{- else if or .IsSection .IsHome }}
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
{{- $currentOrdersectionsby := .Params.ordersectionsby | default $defaultOrdersectionsby }}
{{- $pages := .Pages }}
{{- if .Page.IsHome }}
{{- $pages = .Sections }}
{{- else if .Page.Sections}}
{{- $pages = (.Pages | union .Sections) }}
{{- end }}
{{- if $isActive }}
{{- template "section-print" dict "sect" . "currentnode" $currentNode }}
{{- if or .IsHome .Params.chapter $pages }}
<section>
{{- end }}
{{- end }}
{{- if eq $currentOrdersectionsby "title" }}
{{- range $pages.ByTitle }}
{{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "isActive" $isActive }}
{{- end }}
{{- else }}
{{- range $pages.ByWeight }}
{{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "isActive" $isActive }}
{{- end }}
{{- end }}
{{- if $isActive }}
{{- if or .IsHome .Params.chapter $pages }}
</section>
{{- end }}
{{- end }}
{{- else }}
{{- if $isActive }}
{{- template "section-print" dict "sect" . "currentnode" $currentNode }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- define "section-print" }}
{{- $currentNode := .currentnode }}
{{- with .sect }}
{{- $currentNode.Page.Store.Set "printHasMermaid" (or ($currentNode.Page.Store.Get "printHasMermaid") (.Page.Store.Get "htmlHasMermaid")) }}
{{- $currentNode.Page.Store.Set "printHasSwagger" (or ($currentNode.Page.Store.Get "printHasSwagger") (.Page.Store.Get "htmlHasSwagger")) }}
{{/* if we have a relative link in a print page, our print URL is one level to deep; so we are making it absolute to our page by prepending the page's permalink */}}
{{- $link_prefix := strings.TrimRight "/" .Page.RelPermalink }}
{{- $content := partial "content.html" . }}
{{- $content = replaceRE "((?:src|href)\\s*=(?:\\s*[\"']\\s*)?)(\\.[^\"'\\s>]*|[\\w]+[^\"'\\s>:]*)([\"'\\s>])" (printf "${1}%s/${2}${3}" $link_prefix) $content }}
{{- partial "article.html" (dict "page" . "content" $content) }}
{{- end }}
{{- end }}

View file

@ -0,0 +1 @@
{{- partial "article.html" (dict "page" . "content" .Content) }}

View file

@ -1 +1 @@
{{ .Content }}
{{- .Content }}

View file

@ -1,6 +1,4 @@
<footer class="footline">
{{- partial "content-footer.html" . }}
</footer>
</div>
</main><!-- #body-inner -->
{{- partial "custom-comments.html" . }}
@ -9,7 +7,8 @@
<script src="{{"js/clipboard.min.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script>
<script src="{{"js/perfect-scrollbar.min.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script>
<script src="{{"js/featherlight.min.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script>
{{- if (or (.Page.Store.Get "hasMermaid") (and (ne .Params.disableMermaid nil) (not .Params.disableMermaid)) (and (ne .Site.Params.disableMermaid nil) (not .Site.Params.disableMermaid)) ) }}
{{- $wantsMermaid := or (and (eq (.Scratch.Get "relearnOutputFormat") "HTML") (.Page.Store.Get "htmlHasMermaid")) (and (eq (.Scratch.Get "relearnOutputFormat") "PRINT") (.Page.Store.Get "printHasMermaid")) }}
{{- if (or $wantsMermaid (and (ne .Params.disableMermaid nil) (not .Params.disableMermaid)) (and (ne .Site.Params.disableMermaid nil) (not .Site.Params.disableMermaid)) ) }}
<script src="{{"js/jquery.svg.pan.zoom.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script>
{{- if isset .Params "custommermaidurl" }}
<script src="{{ .Params.customMermaidURL }}"></script>
@ -38,7 +37,8 @@
useMermaid( JSON.parse({{ $.Scratch.Get "mermaidInitialize" }}) );
</script>
{{- end }}
{{- if (or (.Page.Store.Get "hasSwagger") (and (ne .Params.disableSwagger nil) (not .Params.disableSwagger)) (and (ne .Site.Params.disableSwagger nil) (not .Site.Params.disableSwagger)) ) }}
{{- $wantsSwagger := or (and (eq (.Scratch.Get "relearnOutputFormat") "HTML") (.Page.Store.Get "htmlHasSwagger")) (and (eq (.Scratch.Get "relearnOutputFormat") "PRINT") (.Page.Store.Get "printHasSwagger")) }}
{{- if (or $wantsSwagger (and (ne .Params.disableSwagger nil) (not .Params.disableSwagger)) (and (ne .Site.Params.disableSwagger nil) (not .Site.Params.disableSwagger)) ) }}
{{- if isset .Params "customswaggerurl" }}
<script src="{{ .Params.customSwaggerURL }}"></script>
{{- else if isset .Site.Params "customswaggerurl" }}

View file

@ -24,7 +24,7 @@
{{- partial "stylesheet.html" . }}
{{- partial "custom-header.html" . }}
</head>
<body class="mobile-support" data-url="{{ .RelPermalink }}">
<body class="mobile-support{{ if eq (.Scratch.Get "relearnOutputFormat") "PRINT" }} print{{ end }}" data-url="{{ .RelPermalink }}">
<div id="body" class="default-animation">
<div id="sidebar-overlay"></div>
<div id="toc-overlay"></div>
@ -56,6 +56,13 @@
{{- end}}
</div>
{{- end }}
{{- with .OutputFormats.Get "PRINT" }}
<div id="top-print-link">
<a class="print-link" title='{{ T "Print-this-chapter" }}' href="{{ .RelPermalink }}">
<i class="fas fa-print fa-fw"></i>
</a>
</div>
{{- end -}}
{{- if .Site.Params.editURL }}
{{- $File := .File }}
{{- $Site := .Site }}
@ -97,15 +104,11 @@
{{- end }}
</div>
</nav>
<main id="body-inner" class="highlightable {{if .Params.chapter}} chapter{{end}}">
<main id="body-inner" class="highlightable{{if .Params.chapter}} chapter{{end}}">
<div class="flex-block-wrapper">
<div id="head-tags">
{{- partial "tags.html" . }}
</div>
{{- if and (not .IsHome) (not .Params.chapter) }}
<h1>{{ if eq .Kind "term" }}{{ .Data.Singular | humanize }} {{ default "::" .Site.Params.titleSeparator }} {{ end }}{{ .Title }}</h1>
{{- end }}
{{- define "breadcrumb" }}
{{- $parent := .page.Parent }}
{{- $ispublished := gt (int (len .page.Permalink)) 0 }}

View file

@ -26,11 +26,11 @@
{{- $defaultAlwaysopen := .Site.Params.alwaysopen | default false }}
{{- if eq $currentOrdersectionsby "title" }}
{{- range .Site.Home.Sections.ByTitle }}
{{- template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" $defaultAlwaysopen }}
{{- template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" $defaultAlwaysopen }}
{{- end }}
{{- else }}
{{- range .Site.Home.Sections.ByWeight }}
{{- template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" $defaultAlwaysopen }}
{{- template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" $defaultAlwaysopen }}
{{- end }}
{{- end }}
</ul>
@ -140,7 +140,7 @@
{{- end }}
{{- else }}
{{- range $pages.ByWeight }}
{{- template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" $defaultAlwaysopen }}
{{- template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" $defaultAlwaysopen }}
{{- end }}
{{- end }}</ul></li>
{{- else }}

View file

@ -10,8 +10,7 @@
<link href="{{(printf "css/theme-%s.css" .) | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet" id="variant-style">
{{- end }}
<link href="{{"css/variant.css" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
<link href="{{"css/theme-relearn-light.css" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet" media="print">
<link href="{{"css/print.css" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet" media="print">
<link href="{{"css/print.css" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet"{{ if ne (.Scratch.Get "relearnOutputFormat") "PRINT" }} media="print"{{ end }}>
{{- range .Site.Params.custom_css }}
<link href="{{(printf "%s" .) | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
{{- end }}

View file

@ -2,4 +2,4 @@
<div class="mermaid" align="{{ if .Get "align" }}{{ .Get "align" }}{{ else }}center{{ end }}">
{{- safeHTML .Inner -}}
</div>
{{- .Page.Store.Set "hasMermaid" true }}
{{- .Page.Store.Set "htmlHasMermaid" true }}

View file

@ -17,4 +17,4 @@
spec-url="{{ $original }}"
sort-tags="true"
></rapi-doc>
{{- .Page.Store.Set "hasSwagger" true }}
{{- .Page.Store.Set "htmlHasSwagger" true }}

View file

@ -1,3 +1,5 @@
@import "theme-relearn-light.css";
#sidebar {
display: none;
}
@ -36,6 +38,7 @@ pre {
color: #777;
}
.navigation,
#top-print-link,
#top-github-link {
/* we don't need this while printing */
display: none;
@ -45,6 +48,7 @@ pre {
}
#body #breadcrumbs .links {
overflow-x: hidden;
visibility: visible;
}
.copy-to-clipboard-button {
display: none;
@ -77,11 +81,23 @@ body,
#body-inner {
overflow: visible !important; /* turn off limitations for perfect scrollbar */
}
#body-inner.chapter h1 {
#body #body-inner {
/* reset paddings for chapters in screen */
padding: 0 3rem 4rem 3rem;
}
#body #body-inner h1 {
border-bottom: 1px solid #ddd;
margin-bottom: 2rem;
padding-bottom: .75rem;
}
#body-inner .chapter h3:first-of-type {
margin-top: 2rem;
}
#body-inner .chapter p {
font-size: 1rem;
}
.footline {
/* in print mode show footer line to signal reader the end of document */
border-top: 1px solid #ddd;
@ -103,7 +119,7 @@ body,
/* we don't need this while printing */
display: none;
}
#sidebar-toggle-span {
#body #sidebar-toggle-span {
/* we don't need this while printing */
display: none;
}
@ -154,3 +170,10 @@ rapi-doc{
#body .tab-nav-button:not(.active) {
opacity: 1;
}
article {
break-before: page;
}
#body-inner article:first-of-type {
break-before: avoid;
}

View file

@ -217,7 +217,6 @@ body div.box.transparent {
#body h4,
#body h5,
#body h6 {
color: #fff;
text-shadow: none;
}
#body div.box,
@ -226,3 +225,19 @@ body div.box.transparent {
text-shadow: none;
}
}
/* if we are in print chapter preview our @media statement from
above will not apply, so we have to repeat it here */
.print #body h1,
.print #body h2,
.print #body h3,
.print #body h4,
.print #body h5,
.print #body h6 {
text-shadow: none;
}
.print #body div.box,
.print #body div.box > .box-label {
box-shadow: none;
text-shadow: none;
}

View file

@ -63,16 +63,16 @@ body {
width: 100%;
}
body #body-inner.chapter h1 {
body #body-inner .chapter h1 {
font-size: 3.5rem;
}
@media only all and (min-width: 48em) and (max-width: 59.938em) {
body #body-inner.chapter h1 {
font-size: 3rem;
@media only screen and (min-width: 48em) and (max-width: 59.938em) {
body #body-inner .chapter h1 {
font-size: 2.8rem;
}
}
@media only all and (max-width: 47.938em) {
body #body-inner.chapter h1 {
@media only screen and (max-width: 47.938em) {
body #body-inner .chapter h1 {
font-size: 2rem;
}
}
@ -437,18 +437,18 @@ th {
}
}
#body-inner.chapter h3:first-of-type {
#body-inner .chapter h3:first-of-type {
font-weight: 200;
margin-top: 0;
text-align: center;
}
#body-inner.chapter h1 {
#body-inner .chapter h1 {
border-bottom: 4px solid rgba( 134, 134, 134, .125 );
font-size: 5rem;
}
#body-inner.chapter p {
#body-inner .chapter p {
font-size: 1.2rem;
text-align: justify;
}
@ -938,12 +938,14 @@ td {
}
.navigation,
#top-print-link,
#top-github-link {
display: block;
float: right;
}
.nav,
.print-link,
.github-link {
border-left: thin solid rgba( 134, 134, 134, .333 );
padding-left: 1rem;
@ -954,6 +956,7 @@ span.nav i{
}
.navigation,
#top-print-link,
#top-github-link {
position: relative;
top: 50%;
@ -982,7 +985,7 @@ span.nav i{
top: 50%;
transform: translateY(-50%);
white-space: nowrap;
width: calc(100% - 4*3.25rem);
width: calc(100% - 5*3.25rem);
}
@media screen and (max-width: 47.938em) {
#body #breadcrumbs {
@ -1278,6 +1281,7 @@ option {
#body .navigation a.highlight:after,
#body #sidebar-toggle-span a.highlight:after,
#body #top-print-link a.highlight:after,
#body #top-github-link a.highlight:after {
background-color: transparent;
}
@ -1529,7 +1533,7 @@ rapi-doc {
}
@media screen and (max-width: 47.938em) {
#breadcrumbs .links, #top-github-link-text {
#breadcrumbs .links {
display: none;
}
}

View file

@ -7,6 +7,8 @@ if( isIE ){
else{
document.querySelector( 'body' ).classList.add( 'mobile-support' );
}
var isPrint = document.querySelector( 'body' ).classList.contains( 'print' );
var touchsupport = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0)
var formelements = 'button, datalist, fieldset, input, label, legend, meter, optgroup, option, output, progress, select, textarea';
@ -295,6 +297,10 @@ function initArrowNav(){
}
function initMenuScrollbar(){
if( isPrint ){
return;
}
var content = '#body-inner';
if( isIE ){
// IE can not display the topbar as sticky; so we let