Coder Social home page Coder Social logo

Site search middleware about caddy HOT 7 CLOSED

caddyserver avatar caddyserver commented on June 13, 2024
Site search middleware

from caddy.

Comments (7)

pedronasser avatar pedronasser commented on June 13, 2024

Could you give some more information you have in mind for this idea? An example?
How would this search work? How would the result be printed?

from caddy.

mholt avatar mholt commented on June 13, 2024

Here's what I was thinking:

  • At startup, the middleware launches a service goroutine that runs for the lifetime of the server. Initially it creates an index of the site... presumably in memory, although there are good packages for lightweight persistent data stores available too.
  • Periodically the service function re-indexes.
  • An endpoint is "exposed" (meaning that a request to a certain URL would be handled by the search middleware and not passed onto other handlers) such as /search (customizable). A GET request here with a "q" parameter would perform a search.
  • The search results would be rendered by a template specified by the user (or perhaps a default template), similar to the browse middleware.
  • The search endpoint could also be exposed as a JSON API

from caddy.

pedronasser avatar pedronasser commented on June 13, 2024

Ok, got everything.
I'll try work something out.

from caddy.

mholt avatar mholt commented on June 13, 2024

Awesome! You got it. This is something that would make a great addition to any site.

There is a pretty popular indexing library called bleve that would be worth looking into.

Also, for the record, it will be important to be able to specify a base path to index, but also make it possible to exclude paths from being indexed, for example, if part of the site is a dynamic PHP site or something - no point in indexing PHP source files.

from caddy.

mholt avatar mholt commented on June 13, 2024

Yay, this is done! \o/ Thanks @pedronasser

from caddy.

blankoworld avatar blankoworld commented on June 13, 2024

@mholt what's about this functionnality? Which directive should I use to have a search bar in my website and a /search endpoint?

from caddy.

francislavoie avatar francislavoie commented on June 13, 2024

@blankoworld I think it was https://github.com/pedronasser/caddy-search, but it doesn't seem supported anymore as far as I can tell. It's not in the official list of plugins anymore

from caddy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.