Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions great_docs/_translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3955,6 +3955,34 @@
"ar": "حزم إضافية",
"he": "חבילות נוספות",
},
# ── Navbar logo tooltip (release date on second line) ─────────────
"logo_tooltip_released": {
"en": "Released {date}",
"fr": "Publié le {date}",
"de": "Veröffentlicht am {date}",
"es": "Publicado el {date}",
"pt": "Publicado em {date}",
"it": "Rilasciato il {date}",
"nl": "Uitgebracht op {date}",
"ja": "リリース日 {date}",
"ko": "출시일 {date}",
"zh-Hans": "发布于 {date}",
"zh-Hant": "發佈於 {date}",
"ru": "Выпущено {date}",
"pl": "Wydano {date}",
"tr": "Yayınlanma tarihi {date}",
"sv": "Utgiven {date}",
"da": "Udgivet {date}",
"nb": "Utgitt {date}",
"is": "Gefið út {date}",
"fi": "Julkaistu {date}",
"cs": "Vydáno {date}",
"ro": "Lansat pe {date}",
"el": "Κυκλοφόρησε {date}",
"hi": "प्रकाशित {date}",
"ar": "صدر بتاريخ {date}",
"he": "שוחרר ב-{date}",
},
}


Expand Down
44 changes: 39 additions & 5 deletions great_docs/assets/post-render.py
Original file line number Diff line number Diff line change
Expand Up @@ -2958,28 +2958,62 @@ def inject_version_badge():

badge_html = f'<span class="version-badge"{title_attr}>v{version}</span>'

# Build a Tippy.js tooltip for the logo (used when navbar has a logo
# instead of a text title). The tooltip shows version tag + release date.
# Uses HTML content: <code> for the version, <br> for the line break.
import html as _html_esc

version_html = f"<code>v{_html_esc.escape(version)}</code>"
if published_at:
date_str = published_at[:10]
released_line = _t("logo_tooltip_released", "Released {date}").replace(
"{date}", _html_esc.escape(date_str)
)
logo_tooltip_html = f"{version_html}<br>{_html_esc.escape(released_line)}"
else:
logo_tooltip_html = version_html

# Pattern to match the <a> navbar-brand-logo link wrapping logo images
logo_brand_pattern = re.compile(r'(<a\b[^>]*class="navbar-brand navbar-brand-logo"[^>]*)>')

badge_count = 0
logo_count = 0

for html_file in all_html_files:
with open(html_file, "r") as file:
content = file.read()

modified = False

match = navbar_title_pattern.search(content)
if match:
# Only inject if badge not already present
if "version-badge" not in content:
replacement = f"{match.group(1)}{match.group(2)} {badge_html}{match.group(3)}"
content = navbar_title_pattern.sub(replacement, content)
modified = True
badge_count += 1

with open(html_file, "w") as file:
file.write(content)
# When there's a logo but no text title, add a tooltip to the logo link
if not match:
logo_match = logo_brand_pattern.search(content)
if logo_match and 'data-tippy-content="' not in logo_match.group(0):
escaped_tooltip = logo_tooltip_html.replace('"', "&quot;")
replacement = f'{logo_match.group(1)} data-tippy-content="{escaped_tooltip}">'
content = logo_brand_pattern.sub(replacement, content, count=1)
modified = True
logo_count += 1

badge_count += 1
if modified:
with open(html_file, "w") as file:
file.write(content)

if badge_count > 0:
print(f"Injected version badge into {badge_count} HTML files")
else:
print("No navbar titles found for version badge injection")
if logo_count > 0:
print(f"Added version tooltip to navbar logo in {logo_count} HTML files")
if badge_count == 0 and logo_count == 0:
print("No navbar titles or logos found for version badge injection")


inject_version_badge()
Expand Down
5 changes: 5 additions & 0 deletions great_docs/assets/tooltips.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@
// Create options with current theme
var options = Object.assign({}, CONFIG.defaultOptions, {
theme: getThemeName(),
allowHTML: true,
// Read content from data-tippy-content so HTML tags are rendered
content: function (el) {
return el.getAttribute("data-tippy-content") || "";
},
// Material filling effect via CSS
onMount: function (instance) {
instance.popper.classList.add("gd-tooltip-mounted");
Expand Down
Loading