diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-07-23 12:13:33 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-07-23 12:13:33 +0400 |
commit | 1df0345e9e642ca7e9d73c12430921b0fe62d25e (patch) | |
tree | fc2584e67ce95d8f832420a3df0f7594a475d359 | |
parent | 6b4d5d21be69705f22cb2e848fdba9f182ef2bc5 (diff) |
Explore area
Create one place for exploring GitLab instance projects and groups for
both signed in and anonymous users
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r-- | app/assets/stylesheets/sections/explore.scss | 8 | ||||
-rw-r--r-- | app/controllers/public/explore_controller.rb | 12 | ||||
-rw-r--r-- | app/controllers/public/groups_controller.rb | 2 | ||||
-rw-r--r-- | app/finders/trending_projects_finder.rb | 19 | ||||
-rw-r--r-- | app/views/layouts/devise.html.haml | 2 | ||||
-rw-r--r-- | app/views/layouts/public.html.haml | 25 | ||||
-rw-r--r-- | app/views/public/explore/index.html.haml | 18 | ||||
-rw-r--r-- | app/views/public/groups/index.html.haml | 8 | ||||
-rw-r--r-- | app/views/public/projects/index.html.haml | 5 | ||||
-rw-r--r-- | config/routes.rb | 3 |
10 files changed, 82 insertions, 20 deletions
diff --git a/app/assets/stylesheets/sections/explore.scss b/app/assets/stylesheets/sections/explore.scss new file mode 100644 index 00000000000..9b92128624c --- /dev/null +++ b/app/assets/stylesheets/sections/explore.scss @@ -0,0 +1,8 @@ +.explore-title { + text-align: center; + + h3 { + font-weight: normal; + font-size: 30px; + } +} diff --git a/app/controllers/public/explore_controller.rb b/app/controllers/public/explore_controller.rb new file mode 100644 index 00000000000..aa781dc998d --- /dev/null +++ b/app/controllers/public/explore_controller.rb @@ -0,0 +1,12 @@ +class Public::ExploreController < ApplicationController + skip_before_filter :authenticate_user!, + :reject_blocked, + :add_abilities + + layout "public" + + def index + @trending_projects = TrendingProjectsFinder.new.execute(current_user) + @trending_projects = @trending_projects.page(params[:page]).per(10) + end +end diff --git a/app/controllers/public/groups_controller.rb b/app/controllers/public/groups_controller.rb index 7eb159c577d..e22d0837035 100644 --- a/app/controllers/public/groups_controller.rb +++ b/app/controllers/public/groups_controller.rb @@ -3,7 +3,7 @@ class Public::GroupsController < ApplicationController :reject_blocked, :set_current_user_for_observers, :add_abilities - layout "public_groups" + layout "public" def index @groups = GroupsFinder.new.execute(current_user) diff --git a/app/finders/trending_projects_finder.rb b/app/finders/trending_projects_finder.rb new file mode 100644 index 00000000000..32d7968924a --- /dev/null +++ b/app/finders/trending_projects_finder.rb @@ -0,0 +1,19 @@ +class TrendingProjectsFinder + def execute(current_user, start_date = nil) + start_date ||= Date.today - 1.month + + projects = projects_for(current_user) + + # Determine trending projects based on comments count + # for period of time - ex. month + projects.joins(:notes).where('notes.created_at > ?', start_date). + select("projects.*, count(notes.id) as ncount"). + group("projects.id").order("ncount DESC") + end + + private + + def projects_for(current_user) + ProjectsFinder.new.execute(current_user) + end +end diff --git a/app/views/layouts/devise.html.haml b/app/views/layouts/devise.html.haml index ff27fcc0f40..852352a5004 100644 --- a/app/views/layouts/devise.html.haml +++ b/app/views/layouts/devise.html.haml @@ -33,6 +33,6 @@ %hr .container .footer-links - = link_to "Explore public projects", public_projects_path + = link_to "Explore", public_explore_path = link_to "Documentation", "http://doc.gitlab.com/" = link_to "About GitLab", "https://about.gitlab.com/" diff --git a/app/views/layouts/public.html.haml b/app/views/layouts/public.html.haml index 3c76bbb9575..9d76c239999 100644 --- a/app/views/layouts/public.html.haml +++ b/app/views/layouts/public.html.haml @@ -1,11 +1,28 @@ +- page_title = 'Explore' !!! 5 %html{ lang: "en"} - = render "layouts/head", title: "Public Projects" + = render "layouts/head", title: page_title %body{class: "#{app_theme} application", :'data-page' => body_data_page} = render "layouts/broadcast" - if current_user - = render "layouts/head_panel", title: "Public Projects" + = render "layouts/head_panel", title: page_title - else - = render "layouts/public_head_panel", title: "Public Projects" + = render "layouts/public_head_panel", title: page_title .container.navless-container - .content= yield + .content + .explore-title + %h3 + Explore GitLab + %p.lead + Discover projects and groups. Share your projects with others + + + %ul.nav.nav-tabs + = nav_link(controller: :explore) do + = link_to 'Trending Projects', public_explore_path + = nav_link(controller: :projects) do + = link_to 'All Projects', public_projects_path + = nav_link(controller: :groups) do + = link_to 'All Groups', public_groups_path + + = yield diff --git a/app/views/public/explore/index.html.haml b/app/views/public/explore/index.html.haml new file mode 100644 index 00000000000..8e29ef53565 --- /dev/null +++ b/app/views/public/explore/index.html.haml @@ -0,0 +1,18 @@ +.explore-trending-block + %p.lead + %i.icon-comments-alt + See most discussed projects for last month + %hr + %ul.bordered-list + - @trending_projects.each do |project| + %li + %h4.project-title + .project-access-icon + = visibility_level_icon(project.visibility_level) + = link_to project.name_with_namespace, project + + .project-description + = project.description + + .center + = link_to 'Show all projects', public_projects_path, class: 'btn btn-primary' diff --git a/app/views/public/groups/index.html.haml b/app/views/public/groups/index.html.haml index 7a2e5737804..c20af08029f 100644 --- a/app/views/public/groups/index.html.haml +++ b/app/views/public/groups/index.html.haml @@ -1,11 +1,3 @@ -%h3.page-title - Groups (#{@groups.total_count}) - -%p.light - Group allows you to keep projects organized. - Use groups for uniting related projects. - -%hr .clearfix .pull-left = form_tag public_groups_path, method: :get, class: 'form-inline form-tiny' do |f| diff --git a/app/views/public/projects/index.html.haml b/app/views/public/projects/index.html.haml index 7d4d94ce42b..30712a47518 100644 --- a/app/views/public/projects/index.html.haml +++ b/app/views/public/projects/index.html.haml @@ -1,8 +1,3 @@ -%h3.page-title - Projects (#{@projects.total_count}) -.light - You can browse public projects in read-only mode until signed in. -%hr .clearfix .pull-left = form_tag public_projects_path, method: :get, class: 'form-inline form-tiny' do |f| diff --git a/config/routes.rb b/config/routes.rb index 7babab3438a..a8c782ecbf2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -52,7 +52,8 @@ Gitlab::Application.routes.draw do namespace :public do resources :projects, only: [:index] resources :groups, only: [:index] - root to: "projects#index" + get 'explore' => 'explore#index' + root to: "explore#index" end # |