forked from rosindex/rosindex
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathindex.html
405 lines (372 loc) · 14.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
---
layout: default
---
<div class="container-fluid" style="margin-top:20px; height:100%;">
<div class="container-fluid" style="height:100%;">
<div class="row" style="height:var(--breadcrumb-height);">
<ol class="breadcrumb showAsHome" style="display:none">
<li class="active">Home</li>
</ol>
<ol class="breadcrumb showAsSearch" style="display:none">
<li><a href="{{site.baseurl}}/">Home</a></li>
<li class="active">Package List</li>
</ol>
</div>
<div class="row" style="height:var(--distro-height);">
{% include distro_switch.html %}
</div>
<div class="row" style="height:var(--search-height);">
<div class="panel panel-default" style="height:100%;">
<div class="panel-heading" style="height:100%;">
<div class="row" style="height:100%;">
<div class="col-xs-6">
<div class="input-group">
<input id="search-query" type="text" class="form-control"
autocomplete="off" placeholder="Search packages">
<span class="input-group-btn">
<button id="search-button" title="Search packages" class="btn btn-default">
<span class="glyphicon glyphicon-search"></span>
</button>
</span>
<span class="input-group-addon showCellAsSearch" style="display:none">
<input type="checkbox" id="search-enable-box"/>
<span class="hidden-xs"> Enable search </span>
</span>
</div>
</div>
<div class="col-xs-4" style="line-height:35px;">
<p class="showAsSearch" style="display:none;">
<span class="hidden-xs">Showing </span>
<span id="table-filtered-count">0</span> of
<span id="table-unfiltered-count">0</span>
<span class="hidden-xs"> packages</span>
</p>
</div>
<div class="col-xs-2 text-right" style="line-height:35px">
<p>
<a href="{{site.baseurl}}/help/package_list/">
<span class="glyphicon glyphicon-question-sign"></span>
<span class="hidden-xs"> Help</span>
</a>
</p>
</div>
</div>
</div>
</div>
</div>
<div class="row showAsHome" style="display:none;">
<h2>Welcome to ROS Index</h2>
<p>
ROS Index is the entry point for searching ROS and ROS 2 resources, including packages, repositories, and system dependencies.
</p>
<p>
You can enter keywords and phrases in the search bar and then filter results by resource type, or you can browse the complete package, repository and system dependency lists.
</p>
<p>
New to ROS Index? Be sure to follow our
<a href="{{site.baseurl}}/help/tutorial">Tutorial</a>
To learn more about the process of searching for packages.
</p>
<h2>Active Distributions</h2>
<p>
<a href="https://wiki.ros.org/noetic">ROS Noetic</a>
</p>
<p>
<a href="https://docs.ros.org/en/humble/Releases/Release-Humble-Hawksbill.html">ROS 2 Humble</a>
</p>
<p>
<a href="https://docs.ros.org/en/jazzy/Releases/Release-Jazzy-Jalisco.html">ROS 2 Jazzy</a>
</p>
<h2>Development Distribution</h2>
<p>
<a href="http://docs.ros.org/en/rolling/Releases/Release-Rolling-Ridley.html">ROS 2 Rolling</a>
</p>
<h2>More resources</h2>
<p>
<a href="https://discourse.ros.org/">ROS Discourse</a>
</p>
<p>
<a href="https://robotics.stackexchange.com/">Robotics Stack Exchange</a>
</p>
<p>
<a href="https://www.ros.org/">ros.org</a>
</p>
</div>
<div class="row tab-table showAsSearch" style="height:calc(var(--content-height) - var(--search-height) - var(--distro-height) - var(--breadcrumb-height) - var(--table-margins))">
<div id="packages-table"></div>
</div>
</div>
</div>
<!-- See https://github.com/olifolkerd/tabulator/issues/4419 for issue with Tabulator post-5.6.0 -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/tabulator.min.css" rel="stylesheet">
<!-- <script src={{ "/js/tabulator.js" | prepend: site.baseurl }}></script> -->
<script src={{ "/js/distro_switch.js" | prepend: site.baseurl }}></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/tabulator.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/build/global/luxon.min.js"></script>
<script src="{{site.baseurl}}/js/lunr.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var gData_promises = {};
var gIndex_promises = {};
var gTable = null;
var gDistro = "{{ site.distros[0] }}";
const DEFAULT_SORT = [{column:"url", dir:"asc"}];
function setHome() {
// Show the page as a home page, without the package table.
$("body").css("height", "auto");
$(".page-content").css("height", "auto");
$(".wrapper").css("height", "auto");
$(".showAsSearch").css("display", "none");
$(".showCellAsSearch").css("display", "none");
$(".showAsHome").css("display", "block");
}
function setSearch() {
// Show the page as a package search/list page.
$("body").css("height", "100vh");
$(".page-content").css("height", "var(--content-height)");
$(".wrapper").css("height", "100%");
$(".showAsHome").css("display", "none");
$(".showAsSearch").css("display", "block");
$(".showCellAsSearch").css("display", "table-cell");
}
function addFilter(table, field, type, value) {
// Add a new table filter, removing existing.
removeFilterByField(table, field);
table.addFilter(field, type, value);
}
function removeFilterByField(table, field) {
// remove all filters on a specified field, if any.
for (const existingFilter of table.getFilters()) {
if ('field' in existingFilter && existingFilter['field'] == field) {
table.removeFilter(existingFilter.field, existingFilter.type, existingFilter.value);
}
}
}
function getData(distro) {
// Start and return a promise to get distro json data.
if (distro in gData_promises) {
return gData_promises[distro];
}
gData_promises[distro] =
fetch(`{{site.baseurl}}/search/packages/data.${distro}.json`)
.then((response) => response.json());
return gData_promises[distro];
}
function getIndex(distro) {
// Start and return a promise to get distro json index.
if (distro in gIndex_promises) {
return gIndex_promises[distro];
}
gIndex_promises[distro] =
fetch(`{{site.baseurl}}/search/packages/index.${distro}.json`)
.then((response) => response.json())
.then((indexData) => {
return lunr.Index.load(indexData);
});
return gIndex_promises[distro];
}
function getWindowSearchQuery() {
return new URL(window.location.toString()).searchParams.get('pkgs');
}
function getIsSearch() {
return new URL(window.location.toString()).searchParams.has('search_packages');
}
function setWindowSearchQuery(query) {
// Populate the search input with querystring parameter.
var url = new URL(window.location.toString());
url.searchParams.set('pkgs', query);
url.searchParams.set('search_packages', true);
window.history.pushState({}, '', url);
}
function copySearchQueryToUI() {
var query = getWindowSearchQuery() || '';
$('#search-query').val(query);
$("#search-enable-box").prop("checked", !!query);
}
function copyUIToSearchQuery() {
if ($("#search-enable-box").prop("checked")) {
setWindowSearchQuery($('#search-query').val());
} else {
setWindowSearchQuery('');
}
}
function getSearchArray(distro, query) {
// Returns a promise resolving to a search array of id hits.
if (!query) {
return Promise.resolve(null);
}
return getIndex(distro).then(searchIndex => {
var searchResults = searchIndex.search(query);
var searchArray = searchResults.map((result) => parseInt(result.ref));
console.log(`Search returned ${searchArray.length} results`);
// Tabulator filters don't seem to work with zero entries
searchArray = searchArray.length ? searchArray : [-1];
return searchArray;
});
}
function setTableFilter(table, searchArray) {
// Set the sort and filter for a table with search results.
// Must be called after table built event.
if (searchArray) {
addFilter(table, 'id', 'in', searchArray);
} else {
removeFilterByField(table, 'id');
}
}
function makeTable(distro, data, searchArray) {
const CALENDAR = "\u{1F4C5}";
const STAR = "\u2605";
const LEFT_ARROW = "\u2B05";
const RIGHT_ARROW = "\u27A1";
var tableSort = DEFAULT_SORT;
if (searchArray) {
var tableFilter = [{field: 'id', type: 'in', value: searchArray}];
} else {
var tableFilter = [];
}
const table = new Tabulator("#packages-table", {
columnDefaults:{ tooltip:true },
maxHeight:"100%",
data:data, //assign data to table
layout:"fitColumns", //fit columns to width of table (optional)
rowHeight:30, // Workaround for https://github.com/olifolkerd/tabulator/issues/4419
initialSort: tableSort,
initialFilter: tableFilter,
columns:[ //Define Table Columns
{ title:"Name", field:"url", width:200,
formatter:"link", formatterParams:{labelField:"name", urlPrefix:"{{site.baseurl}}"}},
{ title:"Description", field:"description", minWidth:300},
{ title:STAR, field:"released", width:40, formatter:"tickCross", headerTooltip:"release status", hozAlign:"center",
formatterParams: {allowTruthy: true, allowEmpty: true}},
{ title:CALENDAR, field: "last_commit_time", width:80, headerHozAlign:"center", headerTooltip:"last commit date",
sorter:"date", sorterParams:{format:"yyyy-MM-dd"}},
{ title:LEFT_ARROW, field:"pkg_deps", width:40, headerTooltip:"package dependency count"},
{ title:RIGHT_ARROW, field:"dependants", width:40, headerTooltip:"package used by count"},
{ title:"Authors", field:"authors", width:120},
{ title:"Maintainers", field:"maintainers", width:120},
{ title:"Repo", field:"repo_name", width:100,
formatter:"link", formatterParams:{labelField:"repo_name", url:(cell) => {
return `{{site.baseurl}}/r/${cell.getValue()}/#${distro}`}}},
{ title:"Org", field:"org", width:100},
],
});
return table;
}
function makeBuiltTable(distro, data, searchArray) {
// Returns a promise resolving to a built Tabulator table.
var table = makeTable(distro, data, searchArray);
var tablePromise = new Promise((resolve, reject) => {
table.on("dataFiltered", (filters, rows) => {
console.log(`Table filtered: total: ${table.getDataCount()} rowCount: ${rows.length}`);
$("#table-filtered-count").text(rows.length);
$("#table-unfiltered-count").text(table.getDataCount());
});
table.on("tableBuilt", () => {
resolve(table);
});
});
return tablePromise;
}
function showTable(distro, query) {
// Returns a promise that displays a Tabulator table.
var searchPromise = query ? getSearchArray(distro, query) : Promise.resolve(null);
return Promise.all([getData(distro), searchPromise]).then(values => {
var data = values[0];
var searchArray = values[1];
if (!searchArray) {
$("#table-filtered-count").text(data.length);
$("#table-unfiltered-count").text(data.length);
}
if (gTable) {
setTableFilter(gTable, searchArray);
gTable.replaceData(data).then(console.log('table data replaced'));
return;
}
else {
makeBuiltTable(distro, data, searchArray).then(table => {
gTable = table;
});
}
});
}
$(function() {
copySearchQueryToUI();
gDistro = setupDistroSwitch("{{ site.distros[0] }}");
getData(gDistro);
if (getIsSearch()) {
var query = getWindowSearchQuery();
showTable(gDistro, query).then(setSearch());
} else {
setHome();
}
window.addEventListener("popstate", (event) => {
console.log(`onpopstate: url: ${document.location.toString()}`);
if (getIsSearch()) {
copySearchQueryToUI();
var query = getWindowSearchQuery();
showTable(gDistro, query).then(setSearch());
} else {
setHome();
}
});
window.addEventListener('hashchange', (event) => {
// Reload the table if the distro changes.
var url = new URL(document.location.toString());
console.log(`hash change url: ${url.href}`);
if (url.hash) {
gDistro = url.hash.substring(1);
} else {
gDistro = gDistro || "{{ site.distros[0] }}";
}
getData(gDistro);
var query = getWindowSearchQuery();
if (gTable) {
gTable.clearData();
}
if (getIsSearch()) {
showTable(gDistro, query).then(setSearch());
} else {
setHome();
}
});
$('#search-query').on('focus', (e) => {
// Pre-load index to speed up search response.
getIndex(gDistro);
});
$('#search-query').bind('keypress', (e) => {
if (e.which == 13) {
$("#search-enable-box").prop("checked", true);
copyUIToSearchQuery();
var query = getWindowSearchQuery() || '';
showTable(gDistro, query).then(setSearch());
}
});
$("#search-enable-box").on('click', (e) => {
var element = e.currentTarget;
var query = $("#search-query").val();
if (element.checked && query) {
copyUIToSearchQuery();
} else {
setWindowSearchQuery('');
query = '';
if (gTable) {
gTable.setSort(DEFAULT_SORT);
}
}
showTable(gDistro, query).then(setSearch());
});
$("#search-button").on('click', (e) => {
var query = $("#search-query").val();
if (query) {
$("#search-enable-box").prop("checked", true);
copyUIToSearchQuery();
} else {
setWindowSearchQuery('');
query = '';
if (gTable) {
gTable.setSort(DEFAULT_SORT);
}
}
showTable(gDistro, query).then(setSearch());
});
});
</script>