2015-04-30 13:06:18 -04:00
|
|
|
class Explore::ProjectsController < Explore::ApplicationController
|
2017-03-03 05:35:04 -05:00
|
|
|
include ParamsBackwardCompatibility
|
|
|
|
|
|
|
|
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-06-21 09:48:12 -04:00
|
|
|
ProjectsFinder.new(current_user: current_user, params: params)
|
2017-08-10 09:01:38 -04:00
|
|
|
.execute
|
|
|
|
.includes(:route, namespace: :route)
|
|
|
|
.page(params[:page])
|
|
|
|
.without_count
|
2017-03-15 07:58:41 -04:00
|
|
|
end
|
2014-07-23 05:03:49 -04:00
|
|
|
end
|