Skip to content

Commit 8e27b66

Browse files
authored
Added filter to remove all non-static boostlook.css on library docs (#1684) (#1685)
1 parent c7b255b commit 8e27b66

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

core/htmlhelper.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ def modernize_legacy_page(
148148
head_selector="head",
149149
insert_body=True,
150150
original_docs_type=None,
151+
skip_replace_boostlook=False,
151152
show_footer=True,
152153
show_navbar=True,
153154
):
@@ -177,6 +178,8 @@ def modernize_legacy_page(
177178
tag.attrs.pop("class")
178179

179180
result = convert_name_to_id(result)
181+
if not skip_replace_boostlook:
182+
result = remove_library_boostlook(result)
180183

181184
# Use the base HTML to later extract the <head> and (part of) the <body>
182185
placeholder = BeautifulSoup(base_html, "html.parser")
@@ -291,6 +294,17 @@ def convert_name_to_id(soup):
291294
return soup
292295

293296

297+
def remove_library_boostlook(soup):
298+
for tag in soup.find_all("link"):
299+
if (
300+
tag.get("href").endswith("boostlook.css")
301+
and tag.get("href") != "/static/css/boostlook.css"
302+
):
303+
tag.decompose()
304+
305+
return soup
306+
307+
294308
def format_nested_lists(soup):
295309
"""Flattens nested lists"""
296310
try:

core/views.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
3434
get_s3_client,
3535
)
3636
from .constants import SourceDocType
37-
from .htmlhelper import modernize_legacy_page, convert_name_to_id
37+
from .htmlhelper import (
38+
modernize_legacy_page,
39+
convert_name_to_id,
40+
remove_library_boostlook,
41+
)
3842
from .markdown import process_md
3943
from .models import RenderedContent
4044
from .tasks import (
@@ -468,11 +472,12 @@ def process_content(self, content):
468472
)
469473

470474
context["hide_footer"] = True
471-
context["skip_use_boostbook_v2"] = "/antora/" in self.kwargs.get("content_path")
475+
context["skip_use_boostlook"] = "/antora/" in self.kwargs.get("content_path")
472476
if source_content_type == SourceDocType.ASCIIDOC:
473477
extracted_content = content.decode(chardet.detect(content)["encoding"])
474478
soup = BeautifulSoup(extracted_content, "html.parser")
475479
soup = convert_name_to_id(soup)
480+
soup = remove_library_boostlook(soup)
476481
soup.find("head").append(
477482
soup.new_tag("script", src=f"{STATIC_URL}js/theme_handling.js")
478483
)
@@ -492,6 +497,7 @@ def process_content(self, content):
492497
insert_body=insert_body,
493498
head_selector=head_selector,
494499
original_docs_type=SourceDocType.ANTORA,
500+
skip_replace_boostlook=context["skip_use_boostlook"],
495501
show_footer=False,
496502
show_navbar=False,
497503
)

templates/docs_libs_placeholder.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
{% block extra_head %}
55
<link href="{% static 'css/styles.css' %}" rel="stylesheet" />
66
<link rel="preload" data-modernizer="boost-legacy-docs-extra-head" href="{% static 'css/fonts.css' %}" rel="stylesheet" />
7-
<link rel="preload" data-modernizer="boost-legacy-docs-extra-head" href="{% static 'css/boostlook.css' %}" rel="stylesheet" />
7+
{% if not skip_use_boostlook %}
8+
<link rel="preload" data-modernizer="boost-legacy-docs-extra-head" href="{% static 'css/boostlook.css' %}" rel="stylesheet" />
9+
{% endif %}
810
{% comment %}These style tweaks ensure that legacy doc pages are rendered decently. Specifically, the <img /> tag is heavily used in nav bar for tutorial navigation.<style data-modernizer="boost-legacy-docs-extra-head">
911
img {
1012
display: inline-block;

0 commit comments

Comments
 (0)