FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Append a hash ?digest to CSS files for cache-busting by hugovk · Pull Request #1054 · python/devguide · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
12 changes: 11 additions & 1 deletion conf.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import hashlib
import os
import sys
import time
from pathlib import Path

# Location of custom extensions.
sys.path.insert(0, os.path.abspath(".") + "/_extensions")
Expand Down Expand Up @@ -32,14 +34,22 @@
'.github',
]

def _asset_hash(path: os.PathLike[str]) -> str:
"""Append a `?digest=` to an url based on the file content."""
full_path = (Path(html_static_path[0]) / path).resolve()
digest = hashlib.sha1(full_path.read_bytes()).hexdigest()

return f"{path}?digest={digest}"


html_theme = 'furo'
html_theme_options = {
"source_repository": "https://github.com/python/devguide",
"source_branch": "main",
}
html_static_path = ['_static']
html_css_files = [
'devguide_overrides.css',
_asset_hash('devguide_overrides.css'),
]
html_logo = "_static/python-logo.svg"
html_favicon = "_static/favicon.png"
Expand Down

Back | FazBrowse Home | New Git URL