summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-09-24 22:14:28 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-09-24 22:14:28 +0300
commit2f6342978bfb0bd7aafc345a36bb0846b73cc80d (patch)
tree4599e4dc145c3ca48d3dfbb958f457c55da4f424
parent61eb050993e85459282dd6f39c1f703d29b6d3a7 (diff)
downloadgitlab-ce-2f6342978bfb0bd7aafc345a36bb0846b73cc80d.tar.gz
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
-rw-r--r--app/assets/stylesheets/sections/projects.scss24
-rw-r--r--app/controllers/projects/application_controller.rb2
-rw-r--r--app/controllers/projects_controller.rb11
-rw-r--r--app/helpers/projects_helper.rb16
-rw-r--r--app/views/projects/empty.html.haml4
-rw-r--r--app/views/projects/notes/_note.html.haml2
-rw-r--r--app/views/public/projects/index.html.haml31
-rw-r--r--config/routes.rb2
-rw-r--r--features/public/public_projects.feature9
-rw-r--r--features/steps/public/projects_feature.rb15
10 files changed, 72 insertions, 44 deletions
diff --git a/app/assets/stylesheets/sections/projects.scss b/app/assets/stylesheets/sections/projects.scss
index f2707f62378..0491b68db57 100644
--- a/app/assets/stylesheets/sections/projects.scss
+++ b/app/assets/stylesheets/sections/projects.scss
@@ -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;
+ }
+}
diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb
index d525bd4a700..8fd4565f367 100644
--- a/app/controllers/projects/application_controller.rb
+++ b/app/controllers/projects/application_controller.rb
@@ -20,7 +20,7 @@ class Projects::ApplicationController < ApplicationController
if current_user
'projects'
else
- 'public'
+ 'public_projects'
end
end
end
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 9ba2a758b8a..f31fb666e3e 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -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
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 3a1cf59fd1a..9071c688df1 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -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
diff --git a/app/views/projects/empty.html.haml b/app/views/projects/empty.html.haml
index 001857cefda..9f3502e90de 100644
--- a/app/views/projects/empty.html.haml
+++ b/app/views/projects/empty.html.haml
@@ -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
diff --git a/app/views/projects/notes/_note.html.haml b/app/views/projects/notes/_note.html.haml
index fbc924c4e1d..324b698f3b5 100644
--- a/app/views/projects/notes/_note.html.haml
+++ b/app/views/projects/notes/_note.html.haml
@@ -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
diff --git a/app/views/public/projects/index.html.haml b/app/views/public/projects/index.html.haml
index bea99b54ef7..21aee644579 100644
--- a/app/views/public/projects/index.html.haml
+++ b/app/views/public/projects/index.html.haml
@@ -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
diff --git a/config/routes.rb b/config/routes.rb
index 2b444c2a296..9d47faa19d5 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -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
diff --git a/features/public/public_projects.feature b/features/public/public_projects.feature
index 1866d3f47fe..178a769194c 100644
--- a/features/public/public_projects.feature
+++ b/features/public/public_projects.feature
@@ -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
diff --git a/features/steps/public/projects_feature.rb b/features/steps/public/projects_feature.rb
index 2268e9b9c5e..2f2c4de0b2a 100644
--- a/features/steps/public/projects_feature.rb
+++ b/features/steps/public/projects_feature.rb
@@ -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