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

WIP: Search for Community using elasticsearch #222

Merged
merged 169 commits into from Nov 12, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
aa6a383
Install elastisearch gems
surenm Sep 10, 2014
5627224
Update documentation for env variables
surenm Sep 10, 2014
574e5e5
Initialize elasticsearch active record models
surenm Sep 10, 2014
de575f8
Searchable concern method for search helpers
surenm Sep 10, 2014
15b5d31
Include Searchable for Post model
surenm Sep 10, 2014
3d5444e
Include Searchable for User model
surenm Sep 10, 2014
fb9c9ec
Just overriding search
surenm Sep 11, 2014
01a54d3
Moving instance methods outside included block
surenm Sep 11, 2014
00fa24b
Search API controller
surenm Sep 11, 2014
4908879
Simplifying search URL
surenm Sep 11, 2014
055c855
Adding simple search box, and search route and controller.
Sep 11, 2014
aa61594
Merge branch 'search' of github.com:surenm/community into search
Sep 11, 2014
4477167
Search results show up
Sep 11, 2014
ee78eff
Add more fields to post search mapping
surenm Sep 11, 2014
217f057
Better UI for search results. Added slugs to post search mapping
Sep 15, 2014
570f73a
Mention Elasticsearch as an external dependency in README
zachallaun Sep 15, 2014
147f313
Space before |arg| in blocks
zachallaun Sep 15, 2014
14ae55e
Tabs => spaces
zachallaun Sep 15, 2014
0507f54
Fixing typo in procfile
surenm Sep 22, 2014
f841a3f
Nested css classes for search. 2 space indents
Sep 22, 2014
e16a9f3
Merge branch 'search' of github.com:surenm/community into search
Sep 22, 2014
6546b60
Index author full name instead of name
surenm Sep 29, 2014
d4bde7a
Define overridable methods for query_dsl and highlights
surenm Sep 29, 2014
1e9917a
First cuts for query_dsl for Post model
surenm Sep 29, 2014
651a21a
Enable suggestion for User table
surenm Sep 29, 2014
3a48fc0
Route for suggestions api
surenm Sep 29, 2014
b14a23d
Organize class and instance methods into modules
surenm Sep 30, 2014
f630bea
Add searchable to posts, users, threads & subforums
surenm Sep 30, 2014
7876844
Show suggestions from users, threads & sub forums
surenm Sep 30, 2014
38b9501
Don't run elasticsearch as part of procfile
surenm Sep 30, 2014
d0afada
Tokenize suggestion input for threads and sub forums
surenm Sep 30, 2014
5f21d48
Fix filtered query for posts
surenm Sep 30, 2014
60fe3c3
ReBuild search indexes from scratch
surenm Sep 30, 2014
b008574
Change naming based on changes in the search mapping model
Sep 30, 2014
307bc9f
Add slugs and id's for suggestion responses
surenm Sep 30, 2014
65aa324
Put hacker_school_id in the correct index
surenm Sep 30, 2014
617f01d
Link author names to Hacker School profiles, Display post contents in…
Sep 30, 2014
37a1e5f
Strip elastic search metadata from suggestions
surenm Sep 30, 2014
cb6db18
Working on autocomplete search suggestions -
Oct 1, 2014
e3afa23
WIP: Autocomplete search suggestions
Oct 2, 2014
ddb8413
WIP - Autocomplete
Oct 7, 2014
f58e965
Show and hide suggestions menu based on key and mouse events
Oct 7, 2014
ba8d84a
Autocomplete Results are linked
Oct 7, 2014
2c302f5
Beginning to track key events?
Oct 7, 2014
d27750c
WIP - Autocomplete - Onblur events seem to work
Oct 13, 2014
c15a694
Reversed order of test and dev builds
Oct 13, 2014
9acc24e
Simpler autocomplete focus logic
Oct 13, 2014
34ac38a
Added keys to keycode conversion
Oct 14, 2014
98b52a6
facet -> search-filter
zachallaun Oct 14, 2014
7eba0fc
WIP: keyboard shortcuts for search suggestions
zachallaun Oct 14, 2014
72f8736
No need to parse filters in the query
surenm Oct 15, 2014
4832a58
Fix query del for posts
surenm Oct 15, 2014
db9e3a2
Fix indexing to make exact value filters work
surenm Oct 15, 2014
c4f80b1
Expect filters as get parameters
surenm Oct 15, 2014
248c0c2
Breakfix: Query has become search_string for clarity
surenm Oct 15, 2014
138a2f0
Update client for new search API. Routing util now returns query-params.
zachallaun Oct 20, 2014
e9c6272
More robust client-side query model that supports tab completion
zachallaun Oct 20, 2014
ee87cb1
Remove console print
zachallaun Oct 20, 2014
9100e51
WIP: Styling autocomplete component
Oct 21, 2014
5733ff0
Changed will-update-props comparison on query instead of suggestions …
Oct 21, 2014
4157e76
Add logic for hitting enter on author to launch a search but threads …
Oct 21, 2014
3572f6c
Clicking/hitting enter on suggestion does the right thing -
Oct 21, 2014
e90a96e
Rename query data structure to query-data and query string to query-str
Oct 21, 2014
f774fb8
Fixed missed renaming
Oct 21, 2014
5897027
Minor style changes on suggestions box - need to sync selection list …
Oct 21, 2014
eb00561
Added search-filter as a data attribute in suggestions-view.
Oct 21, 2014
6f38cd2
Add counter for each group of results, add simple :before css to disp…
Oct 22, 2014
c691e48
Filter prompts displayed before first suggestion of each type
Oct 22, 2014
99ea80a
Removed breadcrumbs from showing up in navbar view
Oct 22, 2014
a046e6c
First suggestion Search for doesn't show up anymore. Nicer styles for…
Oct 22, 2014
9047324
Nicer styles for search results page
Oct 22, 2014
c57402f
Filtered queries return default highlight content
Oct 22, 2014
e1d3712
CSS hack for suggestion box width. Removed view thread link on results
Oct 22, 2014
33c9c0e
Styles clean up
Oct 22, 2014
ae8b331
Rename hacker-school-id to author-hacker-school-id
Oct 22, 2014
82b295c
Launch search for query data if there is no selected suggestion : wor…
Oct 22, 2014
bb355d6
Modified selection list to support no default first item selection
Oct 23, 2014
4cbea6a
First suggestion is not auto-selected
Oct 23, 2014
20d9227
Allow pagination of search results
surenm Oct 23, 2014
379fa4e
Index only what is necessary
surenm Oct 27, 2014
bd3b98d
Return active record models as search results
surenm Oct 27, 2014
617a28d
Remove allowed_filter_fields
surenm Oct 27, 2014
25f3c48
Improving search_mapping as per suggestion
surenm Oct 27, 2014
49e6694
Improve rake task as per suggestion
surenm Oct 27, 2014
6ebb038
Improving search response highlights
surenm Oct 27, 2014
22c919d
Missing thread title in search response
surenm Oct 27, 2014
a05eb28
Modified result component to new search results structure
Oct 27, 2014
00dd128
WIP - Modifying components structure
Oct 27, 2014
2976e95
Refactor search components
zachallaun Oct 27, 2014
02e9e83
Support ESC in search input box
zachallaun Oct 27, 2014
76e3e22
Fix clicking on suggestions. Support touch events.
zachallaun Oct 27, 2014
44ea79c
Show total number of hits and take time needed
surenm Oct 27, 2014
f72050b
Update search metadata display
zachallaun Oct 27, 2014
6c5bf56
Added pagination of search results
Oct 28, 2014
44396cb
Disable next and prev links for first and last pages
Oct 28, 2014
ecbe6b6
Better styles for pagination
Oct 28, 2014
9d55659
1-indexed page counts for list of pages
surenm Oct 28, 2014
cfe5a21
Work in progress - modifying search box styles
Oct 28, 2014
ab99426
Merge branch 'search' of github.com:surenm/community into search
Oct 28, 2014
6ae05d5
Improve suggestions indexing
surenm Oct 28, 2014
612229d
Pagination with ellipsis
Oct 29, 2014
3a5492c
Merge branch 'search' of github.com:surenm/community into search
Oct 29, 2014
fc6cb9e
Changed navbar styles
Oct 29, 2014
21b65e0
RESULTS_PER_PAGE is searchable constant
surenm Oct 29, 2014
90d3aa1
Fixing ugly code based on suggestions.
surenm Oct 29, 2014
e5cd40b
Use posts instead of records
surenm Oct 29, 2014
58126f3
Media styles for navbar
Oct 29, 2014
b77863c
Bugfix: removed a period that broke everything
surenm Oct 29, 2014
735f17a
More responsive styles for navbar
Oct 29, 2014
9975c1a
Moved search results to screen xs grid structure
Oct 29, 2014
5a76a77
Merging master into search
surenm Oct 29, 2014
3ca79b7
Run migrations and rebuild stuff
surenm Oct 29, 2014
17d2bf4
Merge branch 'search' of github.com:surenm/community into search
surenm Oct 29, 2014
4f1119b
Moved page from routes to query param,
Oct 29, 2014
0aefe3d
Add timestamp to search results metadata
Oct 29, 2014
4c353a9
Show post created at date
surenm Oct 29, 2014
aa49aba
Limit search to only subforums with access
surenm Oct 29, 2014
6eb8df8
Cleaned up pagination. Might need more simplification
Oct 29, 2014
0d47e43
Remove prints
Oct 29, 2014
5106abd
Clone filters because permissions are only internal
surenm Oct 29, 2014
7e13870
Handle cases in search suggestions
surenm Oct 29, 2014
6439484
Show 25 results per page
surenm Oct 29, 2014
96b344c
Better indentation
Oct 30, 2014
86a6b85
Small refactoring for pagination code
zachallaun Nov 10, 2014
1720eb3
Move a def closer to where it's used
zachallaun Nov 10, 2014
1650ad2
Only display autocomplete suggestions if the query hasn't changed
zachallaun Nov 10, 2014
bc38c1c
Only update search suggestions if query hasn't changed for 100ms
zachallaun Nov 10, 2014
d2ec868
Fix suggestions bug (showing suggestions from previous query)
zachallaun Nov 10, 2014
dc69038
Don't issue suggestions queries for the empty string
zachallaun Nov 10, 2014
e973470
Filter suggestions based on required roles
zachallaun Nov 10, 2014
85fdaa1
Merge branch 'master' into search
zachallaun Nov 10, 2014
1ebbe38
Tab in autocomplete box selects next item in selection list
zachallaun Nov 10, 2014
317d1f7
Search by author returns posts in created_at desc order
zachallaun Nov 11, 2014
aa646b4
Fix bug when searching without filters
zachallaun Nov 11, 2014
90d2ff2
Share post body styles with search results
zachallaun Nov 11, 2014
7d73994
Split search CLJS into two files (search-bar and search-results)
zachallaun Nov 11, 2014
67553a7
Various small refactors for search code
zachallaun Nov 11, 2014
0b5cd69
Fix suggestions for multiple words in the middle of the result
davidbalbert Nov 11, 2014
f42bb7b
Cleanup Searchable
davidbalbert Nov 11, 2014
59cdf32
Use Module::Concerning for search-related methods
davidbalbert Nov 11, 2014
bbce9f2
Move search query data to the app level to support setting it from ro…
zachallaun Nov 11, 2014
9a4c6c4
Clean search box when navigating away from the search results page
zachallaun Nov 11, 2014
ba8469e
Update example .env in README.
davidbalbert Nov 11, 2014
dd497da
Fix total pages when total results is divisible by results per page
davidbalbert Nov 11, 2014
1306b41
Remove unneeded `self`
davidbalbert Nov 11, 2014
9c48af7
Formatting fixes: remove extra spaces
davidbalbert Nov 11, 2014
8cf4aab
Formatting cleanup
davidbalbert Nov 11, 2014
e681e37
Reformat. Remove deprecated HTML attributes.
davidbalbert Nov 11, 2014
bf053c8
Don't close over DOM node.
davidbalbert Nov 11, 2014
4ae2f0b
Clean up naming, etc.
davidbalbert Nov 11, 2014
024780a
Refactor search result page
davidbalbert Nov 12, 2014
60a65c5
Show pagination widget when there is one page.
davidbalbert Nov 12, 2014
53c932d
Componentize pagination widget
davidbalbert Nov 12, 2014
3fa4d0a
Use link-to for Pagination.
davidbalbert Nov 12, 2014
3472fd2
Clear suggestions when they're no longer relevant.
davidbalbert Nov 12, 2014
9647a73
Remove outdated comment
davidbalbert Nov 12, 2014
5e78f05
Some cleanup
davidbalbert Nov 12, 2014
89245b4
Be more explicit with search filters
davidbalbert Nov 12, 2014
8731559
Fix cursor deref bug
davidbalbert Nov 12, 2014
6851139
Simplify route-changed
davidbalbert Nov 12, 2014
2f67aca
Simplify Elasticsearch config
davidbalbert Nov 12, 2014
fb0882a
Properly url encode and decode routes
davidbalbert Nov 12, 2014
f09944a
Fix Firefox error display issue by removing unnecessary column structure
zachallaun Nov 12, 2014
c8a915a
Add newline to end of file
zachallaun Nov 12, 2014
e614e50
Remove unnecessary require
davidbalbert Nov 12, 2014
afcb2e9
search#query -> search#search
davidbalbert Nov 12, 2014
9a32c38
CSS fixes
davidbalbert Nov 12, 2014
2b1f546
Use ELASTICSEARCH_URL and BONSAI_URL
davidbalbert Nov 12, 2014
029c1fe
Update README
davidbalbert Nov 12, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -23,3 +23,5 @@ app/assets/javascripts/client-dev
public/client

