Skip to content

Commit

Permalink
SQUASH – generate np versioned pages first, and then include them at …
Browse files Browse the repository at this point in the history
…antora build time
  • Loading branch information
michaelsembwever committed Nov 5, 2024
1 parent 3679b5b commit c7b6b60
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 66 deletions.
5 changes: 4 additions & 1 deletion site-content/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,12 @@ render_site_content_to_html() {
}


prepare_site_html_for_publication() {
generate_native_protocol_specs_pages() {
log_message "INFO" "Processing native protocols spec page"
sudo /usr/local/bin/process-native-protocol-specs-in-docker.sh
}

prepare_site_html_for_publication() {
pushd "${CASSANDRA_WEBSITE_DIR}" > /dev/null

# copy everything to content/ directory
Expand Down Expand Up @@ -407,6 +409,7 @@ then
export NODE_PATH="$(npm -g root)"
export DOCSEARCH_INDEX_VERSION=latest

generate_native_protocol_specs_pages
render_site_content_to_html

prepare_site_html_for_publication
Expand Down
4 changes: 2 additions & 2 deletions site-content/process-native-protocol-specs-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ WEBSITE_DIR="/home/build/cassandra-website"

# Step 0: Download and install Go
echo "Downloading Go $GO_VERSION..."
wget https://golang.org/dl/$GO_TAR
wget -q https://golang.org/dl/$GO_TAR

echo "Installing Go..."
tar -C /usr/local -xzf $GO_TAR
Expand All @@ -27,7 +27,7 @@ go build -o cqlprotodoc

# Step 2: Process the spec files using the parser
echo "Processing the .spec files..."
"$PARSER_DIR"/cqlprotodoc "$WEBSITE_DIR/site-content/source/modules/ROOT/examples/TEXT" "$WEBSITE_DIR/site-content/build/html/_"
"$PARSER_DIR"/cqlprotodoc "$WEBSITE_DIR/site-content/source/modules/ROOT/examples/TEXT" "$WEBSITE_DIR/site-content/source/modules/ROOT/partials/"

# Step 3: Cleanup - Remove the Cassandra and parser directories
echo "Cleaning up..."
Expand Down
66 changes: 3 additions & 63 deletions site-content/source/modules/ROOT/pages/native_protocol.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,79 +5,19 @@

[source, js]
++++
<div id="contentv3" class="doc-container"></div>
<iframe id="iframev3" src="native_protocol_v3.html" style="display:none;"></iframe>
include::ROOT:partial$native_protocol_v3.html[]
++++

== Native Protocol Version 4

[source, js]
++++
<div id="contentv4" class="doc-container"></div>
<iframe id="iframev4" src="native_protocol_v4.html" style="display:none;"></iframe>
include::ROOT:partial$native_protocol_v4.html[]
++++

== Native Protocol Version 5

[source, js]
++++
<div id="contentv5" class="doc-container"></div>
<iframe id="iframev5" src="native_protocol_v5.html" style="display:none;"></iframe>
include::ROOT:partial$native_protocol_v5.html[]
++++

[source, js]
++++
<script>
function copyBodyContent(iframeId, contentId) {
var iframe = document.getElementById(iframeId);
var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
var navElement = iframeDocument.querySelector('nav.top');
if (navElement) {
navElement.remove();
}
var preElements = iframeDocument.querySelectorAll('pre');
preElements.forEach(function(preElement) {
if (!preElement.textContent.trim()) {
preElement.remove();
}
});
var h1Elements = iframeDocument.querySelectorAll('h1');
h1Elements.forEach(function(h1Element) {
h1Element.remove();
});
var bodyContent = iframeDocument.body.innerHTML;
document.getElementById(contentId).innerHTML = bodyContent;
}
function setNavigation() {
var containers = document.querySelectorAll('.doc-container');
containers.forEach(function (container) {
var navLinks = container.querySelectorAll('nav a, pre a');
navLinks.forEach(function (link) {
link.addEventListener('click', function (event) {
event.preventDefault();
var section = link.getAttribute('href').replace("#",'');
var targetSection = container.querySelector('h2[id="' + section + '"]') || container.querySelector('h3[id="' + section + '"]') || container.querySelector('h4[id="' + section + '"]') || container.querySelector('h5[id="' + section + '"]');
if (targetSection) {
targetSection.scrollIntoView({ behavior: 'smooth' });
}
});
});
});
}
window.onload = function() {
copyBodyContent('iframev3', 'contentv3');
copyBodyContent('iframev4', 'contentv4');
copyBodyContent('iframev5', 'contentv5');
setNavigation()
}
</script>
++++

0 comments on commit c7b6b60

Please sign in to comment.