Skip to content

Commit

Permalink
add algolia gem
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Panagiotakos committed Feb 26, 2020
1 parent 2c22e1c commit 7196cd4
Show file tree
Hide file tree
Showing 39 changed files with 2,826 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ gem "jekyll-sitemap", "~> 1.3.1"
gem "liquid-c", "~> 4.0.0"
gem "redcarpet", "~> 3.4"
gem "sassc", "~> 2.2"

group :jekyll_plugins do
gem 'jekyll-algolia', "~> 1.0", path: "./jekyll-algolia-dev"
end
30 changes: 29 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,41 @@ GIT
safe_yaml (~> 1.0)
terminal-table (~> 1.8)

PATH
remote: jekyll-algolia-dev
specs:
jekyll-algolia (1.6.0)
algolia_html_extractor (~> 2.6)
algoliasearch (~> 1.26)
filesize (~> 0.1)
jekyll (>= 3.6, < 5.0)
json (~> 2.0)
nokogiri (~> 1.6)
progressbar (~> 1.9)
verbal_expressions (~> 0.1.5)

GEM
remote: https://rubygems.org/
specs:
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
algolia_html_extractor (2.6.2)
json (~> 2.0)
nokogiri (~> 1.10.4)
algoliasearch (1.27.1)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
colorator (1.1.0)
concurrent-ruby (1.1.5)
em-websocket (0.5.1)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0)
eventmachine (1.2.7)
ffi (1.11.1)
filesize (0.2.0)
forwardable-extended (2.6.0)
http_parser.rb (0.6.0)
httpclient (2.8.3)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
jekyll-redirect-from (0.15.0)
Expand All @@ -43,6 +64,7 @@ GEM
jekyll (>= 3.7, < 5.0)
jekyll-watch (2.2.1)
listen (~> 3.0)
json (2.3.0)
kramdown (2.1.0)
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
Expand All @@ -54,8 +76,12 @@ GEM
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
mercenary (0.3.6)
mini_portile2 (2.4.0)
nokogiri (1.10.8)
mini_portile2 (~> 2.4.0)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
progressbar (1.10.1)
public_suffix (3.1.1)
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
Expand All @@ -69,17 +95,19 @@ GEM
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
unicode-display_width (1.6.0)
verbal_expressions (0.1.5)

PLATFORMS
ruby

DEPENDENCIES
jekyll!
jekyll-algolia (~> 1.0)!
jekyll-redirect-from (~> 0.15)
jekyll-sitemap (~> 1.3.1)
liquid-c (~> 4.0.0)
redcarpet (~> 3.4)
sassc (~> 2.2)

BUNDLED WITH
2.0.2
2.1.4
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ cockroachcloud-build: bootstrap
cockroachcloud: jekyll-action := serve --port 4001
cockroachcloud: cockroachcloud-build

.PHONY: algolia
algolia: bootstrap
bundle exec jekyll algolia --config _config_base.yml --builds-config _config_cockroachdb.yml,_config_cockroachcloud.yml

.PHONY: test
test:
go get -u github.com/cockroachdb/htmltest
Expand Down
1 change: 1 addition & 0 deletions _config_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ exclude:
- "ci"
- "scripts"
- "vendor"
- "jekyll-algolia-dev"
- "hackathon.md"

keep_files: [_internal]
Expand Down
3 changes: 3 additions & 0 deletions ci/pull-request
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,6 @@ run vale --no-wrap v19.2 || true

# Step 6. Run htmltest, but skip checking external links to speed things up.
run htmltest --skip-external

# Step 7. Run algolia with staging index
run ALGOLIA_API_KEY=${ALGOLIA_DOCS_STAGING} make algolia
115 changes: 115 additions & 0 deletions jekyll-algolia-dev/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
Hi collaborator!

If you have a fix or a new feature, please start by checking in the [issues][1]
if it is already referenced. If not, feel free to open one.

We use [pull requests][2]
for collaboration. The workflow is as follow:

- Create a local branch, starting from `develop`
- Submit the PR on `develop`
- Wait for review
- Do the changes requested (if any)
- We may ask you to rebase the branch to latest `develop` if it gets out of sync
- Receive the thanks of the Algolia team :)

# Development workflow

Start by running `bundle install` to get all the dependencies up to date.

## Testing

Run `rake test` to launch the test suite. Run `./scripts/test_all_ruby_versions`
to run the test on all the supported ruby versions (requires `rvm`).

## TDD

Run `rake watch` to start a watcher on the code and test files. Whenever you
update the code, the relevant tests will be run. Incredibly useful for TDD.

## Testing local changes on an existing Jekyll website

If you want to test the plugin on an existing Jekyll website while developping,
we suggest updating the website `Gemfile` to point to the correct local directory

```ruby
group :jekyll_plugins do
gem "jekyll-algolia", :path => "/path/to/local/gem/folder"
end
```

## Running integration tests

Integration tests will do a full jekyll run, and push data to an Algolia index,
checking that records and settings are correctly saved. It is the slowest
possible kind of tests, but also the one closest to a real implementation.

Running those tests requires a real Algolia plan. You need to define
`ALGOLIA_APPLICATION_ID`, `ALGOLIA_API_KEY` and `ALGOLIA_INDEX_NAME` (we suggest
using `direnv` for that), and then run `./scripts/test_integration`.

## Linting

Run `rake lint` to check the style of all ruby files. Run `rake
lint:auto_correct` to try to automatically correct the potential violations.
It's always a good practice to double check the modification after an
auto-correct.

# Git Hooks

If you plan on submitting a PR, we suggest you install the git hooks located in
`./scripts/git_hook`. Those hooks will run the linter on each commit, and the
tests before each push. This greatly help reduce the chances of breaking the
build on Travis.

