Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template functions to enable building client side search index #57

Closed
despens opened this issue Oct 19, 2022 · 3 comments
Closed

Template functions to enable building client side search index #57

despens opened this issue Oct 19, 2022 · 3 comments

Comments

@despens
Copy link

despens commented Oct 19, 2022

It be interesting to have functions that would support building an index for client side search engines like lunr.

To me it looks like everything is already more or less in place, except for a function that would format HTML into plain text perhaps.

If that would be there, it could be possible to generate the required json files which then could be compiled into the search index by an external tool.

@Abbe98
Copy link
Collaborator

Abbe98 commented Oct 19, 2022

Maybe the "non-html-content" example cover this use case? It generates a JSON file, not for a search index but I think the concept still applies.

https://github.com/glaciers-in-archives/snowman/tree/main/examples/non-html-content

Since that example was added the to_json function was introduced as well and together with #37 it should be made even easier.

@despens
Copy link
Author

despens commented Oct 20, 2022

Yes I was looking at that one too, and thought that if there is function to retrieve HTML from an API (as in #54) you would just need another function that strips the HTML tags from such a retrieved string, leaving only plain text. That would complete the tools to create a JSON file for each page that could be compiled into an index I believe.

@Abbe98
Copy link
Collaborator

Abbe98 commented Feb 23, 2023

These are the additions I have locally and intend to fully implement:

get_remote <url> - makes a plain HTTP GET request and returns the response body as a string (#54).
from_json <string> - JSON parser that takes a JSON-string and parses it into a data structure that Go templates understand natively (#37).

Together with the unsafe-view option, and the existing to_json and safe_html functions I think we will have a very good system in place.

A question that still stands are what options get_remote should support? Headers, yes. Basic Auth, very much maybe. POST methods, also maybe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants