2015-04-30 17:06:18 +00:00
|
|
|
class Explore::ProjectsController < Explore::ApplicationController
|
2016-03-04 15:11:33 +00:00
|
|
|
include FilterProjects
|
|
|
|
|
2014-07-23 09:03:49 +00:00
|
|
|
def index
|
|
|
|
@projects = ProjectsFinder.new.execute(current_user)
|
2015-03-10 22:59:14 +00: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 15:11:33 +00:00
|
|
|
@projects = filter_projects(@projects)
|
2014-07-23 09:03:49 +00:00
|
|
|
@projects = @projects.sort(@sort = params[:sort])
|
2016-03-19 21:37:54 +00:00
|
|
|
@projects = @projects.includes(:namespace).page(params[:page])
|
2016-02-05 19:33:24 +00: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 09:03:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def trending
|
2016-02-04 19:02:19 +00:00
|
|
|
@projects = TrendingProjectsFinder.new.execute(current_user)
|
2016-03-04 15:11:33 +00:00
|
|
|
@projects = filter_projects(@projects)
|
2016-03-19 21:37:54 +00:00
|
|
|
@projects = @projects.page(params[:page])
|
2016-02-05 19:33:24 +00: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 09:03:49 +00:00
|
|
|
end
|
2014-07-25 19:05:23 +00:00
|
|
|
|
|
|
|
def starred
|
2016-02-04 19:02:19 +00:00
|
|
|
@projects = ProjectsFinder.new.execute(current_user)
|
2016-03-04 15:11:33 +00:00
|
|
|
@projects = filter_projects(@projects)
|
2016-02-04 19:02:19 +00:00
|
|
|
@projects = @projects.reorder('star_count DESC')
|
2016-03-19 21:37:54 +00:00
|
|
|
@projects = @projects.page(params[:page])
|
2016-02-05 19:33:24 +00: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 19:05:23 +00:00
|
|
|
end
|
2014-07-23 09:03:49 +00:00
|
|
|
end
|