.DS_Store

*.swp
4 changes: 4 additions & 0 deletions Gemfile
Expand Up @@ -61,3 +61,7 @@ gem 'faye-websocket'
gem 'eventmachine'

gem 'thread_safe'

gem 'elasticsearch'
gem 'elasticsearch-model'
gem 'elasticsearch-rails'
25 changes: 22 additions & 3 deletions Gemfile.lock
Expand Up @@ -39,9 +39,24 @@ GEM
delayed_job_active_record (4.0.2)
activerecord (>= 3.0, < 4.2)
delayed_job (>= 3.0, < 4.1)
dotenv (1.0.2)
dotenv-rails (1.0.2)
dotenv (= 1.0.2)
dotenv (0.11.1)
dotenv-deployment (~> 0.0.2)
dotenv-deployment (0.0.2)
dotenv-rails (0.11.1)
dotenv (= 0.11.1)
elasticsearch (1.0.5)
elasticsearch-api (= 1.0.5)
elasticsearch-transport (= 1.0.5)
elasticsearch-api (1.0.5)
multi_json
elasticsearch-model (0.1.5)
activesupport (> 3)
elasticsearch (> 0.4)
hashie
elasticsearch-rails (0.1.5)
elasticsearch-transport (1.0.5)
faraday
multi_json
erubis (2.7.0)
eventmachine (1.0.3)
execjs (2.2.2)
Expand All @@ -52,6 +67,7 @@ GEM
websocket-driver (>= 0.3.5)
font-awesome-sass (4.2.1)
sass (~> 3.2)
hashie (3.3.1)
hike (1.2.3)
i18n (0.6.11)
jasmine (2.0.3)
Expand Down Expand Up @@ -168,6 +184,9 @@ DEPENDENCIES
dalli
delayed_job_active_record
dotenv-rails
elasticsearch
elasticsearch-model
elasticsearch-rails
eventmachine
faye-websocket
font-awesome-sass
Expand Down
24 changes: 12 additions & 12 deletions README.md
Expand Up @@ -4,12 +4,13 @@

