skip to main content

@tonyfast s notebooks

site navigation
notebook summary
title
creating accessible search
description
this post explores searching documents with https://lunrjs.com to be added to the blog.
cells
6 total
4 code
state
executed out of order
kernel
Python [conda env:p311] *
language
python
name
conda-env-p311-py
lines of code
68
outputs
0
table of contents
{"kernelspec": {"display_name": "Python [conda env:p311] *", "language": "python", "name": "conda-env-p311-py"}, "language_info": {"codemirror_mode": {"name": "ipython", "version": 3}, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.3"}, "widgets": {"application/vnd.jupyter.widget-state+json": {"state": {}, "version_major": 2, "version_minor": 0}}, "title": "creating accessible search", "description": "this post explores searching documents with https://lunrjs.com to be added to the blog."}
notebook toolbar
Activate
cell ordering
1

creating accessible search

this post explores searching documents with https://lunrjs.com to be added to the blog.

2
    import pandas, importlib.metadata, tonyfast.utils, json
3
4

for sample data we'll use the python distributions on the machine this was created on.

5
    distributions =  pandas.Series(importlib.metadata.distributions())

    dist = distributions.attrgetter("metadata").methodcaller("items").apply(dict).series()[
        "Name Summary Home-page".split()
    ]
    search_index = dist.to_dict(orient="records")
    display({"text/html": "<script>%s</script>" % (template % json.dumps(search_index))}, raw=True)
6