Skip to content

Commit 211c8f2

Browse files
Search tool (#41)
* Fix visualization issues with back slash. * Add search tool. * Remove unexpected end tag. * Fix Google Chrome/Chromium issues. Improve navigation var layout. Improve search results layout.
1 parent fe7d816 commit 211c8f2

5 files changed

Lines changed: 3074 additions & 27 deletions

File tree

_docs/tutorials/getting_started/index.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,21 @@ Run the subscriber.
101101
Run the micro-ROS Agent.
102102
For the micro-ROS Agent to find the XML reference file, the execution must be done from the executable folder.
103103

104-
```bash
104+
```cmd
105105
cd C:\A\install\Lib\uros_agent\
106106
uros_agent.exe udp 8888
107107
```
108108

109109
Run the publisher.
110110

111-
```bash
111+
```cmd
112112
cd C:\C\install\Lib\int32_publisher_c\
113113
int32_publisher_c.exe
114114
```
115115

116116
Run the subscriber.
117117

118-
```bash
118+
```cmd
119119
cd C:\C\install\Lib\int32_subscriber_c\
120120
int32_subscriber_c.exe
121121
```
@@ -174,21 +174,21 @@ Run the subscriber.
174174
Run the micro-ROS Agent.
175175
For the micro-ROS Agent to find the XML reference file, the execution must be done from the executable folder.
176176

177-
```bash
177+
```cmd
178178
cd C:\A\install\Lib\uros_agent\
179179
uros_agent.exe udp 8888
180180
```
181181

182182
Run the publisher.
183183

184-
```bash
184+
```cmd
185185
cd C:\C\install\Lib\string_publisher_c\
186186
string_publisher_c.exe
187187
```
188188

189189
Run the subscriber.
190190

191-
```bash
191+
```cmd
192192
cd C:\C\install\Lib\string_subscriber_c\
193193
string_subscriber_c.exe
194194
```
@@ -256,21 +256,21 @@ Run the subscriber.
256256
Run the micro-ROS Agent.
257257
For the micro-ROS Agent to find the XML reference file, the execution must be done from the executable folder.
258258

259-
```bash
259+
```cmd
260260
cd C:\A\install\Lib\uros_agent\
261261
uros_agent.exe udp 8888
262262
```
263263

264264
Run the publisher.
265265

266-
```bash
266+
```cmd
267267
cd C:\C\install\Lib\complex_msg_publisher_c\
268268
complex_msg_publisher_c.exe
269269
```
270270

271271
Run the subscriber.
272272

273-
```bash
273+
```cmd
274274
cd C:\C\install\Lib\complex_msg_subscriber_c\
275275
complex_msg_subscriber_c.exe
276276
```
@@ -386,35 +386,35 @@ Run the display node.
386386
Run the micro-ROS Agent.
387387
For the micro-ROS Agent to find the XML reference file, the execution must be done from the executable folder.
388388

389-
```bash
389+
```cmd
390390
cd C:\A\install\Lib\uros_agent\
391391
uros_agent.exe udp 8888
392392
```
393393

394394
Run the altitude_sensor node.
395395

396-
```bash
396+
```cmd
397397
cd C:\C\install\Lib\rad0_altitude_sensor_c
398398
rad0_altitude_sensor_c.exe
399399
```
400400

401401
Run the actuator node.
402402

403-
```bash
403+
```cmd
404404
cd C:\C\install\Lib\rad0_actuator_c
405405
rad0_actuator_c.exe
406406
```
407407

408408
Run the display node.
409409

410-
```bash
410+
```cmd
411411
cd C:\C\install\Lib\rad0_display_c\
412412
rad0_display_c.exe
413413
```
414414

415415
###### ROS2 nodes
416416

417-
```bash
417+
```cmd
418418
cd C:\A\install\Lib\rad0_control_cpp\
419419
rad0_control_cpp.exe
420420
```

_includes/search-lunr.html

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<script src="/js/lunr.js"></script>
2+
3+
<script>
4+
{% assign counter = 0 %}
5+
var documents = [{% for page in site.pages %}{% if page.url contains '.xml' or page.url contains 'assets' %}{% else %}{
6+
"id": {{ counter }},
7+
"url": "{{ site.url }}{{ page.url }}",
8+
"title": "{{ page.title }}",
9+
"body": "{{ page.content | markdownify | replace: '.', '. ' | replace: '</h2>', ': ' | replace: '</h3>', ': ' | replace: '</h4>', ': ' | replace: '</p>', ' ' | strip_html | strip_newlines | replace: ' ', ' ' | replace: '"', ' ' }}"{% assign counter = counter | plus: 1 %}
10+
}, {% endif %}{% endfor %}{% for page in site.without-plugin %}{
11+
"id": {{ counter }},
12+
"url": "{{ site.url }}{{ page.url }}",
13+
"title": "{{ page.title }}",
14+
"body": "{{ page.content | markdownify | replace: '.', '. ' | replace: '</h2>', ': ' | replace: '</h3>', ': ' | replace: '</h4>', ': ' | replace: '</p>', ' ' | strip_html | strip_newlines | replace: ' ', ' ' | replace: '"', ' ' }}"{% assign counter = counter | plus: 1 %}
15+
}, {% endfor %}{% for page in site.posts %}{
16+
"id": {{ counter }},
17+
"url": "{{ site.url }}{{ page.url }}",
18+
"title": "{{ page.title }}",
19+
"body": "{{ page.date | date: "%Y/%m/%d" }} - {{ page.content | markdownify | replace: '.', '. ' | replace: '</h2>', ': ' | replace: '</h3>', ': ' | replace: '</h4>', ': ' | replace: '</p>', ' ' | strip_html | strip_newlines | replace: ' ', ' ' | replace: '"', ' ' }}"{% assign counter = counter | plus: 1 %}
20+
}, {% endfor %}{% for page in site.docs %}{
21+
"id": {{ counter }},
22+
"url": "{{ site.url }}{{ page.url }}",
23+
"title": "{{ page.title }}",
24+
"body": "{{ page.date | date: "%Y/%m/%d" }} - {{ page.content | markdownify | replace: '.', '. ' | replace: '\', '/' | replace: '</h2>', ': ' | replace: '</h3>', ': ' | replace: '</h4>', ': ' | replace: '</p>', ' ' | strip_html | strip_newlines | replace: ' ', ' ' | replace: '"', ' ' }}"{% assign counter = counter | plus: 1 %}
25+
}{% if forloop.last %}{% else %}, {% endif %}{% endfor %}];
26+
27+
var idx = lunr(function () {
28+
this.ref('id')
29+
this.field('title')
30+
this.field('body')
31+
32+
documents.forEach(function (doc) {
33+
this.add(doc)
34+
}, this)
35+
});
36+
function lunr_search(term) {
37+
document.getElementById('lunrsearchresults').innerHTML = '<ul></ul>';
38+
if(term) {
39+
document.getElementById('lunrsearchresults').innerHTML = "<p>Search results for '" + term + "'</p>" + document.getElementById('lunrsearchresults').innerHTML;
40+
//put results on the screen.
41+
var results = idx.search(term);
42+
if(results.length>0){
43+
//console.log(idx.search(term));
44+
//if results
45+
for (var i = 0; i < results.length; i++) {
46+
// more statements
47+
var ref = results[i]['ref'];
48+
var url = documents[ref]['url'];
49+
var title = documents[ref]['title'];
50+
var body = documents[ref]['body'].substring(0,160)+'...';
51+
document.querySelectorAll('#lunrsearchresults ul')[0].innerHTML = document.querySelectorAll('#lunrsearchresults ul')[0].innerHTML + "<li class='lunrsearchresult'><a href='" + url + "'><span class='title'>" + title + "</span><br /><span class='body'>"+ body +"</span><br /><span class='url'>"+ url +"</span></a></li>";
52+
}
53+
} else {
54+
document.querySelectorAll('#lunrsearchresults ul')[0].innerHTML = "<li class='lunrsearchresult'>No results found...</li>";
55+
}
56+
}
57+
return false;
58+
}
59+
</script>
60+
<style>
61+
.lunrsearchresult .title {color: #d9230f;}
62+
.lunrsearchresult .url {color: silver;}
63+
.lunrsearchresult a {display: block; color: #777;}
64+
.lunrsearchresult a:hover, .lunrsearchresult a:focus {text-decoration: none;}
65+
.lunrsearchresult a:hover .title {text-decoration: underline;}
66+
</style>
67+
68+
<form class="navbar-form navbar-right" onSubmit="return lunr_search(document.getElementById('lunrsearch').value);">
69+
<div class="form-group">
70+
<label for="lunrsearch" class="fa fa-search"></label>
71+
<input type="text" class="form-control fa fa-search" id="lunrsearch" name="q" maxlength="255" value="" placeholder="Search via Lunr.js" />
72+
</div>
73+
</form>

_includes/topnav.html

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,11 @@
1616
<li {% if page.sectionid=='docs' %} class="active" {% endif %}><a href="{{ "/docs/home/" | prepend: site.baseurl }}">Docs</a></li>
1717
<li {% if page.sectionid=='posts' %} class="active" {% endif %}><a href="{{ site.posts.first.url | prepend: site.baseurl }}">Updates</a></li>
1818
</ul>
19-
<div class="navbar-right">
20-
<!--form class="navbar-form navbar-left">
21-
<!div class="form-group has-feedback">
22-
<input id="search-box" type="search" class="form-control" placeholder="Search...">
23-
<i class="fa fa-search form-control-feedback"></i>
24-
</div>
25-
</form-->
26-
<ul class="nav navbar-nav">
27-
<li><a href="{{ site.git_address }}"><i class="fa fa-github" aria-hidden="true"></i></a></li>
28-
</ul>
29-
</div>
30-
</div>
19+
<ul class="nav navbar-nav navbar-right">
20+
<li>{% include search-lunr.html %}</li>
21+
<li><a href="{{ site.git_address }}"><span class="fa fa-github" aria-hidden="true"></span></a></li>
22+
</ul>
23+
</div>
24+
3125
</div>
3226
</nav>

_layouts/default.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
<body>
77

88
{% include topnav.html %}
9-
9+
<div class="container" id="lunrsearchresults">
10+
<ul></ul>
11+
</div>
12+
1013
<div class="page-content">
1114
<div class="wrapper">
1215
{{ content }}

0 commit comments

Comments
 (0)