Commit f4205abb7725c96c1a967f5b3779e09c6e94a21d
Exists in
master
and in
4 other branches
Merge branch 'master' of dev.gitlab.org:gitlab/gitlabhq
Showing
11 changed files
with
148 additions
and
17 deletions
Show diff stats
app/assets/stylesheets/sections/projects.scss
| @@ -81,9 +81,11 @@ ul.nav.nav-projects-tabs { | @@ -81,9 +81,11 @@ ul.nav.nav-projects-tabs { | ||
| 81 | 81 | ||
| 82 | .public-projects { | 82 | .public-projects { |
| 83 | li { | 83 | li { |
| 84 | - margin-top: 8px; | ||
| 85 | - margin-bottom: 5px; | ||
| 86 | - border-bottom: 1px solid #eee; | 84 | + .project-title { |
| 85 | + font-size: 14px; | ||
| 86 | + line-height: 2; | ||
| 87 | + font-weight: normal; | ||
| 88 | + } | ||
| 87 | 89 | ||
| 88 | .description { | 90 | .description { |
| 89 | margin-left: 15px; | 91 | margin-left: 15px; |
| @@ -92,6 +94,14 @@ ul.nav.nav-projects-tabs { | @@ -92,6 +94,14 @@ ul.nav.nav-projects-tabs { | ||
| 92 | } | 94 | } |
| 93 | } | 95 | } |
| 94 | 96 | ||
| 97 | +.public-clone { | ||
| 98 | + background: #333; | ||
| 99 | + color: #f5f5f5; | ||
| 100 | + padding: 5px 10px; | ||
| 101 | + margin: 1px; | ||
| 102 | + font-weight: normal; | ||
| 103 | +} | ||
| 104 | + | ||
| 95 | .new-tag-btn { | 105 | .new-tag-btn { |
| 96 | position: relative; | 106 | position: relative; |
| 97 | top: -5px; | 107 | top: -5px; |
app/controllers/public/projects_controller.rb
| @@ -10,4 +10,15 @@ class Public::ProjectsController < ApplicationController | @@ -10,4 +10,15 @@ class Public::ProjectsController < ApplicationController | ||
| 10 | @projects = @projects.search(params[:search]) if params[:search].present? | 10 | @projects = @projects.search(params[:search]) if params[:search].present? |
| 11 | @projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20) | 11 | @projects = @projects.includes(:namespace).order("namespaces.path, projects.name ASC").page(params[:page]).per(20) |
| 12 | end | 12 | end |
| 13 | + | ||
| 14 | + def show | ||
| 15 | + @project = Project.public_only.find_with_namespace(params[:id]) | ||
| 16 | + render_404 and return unless @project | ||
| 17 | + | ||
| 18 | + @repository = @project.repository | ||
| 19 | + @recent_tags = @repository.tags.first(10) | ||
| 20 | + | ||
| 21 | + @commit = @repository.commit(params[:ref]) | ||
| 22 | + @tree = Tree.new(@repository, @commit.id) | ||
| 23 | + end | ||
| 13 | end | 24 | end |
app/views/layouts/errors.html.haml
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | %html{ lang: "en"} | 2 | %html{ lang: "en"} |
| 3 | = render "layouts/head", title: "Error" | 3 | = render "layouts/head", title: "Error" |
| 4 | %body{class: "#{app_theme} application"} | 4 | %body{class: "#{app_theme} application"} |
| 5 | - = render "layouts/head_panel", title: "" | 5 | + = render "layouts/head_panel", title: "" if current_user |
| 6 | = render "layouts/flash" | 6 | = render "layouts/flash" |
| 7 | .container | 7 | .container |
| 8 | .content | 8 | .content |
app/views/layouts/public.html.haml
| @@ -10,10 +10,16 @@ | @@ -10,10 +10,16 @@ | ||
| 10 | .container | 10 | .container |
| 11 | %div.app_logo | 11 | %div.app_logo |
| 12 | %span.separator | 12 | %span.separator |
| 13 | - = link_to root_path, class: "home" do | 13 | + = link_to public_root_path, class: "home" do |
| 14 | %h1 GITLAB | 14 | %h1 GITLAB |
| 15 | %span.separator | 15 | %span.separator |
| 16 | %h1.project_name Public Projects | 16 | %h1.project_name Public Projects |
| 17 | + %ul.nav | ||
| 18 | + %li | ||
| 19 | + %a | ||
| 20 | + %div.hide.turbolink-spinner | ||
| 21 | + %i.icon-refresh.icon-spin | ||
| 22 | + Loading... | ||
| 17 | 23 | ||
| 18 | .container.navless-container | 24 | .container.navless-container |
| 19 | .content | 25 | .content |
app/views/public/projects/index.html.haml
| @@ -11,22 +11,20 @@ | @@ -11,22 +11,20 @@ | ||
| 11 | = search_field_tag :search, params[:search], placeholder: "gitlab-ci", class: "span3 search-text-input", id: "projects_search" | 11 | = search_field_tag :search, params[:search], placeholder: "gitlab-ci", class: "span3 search-text-input", id: "projects_search" |
| 12 | = submit_tag 'Search', class: "btn btn-primary wide" | 12 | = submit_tag 'Search', class: "btn btn-primary wide" |
| 13 | 13 | ||
| 14 | -%hr | ||
| 15 | - | ||
| 16 | .public-projects | 14 | .public-projects |
| 17 | - %ul.unstyled | 15 | + %ul.bordered-list |
| 18 | - @projects.each do |project| | 16 | - @projects.each do |project| |
| 19 | - %li.clearfix | ||
| 20 | - %div | ||
| 21 | - %i.icon-share | ||
| 22 | - - if current_user | ||
| 23 | - = link_to_project project | ||
| 24 | - - else | 17 | + %li |
| 18 | + .project-title | ||
| 19 | + %i.icon-share.cgray | ||
| 20 | + = link_to public_project_path(project) do | ||
| 25 | = project.name_with_namespace | 21 | = project.name_with_namespace |
| 26 | .pull-right | 22 | .pull-right |
| 27 | - %pre.dark.tiny git clone #{project.http_url_to_repo} | ||
| 28 | - %div.description | ||
| 29 | - = project.description | 23 | + %pre.public-clone git clone #{project.http_url_to_repo} |
| 24 | + | ||
| 25 | + - if project.description.present? | ||
| 26 | + %div.description | ||
| 27 | + = project.description | ||
| 30 | - unless @projects.present? | 28 | - unless @projects.present? |
| 31 | %h3.nothing_here_message No public projects | 29 | %h3.nothing_here_message No public projects |
| 32 | 30 |
| @@ -0,0 +1,46 @@ | @@ -0,0 +1,46 @@ | ||
| 1 | +%h3.page-title | ||
| 2 | + = @project.name_with_namespace | ||
| 3 | + .pull-right | ||
| 4 | + %pre.public-clone git clone #{@project.http_url_to_repo} | ||
| 5 | + .pull-right | ||
| 6 | + - if current_user | ||
| 7 | + = link_to 'Browse project', @project, class: 'btn btn-create append-right-10' | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +%div | ||
| 11 | + = link_to public_root_path do | ||
| 12 | + ← To projects list | ||
| 13 | + .pull-right | ||
| 14 | + %span.light= @project.description | ||
| 15 | + | ||
| 16 | +%br | ||
| 17 | +.row | ||
| 18 | + .span9 | ||
| 19 | + = render 'tree', tree: @tree | ||
| 20 | + .span3 | ||
| 21 | + %h5 Repository: | ||
| 22 | + %div | ||
| 23 | + %p | ||
| 24 | + %span.light Bare size is | ||
| 25 | + #{@project.repository.size} MB | ||
| 26 | + | ||
| 27 | + %p | ||
| 28 | + = pluralize(@repository.round_commit_count, 'commit') | ||
| 29 | + %p | ||
| 30 | + = pluralize(@repository.branch_names.count, 'branch') | ||
| 31 | + %p | ||
| 32 | + = pluralize(@repository.tag_names.count, 'tag') | ||
| 33 | + | ||
| 34 | + - if @recent_tags.present? | ||
| 35 | + %hr | ||
| 36 | + %h5 Most Recent Tags: | ||
| 37 | + %ul.unstyled | ||
| 38 | + - @recent_tags.each do |tag| | ||
| 39 | + %li | ||
| 40 | + %p | ||
| 41 | + %i.icon-tag | ||
| 42 | + %strong= tag.name | ||
| 43 | + %small.light.pull-right | ||
| 44 | + %i.icon-calendar | ||
| 45 | + = time_ago_in_words(tag.commit.committed_date) | ||
| 46 | + ago |
config/routes.rb
| @@ -55,6 +55,8 @@ Gitlab::Application.routes.draw do | @@ -55,6 +55,8 @@ Gitlab::Application.routes.draw do | ||
| 55 | # | 55 | # |
| 56 | namespace :public do | 56 | namespace :public do |
| 57 | resources :projects, only: [:index] | 57 | resources :projects, only: [:index] |
| 58 | + resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:show] | ||
| 59 | + | ||
| 58 | root to: "projects#index" | 60 | root to: "projects#index" |
| 59 | end | 61 | end |
| 60 | 62 |
| @@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
| 1 | +Feature: Public Projects Feature | ||
| 2 | + Background: | ||
| 3 | + Given public project "Community" | ||
| 4 | + And private project "Enterprise" | ||
| 5 | + | ||
| 6 | + Scenario: I visit public area | ||
| 7 | + When I visit the public projects area | ||
| 8 | + Then I should see project "Community" | ||
| 9 | + And I should not see project "Enterprise" | ||
| 10 | + | ||
| 11 | + Scenario: I visit public project page | ||
| 12 | + When I visit public page for "Community" project | ||
| 13 | + Then I should see public project details | ||
| 14 | + And I should see project readme |
| @@ -0,0 +1,35 @@ | @@ -0,0 +1,35 @@ | ||
| 1 | +class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps | ||
| 2 | + include SharedPaths | ||
| 3 | + | ||
| 4 | + step 'I should see project "Community"' do | ||
| 5 | + page.should have_content "Community" | ||
| 6 | + end | ||
| 7 | + | ||
| 8 | + step 'I should not see project "Enterprise"' do | ||
| 9 | + page.should_not have_content "Enterprise" | ||
| 10 | + end | ||
| 11 | + | ||
| 12 | + step 'I should see public project details' do | ||
| 13 | + page.should have_content '32 branches' | ||
| 14 | + page.should have_content '16 tags' | ||
| 15 | + end | ||
| 16 | + | ||
| 17 | + step 'I should see project readme' do | ||
| 18 | + page.should have_content 'README.md' | ||
| 19 | + end | ||
| 20 | + | ||
| 21 | + step 'public project "Community"' do | ||
| 22 | + create :project_with_code, name: 'Community', public: true | ||
| 23 | + end | ||
| 24 | + | ||
| 25 | + step 'private project "Enterprise"' do | ||
| 26 | + create :project, name: 'Enterprise' | ||
| 27 | + end | ||
| 28 | + | ||
| 29 | + private | ||
| 30 | + | ||
| 31 | + def project | ||
| 32 | + @project ||= Project.find_by_name("Community") | ||
| 33 | + end | ||
| 34 | +end | ||
| 35 | + |
features/steps/shared/paths.rb
| @@ -275,6 +275,10 @@ module SharedPaths | @@ -275,6 +275,10 @@ module SharedPaths | ||
| 275 | visit public_root_path | 275 | visit public_root_path |
| 276 | end | 276 | end |
| 277 | 277 | ||
| 278 | + step 'I visit public page for "Community" project' do | ||
| 279 | + visit public_project_path(Project.find_by_name("Community")) | ||
| 280 | + end | ||
| 281 | + | ||
| 278 | # ---------------------------------------- | 282 | # ---------------------------------------- |
| 279 | # Snippets | 283 | # Snippets |
| 280 | # ---------------------------------------- | 284 | # ---------------------------------------- |