## Dependencies

- Ruby 2.1.2
- Ruby 2.1.3
- bundler
- foreman
- Postgres 9.3.4
- Postgres 9.3.5
- redis
- leiningen
- Elasticsearch

### Installing dependencies on OS X using rvm, Homebrew, and Postgres.app

Expand All @@ -19,8 +20,8 @@ We recommend [Postgres.app](http://postgresapp.com/) if you're on OS X.

```sh
$ rvm get head
$ rvm install ruby-2.1.2
$ rvm use ruby-2.1.2
$ rvm install ruby-2.1.3
$ rvm use ruby-2.1.3
$ gem install bundler
$ gem install foreman
```
Expand All @@ -29,9 +30,8 @@ $ gem install foreman

```sh
$ brew update
$ brew install leiningen
$ brew install redis
# follow the printed instructions to have redis start automatically on boot
$ brew install leiningen redis elasticsearch
# follow the printed instructions to have redis and elasticsearch start automatically on boot
```

## Configuration
Expand All @@ -50,15 +50,15 @@ HACKER_SCHOOL_CLIENT_SECRET=your_client_secret

JASMINE_CONFIG_PATH=test/javascripts/support/jasmine.yml

# If you want to develop against a local copy of the Hacker School API, add:
HACKER_SCHOOL_SITE=http://localhost:5000

# If you want to import accounts from Hacker School
# (You won't be able to do this unless you are Hacker School faculty)
HACKER_SCHOOL_API_SECRET_TOKEN=hacker_school_api_secret
# HACKER_SCHOOL_API_SECRET_TOKEN=hacker_school_api_secret

# If you want to develop against a local copy of the Hacker School API, add:
# HACKER_SCHOOL_SITE=http://localhost:5000

# Needed for batch mail sending in production
MAILGUN_API_KEY=your_mailgun_api_key
# MAILGUN_API_KEY=your_mailgun_api_key
```

To generate a Hacker School client id and secret, go to your [Hacker School settings page](https://www.hackerschool.com/settings) and make a new OAuth app. The redirect url should be `http://localhost:5001/login/complete` (or your development host name if you don't develop off of localhost).
Expand Down
2,051 changes: 1,049 additions & 1,002 deletions app/assets/javascripts/client-prod.js

Large diffs are not rendered by default.

168 changes: 109 additions & 59 deletions app/assets/stylesheets/app.css.scss
Expand Up @@ -2,12 +2,39 @@
@include make-sm-column(12);
}

