Class: Explore::ProjectsController

Inherits:
ApplicationController
  • Object
show all
Includes:
FilterProjects
Defined in:
app/controllers/explore/projects_controller.rb

Instance Method Summary collapse

Methods included from FilterProjects

#filter_projects

Instance Method Details

#indexObject


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/explore/projects_controller.rb', line 4

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 = filter_projects(@projects)
  @projects = @projects.sort(@sort = params[:sort])
  @projects = @projects.includes(:namespace).page(params[:page])

  respond_to do |format|
    format.html
    format.json do
      render json: {
        html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects })
      }
    end
  end
end

#starredObject


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/explore/projects_controller.rb', line 38

def starred
  @projects = ProjectsFinder.new.execute(current_user)
  @projects = filter_projects(@projects)
  @projects = @projects.reorder('star_count DESC')
  @projects = @projects.page(params[:page])

  respond_to do |format|
    format.html
    format.json do
      render json: {
        html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects })
      }
    end
  end
end

23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/explore/projects_controller.rb', line 23

def trending
  @projects = TrendingProjectsFinder.new.execute(current_user)
  @projects = filter_projects(@projects)
  @projects = @projects.page(params[:page])

  respond_to do |format|
    format.html
    format.json do
      render json: {
        html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects })
      }
    end
  end
end