Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@ gem 'mysql2'
gem 'rails_autolink'
gem 'rdiscount'
gem 'delayed_job'
gem 'delayed_job_active_record'
gem 'delayed_job_active_record'
gem 'elastic_searchable'

5 changes: 5 additions & 0 deletions app/controllers/content_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
class ContentController < ApplicationController

def resultspage
@posts = Post.search params[:query]
end

def frontpage
@page = page_number(params[:page])
@posts = Post.find_frontpage(@page)
Expand Down
4 changes: 3 additions & 1 deletion app/models/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ class Post < ActiveRecord::Base
validates :title, :length => { :maximum => 255 }, :allow_blank => false
validates :text, :length => { :minimum => 2 }, :allow_blank => false

make_voteable
make_voteable

elastic_searchable

# Finds user posts with given page and standard ordering
# (see <tt>Post.order_algorithm</tt> for order algorithm).
Expand Down
3 changes: 3 additions & 0 deletions app/views/content/resultspage.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<% @posts.each do |post| %>
<%= render partial: "posts/preview", locals: { post: post } %>
<% end %>
5 changes: 5 additions & 0 deletions config/initializers/elastic_searchable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# config/initializers/elastic_searchable.rb
# (optional) customize elasticsearch host
# default is localhost:9200
# ElasticSearchable.base_uri = 'server:9200'

2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Hackful::Application.routes.draw do
match "/results/:query" => "content#resultspage"

get "admin/mail"
post "admin/send_newsletter"

Expand Down