Commit 2f6342978bfb0bd7aafc345a36bb0846b73cc80d
1 parent
61eb0509
Exists in
master
and in
4 other branches
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
Showing
10 changed files
with
72 additions
and
44 deletions
Show diff stats
app/assets/stylesheets/sections/projects.scss
... | ... | @@ -79,21 +79,6 @@ ul.nav.nav-projects-tabs { |
79 | 79 | margin: 0px; |
80 | 80 | } |
81 | 81 | |
82 | -.public-projects { | |
83 | - li { | |
84 | - .project-title { | |
85 | - font-size: 14px; | |
86 | - line-height: 2; | |
87 | - font-weight: normal; | |
88 | - } | |
89 | - | |
90 | - .description { | |
91 | - margin-left: 15px; | |
92 | - color: #aaa; | |
93 | - } | |
94 | - } | |
95 | -} | |
96 | - | |
97 | 82 | .my-projects { |
98 | 83 | li { |
99 | 84 | .project-title { |
... | ... | @@ -110,7 +95,6 @@ ul.nav.nav-projects-tabs { |
110 | 95 | } |
111 | 96 | } |
112 | 97 | |
113 | - | |
114 | 98 | .public-clone { |
115 | 99 | background: #333; |
116 | 100 | color: #f5f5f5; |
... | ... | @@ -123,3 +107,11 @@ ul.nav.nav-projects-tabs { |
123 | 107 | position: relative; |
124 | 108 | top: -5px; |
125 | 109 | } |
110 | + | |
111 | +.public-projects .repo-info { | |
112 | + color: #777; | |
113 | + | |
114 | + a { | |
115 | + color: #777; | |
116 | + } | |
117 | +} | ... | ... |
app/controllers/projects/application_controller.rb
app/controllers/projects_controller.rb
... | ... | @@ -55,10 +55,9 @@ class ProjectsController < Projects::ApplicationController |
55 | 55 | end |
56 | 56 | |
57 | 57 | def show |
58 | - return authenticate_user! unless @project.public | |
58 | + return authenticate_user! unless @project.public || current_user | |
59 | 59 | |
60 | 60 | limit = (params[:limit] || 20).to_i |
61 | - | |
62 | 61 | @events = @project.events.recent |
63 | 62 | @events = event_filter.apply_filter(@events) |
64 | 63 | @events = @events.limit(limit).offset(params[:offset] || 0) |
... | ... | @@ -70,12 +69,12 @@ class ProjectsController < Projects::ApplicationController |
70 | 69 | respond_to do |format| |
71 | 70 | format.html do |
72 | 71 | if @project.empty_repo? |
73 | - render "projects/empty" | |
72 | + render "projects/empty", layout: user_layout | |
74 | 73 | else |
75 | 74 | if current_user |
76 | 75 | @last_push = current_user.recent_push(@project.id) |
77 | 76 | end |
78 | - render :show, layout: current_user ? "project" : "public" | |
77 | + render :show, layout: user_layout | |
79 | 78 | end |
80 | 79 | end |
81 | 80 | format.js |
... | ... | @@ -126,4 +125,8 @@ class ProjectsController < Projects::ApplicationController |
126 | 125 | def set_title |
127 | 126 | @title = 'New Project' |
128 | 127 | end |
128 | + | |
129 | + def user_layout | |
130 | + current_user ? "projects" : "public_projects" | |
131 | + end | |
129 | 132 | end | ... | ... |
app/helpers/projects_helper.rb
... | ... | @@ -103,4 +103,20 @@ module ProjectsHelper |
103 | 103 | |
104 | 104 | nav_tabs.flatten |
105 | 105 | end |
106 | + | |
107 | + def git_user_name | |
108 | + if current_user | |
109 | + current_user.name | |
110 | + else | |
111 | + "Your name" | |
112 | + end | |
113 | + end | |
114 | + | |
115 | + def git_user_email | |
116 | + if current_user | |
117 | + current_user.email | |
118 | + else | |
119 | + "your@email.com" | |
120 | + end | |
121 | + end | |
106 | 122 | end | ... | ... |
app/views/projects/empty.html.haml
... | ... | @@ -16,8 +16,8 @@ |
16 | 16 | %legend Git global setup: |
17 | 17 | %pre.dark |
18 | 18 | :preserve |
19 | - git config --global user.name "#{current_user.name}" | |
20 | - git config --global user.email "#{current_user.email}" | |
19 | + git config --global user.name "#{git_user_name}" | |
20 | + git config --global user.email "#{git_user_email}" | |
21 | 21 | |
22 | 22 | %fieldset |
23 | 23 | %legend Create Repository | ... | ... |
app/views/projects/notes/_note.html.haml
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | %i.icon-link |
6 | 6 | Link here |
7 | 7 | |
8 | - - if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project) | |
8 | + - if(note.author_id == current_user.try(:id)) || can?(current_user, :admin_note, @project) | |
9 | 9 | = link_to "#", title: "Edit comment", class: "js-note-edit" do |
10 | 10 | %i.icon-edit |
11 | 11 | Edit | ... | ... |
app/views/public/projects/index.html.haml
... | ... | @@ -2,29 +2,40 @@ |
2 | 2 | .span6 |
3 | 3 | %h3.page-title |
4 | 4 | Projects (#{@projects.total_count}) |
5 | - %small with read-only access | |
5 | + .light | |
6 | + You can browse public projects in read-only mode until signed in. | |
7 | + | |
6 | 8 | .span6 |
7 | 9 | .pull-right |
8 | 10 | = form_tag public_projects_path, method: :get, class: 'form-inline' do |f| |
9 | 11 | .search-holder |
10 | - .controls | |
11 | - = search_field_tag :search, params[:search], placeholder: "Filter by name", class: "span3 search-text-input", id: "projects_search" | |
12 | - = submit_tag 'Search', class: "btn btn-primary wide" | |
13 | - | |
12 | + = search_field_tag :search, params[:search], placeholder: "Filter by name", class: "span3 search-text-input", id: "projects_search" | |
13 | + = submit_tag 'Search', class: "btn btn-primary wide" | |
14 | +%hr | |
14 | 15 | .public-projects |
15 | - %ul.bordered-list | |
16 | + %ul.bordered-list.top-list | |
16 | 17 | - @projects.each do |project| |
17 | 18 | %li |
18 | - .project-title | |
19 | - %i.icon-share.cgray | |
19 | + %h4 | |
20 | 20 | = link_to project_path(project) do |
21 | - %strong= project.name_with_namespace | |
21 | + = project.name_with_namespace | |
22 | 22 | .pull-right |
23 | 23 | %pre.public-clone git clone #{project.http_url_to_repo} |
24 | 24 | |
25 | 25 | - if project.description.present? |
26 | - %div.description | |
26 | + %p | |
27 | 27 | = project.description |
28 | + | |
29 | + .repo-info | |
30 | + - unless project.empty_repo? | |
31 | + = link_to pluralize(project.repository.round_commit_count, 'commit'), project_commits_path(project, project.default_branch) | |
32 | + · | |
33 | + = link_to pluralize(project.repository.branch_names.count, 'branch'), project_branches_path(project) | |
34 | + · | |
35 | + = link_to pluralize(project.repository.tag_names.count, 'tag'), project_tags_path(project) | |
36 | + - else | |
37 | + %i.icon-warning-sign | |
38 | + Empty repository | |
28 | 39 | - unless @projects.present? |
29 | 40 | %h3.nothing_here_message No public projects |
30 | 41 | ... | ... |
config/routes.rb
features/public/public_projects.feature
... | ... | @@ -9,11 +9,10 @@ Feature: Public Projects Feature |
9 | 9 | And I should not see project "Enterprise" |
10 | 10 | |
11 | 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 | |
12 | + When I visit project "Community" page | |
13 | + Then I should see project "Community" home page | |
15 | 14 | |
16 | 15 | Scenario: I visit an empty public project page |
17 | 16 | Given public empty project "Empty Public Project" |
18 | - When I visit empty public project page | |
19 | - Then I should see empty public project details | |
20 | 17 | \ No newline at end of file |
18 | + When I visit empty project page | |
19 | + Then I should see empty public project details | ... | ... |
features/steps/public/projects_feature.rb
... | ... | @@ -31,19 +31,28 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps |
31 | 31 | create :project, name: 'Empty Public Project', public: true |
32 | 32 | end |
33 | 33 | |
34 | - step 'I visit empty public project page' do | |
34 | + step 'I visit empty project page' do | |
35 | 35 | project = Project.find_by_name('Empty Public Project') |
36 | - visit public_project_path(project) | |
36 | + visit project_path(project) | |
37 | + end | |
38 | + | |
39 | + step 'I visit project "Community" page' do | |
40 | + project = Project.find_by_name('Community') | |
41 | + visit project_path(project) | |
37 | 42 | end |
38 | 43 | |
39 | 44 | step 'I should see empty public project details' do |
40 | - page.should have_content 'Empty Repository' | |
45 | + page.should have_content 'Git global setup' | |
41 | 46 | end |
42 | 47 | |
43 | 48 | step 'private project "Enterprise"' do |
44 | 49 | create :project, name: 'Enterprise' |
45 | 50 | end |
46 | 51 | |
52 | + step 'I should see project "Community" home page' do | |
53 | + page.should have_content 'Repo size is' | |
54 | + end | |
55 | + | |
47 | 56 | private |
48 | 57 | |
49 | 58 | def project | ... | ... |