Skip to content

Commit

Permalink
[spalenque] - #11362 - add opengraph metadata to every page
Browse files Browse the repository at this point in the history
  • Loading branch information
santipalenque committed Aug 8, 2016
1 parent d449af5 commit ba9ab80
Show file tree
Hide file tree
Showing 20 changed files with 82 additions and 51 deletions.
6 changes: 2 additions & 4 deletions coa/templates/COALandingPage.ss
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="globalsign-domain-verification" content="tWFOHNAA_WMHmHfBMq38uTgupHFugV_dZ2rqyRxNMx" />
<meta property="og:image" content="http://www.openstack.org/assets/coa/coa-og2.jpg" />
<meta property="og:title" content="Certified OpenStack Administrator" />
<meta property="og:url" content="http://www.openstack.org/coa" />
<meta property="og:description" content="OpenStack skills are in high demand. Certified OpenStack Administrator (COA) is the only professional certification offered by the OpenStack Foundation, designed to help companies identify top professionals and job seekers demonstrate their skills." />
$MetaTags(false)

<title>$Title &raquo; OpenStack Open Source Cloud Computing Software</title>

<% base_tag %>
Expand Down
2 changes: 2 additions & 0 deletions marketplace/templates/MarketPlacePage.ss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="globalsign-domain-verification" content="tWFOHNAA_WMHmHfBMq38uTgupHFugV_dZ2rqyRxNMx" />
$MetaTags(false)

<title>$Title &raquo; OpenStack Open Source Cloud Computing Software</title>
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://www.openstack.org/blog/feed/" />
<!-- Fonts -->
Expand Down
6 changes: 5 additions & 1 deletion openstack/_config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ File:

Injector:
TransactionManager:
factory: SapphireTransactionManagerFactory
factory: SapphireTransactionManagerFactory

Page:
extensions:
- 'PageOpenGraphObjectExtension'
18 changes: 16 additions & 2 deletions openstack/code/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ class Page extends SiteTree
private static $db = array(
'IncludeJquery' => 'Boolean',
'PageJavaScript' => 'Text',
'IncludeShadowBox' => 'Boolean'
'IncludeShadowBox' => 'Boolean',
'MetaTitle' => 'Varchar(255)',
);

private static $has_one = array();
private static $has_one = array(
'MetaImage' => 'BetterImage'
);

