Commit 1df0345e authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Explore area

Create one place for exploring GitLab instance projects and groups for
both signed in and anonymous users
Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 6b4d5d21
.explore-title {
text-align: center;
h3 {
font-weight: normal;
font-size: 30px;
}
}
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)
......
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/"
- 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
.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'
%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|
......
%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
#
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment