@@ -19,65 +19,34 @@ The [Neurodata Extensions Catalog (NDX Catalog)](https://github.com/nwb-extensio
1919<p ><span id =" search-process " style =" display : none " >Showing <span id =" search-results-count " ></span > results for "<strong id =" search-query " ></strong >"</span ><span id =" show-all " style =" display : none " >Showing <span id =" show-all-count " ></span > extensions</span ></p >
2020<ul id =" search-results " ></ul >
2121
22- <script src =" {{ site.url }}/js/lunr.min.js " ></script >
23- <script src =" {{ site.url }}/js/jquery-3.5.0.min.js " ></script >
24- <script src =" {{ site.url }}/js/js-yaml.min.js " ></script >
22+ <script src =" {{ site.url }}{{ site.baseurl }} /js/lunr.min.js " ></script >
23+ <script src =" {{ site.url }}{{ site.baseurl }} /js/jquery-3.5.0.min.js " ></script >
24+ <script src =" {{ site.url }}{{ site.baseurl }} /js/js-yaml.min.js " ></script >
2525<script src =" https://cdn.jsdelivr.net/npm/marked/marked.min.js " ></script >
26+ <
script src =
" https://cdn.jsdelivr.net/npm/[email protected] /dist/purify.min.js " ></
script >
2627
2728<script >
2829(function () {
29- window .data = {}
3030
31- function loadSearch () {
32- var fileref = document .createElement (' script' )
33- fileref .setAttribute (" type" , " text/javascript" )
34- fileref .setAttribute (" src" , " {{ site.baseurl }}/js/search.js" )
35- document .getElementsByTagName (" head" )[0 ].appendChild (fileref)
36- }
37-
38- $ .getJSON (" https://api.github.com/orgs/{{ site.github_username }}/repos" ).done (function (data ) {
39- countTotal = 0
40- $ .each (data, function (key , recordJson ) {
41- if (recordJson .name .startsWith (" {{ site.prefix }}" ) && recordJson .name .endsWith (" {{ site.suffix }}" ) ) {
42- countTotal += 1
43- }
31+ function loadSearch () {
32+ var fileref = document .createElement (' script' )
33+ fileref .setAttribute (" type" , " text/javascript" )
34+ fileref .setAttribute (" src" , " {{ site.baseurl }}/js/search.js" )
35+ document .getElementsByTagName (" head" )[0 ].appendChild (fileref)
36+ }
37+
38+ $ .getJSON (' {{ site.baseurl }}/data/records.json' ).done (function (data ) {
39+ Object .keys (data).forEach (key => {
40+ // add DOMPurify to sanitize parsed HTML, because marked doesn't sanitize
41+ data[key].readme = DOMPurify .sanitize (
42+ marked .parse (data[key].readme )
43+ );
44+ // data[key].pypi_version_badge = "https://img.shields.io/pypi/v/" + data[key].name;
45+ });
46+ window .data = data;
47+ loadSearch ();
4448 });
45- countLoaded = 0
46- $ .each (data, function (key , recordJson ) {
47- if (recordJson .name .startsWith (" {{ site.prefix }}" ) && recordJson .name .endsWith (" {{ site.suffix }}" ) ) {
48- var resultJson = {}
49- resultJson .ref = recordJson .name
50- resultJson .record_url = recordJson .html_url
51- resultJson .last_updated = recordJson .pushed_at
52- window .data [recordJson .name ] = resultJson
53-
54- var metaUrl = " https://api.github.com/repos/{{ site.github_username }}/" + recordJson .name + " /contents/ndx-meta.yaml"
55- $ .getJSON (metaUrl).done (function (res , status ) {
56- if (status == " success" ) {
57- metaJson = jsyaml .load (atob (res .content ))
58- for (k in metaJson) {
59- window .data [recordJson .name ][k] = metaJson[k]
60- }
61- }
62- var readmeUrl = " https://api.github.com/repos/{{ site.github_username }}/" + recordJson .name + " /contents/README.md"
63- $ .getJSON (readmeUrl).done (function (res , status ) {
64- if (status == " success" ) {
65- readmeText = atob (res .content )
66- var readmeHtml = marked .parse (readmeText)
67- window .data [recordJson .name ].readme = readmeHtml
68-
69- countLoaded += 1
70- if (countLoaded == countTotal) {
71- loadSearch ()
72- }
73- }
74- });
75- });
76- }
77- });
78- });
7949})();
80-
8150</script >
8251
8352</div >
0 commit comments