Commit 122acb2254c94823bd7b7b64aa1bd953df5fdf66

Authored by Dmitriy Zaporozhets
1 parent 4c6224aa

fix unauth for public

app/controllers/public/projects_controller.rb
... ... @@ -6,6 +6,6 @@ class Public::ProjectsController < ApplicationController
6 6 layout 'public'
7 7  
8 8 def index
9   - @projects = Project.where(public: true)
  9 + @projects = Project.public
10 10 end
11 11 end
... ...
app/models/project.rb
... ... @@ -81,6 +81,7 @@ class Project < ActiveRecord::Base
81 81 scope :sorted_by_activity, ->() { order("(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC") }
82 82 scope :personal, ->(user) { where(namespace_id: user.namespace_id) }
83 83 scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) }
  84 + scope :public, where(public: true)
84 85  
85 86 class << self
86 87 def active
... ...
app/views/layouts/_head.html.haml
... ... @@ -6,12 +6,14 @@
6 6 = favicon_link_tag 'favicon.ico'
7 7 = stylesheet_link_tag "application"
8 8 = javascript_include_tag "application"
9   - -# Atom feed
10   - - if controller_name == 'projects' && action_name == 'index'
11   - = auto_discovery_link_tag :atom, projects_url(:atom, private_token: current_user.private_token), title: "Dashboard feed"
12   - - if @project && !@project.new_record?
13   - - if current_controller?(:tree, :commits)
14   - = auto_discovery_link_tag(:atom, project_commits_url(@project, @ref, format: :atom, private_token: current_user.private_token), title: "Recent commits to #{@project.name}:#{@ref}")
15   - - if current_controller?(:issues)
16   - = auto_discovery_link_tag(:atom, project_issues_url(@project, :atom, private_token: current_user.private_token), title: "#{@project.name} issues")
17 9 = csrf_meta_tags
  10 +
  11 + -# Atom feed
  12 + - if current_user
  13 + - if controller_name == 'projects' && action_name == 'index'
  14 + = auto_discovery_link_tag :atom, projects_url(:atom, private_token: current_user.private_token), title: "Dashboard feed"
  15 + - if @project && !@project.new_record?
  16 + - if current_controller?(:tree, :commits)
  17 + = auto_discovery_link_tag(:atom, project_commits_url(@project, @ref, format: :atom, private_token: current_user.private_token), title: "Recent commits to #{@project.name}:#{@ref}")
  18 + - if current_controller?(:issues)
  19 + = auto_discovery_link_tag(:atom, project_issues_url(@project, :atom, private_token: current_user.private_token), title: "#{@project.name} issues")
... ...
app/views/layouts/public.html.haml
1 1 !!! 5
2 2 %html{ lang: "en"}
3   - = render "layouts/head", title: "Error"
  3 + = render "layouts/head", title: "Public Area"
4 4 %body{class: "#{app_theme} application"}
5 5 %header.navbar.navbar-static-top.navbar-gitlab
6 6 .navbar-inner
7 7 .container
8 8 %div.app_logo
9 9 %span.separator
10   - = link_to public_root_path, class: "home" do
  10 + = link_to root_path, class: "home" do
11 11 %h1 GITLAB
12 12 %span.separator
13   - %h1.project_name Public
  13 + %h1.project_name Public Area
14 14 .container
15 15 .content
16 16 .prepend-top-20
... ...
app/views/public/projects/index.html.haml
... ... @@ -3,7 +3,7 @@
3 3 %small Read-Only Access
4 4 %hr
5 5  
6   -%ul.well-list
  6 +%ul.unstyled
7 7 - @projects.each do |project|
8 8 %li.clearfix
9 9 %h5
... ...