public function InPast($fieldname)
{
Expand All @@ -43,6 +46,11 @@ function getCMSFields()
$fields = parent::getCMSFields();


// metadata
$fields->fieldByName('Root.Main.Metadata')->push(new UploadField("MetaImage",$this->fieldLabel('MetaImage')));
$fields->fieldByName('Root.Main.Metadata')->push(new TextField("MetaTitle",$this->fieldLabel('MetaTitle')));


$fields->addFieldToTab('Root.Settings', new TextField ('PageCSS', 'Custom CSS File For This Page (must be in CSS directory)'));

$fields->addFieldToTab('Root.Settings', new CheckboxField ('IncludeJquery', 'Include JQuery In This Page'));
Expand Down Expand Up @@ -515,4 +523,10 @@ public function getNavigationMenu() {
$response->setBody($jsonp);
return $response;
}

public function MetaTags()
{
$tags = parent::MetaTags(false);
return $tags;
}
}
40 changes: 40 additions & 0 deletions openstack/code/PageOpenGraphObjectExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/**
* Copyright 2016 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

class PageOpenGraphObjectExtension extends OpenGraphObjectExtension
{
public static $default_image = '/themes/openstack/images/openstack-logo-full.png';

public function getOGImage()
{
if ($this->owner->hasField('MetaImage') && $this->owner->MetaImage()->Exists()) {
return $this->owner->MetaImage()->getURL();
} elseif ($this->owner->is_a('SummitPage') || $this->owner->is_a('IEntity')) {
return Director::absoluteURL('/summit/images/summit-logo.png');
} else {
return Director::absoluteURL(self::$default_image);
}
}

public function getOGTitle()
{
if($this->owner->hasField('MetaTitle')) {
$title = trim($this->owner->MetaTitle);
if(!empty($title)) return $title;
}

return $this->owner->Title." &raquo; OpenStack Open Source Cloud Computing Software";
}

}
2 changes: 0 additions & 2 deletions sample._ss_environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@
define('PARSE_REST_KEY','');
define('PARSE_MASTER_KEY','');

//SOCIAL MEDIA
define('FB_APP_ID','');
// COA
define('COA_FILE_API_BASE_URL','');
define('COA_FILE_API_BASE_USER','');
Expand Down
2 changes: 2 additions & 0 deletions software/templates/SoftwareHomePage.ss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="globalsign-domain-verification" content="tWFOHNAA_WMHmHfBMq38uTgupHFugV_dZ2rqyRxNMx" />
$MetaTags(false)

<title>$Title &raquo; OpenStack Open Source Cloud Computing Software</title>

<% base_tag %>
Expand Down
2 changes: 2 additions & 0 deletions software/templates/SoftwareSubPage.ss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="globalsign-domain-verification" content="tWFOHNAA_WMHmHfBMq38uTgupHFugV_dZ2rqyRxNMx" />
$MetaTags(false)

<title>$Title &raquo; OpenStack Open Source Cloud Computing Software</title>

<% base_tag %>
Expand Down
2 changes: 2 additions & 0 deletions summit-voting-app/templates/PresentationVotingPage.ss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
$MetaTags(false)

<title>Vote For $Parent.Title Summit Presentations | OpenStack Open Source Cloud Computing Software</title>
<!-- Bootstrap Core CSS -->
<% require css("themes/openstack/css/bootstrap3.css") %>
Expand Down
3 changes: 0 additions & 3 deletions summit/_config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ SummitLocationImage:
SummitVenueFloor:
extensions:
- SummitEntity
SummitPage:
extensions:
- SummitPageOpenGraphObjectExtension
Injector:
RSVPTextBoxUIBuilder:
class: RSVPTextBoxQuestionTemplateUIBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ public function getLink() {

}

public function Link() {
return $this->getLink();
}

public function getAvgRate() {
return $this->AvgFeedbackRate;
}
Expand Down
3 changes: 1 addition & 2 deletions summit/code/pages/SummitAppSchedPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ public function ViewEvent(SS_HTTPRequest $request)
array('SummitAppEventPage', 'SummitPage', 'Page'),
array(
'Event' => $event,
'FB_APP_ID' => FB_APP_ID,
'goback' => $goback,
'Token' => $token
));
Expand Down Expand Up @@ -538,7 +537,7 @@ public function MetaTags()
if(!is_null($entity)){
return $entity->MetaTags();
}
$tags = parent::MetaTags(false);
$tags = parent::MetaTags();
// IOS
$tags .= AppLinkIOSMetadataBuilder::buildAppLinksMetaTags($tags, "schedule");
// Android
Expand Down
2 changes: 1 addition & 1 deletion summit/code/pages/SummitEntityOpenGraphObjectExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static function buildAppLinksMetaTags(&$tags, $url_path){
}
}

class SummitEntityOpenGraphObjectExtension extends SummitPageOpenGraphObjectExtension
class SummitEntityOpenGraphObjectExtension extends PageOpenGraphObjectExtension
{
public function MetaTags(&$tags)
{
Expand Down
2 changes: 1 addition & 1 deletion summit/code/pages/SummitPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public function MainNavClass(){

public function MetaTags()
{
$tags = parent::MetaTags(false);
$tags = parent::MetaTags();
return $tags;
}

Expand Down
23 changes: 0 additions & 23 deletions summit/code/pages/SummitPageOpenGraphObjectExtension.php

This file was deleted.

7 changes: 0 additions & 7 deletions summit/javascript/schedule/share-buttons.tag
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@
<share-buttons>

<div class="facebook share_icon" onclick={shareFacebook}>
<meta property="og:title" content="{this.share_info.title}" />
<meta property="og:site_name" content="Openstack"/>
<meta property="og:description" content="{this.share_info.description}" />
<meta property="og:type" content="article" />
<meta property="og:image" content="{this.share_info.image}" />
<meta property="og:url" content="{this.share_info.url}" />
<meta property="fb:app_id" content="{this.share_info.fb_app_id}" />
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-facebook fa-stack-1x fa-inverse"></i>
Expand Down
1 change: 1 addition & 0 deletions summit/templates/Includes/Head.ss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
$MetaTags()

<title>OpenStack Summit | $Title</title>

Expand Down
5 changes: 1 addition & 4 deletions summit/templates/Layout/SummitAppEventPage.ss
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,7 @@
{
event_id: {$Event.ID},
url: "{$AbsoluteLink}events/{$Event.ID}",
title : "{$Event.Title.JS}",
description: "{$Event.ShortDescription().JS}",
image: "/themes/openstack/images/openstack-logo-full.png",
fb_app_id : {$FB_APP_ID},
fb_app_id : {$SiteConfig.OGApplicationID},
token: "{$Token}"
};
</script>
Expand Down
1 change: 0 additions & 1 deletion summit/templates/SummitPage.ss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<head>
<% include Head %>
<% include Analytics %>
$MetaTags
$FBTrackingCode
$TwitterTrackingCode
<link rel="stylesheet" type="text/css" href="/themes/openstack/static/css/tooltipster.css" />
Expand Down
2 changes: 2 additions & 0 deletions themes/openstack/templates/Page.ss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<meta name="globalsign-domain-verification" content="tWFOHNAA_WMHmHfBMq38uTgupHFugV_dZ2rqyRxNMx" />
<title>$Title &raquo; OpenStack Open Source Cloud Computing Software</title>

$MetaTags(false)

<% base_tag %>

<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://www.openstack.org/blog/feed/" />
Expand Down

0 comments on commit ba9ab80

Please sign in to comment.