From bd21e3d7319dce4600881f7f8677b28f3f55cc5e Mon Sep 17 00:00:00 2001
From: Douwe Maan <douwe@gitlab.com>
Date: Fri, 25 Dec 2015 16:41:02 +0100
Subject: [PATCH] Add Open Graph data for group, project and commit.

---
 app/helpers/page_layout_helper.rb        |  2 ++
 app/views/groups/show.html.haml          |  2 ++
 app/views/layouts/_head.html.haml        | 10 +++++-----
 app/views/projects/commit/show.html.haml |  4 +++-
 app/views/projects/show.html.haml        |  2 ++
 5 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/app/helpers/page_layout_helper.rb b/app/helpers/page_layout_helper.rb
index 791cb9e50bd..b84644d6996 100644
--- a/app/helpers/page_layout_helper.rb
+++ b/app/helpers/page_layout_helper.rb
@@ -53,6 +53,8 @@ module PageLayoutHelper
       @project.avatar_url || default
     elsif @user
       avatar_icon(@user)
+    elsif @group
+      @group.avatar_url || default
     else
       default
     end
diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml
index c2c7c581b3e..8179cdfac80 100644
--- a/app/views/groups/show.html.haml
+++ b/app/views/groups/show.html.haml
@@ -1,3 +1,5 @@
+- page_description @group.description
+
 - unless can?(current_user, :read_group, @group)
   - @disable_search_panel = true
 
diff --git a/app/views/layouts/_head.html.haml b/app/views/layouts/_head.html.haml
index 2e0bd2007a3..2e9a34a8807 100644
--- a/app/views/layouts/_head.html.haml
+++ b/app/views/layouts/_head.html.haml
@@ -1,13 +1,11 @@
+- site_name = "GitLab"
 %head{prefix: "og: http://ogp.me/ns#"}
   %meta{charset: "utf-8"}
   %meta{'http-equiv' => 'X-UA-Compatible', content: 'IE=edge'}
-  %meta{name: 'referrer', content: 'origin-when-cross-origin'}
-
-  %meta{name: "description", content: page_description}
 
   -# Open Graph - http://ogp.me/
   %meta{property: 'og:type',        content: "object"}
-  %meta{property: 'og:site_name',   content: "GitLab"}
+  %meta{property: 'og:site_name',   content: site_name}
   %meta{property: 'og:title',       content: page_title}
   %meta{property: 'og:description', content: page_description}
   %meta{property: 'og:image',       content: page_image}
@@ -20,8 +18,9 @@
   %meta{property: 'twitter:image',        content: page_image}
   = page_card_meta_tags
 
-  - page_title "GitLab"
+  - page_title site_name
   %title= page_title
+  %meta{name: "description", content: page_description}
 
   = favicon_link_tag 'favicon.ico'
 
@@ -34,6 +33,7 @@
 
   = include_gon
 
+  %meta{name: 'referrer', content: 'origin-when-cross-origin'}
   %meta{name: 'viewport', content: 'width=device-width, initial-scale=1, maximum-scale=1'}
   %meta{name: 'theme-color', content: '#474D57'}
 
diff --git a/app/views/projects/commit/show.html.haml b/app/views/projects/commit/show.html.haml
index 069b8b1f169..58aa45e8d2c 100644
--- a/app/views/projects/commit/show.html.haml
+++ b/app/views/projects/commit/show.html.haml
@@ -1,4 +1,6 @@
-- page_title "#{@commit.title} (#{@commit.short_id})", "Commits"
+- page_title        "#{@commit.title} (#{@commit.short_id})", "Commits"
+- page_description  @commit.description
+
 = render "projects/commits/header_title"
 = render "commit_box"
 - if @ci_commit
diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml
index 7466a098e24..74ce005eaa2 100644
--- a/app/views/projects/show.html.haml
+++ b/app/views/projects/show.html.haml
@@ -1,3 +1,5 @@
+- page_description @project.description
+
 = content_for :meta_tags do
   - if current_user
     = auto_discovery_link_tag(:atom, namespace_project_path(@project.namespace, @project, format: :atom, private_token: current_user.private_token), title: "#{@project.name} activity")
-- 
GitLab