diff --git a/README.md b/README.md index 9b9fb62498..2b631d9d54 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/config.toml b/config.toml index 28af7b764d..bdbf019168 100644 --- a/config.toml +++ b/config.toml @@ -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 diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 2ffcf7e1f6..cb92d7be3b 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -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] diff --git a/exampleSite/content/_index.en.md b/exampleSite/content/_index.en.md index 292fe77299..d2932e1f7c 100644 --- a/exampleSite/content/_index.en.md +++ b/exampleSite/content/_index.en.md @@ -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 diff --git a/exampleSite/content/basics/configuration/_index.en.md b/exampleSite/content/basics/configuration/_index.en.md index a90bbd1742..f766047712 100644 --- a/exampleSite/content/basics/configuration/_index.en.md +++ b/exampleSite/content/basics/configuration/_index.en.md @@ -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 doesn’t 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. diff --git a/exampleSite/content/basics/migration/_index.en.md b/exampleSite/content/basics/migration/_index.en.md index 5ec65e6ff9..4fc255c113 100644 --- a/exampleSite/content/basics/migration/_index.en.md +++ b/exampleSite/content/basics/migration/_index.en.md @@ -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 diff --git a/exampleSite/content/tests/code/_index.en.md b/exampleSite/content/tests/code/_index.en.md index 4c4a8cd93d..df9b895a88 100644 --- a/exampleSite/content/tests/code/_index.en.md +++ b/exampleSite/content/tests/code/_index.en.md @@ -1,4 +1,5 @@ +++ +description = "Some testing for different styles used in syntax highlightning and preformatted blocks" title = "Code" +++ diff --git a/exampleSite/content/tests/code/_index.pir.md b/exampleSite/content/tests/code/_index.pir.md index a384d10cf8..3207c1936c 100644 --- a/exampleSite/content/tests/code/_index.pir.md +++ b/exampleSite/content/tests/code/_index.pir.md @@ -1,4 +1,5 @@ +++ +description = "Some test'n fer different styles used 'n rules highlightn'n an' preformatted blocks" title = "Code" +++ {{< piratify >}} \ No newline at end of file diff --git a/exampleSite/content/tests/images/_index.en.md b/exampleSite/content/tests/images/_index.en.md new file mode 100644 index 0000000000..bd2d96fb80 --- /dev/null +++ b/exampleSite/content/tests/images/_index.en.md @@ -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 + +

+ +### Relative to page up level + +

+ +### Static + +

+ +### External fully qualified + +

+ +### External without scheme + +

+ +### External without scheme and scheme separator + +

