Bug 279896 - Download PDF not working in handbook [404]
Summary: Download PDF not working in handbook [404]
Status: Closed FIXED
Alias: None
Product: Documentation
Classification: Unclassified
Component: Books & Articles (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Document Engineering Group (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-21 18:11 UTC by freebsd.illusive064
Modified: 2024-06-29 15:20 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Comment 1 Graham Perrin 2024-06-21 23:45:03 UTC
Other bugged books include: 

<https://docs.freebsd.org/en/books/faq/>
<https://docs.freebsd.org/en/books/porters-handbook/> (split)
<https://docs.freebsd.org/en/books/porters-handbook/book/> (single page).

Also bugged, the first article that I chose, randomly: 

<https://docs.freebsd.org/en/articles/contributing/>

Let's assume that this bug bites: 

- all pages of all articles and books in the documentation portal. 

Towards identifying the point in time when the issue began: a 2024-06-16 capture of FAQ is not bugged: <https://web.archive.org/web/20240616054751/https://docs.freebsd.org/en/books/faq/>. In the days since then, at a glance, I see nothing in the doc tree that might explain the issue: 

<https://cgit.freebsd.org/doc/log/?qt=range&q=f7e381b076934413d284f4d8e545f22c22ab59c6>
Comment 2 Graham Perrin 2024-06-21 23:54:45 UTC
(In reply to Graham Perrin from comment #1)

> … a 2024-06-16 capture … not bugged: …

Bugged a few hours later: 

<https://web.archive.org/web/20240617093823/https://docs.freebsd.org/en/books/handbook/advanced-networking/>
Comment 3 freebsd.illusive064 2024-06-22 12:00:06 UTC
so hovering over the link I see two suspicious 'nil' values:

https://download.freebsd.org/doc/en/_index/%25!s%28%3cnil%3e%29/%25!s%28%3cnil%3e%29_en.pdf 


./documentation/themes/beastie/i18n/zh-cn.toml:[download-pdf]

```
So, I grep the repo for "Download PDF" and I see (one example)

./documentation/themes/beastie/layouts/books/single.html:          <li><i class="fa fa-file-pdf-o" aria-hidden="true" title="{{ i18n "download-pdf" }}"></i><a href="{{ $pdfUrl }}">{{ i18n "download-pdf" }}</a></li>
```


So the link is decided by `$pdfUrl`

I grep for `$pdfUrl`:
```
 grep -r "\$pdfUrl"

./documentation/themes/beastie/layouts/books/single.html:          {{ $pdfUrl := printf "%s%s/%s" $.Site.Params.downloadBaseUrl $.Site.Home.Language $path }}
```

so the issue, as far as I understand, is here. Something with Site Params.

I cloned the latest as of the time of writing, hope someone who knows the FreeBSD docs can take this further.

Sorry, first time delving into it.
Comment 4 freebsd.illusive064 2024-06-22 12:00:56 UTC
Sorry, I assumed there was some form of markdown support, it seems I can't edit comments though.
Comment 5 freebsd.illusive064 2024-06-22 12:55:23 UTC
I did some more invenstigation  :

  <div class="resources">
        <h3>{{ i18n "resources" }}</h3>
        <ul class="contents">
          {{ $pathSections := split .Page.File "/" }}
          {{ $path := printf "%s/%s/%s_%s.pdf" (index $pathSections 0) (index $pathSections 1) (index $pathSections 1) $.Site.Home.Language }}
          {{ $pdfUrl := printf "%s%s/%s" $.Site.Params.downloadBaseUrl $.Site.Home.Language $path }}
          <li><i class="fa fa-file-pdf-o" aria-hidden="true" title="{{ i18n "download-pdf" }}"></i><a href="{{ $pdfUrl }}">{{ i18n "download-pdf" }}</a></li>
          {{ $editUrl := printf "%s%s/%s" $.Site.Params.editBaseUrl $.Site.Home.Language .Page.File }}
          <li><i class="fa fa-pencil-square-o" aria-hidden="true" title="{{ i18n "edit-page" }}"></i><a href="{{ $editUrl }}" target="_blank">{{ i18n "edit-page" }}</a></li>
        </ul>
      </div>


Here specifically:
          {{ $pathSections := split .Page.File "/" }}
          {{ $path := printf "%s/%s/%s_%s.pdf" (index $pathSections 0) (index $pathSections 1) (index $pathSections 1) $.Site.Home.Language }}

pathSections 1 and 0 are nil, why? I have no idea how this site is made, hopefully someone else can answer that
Comment 6 freebsd.illusive064 2024-06-22 13:45:00 UTC
The last commit that affected $pathSection was in 2023 as per 
doc 09db844c018312d33dbe92806f2ed43418389b95 so I sincerely doubt it was a source code issue.

Considering it was working 16 June, until it wasn't without any commit being made, it is likely a system issue i.e Hugo was updated and the docs were rebuilt etc. 

Not sure, I am out of my depth here.
Comment 7 Danilo G. Baio freebsd_committer freebsd_triage 2024-06-29 13:47:19 UTC
Thank you for reporting this. It appears to be another bug resulting from the recent Hugo upgrade on our build servers.
Comment 8 commit-hook freebsd_committer freebsd_triage 2024-06-29 14:52:20 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/doc/commit/?id=f8c0dc03a753351c921c2b37d45526ab08d58b83

commit f8c0dc03a753351c921c2b37d45526ab08d58b83
Author:     Danilo G. Baio <dbaio@FreeBSD.org>
AuthorDate: 2024-06-29 13:57:59 +0000
Commit:     Danilo G. Baio <dbaio@FreeBSD.org>
CommitDate: 2024-06-29 13:57:59 +0000

    documentation/themes: Fix the Download PDF link after Hugo upgrade

    PR:             279896
    Reported by:    freebsd.illusive064@passinbox.com

 documentation/themes/beastie/layouts/articles/list.html   | 9 ++++++---
 documentation/themes/beastie/layouts/articles/single.html | 9 ++++++---
 documentation/themes/beastie/layouts/books/list.html      | 9 ++++++---
 documentation/themes/beastie/layouts/books/single.html    | 9 ++++++---
 4 files changed, 24 insertions(+), 12 deletions(-)