diff --git a/app/controllers/public/groups_controller.rb b/app/controllers/explore/groups_controller.rb similarity index 84% rename from app/controllers/public/groups_controller.rb rename to app/controllers/explore/groups_controller.rb index e22d08370358e6a7f68c33f635ed406a6989f71d..f8e1a31e0b325fc3014e9821fb54b99c55aee250 100644 --- a/app/controllers/public/groups_controller.rb +++ b/app/controllers/explore/groups_controller.rb @@ -1,9 +1,9 @@ -class Public::GroupsController < ApplicationController +class Explore::GroupsController < ApplicationController skip_before_filter :authenticate_user!, :reject_blocked, :set_current_user_for_observers, :add_abilities - layout "public" + layout "explore" def index @groups = GroupsFinder.new.execute(current_user) diff --git a/app/controllers/explore/projects_controller.rb b/app/controllers/explore/projects_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..05b3289682bba32502c2ee52794ba6a68302e608 --- /dev/null +++ b/app/controllers/explore/projects_controller.rb @@ -0,0 +1,19 @@ +class Explore::ProjectsController < ApplicationController + skip_before_filter :authenticate_user!, + :reject_blocked, + :add_abilities + + layout 'explore' + + def index + @projects = ProjectsFinder.new.execute(current_user) + @projects = @projects.search(params[:search]) if params[:search].present? + @projects = @projects.sort(@sort = params[:sort]) + @projects = @projects.includes(:namespace).page(params[:page]).per(20) + end + + def trending + @trending_projects = TrendingProjectsFinder.new.execute(current_user) + @trending_projects = @trending_projects.page(params[:page]).per(10) + end +end diff --git a/app/controllers/public/explore_controller.rb b/app/controllers/public/explore_controller.rb deleted file mode 100644 index aa781dc998d4ff022ca7de67c120e11628e0dc17..0000000000000000000000000000000000000000 --- a/app/controllers/public/explore_controller.rb +++ /dev/null @@ -1,12 +0,0 @@ -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/projects_controller.rb b/app/controllers/public/projects_controller.rb deleted file mode 100644 index d6238f79547e41083b7805c56defa4ba7945abe0..0000000000000000000000000000000000000000 --- a/app/controllers/public/projects_controller.rb +++ /dev/null @@ -1,14 +0,0 @@ -class Public::ProjectsController < ApplicationController - skip_before_filter :authenticate_user!, - :reject_blocked, :set_current_user_for_observers, - :add_abilities - - layout 'public' - - def index - @projects = Project.publicish(current_user) - @projects = @projects.search(params[:search]) if params[:search].present? - @projects = @projects.sort(@sort = params[:sort]) - @projects = @projects.includes(:namespace).page(params[:page]).per(20) - end -end diff --git a/app/views/public/groups/index.html.haml b/app/views/explore/groups/index.html.haml similarity index 74% rename from app/views/public/groups/index.html.haml rename to app/views/explore/groups/index.html.haml index c20af08029fab9c37d80beedcd8e9d9b95d6eb23..80ddd5c1bde0e001c1d2ae424323dd0b4dc4bcda 100644 --- a/app/views/public/groups/index.html.haml +++ b/app/views/explore/groups/index.html.haml @@ -1,6 +1,6 @@ .clearfix .pull-left - = form_tag public_groups_path, method: :get, class: 'form-inline form-tiny' do |f| + = form_tag explore_groups_path, method: :get, class: 'form-inline form-tiny' do |f| .form-group = search_field_tag :search, params[:search], placeholder: "Filter by name", class: "form-control search-text-input input-mn-300", id: "groups_search" .form-group @@ -17,15 +17,15 @@ %b.caret %ul.dropdown-menu %li - = link_to public_groups_path(sort: nil) do + = link_to explore_groups_path(sort: nil) do Name - = link_to public_groups_path(sort: 'newest') do + = link_to explore_groups_path(sort: 'newest') do Newest - = link_to public_groups_path(sort: 'oldest') do + = link_to explore_groups_path(sort: 'oldest') do Oldest - = link_to public_groups_path(sort: 'recently_updated') do + = link_to explore_groups_path(sort: 'recently_updated') do Recently updated - = link_to public_groups_path(sort: 'last_updated') do + = link_to explore_groups_path(sort: 'last_updated') do Last updated %hr diff --git a/app/views/explore/projects/_project.html.haml b/app/views/explore/projects/_project.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..665d111beadecf334636b2dd15df6d6f5c2b54ac --- /dev/null +++ b/app/views/explore/projects/_project.html.haml @@ -0,0 +1,20 @@ +%li + %h4.project-title + .project-access-icon + = visibility_level_icon(project.visibility_level) + = link_to project.name_with_namespace, project + + - if project.description.present? + %p.project-description.str-truncated + = project.description + + .repo-info + - unless project.empty_repo? + = link_to pluralize(project.repository.round_commit_count, 'commit'), project_commits_path(project, project.default_branch) + · + = link_to pluralize(project.repository.branch_names.count, 'branch'), project_branches_path(project) + · + = link_to pluralize(project.repository.tag_names.count, 'tag'), project_tags_path(project) + - else + %i.icon-warning-sign + Empty repository diff --git a/app/views/public/projects/index.html.haml b/app/views/explore/projects/index.html.haml similarity index 55% rename from app/views/public/projects/index.html.haml rename to app/views/explore/projects/index.html.haml index 30712a47518bf8f8fad1ee8d7b34303b076e8118..32796c8b2b80b9b6582448bed6be6c88d1d1bc7c 100644 --- a/app/views/public/projects/index.html.haml +++ b/app/views/explore/projects/index.html.haml @@ -31,32 +31,7 @@ %hr .public-projects %ul.bordered-list.top-list - - @projects.each do |project| - %li - %h4 - = link_to project_path(project) do - = project.name_with_namespace - - if project.internal? - %small.access-icon - = internal_icon - Internal - .pull-right.hidden-sm.hidden-xs - %pre.public-clone git clone #{project.http_url_to_repo} - - - if project.description.present? - %p - = project.description - - .repo-info - - unless project.empty_repo? - = link_to pluralize(project.repository.round_commit_count, 'commit'), project_commits_path(project, project.default_branch) - · - = link_to pluralize(project.repository.branch_names.count, 'branch'), project_branches_path(project) - · - = link_to pluralize(project.repository.tag_names.count, 'tag'), project_tags_path(project) - - else - %i.icon-warning-sign - Empty repository + = render @projects - unless @projects.present? .nothing-here-block No public projects diff --git a/app/views/explore/projects/trending.html.haml b/app/views/explore/projects/trending.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..5b28273d5dd9170787391bc009a40ee7841c02b3 --- /dev/null +++ b/app/views/explore/projects/trending.html.haml @@ -0,0 +1,11 @@ +.explore-trending-block + %p.lead + %i.icon-comments-alt + See most discussed projects for last month + %hr + .public-projects + %ul.bordered-list + = render @trending_projects + + .center + = link_to 'Show all projects', public_projects_path, class: 'btn btn-primary' diff --git a/app/views/layouts/_head_panel.html.haml b/app/views/layouts/_head_panel.html.haml index fba56b5dc3b413abbbb5d0a48658bb165f0737bf..7c727aca7858bcd908b7019e768b315c15daf9ff 100644 --- a/app/views/layouts/_head_panel.html.haml +++ b/app/views/layouts/_head_panel.html.haml @@ -24,7 +24,7 @@ 'data-original-title' => 'Help' do %i.icon-question-sign %li - = link_to public_root_path, title: "Public area", class: 'has_bottom_tooltip', 'data-original-title' => 'Public area' do + = link_to explore_root_path, title: "Explore", class: 'has_bottom_tooltip', 'data-original-title' => 'Public area' do %i.icon-globe %li = link_to user_snippets_path(current_user), title: "My snippets", class: 'has_bottom_tooltip', 'data-original-title' => 'My snippets' do diff --git a/app/views/layouts/devise.html.haml b/app/views/layouts/devise.html.haml index 852352a5004cceef206e1125f819c73c0cd1a1f6..00b1959912f9e9497961652dcb4ff17f1549bfb1 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_explore_path + = link_to "Explore", explore_root_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/explore.html.haml similarity index 70% rename from app/views/layouts/public.html.haml rename to app/views/layouts/explore.html.haml index 9d76c2399992dff88ac49bd2fb6aee6a505738c8..73b4940e3d3043a53c9760a7cc263cd1f4dbc9b6 100644 --- a/app/views/layouts/public.html.haml +++ b/app/views/layouts/explore.html.haml @@ -18,11 +18,11 @@ %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(path: 'projects#trending') do + = link_to 'Trending Projects', explore_root_path + = nav_link(path: 'projects#index') do + = link_to 'All Projects', explore_projects_path = nav_link(controller: :groups) do - = link_to 'All Groups', public_groups_path + = link_to 'All Groups', explore_groups_path = yield diff --git a/app/views/layouts/public_groups.html.haml b/app/views/layouts/public_groups.html.haml deleted file mode 100644 index bfa37b067b94ceaad1a42e2aeecbc23a07a9fde5..0000000000000000000000000000000000000000 --- a/app/views/layouts/public_groups.html.haml +++ /dev/null @@ -1,11 +0,0 @@ -!!! 5 -%html{ lang: "en"} - = render "layouts/head", title: "Public Groups" - %body{class: "#{app_theme} application", :'data-page' => body_data_page} - = render "layouts/broadcast" - - if current_user - = render "layouts/head_panel", title: "Public Groups" - - else - = render "layouts/public_head_panel", title: "Public Groups" - .container.navless-container - .content= yield diff --git a/app/views/public/explore/index.html.haml b/app/views/public/explore/index.html.haml deleted file mode 100644 index 8e29ef535651a829efbc221863e2a22f8ed483df..0000000000000000000000000000000000000000 --- a/app/views/public/explore/index.html.haml +++ /dev/null @@ -1,18 +0,0 @@ -.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/config/routes.rb b/config/routes.rb index a8c782ecbf287bd78f7c122da68d0641631e5a46..f54f9ea53416281980b5284769606e7f5ceb678d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -47,15 +47,23 @@ Gitlab::Application.routes.draw do get "/s/:username" => "snippets#user_index", as: :user_snippets, constraints: { username: /.*/ } # - # Public namespace + # Explroe area # - namespace :public do - resources :projects, only: [:index] + namespace :explore do + resources :projects, only: [:index] do + collection do + get :trending + end + end + resources :groups, only: [:index] - get 'explore' => 'explore#index' - root to: "explore#index" + root to: "projects#trending" end + # Compatibility with old routing + get 'public' => "explore/projects#index" + get 'public/projects' => "explore/projects#index" + # # Attachments serving #