Skip to content

Replace multiple strings at once when normalizing links

Achilleas Pipinellis requested to merge axil-refactor-sed-normalize into main

Instead of iterating the whole documentation multiple times to replace various strings, iterate the files only once and replace multiple strings.

Related issues

#1584 (closed)

Before

time scripts/normalize-links.sh . 15.9
Replace relative URLs in ./15.9 for /ee/
Replace relative URLs in ./15.9 for /runner/
Replace relative URLs in ./15.9 for /omnibus/
Replace relative URLs in ./15.9 for /charts/
Replace relative URLs in ./15.9 for /operator/
Replace relative URLs in ./15.9 for /assets/
Replace relative URLs in ./15.9 for /frontend/
Replace relative URLs in ./15.9 for /search/
Replace relative URLs in ./15.9 for /
Replace relative URLs in ./15.9 for opensearch.xml
Replace full URLs in ./15.9 for /ee/
Replace full URLs in ./15.9 for /runner/
Replace full URLs in ./15.9 for /omnibus/
Replace full URLs in ./15.9 for /charts/
Replace full URLs in ./15.9 for /operator/
Fix URLs inside the sitemap
Remove CE dir and symlink EE to CE

scripts/normalize-links.sh . 15.9  97.13s user 55.45s system 99% cpu 2:34.03 total

After

time scripts/normalize-links.sh . 15.10
=> Replace relative URLs in ./15.10 for HTML files
=> Replace relative URLs in ./15.10 for CSS files
=> Replace relative URLs in ./15.10 for JavaScript files
=> Replace full URLs in ./15.10 for HTML files
=> Fix URLs inside the sitemap
Remove CE dir and symlink EE to CE

scripts/normalize-links.sh . 15.10  67.06s user 11.66s system 99% cpu 1:18.84 total

Test locally

  1. Remove public and rebuild the site:

    make clean && make compile
  2. Copy public to two versions in order to compare the before and after:

    cp -a public 15.10
    cp -a public 15.9
  3. Run the script in main for 15.10:

    time scripts/normalize-links.sh . 15.10
  4. Check out this branch.

  5. Run the script in this branch for 15.9:

    time scripts/normalize-links.sh . 15.9
  6. Optional. You can use diff to check that the results are the "same" (strings replaced, the only difference should be the version).

    diff 15.9 15.10
Edited by Achilleas Pipinellis

Merge request reports