// Small screen only
@media (max-width: $screen-sm-min) {
// Extra small (below 480 px)
@media (max-width: $screen-xs-min) {
#search-bar {
display: none;
}

#navbar-header {
@include make-xs-column(10);
}

#util-bar {
@include make-xs-column(2);
}
}

// Small (between 480 and 768 px)
@media (min-width: $screen-xs-min) and (max-width: $screen-xs-max) {
#main-content {
padding-left: 0;
padding-right: 0;
}

#navbar-header {
@include make-xs-column(5);
}

#search-bar {
@include make-xs-column(6);
}

#util-bar {
@include make-xs-column(1);
}
}

#notifications {
Expand All @@ -25,62 +52,8 @@
border-bottom: 1px dotted $brand-primary;
height: 45px;
margin-bottom: 1em;
padding: 0 20px;

.navbar-header {
width: 100%;

.header-link { float: left }
.breadcrumbs-container { float: left }

img {
width: 24px;
height: auto;
padding: 2px;
position: relative;
top: 3px;
}

.brand-text {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: bold;
font-size: 1.3em;
margin-left: 5px;
position: relative;
top: 6px;
}

a:hover {
text-decoration: none;
color: $brand-primary;
}
}

.community-nav {
float: right;
list-style: none;
margin-top: 10px;

> li {
display: inline-block;
vertical-align: top;
padding: 0 15px;

@media (max-width: $screen-sm-min) {
padding: 0 10px;
}
}

.navbar-text {
font-weight: bold;
color: #555;
margin: 0;
}
padding: 0 10px;

a {
color: #555;
}
}

