Skip to content

Commit 8fd93ad

Browse files
authored
Add zendesk tag support (#979)
* Add Zendesk verification tag support to main index.html page * Fix test
1 parent eea8802 commit 8fd93ad

File tree

10 files changed

+62
-8
lines changed

10 files changed

+62
-8
lines changed

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100
smv_released_pattern = r"^tags/.*$"
101101
# Format for versioned output directories inside the build directory
102102
smv_outputdir_format = "{ref.name}"
103-
104103
# -- Options for HTML output ----------------------------------------
105104

106105
# The theme to use for pages.
@@ -118,6 +117,7 @@
118117
"github_repository": "scylladb/sphinx-scylladb-theme",
119118
"site_description": "Sphinx Theme for ScyllaDB projects.",
120119
"hide_version_dropdown": ["master"],
120+
"zendesk_tag": "gq6ltsh3nfex3cnwfy4aj9",
121121
"versions_unstable": UNSTABLE_VERSIONS,
122122
"versions_deprecated": DEPRECATED_VERSIONS,
123123
}

docs/source/configuration/template.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,3 +282,27 @@ Configuration options for the like and dislike buttons shown at the bottom of th
282282
html_theme_options = {
283283
'hide_feedback_buttons': 'true',
284284
}
285+
286+
Zendesk options
287+
---------------
288+
289+
Configuration options for enabling zendesk.
290+
291+
.. list-table::
292+
:widths: 20 20 20 40
293+
:header-rows: 1
294+
295+
* - Option
296+
- Type
297+
- Default Value
298+
- Description
299+
* - ``zendesk_tag``
300+
- string
301+
-
302+
- Zendesk verification tag. Example: ``gq6ltsh3nfex3cnwfy4aj9``.
303+
304+
.. code:: python
305+
306+
html_theme_options = {
307+
'zendesk_tag': 'gq6ltsh3nfex3cnwfy4aj9',
308+
}

docs/source/upgrade/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## 1.6.6 - 5 Jan 2024
9+
10+
### Updated
11+
12+
- [#949](https://github.com/scylladb/sphinx-scylladb-theme/pull/949): Enhances Zendesk verification tag support.
13+
814
## 1.6.5 - 18 Dec 2023
915

1016
### Fixed

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "sphinx-scylladb-theme"
3-
version = "1.6.5"
3+
version = "1.6.6"
44
description = "A Sphinx Theme for ScyllaDB documentation projects"
55
authors = ["David García <[email protected]>"]
66
exclude = [".github", "config", "docs", "extensions", ".postcss.config.js", ".prettierrc.json", "deploy.sh", "src", "package.json", "package-lock.json"]

sphinx_scylladb_theme/extensions/multiversion.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ def create_redirect_to_latest_version(app, exception):
8282

8383
out_dir = Path(app.builder.outdir)
8484
head = out_dir.parent
85+
theme_options = app.config.html_theme_options
86+
zendesk_tag = theme_options.get("zendesk_tag", '')
8587

8688
with open(head / "index.html", "w+") as t_file:
87-
t_file.write(build_redirect_body(latest_dir))
89+
t_file.write(build_redirect_body(latest_dir, zendesk_tag))
8890

8991

9092
def setup(app):

sphinx_scylladb_theme/extensions/utils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,33 @@ def copy(src, dest):
3636
shutil.copy(src, dest)
3737

3838

39-
def build_redirect_body(path):
39+
def build_redirect_body(path, zendesk_tag=''):
4040
"""
4141
Builds the contents of the redirection file.
4242
4343
:param path: Path to redirect to.
4444
:type path: str
4545
46+
:param zendesk_tag: Zendesk tag.
47+
:type zendesk_tag: str
48+
4649
:return: HTML body of the redirection.
4750
:rtype: str
4851
"""
52+
53+
zendesk_tag_html = f'<meta name="zd-site-verification" content="{zendesk_tag}" />' if zendesk_tag else ''
54+
4955
html = generate_template(
5056
"""
5157
<html>
5258
<head>
59+
{zendesk_tag_html}
5360
<meta http-equiv="refresh" content="0; url={path}">
5461
</head>
5562
</html>
5663
""",
5764
path=path,
65+
zendesk_tag_html=zendesk_tag_html
5866
)
5967
return html
6068

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
<!-- Zendesk tag -->
2-
<meta name='zd-site-verification' content='gq6ltsh3nfex3cnwfy4aj9' />
1+
<!-- Local meta tags -->

sphinx_scylladb_theme/theme.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ scylladb_scripts = true
2525
tag_substring_removed = -scylla
2626
versions_unstable =
2727
versions_deprecated=
28+
zendesk_tag=
2829
skip_warnings=

tests/extensions/test_extensions_utils.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,21 @@ def test_generate_content():
1919

2020
def test_build_redirect_body():
2121
path = "/redirect"
22-
assert "url=/redirect" in build_redirect_body(path)
22+
result = build_redirect_body(path)
23+
assert "url=/redirect" in result
24+
assert "zendesk" not in result
25+
26+
27+
def test_build_redirect_body_with_zendesk_tag():
28+
path = "/redirect"
29+
zendesk_tag = "test-zendesk-tag"
30+
31+
# Call the function with a Zendesk tag
32+
result = build_redirect_body(path, zendesk_tag)
33+
34+
# Check if the Zendesk meta tag is in the result
35+
assert zendesk_tag in result
36+
assert "url=/redirect" in result
2337

2438

2539
def test_is_url_external():

0 commit comments

Comments
 (0)