Skip to content

Fix pelican landing page links for print/single-file targets#1128

Merged
oscarlevin merged 4 commits intomainfrom
copilot/improve-print-target-links
Mar 21, 2026
Merged

Fix pelican landing page links for print/single-file targets#1128
oscarlevin merged 4 commits intomainfrom
copilot/improve-print-target-links

Conversation

Copy link
Contributor

Copilot AI commented Mar 20, 2026

When a target with deploy-dir produces a single output file (PDF, EPUB, etc.), the pelican-generated landing page linked to the deploy directory rather than the actual file.

Changes

  • pretext/project/__init__.py: Modified deploy_path() to scan output_dir_abspath() for the actual output file when output_filename is not explicitly set and the format is a known single-file type. Returns deploy_dir / filename if exactly one match is found; falls back to directory path otherwise.

    • Added module-level _SINGLE_FILE_FORMAT_EXTENSIONS constant mapping Format.PDF → .pdf, Format.EPUB / Format.KINDLE → .epub, Format.BRAILLE → .brl
  • tests/test_project.py: Added test_deploy_path covering PDF/EPUB auto-detection, explicit output_filename precedence, HTML directory-output unchanged behavior, and fallback when output dir doesn't exist yet.

Before: a PDF print target with deploy-dir="print" would generate <a href="print">Print</a>
After: it generates <a href="print/main.pdf">Print</a>

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • runestone.academy
    • Triggering command: /usr/bin/python python scripts/fetch_core.py (dns block)
    • Triggering command: /usr/bin/python python -m pytest tests/test_project.py::test_deploy tests/test_project.py::test_defaults tests/test_project.py::test_manifest_elaborate tests/test_project.py::test_stage -v (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Print targets should get better links in pelican generated site</issue_title>
<issue_description>Currently the @deploy-dir getting set in the manifest tells pretext deploy to build a static landing page for multiple projects. If you use this for a print target, the landing page will create a link to that directory. It would be much better to create a link to the actual pdf.</issue_description>

Comments on the Issue (you are @copilot in this section)

@oscarlevin It seems like if the user specifies a `output-filename` then the link points to the correct thing. I suspect this is just an oversight in the pelican generation, using `none` instead of the default, perhaps.

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

When output_filename is not set for single-file output formats (PDF, EPUB,
KINDLE, BRAILLE), deploy_path() now scans the output directory for the
actual output file and returns a path including the filename. This allows
the pelican-generated landing page to link directly to the PDF (or other
single-file output) rather than the directory containing it.

Co-authored-by: oscarlevin <6504596+oscarlevin@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PreTeXtBook/pretext-cli/sessions/870d27e1-a45a-439c-943b-f8852da66683
Copilot AI changed the title [WIP] Fix print target links in Pelican generated site Fix pelican landing page links for print/single-file targets Mar 20, 2026
Copilot AI requested a review from oscarlevin March 20, 2026 15:38
@oscarlevin oscarlevin marked this pull request as ready for review March 21, 2026 19:15
@oscarlevin oscarlevin merged commit 4bbdbf2 into main Mar 21, 2026
6 checks passed
@oscarlevin oscarlevin deleted the copilot/improve-print-target-links branch March 21, 2026 19:38
Copilot AI added a commit that referenced this pull request Mar 21, 2026
* Initial plan

* Fix: print targets get better links in pelican generated site

When output_filename is not set for single-file output formats (PDF, EPUB,
KINDLE, BRAILLE), deploy_path() now scans the output directory for the
actual output file and returns a path including the filename. This allows
the pelican-generated landing page to link directly to the PDF (or other
single-file output) rather than the directory containing it.

Co-authored-by: oscarlevin <6504596+oscarlevin@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PreTeXtBook/pretext-cli/sessions/870d27e1-a45a-439c-943b-f8852da66683

* format

* add copilot instructions

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: oscarlevin <6504596+oscarlevin@users.noreply.github.com>
Co-authored-by: Oscar Levin <oscar.levin@unco.edu>
oscarlevin added a commit that referenced this pull request Mar 22, 2026
* Initial plan

* Add test for pretext generate datafile

Co-authored-by: oscarlevin <6504596+oscarlevin@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PreTeXtBook/pretext-cli/sessions/2dcc278a-da1e-4d0d-9c35-f17aa1fa7f57

* Fix pelican landing page links for print/single-file targets (#1128)

* Initial plan

* Fix: print targets get better links in pelican generated site

When output_filename is not set for single-file output formats (PDF, EPUB,
KINDLE, BRAILLE), deploy_path() now scans the output directory for the
actual output file and returns a path including the filename. This allows
the pelican-generated landing page to link directly to the PDF (or other
single-file output) rather than the directory containing it.

Co-authored-by: oscarlevin <6504596+oscarlevin@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PreTeXtBook/pretext-cli/sessions/870d27e1-a45a-439c-943b-f8852da66683

* format

* add copilot instructions

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: oscarlevin <6504596+oscarlevin@users.noreply.github.com>
Co-authored-by: Oscar Levin <oscar.levin@unco.edu>

* Initial plan

* Fix formatting with black and rebase onto main

Co-authored-by: oscarlevin <6504596+oscarlevin@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PreTeXtBook/pretext-cli/sessions/2aff3401-df98-4e89-ad7d-d303784b6b77

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: oscarlevin <6504596+oscarlevin@users.noreply.github.com>
Co-authored-by: Oscar Levin <oscar.levin@unco.edu>
Copilot AI added a commit that referenced this pull request Mar 22, 2026
* Initial plan

* Fix: print targets get better links in pelican generated site

When output_filename is not set for single-file output formats (PDF, EPUB,
KINDLE, BRAILLE), deploy_path() now scans the output directory for the
actual output file and returns a path including the filename. This allows
the pelican-generated landing page to link directly to the PDF (or other
single-file output) rather than the directory containing it.

Co-authored-by: oscarlevin <6504596+oscarlevin@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PreTeXtBook/pretext-cli/sessions/870d27e1-a45a-439c-943b-f8852da66683

* format

* add copilot instructions

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: oscarlevin <6504596+oscarlevin@users.noreply.github.com>
Co-authored-by: Oscar Levin <oscar.levin@unco.edu>
Copilot AI added a commit that referenced this pull request Mar 22, 2026
* Initial plan

* Add test for pretext generate datafile

Co-authored-by: oscarlevin <6504596+oscarlevin@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PreTeXtBook/pretext-cli/sessions/2dcc278a-da1e-4d0d-9c35-f17aa1fa7f57

* Fix pelican landing page links for print/single-file targets (#1128)

* Initial plan

* Fix: print targets get better links in pelican generated site

When output_filename is not set for single-file output formats (PDF, EPUB,
KINDLE, BRAILLE), deploy_path() now scans the output directory for the
actual output file and returns a path including the filename. This allows
the pelican-generated landing page to link directly to the PDF (or other
single-file output) rather than the directory containing it.

Co-authored-by: oscarlevin <6504596+oscarlevin@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PreTeXtBook/pretext-cli/sessions/870d27e1-a45a-439c-943b-f8852da66683

* format

* add copilot instructions

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: oscarlevin <6504596+oscarlevin@users.noreply.github.com>
Co-authored-by: Oscar Levin <oscar.levin@unco.edu>

* Initial plan

* Fix formatting with black and rebase onto main

Co-authored-by: oscarlevin <6504596+oscarlevin@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PreTeXtBook/pretext-cli/sessions/2aff3401-df98-4e89-ad7d-d303784b6b77

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: oscarlevin <6504596+oscarlevin@users.noreply.github.com>
Co-authored-by: Oscar Levin <oscar.levin@unco.edu>
Copilot AI added a commit that referenced this pull request Mar 22, 2026
- Rebased on origin/main (includes new tests and changes from #1124-#1128)
- Ran `poetry run black .` for formatting (reformatted test_generate.py)
- Added Fixed entry in CHANGELOG.md under [Unreleased]

Co-authored-by: oscarlevin <6504596+oscarlevin@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PreTeXtBook/pretext-cli/sessions/72d5b309-fec0-4dad-8af0-1cbe035c2679
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Print targets should get better links in pelican generated site

2 participants