The easiest way is to create a symlink from your `.git/hooks` folder:

```sh
$ git root
$ rm ./.git/hooks
$ ln -s ./scripts/git_hooks/ ./.git/hooks
```

# Tagging and releasing

If you need to release a new version of the gem, run `rake release` from the
`develop` branch. It will ask you for the new version and automatically create
the git tags, create the gem and push it to Rubygems.

# Documentation

## Requirements

The documentation website uses Metalsmith (and not Jekyll), so you'll need:

- Node.js >= v9.2.0, use nvm - [install instructions][3]
- Yarn >= v1.3.2 - [install instructions][4]

## Development

All the documentation source files live in the `./docs-src` folder.

To serve a local version of the documentation (including livereload), run `rake
docs:serve`. The documentation will be available on
[localhost:3000](http://localhost:3000/).

This will create a `./docs-dev` folder and serve files from there. This folder
is ignored by git.

## Deploying docs

To update the documentation website, you should run `rake docs:deploy` from the
`develop` branch. This will merge `develop` into master, build the documentation
into `docs` and push it. The content of the `./docs` folder will then be server
by GitHub pages.

# Project owner

[@pixelastic][5]


[1]: https://github.com/algolia/jekyll-algolia/issues
[2]: https://github.com/algolia/jekyll-algolia/pulls
[3]: https://github.com/creationix/nvm#install-script
[4]: https://yarnpkg.com/en/docs/install#alternatives-tab
[5]: https://github.com/pixelastic
129 changes: 129 additions & 0 deletions jekyll-algolia-dev/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Jekyll Algolia Plugin

[![gem version][1]][16]
![ruby][2]
![jekyll][3]
[![build master][4]][17]
[![build develop][6]][17]
[![coverage master][5]][18]

Add fast and relevant search to your Jekyll site.

## Usage

```shell
$ bundle exec jekyll algolia
```

This will push the content of your Jekyll website to your Algolia index.

## Documentation

Full documentation can be found on
[https://community.algolia.com/jekyll-algolia/][20]

## Installation

The plugin requires at least Jekyll 3.6.0 and Ruby 2.3.0.

First, add the `jekyll-algolia` gem to your `Gemfile`, in the `:jekyll_plugins`
section.

```ruby
# Gemfile

group :jekyll_plugins do
gem 'jekyll-algolia', '~> 1.0'
end
```

Once this is done, download all dependencies with `bundle install`.

## Basic configuration

You need to provide certain Algolia credentials for this plugin to _index_ your
site.

_If you don't yet have an Algolia account, we suggest that you open a free
[Community plan here][8]. You can find more information about the Algolia plans
[in our FAQ][10]._

Once signed in, you should get your application ID from [your dashboard][9] and
define it inside your `_config.yml` file like this:

```yaml
# _config.yml

algolia:
application_id: 'your_application_id'
```
## Run it
Once your application ID is setup, you can run the indexing by running the
following command:
```shell
ALGOLIA_API_KEY='your_admin_api_key' bundle exec jekyll algolia
```

Note that `ALGOLIA_API_KEY` should be set to your admin API key.

## More about the Community plan

The Algolia [Community plan][11] lets you host up to 10k records and perform up
to 100k add/edit/delete operations per month (search operations are free). The
plan is entirely free, with no time limit.

What we ask in exchange is that you display a "Search by Algolia" logo next to
your search results. Our [InstantSearch libraries][12] have a simple boolean
option to toggle that on an off. If you want more flexibility, you can find
all versions of our logo [here][13].

If you need more information about the other Algolia plans, you can [check our
FAQ][10].

# Thanks

Thanks to [Anatoliy Yastreb][14] for a [great tutorial][15] on creating Jekyll
plugins.

[1]: https://badge.fury.io/rb/jekyll-algolia.svg

[2]: https://img.shields.io/badge/ruby-%3E%3D%202.3.0-green.svg

[3]: https://img.shields.io/badge/jekyll-%3E%3D%203.6.0-green.svg

[4]: https://img.shields.io/badge/dynamic/json.svg?label=build%3Amaster&query=value&uri=https%3A%2F%2Fimg.shields.io%2Ftravis%2Falgolia%2Fjekyll-algolia.json%3Fbranch%3Dmaster

[5]: https://coveralls.io/repos/github/algolia/jekyll-algolia/badge.svg?branch=master

[6]: https://img.shields.io/badge/dynamic/json.svg?label=build%3Adevelop&query=value&uri=https%3A%2F%2Fimg.shields.io%2Ftravis%2Falgolia%2Fjekyll-algolia.json%3Fbranch%3Ddevelop

[7]: https://coveralls.io/repos/github/algolia/jekyll-algolia/badge.svg?branch=develop

[8]: #more-about-the-community-plan

[9]: https://www.algolia.com/api-keys

[10]: https://community.algolia.com/jekyll-algolia/faq.html#how-many-records-will-the-plugin-need

[11]: https://www.algolia.com/users/sign_up/hacker

[12]: https://community.algolia.com/instantsearch.js/

[13]: https://www.algolia.com/press/?section=brand-guidelines

[14]: https://github.com/ayastreb/

[15]: https://ayastreb.me/writing-a-jekyll-plugin/

[16]: https://rubygems.org/gems/jekyll-algolia

[17]: https://travis-ci.org/algolia/jekyll-algolia

[18]: https://coveralls.io/github/algolia/jekyll-algolia?branch=master

[19]: https://coveralls.io/github/algolia/jekyll-algolia?branch=develop

[20]: https://community.algolia.com/jekyll-algolia/getting-started.html
Loading

0 comments on commit 7196cd4

Please sign in to comment.