.dropdown-menu {
margin-top: 5px;
Expand Down Expand Up @@ -164,11 +137,88 @@
}
}

#navbar-header {
@include make-sm-column(3);

img {
width: 24px;
height: auto;
padding: 2px;
position: relative;
top: 3px;
}

.brand-text {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-weight: bold;
font-size: 1.3em;
margin-left: 5px;
position: relative;
top: 6px;
}

a:hover {
text-decoration: none;
color: $brand-primary;
}
}

#search-bar {
@include make-sm-column(6);
padding: 0;
}

#util-bar {
@include make-sm-column(3);
text-align: right;
padding: 0 5px;

.community-nav {
list-style: none;
margin-top: 10px;
}

.community-nav > li {
display: inline-block;
vertical-align: top;
padding: 0 15px;

}

.navbar-text {
font-weight: bold;
color: #555;
margin: 0;
}

a {
color: #555;
}

@media (min-width: $screen-md-min) and (max-width: $screen-md-max) {
padding: 0 3px;
.community-nav > li {
padding: 0 10px;
}
}

@media (min-width: $screen-sm-min) and (max-width: $screen-sm-max) {
padding: 0 2px;
.community-nav > li {
padding: 0 5px;
}
.navbar-text {
font-size: small;
font-weight: normal;
}
}
}

.unread-count-icon {
z-index: 1000;
position: absolute;
top: -6px;
left: 10px;
top: -5px;
padding: 0.2em 0.4em;
font-size: 10px;
background-color: red;
Expand Down Expand Up @@ -228,4 +278,4 @@ ul.inline-links {

.notifications {
display: inline;
}
}
4 changes: 2 additions & 2 deletions app/assets/stylesheets/global.css.scss
Expand Up @@ -141,11 +141,11 @@ a:hover {
.visible-xs-inline {
display: none !important;

@media (max-width: $screen-sm-min) {
@media (max-width: $screen-xs-max) {
display: inline !important;
}
}

.pinned-icon {
padding-right: 5px;
}
}
2 changes: 1 addition & 1 deletion app/assets/stylesheets/hacks.css.scss
Expand Up @@ -3,4 +3,4 @@ way down a page. The problem is that the footer jumps up to the top
when we're loading new content. */
.push-down {
height: 500px;
}
}
2 changes: 1 addition & 1 deletion app/assets/stylesheets/index.css.scss
Expand Up @@ -56,4 +56,4 @@
margin-bottom: 0;
}
}
}
}