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>
This commit is contained in:
parent
6b4d5d21be
commit
1df0345e9e
10 changed files with 82 additions and 20 deletions
8
app/assets/stylesheets/sections/explore.scss
Normal file
8
app/assets/stylesheets/sections/explore.scss
Normal file
|
@ -0,0 +1,8 @@
|
|||
.explore-title {
|
||||
text-align: center;
|
||||
|
||||
h3 {
|
||||
font-weight: normal;
|
||||
font-size: 30px;
|
||||
}
|
||||
}
|
12
app/controllers/public/explore_controller.rb
Normal file
12
app/controllers/public/explore_controller.rb
Normal file
|
@ -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
|
|
@ -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)
|
||||
|
|
19
app/finders/trending_projects_finder.rb
Normal file
19
app/finders/trending_projects_finder.rb
Normal file
|
@ -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
|
|
@ -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/"
|
||||
|
|
|
@ -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
|
||||
|
|
18
app/views/public/explore/index.html.haml
Normal file
18
app/views/public/explore/index.html.haml
Normal file
|
@ -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'
|
|
@ -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|
|
||||
|
|
|
@ -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|
|
||||
|
|
|
@ -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
|
||||
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue