Class: ArticleController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/article_controller.rb

Instance Method Summary collapse

Instance Method Details

#searchObject

TODO pop-downs for search queries, as the user types, reasonable query extensions appear TODO Slovak stemmer, I know Snowball stemmer now TODO Search result highlighting



17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/article_controller.rb', line 17

def search
  page = (params[:page] || 1).to_i
  if params[:q]
    query = params[:q]
    search = Sunspot.search(Article) do
      keywords "#{query} #{User::QUERY_AUGMENT_PARTIAL}"
      paginate(:page => page)
      order_by(:published_at, :desc)
    end
    @articles = search.results
  end
end

#showObject



8
9
10
11
12
# File 'app/controllers/article_controller.rb', line 8

def show
  #TODO for admins should be able to fix a page, ie reload its content if the scrapper was fixed
  @article = Article.find(params[:id])
  @article.set_user_status(current_user, ArticleStatus::STATUS_VIEWED)
end