Skip to content

Commit 8357040

Browse files
committed
Refactor and cleanup
1 parent 1ed9188 commit 8357040

File tree

7 files changed

+35
-38
lines changed

7 files changed

+35
-38
lines changed

extra/client_docs_landing.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@
5151
}
5252
</style>
5353

54-
<link rel="canonical" href="https://www.elastic.co/guide/en/elasticsearch/client/index.html"/>
55-
5654
<div class="legalnotice"></div>
5755

5856
<div class="row my-4">
@@ -181,4 +179,4 @@ <h4 class="mt-3">
181179
</div>
182180

183181
<p class="my-4"><a href="https://www.elastic.co/guide/index.html">View all Elastic docs</a></p>
184-
<p class="my-4"><small>The Ruby logo available <a href="https://www.ruby-lang.org/en/about/logo/">here</a> is released under the Creative Commons <a href="https://creativecommons.org/licenses/by-sa/2.5/"> Attribution-Share Alike 2.5 License</a>. The Go gopher created by Renee French available <a href="https://go.dev/blog/gopher">here</a> and the PHP logo available <a href="https://www.php.net/download-logos.php">here</a> are released under the Creative Commons <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.en"> Attribution-Share Alike 4.0 International license</a>. </small></p>
182+
<p class="my-4"><small>The Ruby logo available <a href="https://www.ruby-lang.org/en/about/logo/">here</a> is released under the Creative Commons <a href="https://creativecommons.org/licenses/by-sa/2.5/"> Attribution-Share Alike 2.5 License</a>. The Go gopher created by Renee French available <a href="https://go.dev/blog/gopher">here</a> and the PHP logo available <a href="https://www.php.net/download-logos.php">here</a> are released under the Creative Commons <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.en"> Attribution-Share Alike 4.0 International license</a>. </small></p>

