2015-04-30 13:06:18 -04:00
|
|
|
class Explore::ProjectsController < Explore::ApplicationController
|
2017-03-03 05:35:04 -05:00
|
|
|
include ParamsBackwardCompatibility
|
2017-12-07 04:11:41 -05:00
|
|
|
include RendersMemberAccess
|
2017-03-03 05:35:04 -05:00
|
|
|
|
|
|
|
before_action :set_non_archived_param
|
2016-03-04 10:11:33 -05:00
|
|
|
|
2014-07-23 05:03:49 -04:00
|
|
|
def index
|
2017-03-03 05:35:04 -05:00
|
|
|
params[:sort] ||= 'latest_activity_desc'
|
|
|
|
@sort = params[:sort]
|
2017-08-10 09:01:38 -04:00
|
|
|
@projects = load_projects
|
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-03 05:35:04 -05:00
|
|
|
params[:trending] = true
|
|
|
|
@sort = params[:sort]
|
2017-08-10 09:01:38 -04:00
|
|
|
@projects = load_projects
|
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-08-10 09:01:38 -04:00
|
|
|
@projects = load_projects.reorder('star_count DESC')
|
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
|
|
|
|
2017-03-03 05:35:04 -05:00
|
|
|
private
|
2017-03-15 07:58:41 -04:00
|
|
|
|
2017-03-03 05:35:04 -05:00
|
|
|
def load_projects
|
2017-12-07 04:11:41 -05:00
|
|
|
projects = ProjectsFinder.new(current_user: current_user, params: params)
|
|
|
|
.execute
|
|
|
|
.includes(:route, namespace: :route)
|
|
|
|
.page(params[:page])
|
|
|
|
.without_count
|
|
|
|
|
|
|
|
prepare_projects_for_rendering(projects)
|
2017-03-15 07:58:41 -04:00
|
|
|
end
|
2014-07-23 05:03:49 -04:00
|
|
|
end
|