ORNL / intersect-architecture

https://intersect-architecture.readthedocs.io
Creative Commons Attribution 4.0 International
2 stars 0 forks source link

avoid hardcode in static html footer #22

Closed naughtont3 closed 2 months ago

naughtont3 commented 2 months ago

In PR#12 we setup the license and other information. One part of this was to reflect the Copyright info in a web viewable area (i.e., the footer). As such, we wanted to have a dynamic way to reflect the "INTERSECT Team" that was responsible for this work. So we chose to add a pointer in the footer to the Team anchor on the About page.

The current version of this uses a hard-coded URL in the static #_templates/footer.html:`

The fix will be to use a dynamic base URL using the sphinx jinja and substitute that into the HTML context. This will be something like {{ baseurl }}/about.html#team in the footer.html. But this should resolve to the appropriate base URL for a local build (make install path, a CI build's URL, and the appropriate "release" (e.g., "latest", "v1.2.3", etc.).

naughtont3 commented 2 months ago

Here are a few more notes for the ticket trails (this is sort of close, but wrong b/c of the base URL caveates above) :-D

conf.py tweaks:

  ###
  # TJN: Adding these for our customized footer html template
  #      (see also: "_templates/footer.html").
  #      Note, we add these so we can have the dynamic URL for baseurl as
  #      a variable we can reference in the HTML context of footer.
  #      Example:
  #      <a href="{{ baseurl }}/en/{{ release }}/about.html#team">The Team</a>
  ###
  html_context = {
      "release": release,    # Expose dynamic release from Sphinx to HTML context
      "version": version,    # Expose dynamic version from Sphinx to HTML context
      "baseurl": "https://intersect-architecture.readthedocs.io", # Our base URL
  }

_templates/footer.html:

    <a href="{{ baseurl }}/en/{{ release }}/about.html#team">Team</a>
naughtont3 commented 2 months ago

Should be fixed with 3a134872f9befb92987db20c9789499b91847776

naughtont3 commented 2 months ago

Fix was to use {{ html_baseurl }}about.html#team. note, if included starting slash (e.g., /about.html#team) it would force it to be an absolute path and goof the URL.