preview/preview.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const requestHandler = async (core, parsedUrl, response) => {
8282
const lang = await file.lang();
8383
const initialJsState = await buildInitialJsState(file.alternativesReport);
8484
const templated = template.apply(
85-
file.stream[Symbol.asyncIterator](), lang.trim(), initialJsState, path,
85+
file.stream[Symbol.asyncIterator](), lang.trim(), initialJsState
8686
);
8787
return new Promise((resolve, reject) => {
8888
file.stream.on("error", reject);

resources/asciidoctor/lib/chunker/url_to_v3.rb

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,11 @@ class UrlToV3
77
def initialize(doc)
88
current_url = doc.attr('current-url')
99
outdir = doc.attr('outdir')
10-
1110
current_url ||= 'index.html'
12-
13-
# raise ArgumentError, "Missing required attribute 'current-url'" if current_url.nil?
14-
# raise ArgumentError, "Missing required attribute 'outdir'" if outdir.nil?
15-
16-
# Hardcoded file path
1711
file_path = File.expand_path('v3-mapping.json', __dir__)
18-
# Read content from the specified file and convert it to a dictionary
1912
mapping = JSON.parse(File.read(file_path)) if File.exist?(file_path)
20-
21-
segments = outdir.sub('/tmp/docsbuild/target_repo/raw', '').split('/')
13+
segments = outdir.sub('/tmp/docsbuild/target_repo/raw', '').split('/') # This only works in CI.
14+
version = segments[-1] || 'unknown'
2215

2316
path_dir = if segments.empty?
2417
''
@@ -29,18 +22,25 @@ def initialize(doc)
2922
end
3023

3124
actual_url = path_dir + '/*/' + current_url
32-
33-
if mapping.key?(actual_url)
34-
new_url = mapping[actual_url]
25+
new_url = if mapping.key?(actual_url)
26+
mapping[actual_url]
3527
else
36-
new_url = '/docs'
28+
'/docs'
3729
end
3830

39-
@url = Asciidoctor::Block.new(doc, :pass, source: <<~HTML)
40-
<div id="url-to-v3" style="display: none;">
41-
A newer version is available. For the latest information, see the <a href="https://www.elastic.co#{new_url}">current release documentation</a>
42-
</div>
43-
HTML
31+
if version == '8.18'
32+
@url = Asciidoctor::Block.new(doc, :pass, source: <<~HTML)
33+
<div id="url-to-v3" style="version-warning">
34+
A newer version is available. For the latest information, see the <a href="https://www.elastic.co#{new_url}">current release documentation</a>
35+
</div>
36+
HTML
37+
else
38+
@url = Asciidoctor::Block.new(doc, :pass, source: <<~HTML)
39+
<div id="url-to-v3" class="version-warning">
40+
<bold>IMPORTANT</bold>: No additional bug fixes or documentation updates will be released for this version. For the latest information, see the <a href="https://www.elastic.co#{new_url}">current release documentation</a>
41+
</div>
42+
HTML
43+
end
4444
end
4545
end
4646
end

resources/web/air_gapped_template.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@
6060
<div class="col-12 order-2 col-md-4 order-md-1 col-lg-3 h-almost-full-md sticky-top-md" id="left_col">
6161
<!-- The TOC is appended here -->
6262
</div>
63-
<div id="what-the-what">
64-
<!-- DOCS CURRENT -->
65-
</div>
6663

6764
<div class="col-12 order-1 col-md-8 order-md-2 col-lg-7 order-lg-2 guide-section" id="middle_col">
6865
<!-- start body -->

resources/web/style/page_header.pcss

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,19 @@
55
border: 1px solid #ccc;
66
background: #FFFFD2;
77
color: black;
8+
display: none;
89
}
910

10-
.abstract .page_header {
11+
.version-warning {
12+
padding: 1em;
13+
margin-bottom: 1em;
14+
border: 1px solid #ccc;
15+
background: #FFFFD2;
16+
color: black;
17+
}
18+
19+
.abstract .page_header,
20+
.abstract .version-warning {
1121
width: 100%;
1222
}
1323
}

resources/web/template.html

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@
7373
<script src='https://www.elastic.co/elastic-nav.js'></script>
7474

7575
<div class="main-container">
76-
<div>
77-
<!-- DOCS CURRENT -->
78-
</div>
7976
<section id="content" >
8077
<div class="content-wrapper">
8178

@@ -85,6 +82,7 @@
8582
<div class="col-12 order-2 col-md-4 order-md-1 col-lg-3 h-almost-full-md sticky-top-md" id="left_col">
8683
<!-- The TOC is appended here -->
8784
</div>
85+
8886
<div class="col-12 order-1 col-md-8 order-md-2 col-lg-7 order-lg-2 guide-section" id="middle_col">
8987
<!-- start body -->
9088
<!-- DOCS BODY -->
@@ -146,13 +144,6 @@
146144

147145
<script src="/guide/static/jquery.js"></script>
148146
<script type="text/javascript" src="/guide/static/docs-v1.js"></script>
149-
<script>
150-
var pageHeader = document.querySelector('.page_header');
151-
var urlToV3 = document.querySelector('#url-to-v3');
152-
if (pageHeader && urlToV3) {
153-
pageHeader.innerHTML = urlToV3.innerHTML;
154-
}
155-
</script>
156147
<!-- DOCS FINAL -->
157148
</body>
158149
</html>

template/template.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const readFile = promisify(fs.readFile);
3232
const stat = promisify(fs.stat);
3333

3434
module.exports = templateSource => {
35-
const apply = (rawItr, lang, initialJsState, destPath) => {
35+
const apply = (rawItr, lang, initialJsState) => {
3636
/*
3737
* We apply the template by walking a stream for the template and a stream
3838
* for the raw page in parallel. We do this instead of pulling everything
@@ -185,9 +185,10 @@ module.exports = templateSource => {
185185
const raw = fs.createReadStream(source, {encoding: 'UTF-8'});
186186
const write = fs.createWriteStream(dest, {encoding: 'UTF-8'});
187187
await new Promise((resolve, reject) => {
188-
const out = apply(raw[Symbol.asyncIterator](), lang, initialJsState, dest);
188+
const out = apply(raw[Symbol.asyncIterator](), lang, initialJsState);
189189
write.on("close", resolve);
190190
write.on("error", reject);
191+
// out.on("error", write.destroy) doesn't properly forward the error!
191192
out.on("error", err => write.destroy(err));
192193
out.pipe(write);
193194
}).finally(() => raw.close());

0 commit comments

Comments
 (0)