2015-04-30 13:06:18 -04:00
|
|
|
class Explore::ProjectsController < Explore::ApplicationController
|
2016-03-04 10:11:33 -05:00
|
|
|
include FilterProjects
|
|
|
|
|
2014-07-23 05:03:49 -04:00
|
|
|
def index
|
2017-03-15 07:58:41 -04:00
|
|
|
@projects = load_projects
|
2015-03-10 18:59:14 -04:00
|
|
|
@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?
|
2016-03-04 10:11:33 -05:00
|
|
|
@projects = filter_projects(@projects)
|
2014-07-23 05:03:49 -04:00
|
|
|
@projects = @projects.sort(@sort = params[:sort])
|
2016-03-19 17:37:54 -04:00
|
|
|
@projects = @projects.includes(:namespace).page(params[:page])
|
2016-02-05 14:33:24 -05:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
format.json do
|
|
|
|
render json: {
|
|
|
|
html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects })
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2014-07-23 05:03:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def trending
|
2017-03-15 07:58:41 -04:00
|
|
|
@projects = load_projects(Project.trending)
|
|
|
|
@projects = filter_projects(@projects)
|
2017-01-25 14:53:29 -05:00
|
|
|
@projects = @projects.sort(@sort = params[:sort])
|
2016-03-19 17:37:54 -04:00
|
|
|
@projects = @projects.page(params[:page])
|
2016-02-05 14:33:24 -05:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
format.json do
|
|
|
|
render json: {
|
|
|
|
html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects })
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2014-07-23 05:03:49 -04:00
|
|
|
end
|
2014-07-25 15:05:23 -04:00
|
|
|
|
|
|
|
def starred
|
2017-03-15 07:58:41 -04:00
|
|
|
@projects = load_projects
|
2016-03-04 10:11:33 -05:00
|
|
|
@projects = filter_projects(@projects)
|
2016-02-04 14:02:19 -05:00
|
|
|
@projects = @projects.reorder('star_count DESC')
|
2016-03-19 17:37:54 -04:00
|
|
|
@projects = @projects.page(params[:page])
|
2016-02-05 14:33:24 -05:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
format.json do
|
|
|
|
render json: {
|
|
|
|
html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects })
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2014-07-25 15:05:23 -04:00
|
|
|
end
|
2017-03-15 07:58:41 -04:00
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def load_projects(base_scope = nil)
|
|
|
|
base_scope ||= ProjectsFinder.new.execute(current_user)
|
|
|
|
base_scope.includes(:route, namespace: :route)
|
|
|
|
end
|
2014-07-23 05:03:49 -04:00
|
|
|
end
|