summaryrefslogtreecommitdiff
path: root/app/controllers/explore/projects_controller.rb
blob: b295f295bb10fbf0e1798a17af79500c4279f7ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class Explore::ProjectsController < ApplicationController
  skip_before_filter :authenticate_user!,
                     :reject_blocked

  layout 'explore'

  def index
    @projects = ProjectsFinder.new.execute(current_user)
    @tags = @projects.tags_on(:tags)
    @projects = @projects.tagged_with(params[:tag]) if params[:tag].present?
    @projects = @projects.where(visibility_level: params[:visibility_level]) if params[:visibility_level].present?
    @projects = @projects.search(params[:search]) if params[:search].present?
    @projects = @projects.sort(@sort = params[:sort])
    @projects = @projects.includes(:namespace).page(params[:page]).per(PER_PAGE)
  end

  def trending
    @trending_projects = TrendingProjectsFinder.new.execute(current_user)
    @trending_projects = @trending_projects.page(params[:page]).per(PER_PAGE)
  end

  def starred
    @starred_projects = ProjectsFinder.new.execute(current_user)
    @starred_projects = @starred_projects.reorder('star_count DESC')
    @starred_projects = @starred_projects.page(params[:page]).per(PER_PAGE)
  end
end