Skip to content

Add Algolia search on header bar #469

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

Merged
merged 3 commits into from
Nov 27, 2015
Merged

Conversation

ElPicador
Copy link
Contributor

Hello Scala team,

I've always wanted to be able to easily search inside the Scaladocs, so I've added this feature.

Desktop GIF

You can see it live and test it here: https://scaladocs.algolia.com/.

This pull request uses Algolia API to index and search the documentation.

It does not includes the indexing part, it is done with a internal tool. We have a Jekyll plugin, which handles indexing & searching but it is only compatible with version >2.5, and we could have a better autocomplete, with more context (as seen here).

I was not sure if you wanted to upgrade your Jekyll. But if you prefer I can update the Jekyll version and add the search.

Benefits for the end user

  • Search in the whole documentation, with typo-tolerance
  • Fast results (your search index is replicated in 13 regions worldwide, it is fast no matter where the user is)
  • Instant access to the documentation at the first keystroke, in a few milliseconds
  • Directly scroll to the relevant part of the page

How it works

We've created a free account for you that hosts the documentation. When a user does a search, it uses the Algolia API to retrieve the most relevant results from the documentation and display them in a dropdown.

Testing the pull request locally

If you want to test the PR locally, you can just launch Jekyll.

Updating the index

As it uses our internal tool, it will be update once in a day.

But if you prefered the Jekyll plugins, it adds a new command: jekyll algolia push. This will read the generated HTML files from a jekyll build, extract text & headers and index them in Algolia. You'll basically have to re-run this command everytime you push a new version to gh-pages. See plugin doc

About Algolia

At Algolia we provide a hosted search API and support community websites like Hackernews search, CDNJS, GrowthHackers, Product Hunt or the Laravel documentation with free plans.

If you want to move forward with this implementation, I'll send you the free and unlimited credentials to your Algolia dashboard.

I'm available for any questions you may have or any more information you would need.

@heathermiller
Copy link
Member

WOW! This is incredible! I'll raise this tomorrow during the Scala meeting to take a vote, but it looks amazing. The demo you link to is really great.

The only issue I foresee is that currently scala.github.com runs on Github Pages which means that Jekyll plugins are forbidden, regardless of the version of Jekyll we run. Therefore, just to re-verify, everything is fine with this PR in the absence of Jekyll plugins? Algolia will build an index from our documentation sources on github? Could you explain a bit more about how that's done? I imagine that if we accept this PR, and then reorganize the site, it could have some sort of implications for your indexing, no?

@ElPicador
Copy link
Contributor Author

Hi @heathermiller,

Yes you can't use a Jekyll plugin with Github Pages. But, you can run it in travis like here.

Yes, the PR is complete as the moment (just need to update the Algolia API keys to give you "production" ones.
The index is build from scrapping the web pages of http://docs.scala-lang.org with a internal tool, but we intent to open-source it eventually. For the moment, is it running on our servers.

Yes, if the website is reorganized, it will have some implications on the indexing, because we use CSS selectors to find the data on the pages (eg: all h1 inside .container).

Thanks,

ps: Thanks to @asurak, @Nagriar & @maxiloc for the scrapper

@fommil
Copy link

fommil commented Nov 18, 2015

Cool! We have a documentation server inside ENSIME for the user's project's dependency's docs. Would it be possible for us to use your search embedded?

We're also really keen on creating a Hoogol style type search customised to a project. The tough bit is defining the search DSL . is that something you've thought about?

@fommil
Copy link

fommil commented Nov 18, 2015

Oh we'd need to wait for you to release on a GPL compatible license.

@ElPicador
Copy link
Contributor Author

@fommil: You can use Algolia wherever you want, it's a SaaS product, with a free hacker plan.
I do not understand what you mean by a Hoogol style type search, but we have an "advanced mode"

The dropdown menu is made with autocomplete.js which has a MIT licence.

The scrapping is made by an internal tool, not yet available as OpenSource, but we have a docker image with the python code in it, so you can check it out.

@fommil
Copy link

fommil commented Nov 19, 2015

@ElPicador not interested in SaaS, we'd need it integrated, sorry.

@fommil
Copy link

fommil commented Nov 19, 2015

Hoogol style search wouldn't be captured by "advanced search". It's really very scala specific.

@heathermiller
Copy link
Member

Hi @ElPicador, thanks again for this PR! We discussed it at a group meeting, and everyone seems to like it :)

Two things:

  1. We might reorganize the site soon (update the look & feel, as it's quite out-dated). That'd require some work on your scraping tool, I imagine. Probably only a few minutes worth of work, as most of the DOM would remain mostly the same, but an update nonetheless. If we do that in the next month or two, would you guys be up for updating the scrape?
  2. Would you update this PR with an appropriate API key?

Thanks again. This is very cool :)

@ElPicador
Copy link
Contributor Author

@heathermiller

  1. Yeah sure, we'll do it. Just keep us informed
  2. I'll update it before monday

@ElPicador
Copy link
Contributor Author

@heathermiller I had time today, so the API keys are updated

@ElPicador
Copy link
Contributor Author

@heathermiller: Could you wait for tomorrow? We have so UI improvement on the way (like http://eslint.org/)

@heathermiller
Copy link
Member

Sure thing :) Thanks @ElPicador

@ElPicador
Copy link
Contributor Author

@heathermiller I tried to improve the UI a bit:
UI improvement

You can also find here the docker image of the scrapper. For the moment it's running in our infra.

If you have any issues please contact [email protected]

@heathermiller
Copy link
Member

Awesome, thanks @ElPicador! LGTM

heathermiller added a commit that referenced this pull request Nov 27, 2015
Add Algolia search on header bar
@heathermiller heathermiller merged commit 0741722 into scala:master Nov 27, 2015
@ElPicador
Copy link
Contributor Author

Thanks @heathermiller 😄

@smarter
Copy link
Member

smarter commented Dec 9, 2015

@ElPicador : Just a suggestion, but it'd be awesome if we could do something similar for the Scala specification which has no search functionality at all currently: http://www.scala-lang.org/files/archive/spec/2.11/ .

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

Successfully merging this pull request may close these issues.

4 participants