2015-04-30 13:06:18 -04:00
|
|
|
class Explore::ProjectsController < Explore::ApplicationController
|
2014-07-23 05:03:49 -04:00
|
|
|
def index
|
|
|
|
@projects = ProjectsFinder.new.execute(current_user)
|
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?
|
2015-08-10 13:42:09 -04:00
|
|
|
@projects = @projects.non_archived
|
2014-07-23 05:03:49 -04:00
|
|
|
@projects = @projects.search(params[:search]) if params[:search].present?
|
2016-02-05 14:33:24 -05:00
|
|
|
@projects = @projects.search(params[:filter_projects]) if params[:filter_projects].present?
|
2014-07-23 05:03:49 -04:00
|
|
|
@projects = @projects.sort(@sort = params[:sort])
|
2016-02-08 20:34:54 -05:00
|
|
|
@projects = @projects.includes(:namespace).page(params[:page]).per(PER_PAGE) if params[:filter_projects].blank?
|
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
|
2016-02-04 14:02:19 -05:00
|
|
|
@projects = TrendingProjectsFinder.new.execute(current_user)
|
|
|
|
@projects = @projects.non_archived
|
2016-02-05 14:33:24 -05:00
|
|
|
@projects = @projects.search(params[:filter_projects]) if params[:filter_projects].present?
|
2016-02-08 20:34:54 -05:00
|
|
|
@projects = @projects.page(params[:page]).per(PER_PAGE) if params[:filter_projects].blank?
|
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
|
2016-02-04 14:02:19 -05:00
|
|
|
@projects = ProjectsFinder.new.execute(current_user)
|
2016-02-05 14:33:24 -05:00
|
|
|
@projects = @projects.search(params[:filter_projects]) if params[:filter_projects].present?
|
2016-02-04 14:02:19 -05:00
|
|
|
@projects = @projects.reorder('star_count DESC')
|
2016-02-08 20:34:54 -05:00
|
|
|
@projects = @projects.page(params[:page]).per(PER_PAGE) if params[:filter_projects].blank?
|
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
|
2014-07-23 05:03:49 -04:00
|
|
|
end
|