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 {
margin: 0px;
}
.public-projects {
li {
.project-title {
font-size: 14px;
line-height: 2;
font-weight: normal;
}
.description {
margin-left: 15px;
color: #aaa;
}
}
}
.my-projects {
li {
.project-title {
......@@ -110,7 +95,6 @@ ul.nav.nav-projects-tabs {
}
}
.public-clone {
background: #333;
color: #f5f5f5;
......@@ -123,3 +107,11 @@ ul.nav.nav-projects-tabs {
position: relative;
top: -5px;
}
.public-projects .repo-info {
color: #777;
a {
color: #777;
}
}
......@@ -20,7 +20,7 @@ class Projects::ApplicationController < ApplicationController
if current_user
'projects'
else
'public'
'public_projects'
end
end
end
......@@ -55,10 +55,9 @@ class ProjectsController < Projects::ApplicationController
end
def show
return authenticate_user! unless @project.public
return authenticate_user! unless @project.public || current_user
limit = (params[:limit] || 20).to_i
@events = @project.events.recent
@events = event_filter.apply_filter(@events)
@events = @events.limit(limit).offset(params[:offset] || 0)
......@@ -70,12 +69,12 @@ class ProjectsController < Projects::ApplicationController
respond_to do |format|
format.html do
if @project.empty_repo?
render "projects/empty"
render "projects/empty", layout: user_layout
else
if current_user
@last_push = current_user.recent_push(@project.id)
end
render :show, layout: current_user ? "project" : "public"
render :show, layout: user_layout
end
end
format.js
......@@ -126,4 +125,8 @@ class ProjectsController < Projects::ApplicationController
def set_title
@title = 'New Project'
end
def user_layout
current_user ? "projects" : "public_projects"
end
end
......@@ -103,4 +103,20 @@ module ProjectsHelper
nav_tabs.flatten
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
......@@ -16,8 +16,8 @@
%legend Git global setup:
%pre.dark
:preserve
git config --global user.name "#{current_user.name}"
git config --global user.email "#{current_user.email}"
git config --global user.name "#{git_user_name}"
git config --global user.email "#{git_user_email}"
%fieldset
%legend Create Repository
......
......@@ -5,7 +5,7 @@
%i.icon-link
Link here
&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
%i.icon-edit
Edit
......
......@@ -2,29 +2,40 @@
.span6
%h3.page-title
Projects (#{@projects.total_count})
%small with read-only access
.light
You can browse public projects in read-only mode until signed in.
.span6
.pull-right
= form_tag public_projects_path, method: :get, class: 'form-inline' do |f|
.search-holder
.controls
= 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"
= 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"
%hr
.public-projects
%ul.bordered-list
%ul.bordered-list.top-list
- @projects.each do |project|
%li
.project-title
%i.icon-share.cgray
%h4
= link_to project_path(project) do
%strong= project.name_with_namespace
= project.name_with_namespace
.pull-right
%pre.public-clone git clone #{project.http_url_to_repo}
- if project.description.present?
%div.description
%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)
&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?
%h3.nothing_here_message No public projects
......
......@@ -55,8 +55,6 @@ Gitlab::Application.routes.draw do
#
namespace :public do
resources :projects, only: [:index]
resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:show]
root to: "projects#index"
end
......
......@@ -9,11 +9,10 @@ Feature: Public Projects Feature
And I should not see project "Enterprise"
Scenario: I visit public project page
When I visit public page for "Community" project
Then I should see public project details
And I should see project readme
When I visit project "Community" page
Then I should see project "Community" home page
Scenario: I visit an empty public project page
Given public empty project "Empty Public Project"
When I visit empty public project page
Then I should see empty public project details
\ No newline at end of file
When I visit empty project page
Then I should see empty public project details
......@@ -31,19 +31,28 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps
create :project, name: 'Empty Public Project', public: true
end
step 'I visit empty public project page' do
step 'I visit empty project page' do
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
step 'I should see empty public project details' do
page.should have_content 'Empty Repository'
page.should have_content 'Git global setup'
end
step 'private project "Enterprise"' do
create :project, name: 'Enterprise'
end
step 'I should see project "Community" home page' do
page.should have_content 'Repo size is'
end
private
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