summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-12-26 11:24:43 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-12-26 11:24:43 +0200
commit7458437ed970b610defc2ab3042ea1494b06e822 (patch)
tree31059d59534a7216fdc2d9645eacd1f8e44dfc6a
parent6a0c0f3f3fc114a8b02e2d3f44539cf36534061c (diff)
downloadgitlab-ce-7458437ed970b610defc2ab3042ea1494b06e822.tar.gz
Improve sorting for public projects page
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--app/controllers/public/projects_controller.rb3
-rw-r--r--app/views/public/projects/index.html.haml6
2 files changed, 6 insertions, 3 deletions
diff --git a/app/controllers/public/projects_controller.rb b/app/controllers/public/projects_controller.rb
index 34425db72ab..e00cd8c7f84 100644
--- a/app/controllers/public/projects_controller.rb
+++ b/app/controllers/public/projects_controller.rb
@@ -8,7 +8,8 @@ class Public::ProjectsController < ApplicationController
def index
@projects = Project.public_or_internal_only(current_user)
@projects = @projects.search(params[:search]) if params[:search].present?
- @projects = case params[:sort]
+ @sort = params[:sort]
+ @projects = case @sort
when 'newest' then @projects.order('created_at DESC')
when 'oldest' then @projects.order('created_at ASC')
when 'recently_updated' then @projects.order('updated_at DESC')
diff --git a/app/views/public/projects/index.html.haml b/app/views/public/projects/index.html.haml
index 193d5c089a0..002ffa916b5 100644
--- a/app/views/public/projects/index.html.haml
+++ b/app/views/public/projects/index.html.haml
@@ -15,12 +15,14 @@
%a.dropdown-toggle.btn{href: '#', "data-toggle" => "dropdown"}
%span.light sort:
- if @sort.present?
- = @sort
+ = @sort.humanize
- else
- Newest
+ Name
%b.caret
%ul.dropdown-menu
%li
+ = link_to public_projects_path(sort: nil) do
+ Name
= link_to public_projects_path(sort: 'newest') do
Newest
= link_to public_projects_path(sort: 'oldest') do