diff --git a/exampleSite/content/tests/images/_index.pir.md b/exampleSite/content/tests/images/_index.pir.md new file mode 100644 index 0000000000..ce50b9d5fe --- /dev/null +++ b/exampleSite/content/tests/images/_index.pir.md @@ -0,0 +1,5 @@ ++++ +description = "Some test'n fer different styles o' image links" +title = "Images" ++++ +{{< piratify >}} \ No newline at end of file diff --git a/exampleSite/content/tests/images/images/magic.gif b/exampleSite/content/tests/images/images/magic.gif new file mode 100644 index 0000000000..235c4edb32 Binary files /dev/null and b/exampleSite/content/tests/images/images/magic.gif differ diff --git a/exampleSite/content/tests/links/_index.en.md b/exampleSite/content/tests/links/_index.en.md new file mode 100644 index 0000000000..eefc343598 --- /dev/null +++ b/exampleSite/content/tests/links/_index.en.md @@ -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) diff --git a/exampleSite/content/tests/links/_index.pir.md b/exampleSite/content/tests/links/_index.pir.md new file mode 100644 index 0000000000..1588583b66 --- /dev/null +++ b/exampleSite/content/tests/links/_index.pir.md @@ -0,0 +1,5 @@ ++++ +description = "Some test'n fer different styles o' links" +title = "Links" ++++ +{{< piratify >}} \ No newline at end of file diff --git a/i18n/ar.toml b/i18n/ar.toml index 73498145ce..bbe66ea2b8 100644 --- a/i18n/ar.toml +++ b/i18n/ar.toml @@ -19,6 +19,9 @@ other = "الذهاب إلى الصفحة الرئيسية" [Edit-this-page] other = "حرر" +[Print-this-chapter] +other = "" + [Shortcuts-Title] other = "المزيد" diff --git a/i18n/de.toml b/i18n/de.toml index 4c5f6550c4..4fc1fd34ad 100644 --- a/i18n/de.toml +++ b/i18n/de.toml @@ -19,6 +19,9 @@ other = "Gehe zur Homepage" [Edit-this-page] other = "Bearbeiten" +[Print-this-chapter] +other = "Ganzes Kapitel drucken" + [Shortcuts-Title] other = "Mehr" diff --git a/i18n/en.toml b/i18n/en.toml index 1d3c05d9f0..93b46c3c6f 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -19,6 +19,9 @@ other = "Go to homepage" [Edit-this-page] other = "Edit" +[Print-this-chapter] +other = "Print whole chapter" + [Shortcuts-Title] other = "More" diff --git a/i18n/es.toml b/i18n/es.toml index 7cffda0f83..acd715526e 100644 --- a/i18n/es.toml +++ b/i18n/es.toml @@ -19,6 +19,9 @@ other = "Ir al inicio" [Edit-this-page] other = "Editar" +[Print-this-chapter] +other = "" + [Shortcuts-Title] other = "Más" diff --git a/i18n/fr.toml b/i18n/fr.toml index 480c6f03ea..ef45dffb74 100644 --- a/i18n/fr.toml +++ b/i18n/fr.toml @@ -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" diff --git a/i18n/hi.toml b/i18n/hi.toml index fd5a99a587..adb62f0336 100644 --- a/i18n/hi.toml +++ b/i18n/hi.toml @@ -19,6 +19,9 @@ other = "मुख्य पृष्ठ पर जाऐ" [Edit-this-page] other = "संपादन करना" +[Print-this-chapter] +other = "" + [Shortcuts-Title] other = "अधिक सामग्री दिखाएं" diff --git a/i18n/id.toml b/i18n/id.toml index 9ccf61c247..d849ebe94e 100644 --- a/i18n/id.toml +++ b/i18n/id.toml @@ -19,6 +19,9 @@ other = "Ke halaman depan" [Edit-this-page] other = "Mengedit" +[Print-this-chapter] +other = "" + [Shortcuts-Title] other = "Lainnya" diff --git a/i18n/ja.toml b/i18n/ja.toml index c4b8e16d96..25f9616f0e 100644 --- a/i18n/ja.toml +++ b/i18n/ja.toml @@ -19,6 +19,9 @@ other = "ホームページへ行く" [Edit-this-page] other = "編集" +[Print-this-chapter] +other = "" + [Shortcuts-Title] other = "更に" diff --git a/i18n/kr.toml b/i18n/kr.toml index b235ed646c..47e399df3d 100644 --- a/i18n/kr.toml +++ b/i18n/kr.toml @@ -19,6 +19,9 @@ other = "메인화면" [Edit-this-page] other = "편집" +[Print-this-chapter] +other = "" + [Shortcuts-Title] other = "외부 링크" diff --git a/i18n/nl.toml b/i18n/nl.toml index 599a13c43c..c919a035f9 100644 --- a/i18n/nl.toml +++ b/i18n/nl.toml @@ -19,6 +19,9 @@ other = "Naar startpagina" [Edit-this-page] other = "Bewerken" +[Print-this-chapter] +other = "" + [Shortcuts-Title] other = "Snelkoppelingen" diff --git a/i18n/pir.toml b/i18n/pir.toml index 8e7dc2bae2..57e9dd0c6e 100644 --- a/i18n/pir.toml +++ b/i18n/pir.toml @@ -19,6 +19,9 @@ other = "Go t' homeplank" [Edit-this-page] other = "Edit" +[Print-this-chapter] +other = "Prrrint whole chapterrr" + [Shortcuts-Title] other = "Morrre" diff --git a/i18n/pt.toml b/i18n/pt.toml index 9410988a9a..00ff652cd9 100644 --- a/i18n/pt.toml +++ b/i18n/pt.toml @@ -19,6 +19,9 @@ other = "Ir para o início" [Edit-this-page] other = "Editar" +[Print-this-chapter] +other = "" + [Shortcuts-Title] other = "Mais" diff --git a/i18n/ru.toml b/i18n/ru.toml index 3d8cf0c861..cf23a35e80 100644 --- a/i18n/ru.toml +++ b/i18n/ru.toml @@ -19,6 +19,9 @@ other = "Перейти на главную" [Edit-this-page] other = "редактировать" +[Print-this-chapter] +other = "" + [Shortcuts-Title] other = "Еще" diff --git a/i18n/tr.toml b/i18n/tr.toml index 9b71b2cb1b..9e7fb10878 100644 --- a/i18n/tr.toml +++ b/i18n/tr.toml @@ -19,6 +19,9 @@ other = "Anasayfaya dön" [Edit-this-page] other = "Düzenlemek" +[Print-this-chapter] +other = "" + [Shortcuts-Title] other = "Dahası Var" diff --git a/i18n/vn.toml b/i18n/vn.toml index ddd45106a8..7cad5b8e85 100644 --- a/i18n/vn.toml +++ b/i18n/vn.toml @@ -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" diff --git a/i18n/zh-cn.toml b/i18n/zh-cn.toml index 9fd215917b..484fc1e515 100644 --- a/i18n/zh-cn.toml +++ b/i18n/zh-cn.toml @@ -19,6 +19,9 @@ other = "转到主页" [Edit-this-page] other = "编辑" +[Print-this-chapter] +other = "" + [Shortcuts-Title] other = "更多" diff --git a/layouts/404.html b/layouts/404.html index 4e6e10377f..a09c8362f8 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -1,3 +1,4 @@ +{{- .Scratch.Set "relearnOutputFormat" "HTML" }} diff --git a/layouts/_default/_markup/render-codeblock-mermaid.html b/layouts/_default/_markup/render-codeblock-mermaid.html index 91940913f8..ee8fb37464 100644 --- a/layouts/_default/_markup/render-codeblock-mermaid.html +++ b/layouts/_default/_markup/render-codeblock-mermaid.html @@ -1,4 +1,4 @@
{{- safeHTML .Inner -}}
-{{- .Page.Store.Set "hasMermaid" true }} +{{- .Page.Store.Set "htmlHasMermaid" true }} diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 4360d5edcc..d93ea31852 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -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") }} - - {{- end }} +{{- partial "content-screen.html" . }} {{- partial "footer.html" . }} \ No newline at end of file diff --git a/layouts/_default/list.print.html b/layouts/_default/list.print.html new file mode 100644 index 0000000000..4c2b2ac9e0 --- /dev/null +++ b/layouts/_default/list.print.html @@ -0,0 +1,4 @@ +{{- .Scratch.Set "relearnOutputFormat" "PRINT" }} +{{- partial "header.html" . }} +{{- partial "content-print.html" . }} +{{- partial "footer.html" . }} \ No newline at end of file diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 3ae3b29397..d93ea31852 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,4 +1,4 @@ +{{- .Scratch.Set "relearnOutputFormat" "HTML" }} {{- partial "header.html" . }} - -{{ partial "content.html" . }} +{{- partial "content-screen.html" . }} {{- partial "footer.html" . }} \ No newline at end of file diff --git a/layouts/_default/single.print.html b/layouts/_default/single.print.html new file mode 100644 index 0000000000..4c2b2ac9e0 --- /dev/null +++ b/layouts/_default/single.print.html @@ -0,0 +1,4 @@ +{{- .Scratch.Set "relearnOutputFormat" "PRINT" }} +{{- partial "header.html" . }} +{{- partial "content-print.html" . }} +{{- partial "footer.html" . }} \ No newline at end of file diff --git a/layouts/_default/taxonomy.html b/layouts/_default/taxonomy.html new file mode 100644 index 0000000000..8a1a940af8 --- /dev/null +++ b/layouts/_default/taxonomy.html @@ -0,0 +1,23 @@ +{{- .Scratch.Set "relearnOutputFormat" "HTML" }} +{{- partial "header.html" . }} +
+ +

