Commit 2f634297 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Public projects feature - step2

* Render right layout depends on current_user
* show sample git username/email when repo is empty
* Show extra info when browsing public area
* Fixed some tests related to public projects
* show comments in read-only for public projects
* Remove old public routing
parent 61eb0509
...@@ -79,21 +79,6 @@ ul.nav.nav-projects-tabs { ...@@ -79,21 +79,6 @@ ul.nav.nav-projects-tabs {
margin: 0px; margin: 0px;
} }
.public-projects {
li {
.project-title {
font-size: 14px;
line-height: 2;
font-weight: normal;
}
.description {
margin-left: 15px;
color: #aaa;
}
}
}
.my-projects { .my-projects {
li { li {
.project-title { .project-title {
...@@ -110,7 +95,6 @@ ul.nav.nav-projects-tabs { ...@@ -110,7 +95,6 @@ ul.nav.nav-projects-tabs {
} }
} }
.public-clone { .public-clone {
background: #333; background: #333;
color: #f5f5f5; color: #f5f5f5;
...@@ -123,3 +107,11 @@ ul.nav.nav-projects-tabs { ...@@ -123,3 +107,11 @@ ul.nav.nav-projects-tabs {
position: relative; position: relative;
top: -5px; top: -5px;
} }
.public-projects .repo-info {
color: #777;
a {
color: #777;
}
}
...@@ -20,7 +20,7 @@ class Projects::ApplicationController < ApplicationController ...@@ -20,7 +20,7 @@ class Projects::ApplicationController < ApplicationController
if current_user if current_user
'projects' 'projects'
else else
'public' 'public_projects'
end end
end end
end end
...@@ -55,10 +55,9 @@ class ProjectsController < Projects::ApplicationController ...@@ -55,10 +55,9 @@ class ProjectsController < Projects::ApplicationController
end end
def show def show
return authenticate_user! unless @project.public return authenticate_user! unless @project.public || current_user
limit = (params[:limit] || 20).to_i limit = (params[:limit] || 20).to_i
@events = @project.events.recent @events = @project.events.recent
@events = event_filter.apply_filter(@events) @events = event_filter.apply_filter(@events)
@events = @events.limit(limit).offset(params[:offset] || 0) @events = @events.limit(limit).offset(params[:offset] || 0)
...@@ -70,12 +69,12 @@ class ProjectsController < Projects::ApplicationController ...@@ -70,12 +69,12 @@ class ProjectsController < Projects::ApplicationController
respond_to do |format| respond_to do |format|
format.html do format.html do
if @project.empty_repo? if @project.empty_repo?
render "projects/empty" render "projects/empty", layout: user_layout
else else
if current_user if current_user
@last_push = current_user.recent_push(@project.id) @last_push = current_user.recent_push(@project.id)
end end
render :show, layout: current_user ? "project" : "public" render :show, layout: user_layout
end end
end end
format.js format.js
...@@ -126,4 +125,8 @@ class ProjectsController < Projects::ApplicationController ...@@ -126,4 +125,8 @@ class ProjectsController < Projects::ApplicationController
def set_title def set_title
@title = 'New Project' @title = 'New Project'
end end
def user_layout
current_user ? "projects" : "public_projects"
end
end end
...@@ -103,4 +103,20 @@ module ProjectsHelper ...@@ -103,4 +103,20 @@ module ProjectsHelper
nav_tabs.flatten nav_tabs.flatten
end end
def git_user_name
if current_user
current_user.name
else
"Your name"
end
end
def git_user_email
if current_user
current_user.email
else
"your@email.com"
end
end
end end
...@@ -16,8 +16,8 @@ ...@@ -16,8 +16,8 @@
%legend Git global setup: %legend Git global setup:
%pre.dark %pre.dark
:preserve :preserve
git config --global user.name "#{current_user.name}" git config --global user.name "#{git_user_name}"
git config --global user.email "#{current_user.email}" git config --global user.email "#{git_user_email}"
%fieldset %fieldset
%legend Create Repository %legend Create Repository
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
%i.icon-link %i.icon-link
Link here Link here
&nbsp; &nbsp;
- if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project) - if(note.author_id == current_user.try(:id)) || can?(current_user, :admin_note, @project)
= link_to "#", title: "Edit comment", class: "js-note-edit" do = link_to "#", title: "Edit comment", class: "js-note-edit" do
%i.icon-edit %i.icon-edit
Edit Edit
......
...@@ -2,29 +2,40 @@ ...@@ -2,29 +2,40 @@
.span6 .span6
%h3.page-title %h3.page-title
Projects (#{@projects.total_count}) Projects (#{@projects.total_count})
%small with read-only access .light
You can browse public projects in read-only mode until signed in.
.span6 .span6
.pull-right .pull-right
= form_tag public_projects_path, method: :get, class: 'form-inline' do |f| = form_tag public_projects_path, method: :get, class: 'form-inline' do |f|
.search-holder .search-holder
.controls = search_field_tag :search, params[:search], placeholder: "Filter by name", class: "span3 search-text-input", id: "projects_search"
= search_field_tag :search, params[:search], placeholder: "Filter by name", class: "span3 search-text-input", id: "projects_search" = submit_tag 'Search', class: "btn btn-primary wide"
= submit_tag 'Search', class: "btn btn-primary wide" %hr
.public-projects .public-projects
%ul.bordered-list %ul.bordered-list.top-list
- @projects.each do |project| - @projects.each do |project|
%li %li
.project-title %h4
%i.icon-share.cgray
= link_to project_path(project) do = link_to project_path(project) do
%strong= project.name_with_namespace = project.name_with_namespace
.pull-right .pull-right
%pre.public-clone git clone #{project.http_url_to_repo} %pre.public-clone git clone #{project.http_url_to_repo}
- if project.description.present? - if project.description.present?
%div.description %p
= project.description = project.description
.repo-info
- unless project.empty_repo?
= link_to pluralize(project.repository.round_commit_count, 'commit'), project_commits_path(project, project.default_branch)
&middot;
= link_to pluralize(project.repository.branch_names.count, 'branch'), project_branches_path(project)
&middot;
= link_to pluralize(project.repository.tag_names.count, 'tag'), project_tags_path(project)
- else
%i.icon-warning-sign
Empty repository
- unless @projects.present? - unless @projects.present?
%h3.nothing_here_message No public projects %h3.nothing_here_message No public projects
......
...@@ -55,8 +55,6 @@ Gitlab::Application.routes.draw do ...@@ -55,8 +55,6 @@ Gitlab::Application.routes.draw do
# #
namespace :public do namespace :public do
resources :projects, only: [:index] resources :projects, only: [:index]
resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:show]
root to: "projects#index" root to: "projects#index"
end end
......
...@@ -9,11 +9,10 @@ Feature: Public Projects Feature ...@@ -9,11 +9,10 @@ Feature: Public Projects Feature
And I should not see project "Enterprise" And I should not see project "Enterprise"
Scenario: I visit public project page Scenario: I visit public project page
When I visit public page for "Community" project When I visit project "Community" page
Then I should see public project details Then I should see project "Community" home page
And I should see project readme
Scenario: I visit an empty public project page Scenario: I visit an empty public project page
Given public empty project "Empty Public Project" Given public empty project "Empty Public Project"
When I visit empty public project page When I visit empty project page
Then I should see empty public project details Then I should see empty public project details
\ No newline at end of file
...@@ -31,19 +31,28 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps ...@@ -31,19 +31,28 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps
create :project, name: 'Empty Public Project', public: true create :project, name: 'Empty Public Project', public: true
end end
step 'I visit empty public project page' do step 'I visit empty project page' do
project = Project.find_by_name('Empty Public Project') project = Project.find_by_name('Empty Public Project')
visit public_project_path(project) visit project_path(project)
end
step 'I visit project "Community" page' do
project = Project.find_by_name('Community')
visit project_path(project)
end end
step 'I should see empty public project details' do step 'I should see empty public project details' do
page.should have_content 'Empty Repository' page.should have_content 'Git global setup'
end end
step 'private project "Enterprise"' do step 'private project "Enterprise"' do
create :project, name: 'Enterprise' create :project, name: 'Enterprise'
end end
step 'I should see project "Community" home page' do
page.should have_content 'Repo size is'
end
private private
def project def project
......
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