Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace links to ephemeral file URLs with persistent "resource" links #1886

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

per1234
Copy link
Contributor

@per1234 per1234 commented Apr 19, 2024

What This PR Changes

In addition to the Markdown content source files, this repository hosts non-text files. These are linked to in various places in the content.

The website publishing system hosts these non-text files in paths under the static subfolder of the website (e.g., https://docs.arduino.cc/static/d7e16a6657c086a034a14a6619cffe7b/ABX00074-schematics.pdf). The path of the published file includes the file's MD5 hash (e.g., d7e16a6657c086a034a14a6619cffe7b). This means that the URL will change every time the file is modified. For this reason, hardcoding links to these URLs in the content should be avoided whenever possible.

The repository contains a special static folder. The files under that folder are published under the root of the website, using the same paths as are present in the static folder at the time of publishing. In addition to the files that are hosted in the repository's static folder, the repository infrastructure also finds all files under the content/hardware folder with suffix matching standardized patterns used by the common product "resource" files and copies them to the appropriate locations under the static folder before publishing the website:

- name: Copy Static Files
run: |
mkdir -p static/resources/datasheets static/resources/schematics static/resources/pinouts
find ./content/hardware -type f -name "*-schematics.pdf" -exec cp {} ./static/resources/schematics/ \;
find ./content/hardware -type f -name "*-datasheet.pdf" -exec cp {} ./static/resources/datasheets/ \;
find ./content/hardware -type f -name "*-full-pinout.pdf" -exec cp {} ./static/resources/pinouts/ \;
find ./content/hardware -type f -name "*-pinout.png" -exec cp {} ./static/resources/pinouts/ \;

(and the same system in .github/workflows/deploy-prd.yml and .github/workflows/deploy-stg.yml)

In order to avoid broken links and the burden of maintaining ephemeral links, these file paths (e.g., /resources/schematics/ABX00074-schematics.pdf / https://docs.arduino.cc/resources/schematics/ABX00074-schematics.pdf) should always be targeted in links when available instead of using the ephemeral URLs.

Contribution Guidelines

Additional Context

There are two different possible valid approaches for linking to these files in the content source:

  • Link to full URL
    e.g.:
    [Portenta C33 schematics](https://docs.arduino.cc/resources/schematics/ABX00074-schematics.pdf)
  • Domain-less link
    e.g.:
    [Portenta C33 schematics](/resources/schematics/ABX00074-schematics.pdf)

My impression is that the latter is the best approach. This makes it possible to produce functional links in preview builds of the website (either through this repository's currently broken automatic preview system, or local builds) to files that are not already published on docs.arduino.cc website. For this reason, I took the domain-less approach in the changes made in this PR.


Related: #1881 (comment)

In addition to the Markdown content source files, this repository hosts non-text files. These are linked to in various
places in the content.

The website publishing system hosts these non-text files in paths under the `static` subfolder of the website. The path
of the published file includes the file's MD5 hash. This means that the URL will change every time the file is modified.
For this reason, hardcoding links to these URLs in the content should be avoided whenever possible.

The repository contains a special `static` folder. The files under that folder are published under the root of the
website, using the same paths as are present in the `static` folder at the time of publishing. In addition to the files
that are hosted in the repository's `static` folder, the repository infrastructure also finds all files under the
`content/hardware` folder with suffix matching standardized patterns used by the common product "resource" files and
copies them to the appropriate locations under the `static` folder before publishing the website. Links should always
target the files at this location when available instead of using the ephemeral URLS.
@per1234 per1234 added enhancement New feature or request arduino Bugs and fixes added by the Arduino Team labels Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arduino Bugs and fixes added by the Arduino Team enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant