Skip to content

Commit 9bc7dae

Browse files
committed
🔍 [2.1.75] Search documentation
1 parent 50921e1 commit 9bc7dae

File tree

6 files changed

+337
-11
lines changed

6 files changed

+337
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
The following enhancements and changes have been made to ***Auto Build Marlin***.
44

5+
## 2.1.75
6+
- Info Panel: Search marlinfw.org site for documentation.
7+
- Config Editor: Add parsing for Marlin `2.1.3-b3` macros.
8+
59
## 2.1.74
610
- Config Editor: Fix int and float value sanitizing
711
- ABM Panel: Fix parsing of arch list from `pins.h`

abm/css/infoview.css

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* {
88
--marlin-svg: url(marlin-b.svg);
99
--abm-info-color: var(--vscode-editor-color);
10+
--abm-info-overlay-bg: var(--vscode-sideBarSectionHeader-background);
1011
--abm-item-label-width: 24em;
1112
--abm-field-max-width: calc(100% - var(--abm-item-label-width) - 2em);
1213
}
@@ -20,6 +21,12 @@ body.vscode-light {
2021
--abm-info-color-comment: #3C2200;
2122
--abm-info-legend-color: #000;
2223
--abm-info-legend-bg: #FFFA;
24+
--color-h1-gcode: #B88;
25+
--color-h1-basics: #8B8;
26+
--color-h1-feat: #8BB;
27+
--color-h1-hardware: #88B;
28+
--color-h1-devel: #BB8;
29+
--color-h1-setting: #B8B;
2330
}
2431

2532
body.vscode-dark {
@@ -32,6 +39,12 @@ body.vscode-dark {
3239
--abm-info-color-comment: #827461;
3340
--abm-info-legend-color: #FFF;
3441
--abm-info-legend-bg: #0008;
42+
--color-h1-gcode: #B88;
43+
--color-h1-basics: #8B8;
44+
--color-h1-feat: #8BB;
45+
--color-h1-hardware: #88B;
46+
--color-h1-devel: #BB8;
47+
--color-h1-setting: #B8B;
3548
}
3649

3750
body.vscode-high-contrast {
@@ -44,6 +57,12 @@ body.vscode-high-contrast {
4457
--abm-info-color-comment: #827461;
4558
--abm-info-legend-color: #FF0;
4659
--abm-info-legend-bg: #009;
60+
--color-h1-gcode: #B88;
61+
--color-h1-basics: #8B8;
62+
--color-h1-feat: #8BB;
63+
--color-h1-hardware: #88B;
64+
--color-h1-devel: #BB8;
65+
--color-h1-setting: #B8B;
4766
}
4867
body.vscode-high-contrast-light {
4968
--abm-info-legend-color: #009;
@@ -60,9 +79,7 @@ body {
6079
background: var(--marlin-svg) transparent no-repeat fixed center;
6180
background-size: 80%;
6281
}
63-
h1, h2, h3, h4, h5, h6 {
64-
text-align: center;
65-
}
82+
h1, h2 { text-align: center; }
6683

6784
/* Prevent text selection on all the elements */
6885
* {
@@ -82,6 +99,47 @@ pre {
8299
user-select: text;
83100
}
84101

85-
/* Media variants for wider and small screens */
86-
@media screen and (min-width: 800px) {
102+
[data-search-form] {
103+
padding-bottom: 4px;
104+
font-size: 150%;
105+
label { font-weight: bold; margin-right: 0.5em; }
106+
input { font-size: 110%; border-radius: 1em; padding: 2px 0.5em; }
107+
text-align: center;
108+
}
109+
[data-search-results] {
110+
h3, h4 { text-align: left; }
111+
h2 { border-radius: 0.5em; width: auto; padding: 4px 0; margin-bottom: 0; }
112+
h2.gcode { background: var(--color-h1-gcode); }
113+
h2.basics { background: var(--color-h1-basics); }
114+
h2.feat { background: var(--color-h1-feat); }
115+
h2.hardware { background: var(--color-h1-hardware); }
116+
h2.devel { background: var(--color-h1-devel); }
117+
h2.setting { background: var(--color-h1-setting); }
118+
h2.config { background: var(--color-h1-setting); }
119+
div.item {
120+
clear: both;
121+
padding: 1em;
122+
border-bottom: 1px solid black;
123+
span.label {
124+
float: right;
125+
font-weight: bold;
126+
margin-right: 1em;
127+
}
128+
>a { clear: both; }
129+
background-color: #FFF4;
130+
&.odd { background-color: #FFFA; }
87131
}
132+
&>h1 {
133+
color: var(--color-data-search);
134+
background: var(--color-data-search-bg);
135+
}
136+
}
137+
p.found { text-align: center; }
138+
139+
div.overlay {
140+
width: 100%;
141+
position: fixed;
142+
background-color: var(--abm-info-overlay-bg);
143+
box-shadow: 0 0 24px -6px #000;
144+
h1 { margin: 0 0 4px 0; }
145+
}

abm/info.html

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,52 @@
88
/>
99
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
1010
<link href="${ cssUri }" rel="stylesheet" />
11+
<script nonce="${ nonce }">
12+
//<![CDATA[
13+
const searchData = ${ _searchData };
14+
// ]]>
15+
</script>
1116
<script nonce="${ nonce }" src="${ vsviewUri }"></script>
1217
<script nonce="${ nonce }" src="${ schemaUri }"></script>
1318
<script nonce="${ nonce }" src="${ jqueryUri }"></script>
1419
<script nonce="${ nonce }" src="${ scriptUri }"></script>
1520
<title>Marlin Info</title>
1621
</head>
1722
<body id="abm-info">
23+
<!-- Based on marlinfw.org live site search page -->
24+
25+
<div id="search" class="container" role="main">
26+
27+
<div class="overlay">
28+
29+
<h1>🔍 Marlin Documentation</h1>
30+
31+
<!-- Search form -->
32+
<form data-search-form>
33+
<label for="q">Search:</label><input type="search" name="q" id="q" placeholder="@marlinfw.org" autocomplete="off" data-search-input />
34+
</form>
35+
36+
<!-- Search results placeholder -->
37+
<p class="found" data-search-found>
38+
<span data-search-found-count></span> result(s) found for &ldquo;<span data-search-found-term></span>&rdquo;.
39+
</p>
40+
41+
</div>
42+
43+
<div data-search-results></div>
44+
45+
<!-- Search result template -->
46+
<script type="text/x-template" id="search-result">
47+
<div class="##DivClass##">
48+
<a href="https://marlinfw.org##Url##" title="Open ##Url## in browser…">
49+
<h3 class="title">##Title##</h3>
50+
<p class="excerpt">##Excerpt##</p>
51+
</a>
52+
##CustomHTML##
53+
</div>
54+
</script>
55+
56+
</div>
57+
1858
</body>
1959
</html>

abm/info.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const vscode = require("vscode"),
2626
const ConfigSchema = schema.ConfigSchema;
2727
var schemas;
2828

29+
const jsonFeedUrl = 'https://marlinfw.org/feeds/feed.json';
2930
class InfoPanelProvider {
3031

3132
constructor(context) { this.context = context; }
@@ -48,7 +49,7 @@ class InfoPanelProvider {
4849
enableScripts: true,
4950
localResourceRoots: [ this.context.extensionUri ]
5051
};
51-
wv.html = this.getWebViewHtml(wv);
52+
wv.html = await this.getWebViewHtml(wv);
5253

5354
// Handle show/hide events.
5455
wvv.onDidChangeVisibility(() => {
@@ -91,20 +92,34 @@ class InfoPanelProvider {
9192
}
9293
jsUri(webview, file) { return this.resourceUri(webview, 'js', file); }
9394

95+
async fetchMarlinSiteIndex() {
96+
try {
97+
const response = await fetch(jsonFeedUrl);
98+
if (!response.ok) throw new Error('Network response was not ok');
99+
const searchData = await response.text()
100+
return searchData;
101+
} catch (error) {
102+
console.error('Failed to fetch search data:', error);
103+
return null;
104+
}
105+
}
106+
94107
/**
95108
* Static HTML as the starting point for info webviews.
96109
* Attached scripts are invoked in the webview's context.
97110
*/
98-
getWebViewHtml(webview) {
111+
async getWebViewHtml(webview) {
99112
// Local path to script and css for the webview
100113
const nonce = abm.getNonce(), // Use a nonce to whitelist which scripts can be run
101114
jqueryUri = this.jsUri(webview, 'jquery-3.6.0.min.js'),
102115
vsviewUri = this.jsUri(webview, 'vsview.js'),
103116
schemaUri = this.jsUri(webview, 'schema.js'),
104117
scriptUri = this.jsUri(webview, 'infoview.js'),
105-
cssUri = this.resourceUri(webview, 'css', 'infoview.css');
118+
cssUri = this.resourceUri(webview, 'css', 'infoview.css'),
119+
_searchData = (await this.fetchMarlinSiteIndex()).replaceAll('`', '\\`');
106120

107-
return eval(`\`${ abm.load_html('info.html') }\``);
121+
const merged_html = eval(`\`${ abm.load_html('info.html') }\``);
122+
return merged_html;
108123
}
109124
}
110125

0 commit comments

Comments
 (0)