{{ if eq .Kind "term" }}{{ .Data.Singular | humanize }} {{ default "::" .Site.Params.titleSeparator }} {{ end }}{{ .Title }}

+ + + +
+{{- partial "footer.html" . }} \ No newline at end of file diff --git a/layouts/_default/taxonomy.print.html b/layouts/_default/taxonomy.print.html new file mode 100644 index 0000000000..f747eea81f --- /dev/null +++ b/layouts/_default/taxonomy.print.html @@ -0,0 +1,23 @@ +{{- .Scratch.Set "relearnOutputFormat" "PRINT" }} +{{- partial "header.html" . }} +
+ +

{{ if eq .Kind "term" }}{{ .Data.Singular | humanize }} {{ default "::" .Site.Params.titleSeparator }} {{ end }}{{ .Title }}

+ + + +
+{{- partial "footer.html" . }} \ No newline at end of file diff --git a/layouts/index.html b/layouts/index.html index 1bfd71053a..e6c1830cd8 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,16 +1,22 @@ +{{- .Scratch.Set "relearnOutputFormat" "HTML" }} {{- partial "header.html" . }} +{{- if .Site.Home.Content }} + {{- partial "content-screen.html" .Site.Home }} +{{- else }} +
-{{if .Site.Home.Content }} -{{.Site.Home.Content}} -{{else}} -

Customize your own home page

-

- The site is working. Don't forget to customize this page with your own. You typically have 3 choices : -

- -{{ end }} +

Customize your own home page

+

+ The site is working. Don't forget to customize this page with your own. You typically have 3 choices : +

+ + + +
+{{- end }} {{- partial "footer.html" . }} \ No newline at end of file diff --git a/layouts/index.print.html b/layouts/index.print.html new file mode 100644 index 0000000000..a04c5856a8 --- /dev/null +++ b/layouts/index.print.html @@ -0,0 +1,22 @@ +{{- .Scratch.Set "relearnOutputFormat" "PRINT" }} +{{- partial "header.html" . }} +{{- if .Site.Home.Content }} + {{- partial "content-print.html" .Site.Home }} +{{- else }} +
+ +

Customize your own home page

+

+ The site is working. Don't forget to customize this page with your own. You typically have 3 choices : +

+ + + +
+{{- end }} +{{- partial "footer.html" . }} \ No newline at end of file diff --git a/layouts/partials/article.html b/layouts/partials/article.html new file mode 100644 index 0000000000..1564dfab01 --- /dev/null +++ b/layouts/partials/article.html @@ -0,0 +1,11 @@ +{{- $content := .content }} +{{- with .page }} + + +{{ if and (not .IsHome ) (not .Params.chapter) }}

{{ .Title }}

