From 5fb1b9ffe359fd6c13dfb427aa23c985dff87fe1 Mon Sep 17 00:00:00 2001
From: gitlabhq <m@gitlabhq.com>
Date: Wed, 2 Nov 2011 11:21:17 -0400
Subject: [PATCH] view refactoring

---
 app/controllers/admin/mailer_controller.rb    |  1 +
 app/controllers/admin/projects_controller.rb  |  1 +
 .../admin/team_members_controller.rb          |  1 +
 app/controllers/admin/users_controller.rb     |  1 +
 app/controllers/keys_controller.rb            |  1 +
 app/controllers/profile_controller.rb         |  1 +
 app/helpers/application_helper.rb             |  2 ++
 app/views/admin/_top_menu.html.haml           |  6 ----
 app/views/admin/projects/index.html.haml      |  2 +-
 app/views/admin/team_members/index.html.haml  |  2 +-
 app/views/admin/users/index.html.haml         |  2 +-
 app/views/layouts/admin.html.haml             | 27 +++++++++++++++++
 app/views/layouts/application.html.haml       |  6 ----
 app/views/layouts/profile.html.haml           | 29 +++++++++++++++++++
 app/views/profile/_top_menu.html.haml         |  5 ----
 15 files changed, 67 insertions(+), 20 deletions(-)
 delete mode 100644 app/views/admin/_top_menu.html.haml
 create mode 100644 app/views/layouts/admin.html.haml
 create mode 100644 app/views/layouts/profile.html.haml
 delete mode 100644 app/views/profile/_top_menu.html.haml

diff --git a/app/controllers/admin/mailer_controller.rb b/app/controllers/admin/mailer_controller.rb
index d2fbbcd4968..458ad277e12 100644
--- a/app/controllers/admin/mailer_controller.rb
+++ b/app/controllers/admin/mailer_controller.rb
@@ -1,4 +1,5 @@
 class Admin::MailerController < ApplicationController
+  layout "admin"
   before_filter :authenticate_user!
   before_filter :authenticate_admin!
 
diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb
index a71136398fa..21b25fc0c50 100644
--- a/app/controllers/admin/projects_controller.rb
+++ b/app/controllers/admin/projects_controller.rb
@@ -1,4 +1,5 @@
 class Admin::ProjectsController < ApplicationController
+  layout "admin"
   before_filter :authenticate_user!
   before_filter :authenticate_admin!
 
diff --git a/app/controllers/admin/team_members_controller.rb b/app/controllers/admin/team_members_controller.rb
index 8ae32bc6613..d04d32a63fe 100644
--- a/app/controllers/admin/team_members_controller.rb
+++ b/app/controllers/admin/team_members_controller.rb
@@ -1,4 +1,5 @@
 class Admin::TeamMembersController < ApplicationController
+  layout "admin"
   before_filter :authenticate_user!
   before_filter :authenticate_admin!
 
diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb
index 6560576581c..1c008d90f7d 100644
--- a/app/controllers/admin/users_controller.rb
+++ b/app/controllers/admin/users_controller.rb
@@ -1,4 +1,5 @@
 class Admin::UsersController < ApplicationController
+  layout "admin"
   before_filter :authenticate_user!
   before_filter :authenticate_admin!
 
diff --git a/app/controllers/keys_controller.rb b/app/controllers/keys_controller.rb
index d3c93b5fff6..84f47675936 100644
--- a/app/controllers/keys_controller.rb
+++ b/app/controllers/keys_controller.rb
@@ -1,4 +1,5 @@
 class KeysController < ApplicationController
+  layout "profile"
   respond_to :js
 
   def index
diff --git a/app/controllers/profile_controller.rb b/app/controllers/profile_controller.rb
index a0078f0e0a3..2e58f3e1d6d 100644
--- a/app/controllers/profile_controller.rb
+++ b/app/controllers/profile_controller.rb
@@ -1,4 +1,5 @@
 class ProfileController < ApplicationController
+  layout "profile"
   def show
     @user = current_user
   end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index fbca5ea5d66..ef92953dab3 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -28,6 +28,8 @@ module ApplicationHelper
     else
       "Never"
     end
+  rescue 
+    "Never"
   end
 
   def markdown(text)
diff --git a/app/views/admin/_top_menu.html.haml b/app/views/admin/_top_menu.html.haml
deleted file mode 100644
index d63caa7e8ee..00000000000
--- a/app/views/admin/_top_menu.html.haml
+++ /dev/null
@@ -1,6 +0,0 @@
-%div.top_project_menu
-  %span= link_to "Users", admin_users_path, :style => "width:50px;", :class => controller.controller_name == "users" ? "current" : nil
-  %span= link_to "Projects", admin_projects_path, :style => "width:50px;", :class => controller.controller_name == "projects" ? "current" : nil
-  %span= link_to "Teams", admin_team_members_path, :style => "width:50px;", :class => controller.controller_name == "team_members" ? "current" : nil
-  %span= link_to "Emails", admin_emails_path, :style => "width:50px;", :class => controller.controller_name == "mailer" ? "current" : nil
-
diff --git a/app/views/admin/projects/index.html.haml b/app/views/admin/projects/index.html.haml
index 327561dea99..c529b82ea44 100644
--- a/app/views/admin/projects/index.html.haml
+++ b/app/views/admin/projects/index.html.haml
@@ -1,5 +1,5 @@
 %table
-  %tr
+  %thead
     %th Name
     %th Code
     %th Path
diff --git a/app/views/admin/team_members/index.html.haml b/app/views/admin/team_members/index.html.haml
index 5aa4b597878..33f58fa50b1 100644
--- a/app/views/admin/team_members/index.html.haml
+++ b/app/views/admin/team_members/index.html.haml
@@ -1,7 +1,7 @@
 - @admin_team_members.group_by(&:project).sort.each do |project, members|
   %h3= link_to project.name, [:admin, project]
   %table
-    %tr
+    %thead
       %th Name
       %th Email
       %th Read
diff --git a/app/views/admin/users/index.html.haml b/app/views/admin/users/index.html.haml
index 3b5aa3996bb..cbec1060962 100644
--- a/app/views/admin/users/index.html.haml
+++ b/app/views/admin/users/index.html.haml
@@ -1,5 +1,5 @@
 %table
-  %tr
+  %thead
     %th Admin
     %th Name
     %th Email
diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml
new file mode 100644
index 00000000000..d3de20dabd9
--- /dev/null
+++ b/app/views/layouts/admin.html.haml
@@ -0,0 +1,27 @@
+!!!
+%html
+  %head
+    %title
+      GitLab #{" - #{@project.name}" if @project && !@project.new_record?}
+    = stylesheet_link_tag    "application"
+    = javascript_include_tag "application"
+    = csrf_meta_tags
+    %link{:href => "/assets/favicon.png", :rel => "icon", :type => "image/png"}/
+    = javascript_tag do
+      REQ_URI = "#{request.env["REQUEST_URI"]}";
+      REQ_REFFER = "#{request.env["HTTP_REFERER"]}";
+  %body{ :class => content_for?(:body_class) ? yield(:body_class) : 'project-page', :id => yield(:boyd_id)}
+    #container
+      = render :partial => "layouts/flash"
+      = render :partial => "layouts/head_panel"
+      .project-container
+        .project-sidebar
+          .fixed
+            %aside
+              = link_to "Users", admin_users_path, :class => controller.controller_name == "users" ? "current" : nil
+              = link_to "Projects", admin_projects_path, :class => controller.controller_name == "projects" ? "current" : nil
+              = link_to "Teams", admin_team_members_path, :class => controller.controller_name == "team_members" ? "current" : nil
+              = link_to "Emails", admin_emails_path, :class => controller.controller_name == "mailer" ? "current" : nil
+
+        .project-content
+          = yield
diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml
index b525df4493e..8cc6325340b 100644
--- a/app/views/layouts/application.html.haml
+++ b/app/views/layouts/application.html.haml
@@ -19,11 +19,5 @@
       = render :partial => "layouts/flash"
       = render :partial => "layouts/head_panel"
       %div{ :id => "main", :role => "main", :class => "container_4" }
-        - if @project && !@project.new_record?
-          .top_bar.container= render :partial => "projects/top_menu" 
-        - if ["keys", "profile"].include?(controller.controller_name)
-          .top_bar.container= render :partial => "profile/top_menu"
-        - if admin_namespace?
-          .top_bar.container= render :partial => "admin/top_menu"
         = render :partial => "layouts/page_title"
         = yield
diff --git a/app/views/layouts/profile.html.haml b/app/views/layouts/profile.html.haml
new file mode 100644
index 00000000000..007e03cf5d8
--- /dev/null
+++ b/app/views/layouts/profile.html.haml
@@ -0,0 +1,29 @@
+!!!
+%html
+  %head
+    %title
+      GitLab #{" - #{@project.name}" if @project && !@project.new_record?}
+    = stylesheet_link_tag    "application"
+    = javascript_include_tag "application"
+    = csrf_meta_tags
+    %link{:href => "/assets/favicon.png", :rel => "icon", :type => "image/png"}/
+    = javascript_tag do
+      REQ_URI = "#{request.env["REQUEST_URI"]}";
+      REQ_REFFER = "#{request.env["HTTP_REFERER"]}";
+  %body{ :class => content_for?(:body_class) ? yield(:body_class) : 'project-page', :id => yield(:boyd_id)}
+    #container
+      = render :partial => "layouts/flash"
+      = render :partial => "layouts/head_panel"
+      .project-container
+        .project-sidebar
+          .fixed
+            %aside
+              = link_to "Profile", profile_path, :class => current_page?(:controller => "profile", :action => :show) ? "current" : nil
+              = link_to "Password", profile_password_path,  :class => current_page?(:controller => "profile", :action => :password) ? "current" : nil
+              = link_to keys_path,  :class => controller.controller_name == "keys" ? "current" : nil do 
+                Keys
+                - unless current_user.keys.empty?
+                  %span{ :class => "number" }= current_user.keys.count
+
+        .project-content
+          = yield
diff --git a/app/views/profile/_top_menu.html.haml b/app/views/profile/_top_menu.html.haml
deleted file mode 100644
index 6bf3b09f499..00000000000
--- a/app/views/profile/_top_menu.html.haml
+++ /dev/null
@@ -1,5 +0,0 @@
-%div.top_project_menu
-  %span= link_to "Profile", profile_path, :class => current_page?(:controller => "profile", :action => :show) ? "current" : nil
-  %span= link_to "Password", profile_password_path, :style => "width:70px;", :class => current_page?(:controller => "profile", :action => :password) ? "current" : nil
-  %span= link_to "Keys", keys_path,  :class => controller.controller_name == "keys" ? "current" : nil
-
-- 
GitLab