rubyworks / smeagol

Read-Only Gollum Server
http://rubyworks.github.com/smeagol
Other
92 stars 5 forks source link

Search #41

Open Atalanta opened 12 years ago

Atalanta commented 12 years ago

What do you think would be involved in adding a search capability to Smeagol? One of the great advantages of Gollum is the super-fast git-backed search.

benbjohnson commented 12 years ago

Can you send me a link to info on the Gollum search? I haven't see that before.

Atalanta commented 12 years ago

Oh sure - it's dead simple - just calls out to git grep. Lines 432-450 here: https://github.com/github/gollum/blob/master/lib/gollum/wiki.rb

And then in front end:

https://github.com/github/gollum/blob/master/lib/gollum/frontend/app.rb there's a /search route.

trans commented 12 years ago

Search functionality would be a sweet addition, if anyone wants to submit a patch.

jalberto commented 11 years ago

Is there any progress on this feature?

pearofducks commented 11 years ago

As Atalanta pointed out we get search for free out of what is now gollum-lib. So it's pretty trivial to get this started on the backend, it just needs a view and I haven't quite mastered how smeagol is rendering.

Outside of the rendering issue, the method is going to look very close to this (most of which is taken from here):

    get '/search' do
      @query = params[:q]
      wiki = Smeagol::Wiki.new(repository.path, :base_path => mount_path)
      # Sort wiki search results by count (desc) and then by name (asc)
      @results = wiki.search(@query).sort{ |a, b| (a[:count] <=> b[:count]).nonzero? || b[:name] <=> a[:name] }.reverse
      @name = @query
      mustache :search
    end
openhoat commented 10 years ago

Any chance to have this feature one day ?

pberto commented 9 years ago

I 'd like also to get the search feature available.