From 44f7ff47eebd1a552b906059400888958f2709ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Wed, 29 Jan 2025 14:19:21 +0100 Subject: [PATCH] theme: add new source output format #1001 --- exampleSite/config/_default/params.toml | 8 ++++- .../frontmatter/reference/frontmatter.toml | 8 ++++- .../authoring/frontmatter/topbar/_index.en.md | 15 ++++++-- .../frontmatter/topbar/_index.pir.md | 6 ++-- .../customization/topbar/_index.en.md | 3 +- .../customization/topbar/_index.pir.md | 2 +- .../sitemanagement/outputformats/_index.en.md | 36 +++++++++++++++++-- .../outputformats/_index.pir.md | 2 +- .../introduction/releasenotes/7/3.en.md | 4 +-- .../introduction/releasenotes/7/4.en.md | 4 +++ exampleSite/i18n/art-x-pir.toml | 3 ++ hugo.toml | 8 +++++ i18n/ar.toml | 3 ++ i18n/cs.toml | 3 ++ i18n/de.toml | 3 ++ i18n/en.toml | 3 ++ i18n/es.toml | 3 ++ i18n/fa.toml | 3 ++ i18n/fi.toml | 3 ++ i18n/fr.toml | 3 ++ i18n/hi.toml | 3 ++ i18n/hu.toml | 3 ++ i18n/id.toml | 3 ++ i18n/it.toml | 3 ++ i18n/ja.toml | 3 ++ i18n/ko.toml | 3 ++ i18n/nl.toml | 3 ++ i18n/pl.toml | 3 ++ i18n/pt.toml | 3 ++ i18n/ro.toml | 3 ++ i18n/ru.toml | 3 ++ i18n/sw.toml | 3 ++ i18n/tr.toml | 3 ++ i18n/vi.toml | 3 ++ i18n/zh-CN.toml | 3 ++ i18n/zh-Hans.toml | 3 ++ i18n/zh-Hant.toml | 3 ++ i18n/zh-TW.toml | 3 ++ i18n/zh.toml | 3 ++ layouts/_default/baseof.md | 8 +++-- layouts/_default/baseof.source.md | 4 +++ layouts/_default/list.source.md | 1 + layouts/_default/single.source.md | 1 + layouts/partials/topbar/area/end.html | 3 ++ layouts/partials/topbar/button/source.html | 22 ++++++++++++ layouts/partials/version.txt | 2 +- 46 files changed, 201 insertions(+), 20 deletions(-) create mode 100644 layouts/_default/baseof.source.md create mode 100644 layouts/_default/list.source.md create mode 100644 layouts/_default/single.source.md create mode 100644 layouts/partials/topbar/button/source.html diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index 14de3a6a1d..9fca83b06a 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -141,7 +141,13 @@ disableBreadcrumb = false # This can be overridden in the page's frontmatter. disableMarkdownButton = false -# Hide the print button. +# Hide the Source button. +# Default: false +# This hides the Source button if you activated the Source output format. +# This can be overridden in the page's frontmatter. +disableSourceButton = false + +# Hide the Print button. # Default: false # This hides the print button if you activated the print output format. # This can be overridden in the page's frontmatter. diff --git a/exampleSite/content/authoring/frontmatter/reference/frontmatter.toml b/exampleSite/content/authoring/frontmatter/reference/frontmatter.toml index 817d92f3e8..3e0514a93a 100644 --- a/exampleSite/content/authoring/frontmatter/reference/frontmatter.toml +++ b/exampleSite/content/authoring/frontmatter/reference/frontmatter.toml @@ -58,7 +58,13 @@ disableBreadcrumb = false # If not set, the set value of your site's hugo.toml is used. disableMarkdownButton = false -# Hide the print button. +# Hide the Source button. +# Default: false +# This hides the Source button if you activated the Source output format. +# If not set, the set value of your site's hugo.toml is used. +disableSourceButton = false + +# Hide the Print button. # Default: false # This hides the print button if you activated the print output format. # If not set, the set value of your site's hugo.toml is used. diff --git a/exampleSite/content/authoring/frontmatter/topbar/_index.en.md b/exampleSite/content/authoring/frontmatter/topbar/_index.en.md index 917100cc8c..8845fd26c1 100644 --- a/exampleSite/content/authoring/frontmatter/topbar/_index.en.md +++ b/exampleSite/content/authoring/frontmatter/topbar/_index.en.md @@ -1,9 +1,9 @@ +++ categories = ["howto"] description = "Configure the topbar" -frontmatter = ["disableBreadcrumb", "disableNextPrev", "disableMarkdownButton", "disablePrintButton", "disableToc", "editURL"] -options = ["disableBreadcrumb", "disableNextPrev", "disableMarkdownButton", "disablePrintButton", "disableToc", "editURL"] -outputs = ["html", "rss", "print", "markdown"] +frontmatter = ["disableBreadcrumb", "disableNextPrev", "disableMarkdownButton", "disableSourceButton", "disablePrintButton", "disableToc", "editURL"] +options = ["disableBreadcrumb", "disableNextPrev", "disableMarkdownButton", "disableSourceButton", "disablePrintButton", "disableToc", "editURL"] +outputs = ["html", "rss", "print", "markdown", "source"] title = "Topbar" weight = 4 +++ @@ -16,6 +16,7 @@ Your topbar contains the following elements. Some of them are configuarable: - {{% button style="transparent" icon="list-alt" %}}{{% /button %}} **toc**: [opens the table of contents in an overlay](#table-of-contents) - {{% button style="transparent" icon="empty" %}}{{% /button %}} **breadcrumb**: shows the clickable [breadcrumbs](#breadcrumbs) - {{% button style="transparent" icon="pen" %}}{{% /button %}} **edit**: browses to the editable page if the `editURL` [parameter is set](#edit-button) +- {{% button style="transparent" icon="file-code" %}}{{% /button %}} **source**: browses to the [chapters source code](#source-button) if [source support](configuration/sitemanagement/outputformats#source-support) was activated - {{% button style="transparent" icon="fa-fw fab fa-markdown" %}}{{% /button %}} **markdown**: browses to the [chapters Markdown source](#markdown-button) if [markdown support](configuration/sitemanagement/outputformats#markdown-support) was activated - {{% button style="transparent" icon="print" %}}{{% /button %}} **print**: browses to the [chapters printable page](#print-button) if [print support](configuration/sitemanagement/outputformats#print-support) was activated - {{% button style="transparent" icon="chevron-left" %}}{{% /button %}} **prev**: browses to the [previous page](#arrow-navigation) if there is one @@ -58,6 +59,14 @@ editURL = 'https://github.com/McShelby/hugo-theme-relearn/edit/main/exampleSite/ disableMarkdownButton = true {{< /multiconfig >}} +## Source Button + +{{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} {{% badge style="green" icon="fa-fw fab fa-markdown" title=" " %}}Front Matter{{% /badge %}} You can hide the Source button if the [Source output format](configuration/sitemanagement/outputformats/#source-support) is active by setting `disableSourceButton=true`. + +{{< multiconfig >}} +disableSourceButton = true +{{< /multiconfig >}} + ## Print Button {{% badge style="cyan" icon="gears" title=" " %}}Option{{% /badge %}} {{% badge style="green" icon="fa-fw fab fa-markdown" title=" " %}}Front Matter{{% /badge %}} You can hide the print button if the [print output format](configuration/sitemanagement/outputformats/#print-support) is active by setting `disablePrintButton=true`. diff --git a/exampleSite/content/authoring/frontmatter/topbar/_index.pir.md b/exampleSite/content/authoring/frontmatter/topbar/_index.pir.md index 8066855120..bbd9878c66 100644 --- a/exampleSite/content/authoring/frontmatter/topbar/_index.pir.md +++ b/exampleSite/content/authoring/frontmatter/topbar/_index.pir.md @@ -1,9 +1,9 @@ +++ categories = ["howto"] description = "Configure the topbar" -frontmatter = ["disableBreadcrumb", "disableNextPrev", "disableMarkdownButton", "disablePrintButton", "disableToc", "editURL"] -options = ["disableBreadcrumb", "disableNextPrev", "disableMarkdownButton", "disablePrintButton", "disableToc", "editURL"] -outputs = ["html", "rss", "print", "markdown"] +frontmatter = ["disableBreadcrumb", "disableNextPrev", "disableMarkdownButton", "disableSourceButton", "disablePrintButton", "disableToc", "editURL"] +options = ["disableBreadcrumb", "disableNextPrev", "disableMarkdownButton", "disableSourceButton", "disablePrintButton", "disableToc", "editURL"] +outputs = ["html", "rss", "print", "markdown", "source"] title = "Topbarrr" weight = 4 +++ diff --git a/exampleSite/content/configuration/customization/topbar/_index.en.md b/exampleSite/content/configuration/customization/topbar/_index.en.md index d822516246..8f89ef4172 100644 --- a/exampleSite/content/configuration/customization/topbar/_index.en.md +++ b/exampleSite/content/configuration/customization/topbar/_index.en.md @@ -2,7 +2,7 @@ categories = ["explanation", "reference"] description = "How to extend the topbar" options = ["editURL"] -outputs = ["html", "rss", "print", "markdown"] +outputs = ["html", "rss", "print", "markdown", "source"] title = "Topbar" weight = 4 +++ @@ -36,6 +36,7 @@ The theme ships with the following predefined buttons (from left to right in the - {{% button style="transparent" icon="bars" %}}{{% /button %}} [**sidebar**](https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/topbar/button/sidebar.html): opens the sidebar flyout if in mobile layout - {{% button style="transparent" icon="list-alt" %}}{{% /button %}} [**toc**](https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/topbar/button/toc.html): [opens the table of contents in an overlay](authoring/frontmatter/topbar#table-of-contents) - {{% button style="transparent" icon="pen" %}}{{% /button %}} [**edit**](https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/topbar/button/edit.html): browses to the editable page if the `editURL` [parameter is set](authoring/frontmatter/topbar#edit-button) +- {{% button style="transparent" icon="file-code" %}}{{% /button %}} **source**: [**source**](https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/topbar/button/markdown.html): browses to the chapter's source code if [markdown support](configuration/sitemanagement/outputformats#source-support) was activated - {{% button style="transparent" icon="fa-fw fab fa-markdown" %}}{{% /button %}} [**markdown**](https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/topbar/button/markdown.html): browses to the chapter's markdown source if [markdown support](configuration/sitemanagement/outputformats#markdown-support) was activated - {{% button style="transparent" icon="print" %}}{{% /button %}} [**print**](https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/topbar/button/print.html): browses to the chapter's printable page if [print support](configuration/sitemanagement/outputformats#print-support) was activated - {{% button style="transparent" icon="chevron-left" %}}{{% /button %}} [**prev**](https://github.com/McShelby/hugo-theme-relearn/blob/main/layouts/partials/topbar/button/prev.html): browses to the [previous page](authoring/frontmatter/topbar#arrow-navigation) if there is one diff --git a/exampleSite/content/configuration/customization/topbar/_index.pir.md b/exampleSite/content/configuration/customization/topbar/_index.pir.md index 051ff64232..caf2ed7884 100644 --- a/exampleSite/content/configuration/customization/topbar/_index.pir.md +++ b/exampleSite/content/configuration/customization/topbar/_index.pir.md @@ -2,7 +2,7 @@ categories = ["explanation", "reference"] description = "How to extend the topbar" options = ["editURL"] -outputs = ["html", "rss", "print", "markdown"] +outputs = ["html", "rss", "print", "markdown", "source"] title = "Topbarrr" weight = 4 +++ diff --git a/exampleSite/content/configuration/sitemanagement/outputformats/_index.en.md b/exampleSite/content/configuration/sitemanagement/outputformats/_index.en.md index cf78eac879..d00987be0f 100644 --- a/exampleSite/content/configuration/sitemanagement/outputformats/_index.en.md +++ b/exampleSite/content/configuration/sitemanagement/outputformats/_index.en.md @@ -1,7 +1,7 @@ +++ categories = ["howto"] description = "What formats can a page be displayed in" -outputs = ["html", "rss", "print", "markdown"] +outputs = ["html", "rss", "print", "markdown", "source"] title = "Available Output Formats" weight = 5 +++ @@ -42,7 +42,7 @@ If you don't like the URLs, you can reconfigure `outputFormats.print` in your `h ## Markdown Support -Enable support to show the Markdown source of a page . Add the `markdown` output format to your home, section, and page in `hugo.toml`: +Enable support to show the Markdown source of a page. Add the `markdown` output format to your home, section, and page in `hugo.toml`: {{< multiconfig file=hugo >}} [outputs] @@ -51,6 +51,36 @@ Enable support to show the Markdown source of a page . Add the `markdown` output page = ['html', 'rss', 'markdown'] {{< /multiconfig >}} -By default this adds a Markdown icon in the topbar but [can be deactived](authoring/frontmatter/topbar/#markdown-button). Clicking it switches to the Markdown source of the page. +By default this adds a Markdown icon in the topbar but [can be deactived](authoring/frontmatter/topbar/#markdown-button). Clicking it switches to the Markdown source including the title of the page. The `markdown` output format configuration is [provided by Hugo](https://gohugo.io/templates/output-formats/#output-format-definitions). + +## Source Support + +Enable support to show the source code of a page if it was generated from a file. Add the `source` output format to your home, section, and page in `hugo.toml`: + +{{< multiconfig file=hugo >}} +[outputs] + home = ['html', 'rss', 'source'] + section = ['html', 'rss', 'source'] + page = ['html', 'rss', 'source'] +{{< /multiconfig >}} + +By default this adds a Source icon in the topbar but [can be deactived](authoring/frontmatter/topbar/#source-button). Clicking it switches to the source code of the page. + +The Source output format differs from the Markdown format, as it prints the source code _as is_ including the front matter. + +The URL won't be [configured ugly](https://gohugo.io/templates/output-formats/#configure-output-formats) for [Hugo's URL handling](https://gohugo.io/content-management/urls/#ugly-urls), even with `uglyURLs=true` in `hugo.toml`. This is because each mime type can only have one suffix. + +If you don't like the URLs, you can reconfigure `outputFormats.source` in your `hugo.toml` to something other than the default of: + +{{< multiconfig file=hugo >}} +[outputFormats] + [outputFormats.source] + name= 'source' + baseName = 'index.source' + isHTML = false + mediaType = 'text/markdown' + permalinkable = false + noUgly = true +{{< /multiconfig >}} diff --git a/exampleSite/content/configuration/sitemanagement/outputformats/_index.pir.md b/exampleSite/content/configuration/sitemanagement/outputformats/_index.pir.md index c2e31307d5..e7b39e69a0 100644 --- a/exampleSite/content/configuration/sitemanagement/outputformats/_index.pir.md +++ b/exampleSite/content/configuration/sitemanagement/outputformats/_index.pir.md @@ -1,7 +1,7 @@ +++ categories = ["howto"] description = "What formats can a page be displayed in" -outputs = ["html", "rss", "print", "markdown"] +outputs = ["html", "rss", "print", "markdown", "source"] title = "Available Output Formats" weight = 5 +++ diff --git a/exampleSite/content/introduction/releasenotes/7/3.en.md b/exampleSite/content/introduction/releasenotes/7/3.en.md index f882584ca1..383c737bed 100644 --- a/exampleSite/content/introduction/releasenotes/7/3.en.md +++ b/exampleSite/content/introduction/releasenotes/7/3.en.md @@ -14,9 +14,9 @@ weight = -3 - {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The topbar button for the print format [can now be hidden](authoring/frontmatter/topbar/#print-button) if the print output format is active by setting `disablePrintButton=true` in your `hugo.toml` or Front Matter. -- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The theme supports the new [`markdown` output format](configuration/sitemanagement/outputformats/#markdown-support) which behaves similar in configuration as the `print` output format but allows the original Markdown source of a page to be viewed. +- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The theme supports the new [`markdown` output format](configuration/sitemanagement/outputformats/#markdown-support) which behaves similar in configuration as the `print` output format but allows the Markdown source of a page to be viewed. - You can see this in action on the above linked page, accessible by clikcking the topbar button. + You can see this in action on the above linked page, accessible by clicking the topbar button. - {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} Keyboard support for code blocks was improved so the _copy to clipboard_ button is now reachable by TAB if `disableHoverBlockCopyToClipBoard=false` was set in the `hugo.toml`. diff --git a/exampleSite/content/introduction/releasenotes/7/4.en.md b/exampleSite/content/introduction/releasenotes/7/4.en.md index d323e82821..d4087be543 100644 --- a/exampleSite/content/introduction/releasenotes/7/4.en.md +++ b/exampleSite/content/introduction/releasenotes/7/4.en.md @@ -11,3 +11,7 @@ weight = -4 ### New - {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} Table headers are sticky now. + +- {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} The theme supports the new [`source` output format](configuration/sitemanagement/outputformats/#source-support) which behaves similar in configuration as the `markdown` output format but allows the original Markdown source including the front matter of a page to be viewed. + + You can see this in action on the above linked page, accessible by clicking the topbar button. diff --git a/exampleSite/i18n/art-x-pir.toml b/exampleSite/i18n/art-x-pir.toml index 134d5d9ac9..a3689da683 100644 --- a/exampleSite/i18n/art-x-pir.toml +++ b/exampleSite/i18n/art-x-pir.toml @@ -43,6 +43,9 @@ other = "Edit" [Show-Markdown] other = "Show Marrrkd'n" +[Show-source] +other = "Show source code" + [Print-this-chapter] other = "Prrrint whole chapterrr" diff --git a/hugo.toml b/hugo.toml index 6acc2191ca..c3ce3171a2 100644 --- a/hugo.toml +++ b/hugo.toml @@ -15,6 +15,14 @@ permalinkable = false noUgly = true + [outputFormats.source] + name= 'source' + baseName = 'index.source' + isHTML = false + mediaType = 'text/markdown' + permalinkable = false + noUgly = true + # unused since 7.0.0 but left in here to generate warnings [outputFormats.search] name= 'search' diff --git a/i18n/ar.toml b/i18n/ar.toml index 80a01d222b..ceb2bd2ef5 100644 --- a/i18n/ar.toml +++ b/i18n/ar.toml @@ -43,6 +43,9 @@ other = "حرر" [Show-Markdown] other = "إظهار Markdown" +[Show-source] +other = "إظهار شفرة المصدر" + [Print-this-chapter] other = "طباعة الفصل بأكمله" diff --git a/i18n/cs.toml b/i18n/cs.toml index 0bc02c33c4..abb72af3c5 100644 --- a/i18n/cs.toml +++ b/i18n/cs.toml @@ -43,6 +43,9 @@ other = "Upravit" [Show-Markdown] other = "Zobrazit Markdown" +[Show-source] +other = "Zobrazit zdrojový kód" + [Print-this-chapter] other = "Vytisknout kapitolu" diff --git a/i18n/de.toml b/i18n/de.toml index 4c61379423..e6658ce665 100644 --- a/i18n/de.toml +++ b/i18n/de.toml @@ -43,6 +43,9 @@ other = "Bearbeiten" [Show-Markdown] other = "Markdown anzeigen" +[Show-source] +other = "Quelldatei anzeigen" + [Print-this-chapter] other = "Ganzes Kapitel drucken" diff --git a/i18n/en.toml b/i18n/en.toml index 730be74c4f..8a6489d02e 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -43,6 +43,9 @@ other = "Edit" [Show-Markdown] other = "Show Markdown" +[Show-source] +other = "Show source code" + [Print-this-chapter] other = "Print whole chapter" diff --git a/i18n/es.toml b/i18n/es.toml index ceb8bba7ed..294cdcf330 100644 --- a/i18n/es.toml +++ b/i18n/es.toml @@ -43,6 +43,9 @@ other = "Editar" [Show-Markdown] other = "Mostrar Markdown" +[Show-source] +other = "Mostrar código fuente" + [Print-this-chapter] other = "Imprimir todo el capítulo" diff --git a/i18n/fa.toml b/i18n/fa.toml index 82d105582f..d18831ae1f 100644 --- a/i18n/fa.toml +++ b/i18n/fa.toml @@ -43,6 +43,9 @@ other = "ویرایش" [Show-Markdown] other = "نمایش Markdown" +[Show-source] +other = "نمایش کد منبع" + [Print-this-chapter] other = "چاپ کل فصل" diff --git a/i18n/fi.toml b/i18n/fi.toml index 57455536c0..bddfb9a229 100644 --- a/i18n/fi.toml +++ b/i18n/fi.toml @@ -43,6 +43,9 @@ other = "Muokkaa" [Show-Markdown] other = "Näytä Markdown" +[Show-source] +other = "Näytä lähdekoodi" + [Print-this-chapter] other = "Tulosta koko luku" diff --git a/i18n/fr.toml b/i18n/fr.toml index b0c7461b81..5c07213e2d 100644 --- a/i18n/fr.toml +++ b/i18n/fr.toml @@ -43,6 +43,9 @@ other = "Éditer" [Show-Markdown] other = "Afficher Markdown" +[Show-source] +other = "Afficher le code source" + [Print-this-chapter] other = "Imprimer le chapitre entier" diff --git a/i18n/hi.toml b/i18n/hi.toml index 2b8a57ee94..bb5ab18dd8 100644 --- a/i18n/hi.toml +++ b/i18n/hi.toml @@ -43,6 +43,9 @@ other = "संपादन करना" [Show-Markdown] other = "मार्कडाउन दिखाएं" +[Show-source] +other = "स्रोत कोड दिखाएं" + [Print-this-chapter] other = "पूरा अध्याय मुद्रित करें" diff --git a/i18n/hu.toml b/i18n/hu.toml index b8ae26b121..7224d7afbe 100644 --- a/i18n/hu.toml +++ b/i18n/hu.toml @@ -43,6 +43,9 @@ other = "Szerkesztés" [Show-Markdown] other = "Markdown megjelenítése" +[Show-source] +other = "Forráskód megjelenítése" + [Print-this-chapter] other = "Teljes fejezet nyomtatása" diff --git a/i18n/id.toml b/i18n/id.toml index d970f31e38..182639a632 100644 --- a/i18n/id.toml +++ b/i18n/id.toml @@ -43,6 +43,9 @@ other = "Mengedit" [Show-Markdown] other = "Tampilkan Markdown" +[Show-source] +other = "Tampilkan kode sumber" + [Print-this-chapter] other = "Mencetak seluruh bab" diff --git a/i18n/it.toml b/i18n/it.toml index 71c19b194b..097664b6a7 100644 --- a/i18n/it.toml +++ b/i18n/it.toml @@ -43,6 +43,9 @@ other = "Modifica" [Show-Markdown] other = "Mostra Markdown" +[Show-source] +other = "Mostra il codice sorgente" + [Print-this-chapter] other = "Stampa l'intero capitolo" diff --git a/i18n/ja.toml b/i18n/ja.toml index e9343b8541..47c98e76a6 100644 --- a/i18n/ja.toml +++ b/i18n/ja.toml @@ -43,6 +43,9 @@ other = "編集" [Show-Markdown] other = "マークダウンを表示" +[Show-source] +other = "ソースコードを表示" + [Print-this-chapter] other = "章全体を印刷する" diff --git a/i18n/ko.toml b/i18n/ko.toml index 0086176d0f..91a62a12e0 100644 --- a/i18n/ko.toml +++ b/i18n/ko.toml @@ -43,6 +43,9 @@ other = "편집" [Show-Markdown] other = "마크다운 표시" +[Show-source] +other = "소스 코드 표시" + [Print-this-chapter] other = "전체 장 인쇄" diff --git a/i18n/nl.toml b/i18n/nl.toml index 162b1be63f..de09668c07 100644 --- a/i18n/nl.toml +++ b/i18n/nl.toml @@ -43,6 +43,9 @@ other = "Bewerken" [Show-Markdown] other = "Afprijzing weergeven" +[Show-source] +other = "Broncode weergeven" + [Print-this-chapter] other = "Het hele hoofdstuk afdrukken" diff --git a/i18n/pl.toml b/i18n/pl.toml index 109936df94..9c48a8b0e1 100644 --- a/i18n/pl.toml +++ b/i18n/pl.toml @@ -43,6 +43,9 @@ other = "Edycja" [Show-Markdown] other = "Pokaż język Markdown" +[Show-source] +other = "Pokaż kod źródłowy" + [Print-this-chapter] other = "Drukowanie całego rozdziału" diff --git a/i18n/pt.toml b/i18n/pt.toml index 9105eac199..ed67c4f8fd 100644 --- a/i18n/pt.toml +++ b/i18n/pt.toml @@ -43,6 +43,9 @@ other = "Editar" [Show-Markdown] other = "Mostrar Markdown" +[Show-source] +other = "Mostrar código-fonte" + [Print-this-chapter] other = "Imprimir capítulo inteiro" diff --git a/i18n/ro.toml b/i18n/ro.toml index 1582a7c845..2190ee458d 100644 --- a/i18n/ro.toml +++ b/i18n/ro.toml @@ -43,6 +43,9 @@ other = "Editează" [Show-Markdown] other = "Afișează Markdown" +[Show-source] +other = "Afișați codul sursă" + [Print-this-chapter] other = "Tipărește întregul capitol" diff --git a/i18n/ru.toml b/i18n/ru.toml index 65393bcaf7..e201353eb0 100644 --- a/i18n/ru.toml +++ b/i18n/ru.toml @@ -43,6 +43,9 @@ other = "редактировать" [Show-Markdown] other = "Показать Markdown" +[Show-source] +other = "Показать исходный код" + [Print-this-chapter] other = "Печать всей главы" diff --git a/i18n/sw.toml b/i18n/sw.toml index 0291492094..003e01df94 100644 --- a/i18n/sw.toml +++ b/i18n/sw.toml @@ -43,6 +43,9 @@ other = "Hariri" [Show-Markdown] other = "Onyesha Alama" +[Show-source] +other = "Onyesha msimbo wa chanzo" + [Print-this-chapter] other = "Chapisha sura nzima" diff --git a/i18n/tr.toml b/i18n/tr.toml index e16c9d3449..c91bb95ac2 100644 --- a/i18n/tr.toml +++ b/i18n/tr.toml @@ -43,6 +43,9 @@ other = "Düzenlemek" [Show-Markdown] other = "Markdown'ı Göster" +[Show-source] +other = "Kaynak kodunu göster" + [Print-this-chapter] other = "Bölümün tamamını yazdır" diff --git a/i18n/vi.toml b/i18n/vi.toml index 76870a3636..944f29d4b4 100644 --- a/i18n/vi.toml +++ b/i18n/vi.toml @@ -43,6 +43,9 @@ other = "Biên tập" [Show-Markdown] other = "Hiển thị Markdown" +[Show-source] +other = "Hiển thị mã nguồn" + [Print-this-chapter] other = "In toàn bộ chương" diff --git a/i18n/zh-CN.toml b/i18n/zh-CN.toml index 0523c5a8d5..c3bf76e3ab 100644 --- a/i18n/zh-CN.toml +++ b/i18n/zh-CN.toml @@ -43,6 +43,9 @@ other = "编辑" [Show-Markdown] other = "显示 Markdown" +[Show-source] +other = "显示源代码" + [Print-this-chapter] other = "打印整章" diff --git a/i18n/zh-Hans.toml b/i18n/zh-Hans.toml index 0523c5a8d5..c3bf76e3ab 100644 --- a/i18n/zh-Hans.toml +++ b/i18n/zh-Hans.toml @@ -43,6 +43,9 @@ other = "编辑" [Show-Markdown] other = "显示 Markdown" +[Show-source] +other = "显示源代码" + [Print-this-chapter] other = "打印整章" diff --git a/i18n/zh-Hant.toml b/i18n/zh-Hant.toml index 8ebdbf5ece..754b972392 100644 --- a/i18n/zh-Hant.toml +++ b/i18n/zh-Hant.toml @@ -43,6 +43,9 @@ other = "編輯網頁" [Show-Markdown] other = "顯示 Markdown" +[Show-source] +other = "顯示原始程式碼" + [Print-this-chapter] other = "列印整章" diff --git a/i18n/zh-TW.toml b/i18n/zh-TW.toml index 8ebdbf5ece..754b972392 100644 --- a/i18n/zh-TW.toml +++ b/i18n/zh-TW.toml @@ -43,6 +43,9 @@ other = "編輯網頁" [Show-Markdown] other = "顯示 Markdown" +[Show-source] +other = "顯示原始程式碼" + [Print-this-chapter] other = "列印整章" diff --git a/i18n/zh.toml b/i18n/zh.toml index 0523c5a8d5..c3bf76e3ab 100644 --- a/i18n/zh.toml +++ b/i18n/zh.toml @@ -43,6 +43,9 @@ other = "编辑" [Show-Markdown] other = "显示 Markdown" +[Show-source] +other = "显示源代码" + [Print-this-chapter] other = "打印整章" diff --git a/layouts/_default/baseof.md b/layouts/_default/baseof.md index 33cee1f948..5b5582d9e1 100644 --- a/layouts/_default/baseof.md +++ b/layouts/_default/baseof.md @@ -1,4 +1,6 @@ {{/* the following check avoids to print out content of headless bundles if called from nestedContent.gotmpl */}} -{{- if .RelPermalink }} -{{- .RawContent }} -{{- end }} +{{- if .RelPermalink -}} +# {{ .Title }} + +{{ strings.TrimLeft "\n\r\t " .RawContent }} +{{- end }} \ No newline at end of file diff --git a/layouts/_default/baseof.source.md b/layouts/_default/baseof.source.md new file mode 100644 index 0000000000..767e4f9ffa --- /dev/null +++ b/layouts/_default/baseof.source.md @@ -0,0 +1,4 @@ +{{/* the following check avoids to print out content of headless bundles if called from nestedContent.gotmpl */}} +{{- if and .File .File.Filename -}} +{{ readFile .File.Filename | safeHTML }} +{{- end }} \ No newline at end of file diff --git a/layouts/_default/list.source.md b/layouts/_default/list.source.md new file mode 100644 index 0000000000..8712006618 --- /dev/null +++ b/layouts/_default/list.source.md @@ -0,0 +1 @@ +{{ define "_empty" }}{{ end }} \ No newline at end of file diff --git a/layouts/_default/single.source.md b/layouts/_default/single.source.md new file mode 100644 index 0000000000..8712006618 --- /dev/null +++ b/layouts/_default/single.source.md @@ -0,0 +1 @@ +{{ define "_empty" }}{{ end }} \ No newline at end of file diff --git a/layouts/partials/topbar/area/end.html b/layouts/partials/topbar/area/end.html index 2c88ae1b41..d0a442aef4 100644 --- a/layouts/partials/topbar/area/end.html +++ b/layouts/partials/topbar/area/end.html @@ -1,6 +1,9 @@ {{- partial "topbar/button/edit.html" (dict "page" . )}} +{{- partial "topbar/button/source.html" (dict + "page" . +)}} {{- partial "topbar/button/markdown.html" (dict "page" . )}} diff --git a/layouts/partials/topbar/button/source.html b/layouts/partials/topbar/button/source.html new file mode 100644 index 0000000000..b37005e946 --- /dev/null +++ b/layouts/partials/topbar/button/source.html @@ -0,0 +1,22 @@ +{{- $onwidths := cond (isset . "onwidths") .onwidths "area-more" }} +{{- $onwidthm := cond (isset . "onwidthm") .onwidthm "show" }} +{{- $onwidthl := cond (isset . "onwidthl") .onwidthl "show" }} +{{- with .page }} + {{- $format := .OutputFormats.Get "source" }} + {{- $show := and $format (not (.Param "disableSourceButton")) }} + {{- if $show }} + {{- $show = and (not (partial "_relearn/pageIsSpecial.gotmpl" .)) .File .File.Filename }} + {{- end }} + {{- if $show }} + {{- partial "topbar/func/button.html" (dict + "page" . + "class" "topbar-button-source" + "href" $format.RelPermalink + "icon" "file-code" + "onwidths" $onwidths + "onwidthm" $onwidthm + "onwidthl" $onwidthl + "hint" (T "Show-source") + )}} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/layouts/partials/version.txt b/layouts/partials/version.txt index c8f074f0e6..991f608dbb 100644 --- a/layouts/partials/version.txt +++ b/layouts/partials/version.txt @@ -1 +1 @@ -7.3.2+7b470298046df2c96c0da9da07a54572b7c4e1b0 \ No newline at end of file +7.3.2+c6cec2de3e4f3649e19d152e7a1231a66d68c474 \ No newline at end of file