+{{ end }}{{ $content | safeHTML }} + + +{{- end }} \ No newline at end of file diff --git a/layouts/partials/content-print.html b/layouts/partials/content-print.html new file mode 100644 index 0000000000..07abccb2a6 --- /dev/null +++ b/layouts/partials/content-print.html @@ -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 }} +
+ {{- 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 }} +
+ {{- 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 }} +
+ {{- 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 }} +
+ {{- 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 }} \ No newline at end of file diff --git a/layouts/partials/content-screen.html b/layouts/partials/content-screen.html new file mode 100644 index 0000000000..a92573d683 --- /dev/null +++ b/layouts/partials/content-screen.html @@ -0,0 +1 @@ +{{- partial "article.html" (dict "page" . "content" .Content) }} \ No newline at end of file diff --git a/layouts/partials/content.html b/layouts/partials/content.html index fb3ffc233c..ceeab0ce02 100644 --- a/layouts/partials/content.html +++ b/layouts/partials/content.html @@ -1 +1 @@ -{{ .Content }} \ No newline at end of file +{{- .Content }} \ No newline at end of file diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 4b9d154cf8..612cc8da45 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -1,6 +1,4 @@ - + {{- partial "custom-comments.html" . }} @@ -9,7 +7,8 @@ -{{- 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)) ) }} {{- if isset .Params "custommermaidurl" }} @@ -38,7 +37,8 @@ useMermaid( JSON.parse({{ $.Scratch.Get "mermaidInitialize" }}) ); {{- 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" }} {{- else if isset .Site.Params "customswaggerurl" }} diff --git a/layouts/partials/header.html b/layouts/partials/header.html index ab458f69af..23831ff6e4 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -24,7 +24,7 @@ {{- partial "stylesheet.html" . }} {{- partial "custom-header.html" . }} - +
@@ -56,6 +56,13 @@ {{- end}}
{{- end }} + {{- with .OutputFormats.Get "PRINT" }} + + {{- end -}} {{- if .Site.Params.editURL }} {{- $File := .File }} {{- $Site := .Site }} @@ -97,15 +104,11 @@ {{- end }} -
+
{{- partial "tags.html" . }}
- {{- if and (not .IsHome) (not .Params.chapter) }} -

{{ if eq .Kind "term" }}{{ .Data.Singular | humanize }} {{ default "::" .Site.Params.titleSeparator }} {{ end }}{{ .Title }}

- {{- end }} - {{- define "breadcrumb" }} {{- $parent := .page.Parent }} {{- $ispublished := gt (int (len .page.Permalink)) 0 }} diff --git a/layouts/partials/menu.html b/layouts/partials/menu.html index 7b98c57f59..f3a3f8f481 100644 --- a/layouts/partials/menu.html +++ b/layouts/partials/menu.html @@ -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 }} @@ -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 }} {{- else }} diff --git a/layouts/partials/stylesheet.html b/layouts/partials/stylesheet.html index e4d93a2c61..aeea83e5c8 100644 --- a/layouts/partials/stylesheet.html +++ b/layouts/partials/stylesheet.html @@ -10,8 +10,7 @@ {{- end }} - - + {{- range .Site.Params.custom_css }} {{- end }} diff --git a/layouts/shortcodes/mermaid.html b/layouts/shortcodes/mermaid.html index 314162e42b..2a8f134781 100644 --- a/layouts/shortcodes/mermaid.html +++ b/layouts/shortcodes/mermaid.html @@ -2,4 +2,4 @@
{{- safeHTML .Inner -}}
-{{- .Page.Store.Set "hasMermaid" true }} \ No newline at end of file +{{- .Page.Store.Set "htmlHasMermaid" true }} \ No newline at end of file diff --git a/layouts/shortcodes/swagger.html b/layouts/shortcodes/swagger.html index 8bcf0fa529..1f65e4a3e4 100644 --- a/layouts/shortcodes/swagger.html +++ b/layouts/shortcodes/swagger.html @@ -17,4 +17,4 @@ spec-url="{{ $original }}" sort-tags="true" > -{{- .Page.Store.Set "hasSwagger" true }} \ No newline at end of file +{{- .Page.Store.Set "htmlHasSwagger" true }} \ No newline at end of file diff --git a/static/css/print.css b/static/css/print.css index 3613f5d356..76911af1e0 100644 --- a/static/css/print.css +++ b/static/css/print.css @@ -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; +} diff --git a/static/css/theme-neon.css b/static/css/theme-neon.css index da0418f421..f53765aedb 100644 --- a/static/css/theme-neon.css +++ b/static/css/theme-neon.css @@ -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; +} diff --git a/static/css/theme.css b/static/css/theme.css index 95b1d3c917..9ca9c95f0b 100644 --- a/static/css/theme.css +++ b/static/css/theme.css @@ -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; } } diff --git a/static/js/theme.js b/static/js/theme.js index 25191f5ab1..8d7c3f32f4 100644 --- a/static/js/theme.js +++ b/static/js/theme.js @@ -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