Skip to content

Commit

Permalink
[smarcet] - #10925
Browse files Browse the repository at this point in the history
* integration with OpenGraph SS Module
* added app links metadata on event speakers
  • Loading branch information
smarcet committed Aug 1, 2016
1 parent 571e894 commit 8e86dd6
Show file tree
Hide file tree
Showing 15 changed files with 233 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,5 @@ keys.tags.pub
trait-loader/
gridfieldextensions/
fluent/
*.bundle.js
*.bundle.js
opengraph/
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"symfony/yaml": "~2.1|~3.0",
"phpoffice/phpexcel": "dev-master",
"tractorcow/silverstripe-fluent": "dev-patch/default-route",
"google/apiclient": "1.*"
"google/apiclient": "1.*",
"tractorcow/silverstripe-opengraph": "3.1.*@dev"

},
"require-dev": {
Expand All @@ -53,7 +54,8 @@
"html2pdf_v4.03",
"summit/code/infrastructure/traits",
"openstack/code/utils/apis/traits",
"googlemaps/code/traits"
"googlemaps/code/traits",
"summit/code/pages/summit_entities/traits"
]
},
"config": {
Expand Down
8 changes: 8 additions & 0 deletions sample._ss_environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@
// OAUTH 2.0 Client ID to use Google Calendar API
define('GAPI_CLIENT','');

// APP LINKS
// http://applinks.org/documentation/
define('APP_LINKS_IOS_APP_STORE_ID','');
define('APP_LINKS_IOS_APP_NAME','');
define('APP_LINKS_IOS_APP_CUSTOM_SCHEMA','');
define('APP_LINKS_ANDROID_PACKAGE','');
define('APP_LINKS_ANDROID_APP_NAME','');
define('APP_LINKS_ANDROID_APP_CUSTOM_SCHEMA','');

global $_FILE_TO_URL_MAPPING;
$_FILE_TO_URL_MAPPING[''] = '';
Expand Down
9 changes: 8 additions & 1 deletion summit/_config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ PresentationSpeaker:
extensions:
- JSONable
- SummitEntity
- SummitSpeakerOpenGraphObjectExtension
PresentationTopic:
extensions:
- JSONable
Expand All @@ -44,6 +45,7 @@ Presentation:
- Sluggable
- JSONable
- SummitEntity
- SummitEventOpenGraphObjectExtension
status_options:
- Received
- In community voting
Expand All @@ -60,6 +62,7 @@ SummitAttendee:
SummitEvent:
extensions:
- SummitEntity
- SummitEventOpenGraphObjectExtension
SummitEventFeedback:
extensions:
- SummitEntity
Expand All @@ -72,6 +75,7 @@ PresentationMaterial:
SummitAbstractLocation:
extensions:
- SummitEntity
- SummitLocationOpenGraphObjectExtension
SummitType:
extensions:
- SummitEntity
Expand All @@ -90,6 +94,9 @@ SummitLocationImage:
SummitVenueFloor:
extensions:
- SummitEntity
SummitPage:
extensions:
- SummitPageOpenGraphObjectExtension
Injector:
RSVPTextBoxUIBuilder:
class: RSVPTextBoxQuestionTemplateUIBuilder
Expand All @@ -110,4 +117,4 @@ Injector:
RSVPComboBoxUIBuilder:
class: RSVPDropDownQuestionTemplateUIBuilder
RSVPLiteralUIBuilder:
class: RSVPLiteralQuestionTemplateUIBuilder
class: RSVPLiteralQuestionTemplateUIBuilder
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
**/
class SummitEvent extends DataObject implements ISummitEvent
{
use SummitEntityMetaTagGenerator;

private static $db = array
(
'Title' => 'Text',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class PresentationSpeaker extends DataObject
implements IPresentationSpeaker
{

use SummitEntityMetaTagGenerator;

private static $db = [
'FirstName' => 'Varchar(100)',
'LastName' => 'Varchar(100)',
Expand Down
47 changes: 36 additions & 11 deletions summit/code/pages/SummitAppSchedPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,9 @@ public function init()

}

public function ViewEvent()
public function ViewEvent(SS_HTTPRequest $request)
{
$event_id = intval($this->request->param('EVENT_ID'));
$this->event_id = $event_id;
$event = $this->event_repository->getById($event_id);
$event = $this->getSummitEntity($request);
$goback = $this->getRequest()->postVar('goback') ? $this->getRequest()->postVar('goback') : '';

if (is_null($event) || !$event->isPublished()) {
Expand All @@ -152,10 +150,10 @@ public function ViewEvent()
return $this->renderWith(
array('SummitAppEventPage', 'SummitPage', 'Page'),
array(
'Event' => $event,
'Event' => $event,
'FB_APP_ID' => FB_APP_ID,
'goback' => $goback,
'Token' => $token
'goback' => $goback,
'Token' => $token
));
}

Expand Down Expand Up @@ -401,10 +399,28 @@ public function ExportFullSchedule()
}
}

public function ViewSpeakerProfile()
/**
* @param SS_HTTPRequest $request
* @return IEntity|null
*/
private function getSummitEntity(SS_HTTPRequest $request){
$speaker_id = intval($request->param('SPEAKER_ID'));
$event_id = intval($request->param('EVENT_ID'));

if($event_id > 0) {
$this->event_id = $event_id;
return $this->event_repository->getById($event_id);
}
if($speaker_id > 0){
return $this->speaker_repository->getById($speaker_id);
}

return null;
}

public function ViewSpeakerProfile(SS_HTTPRequest $request)
{
$speaker_id = intval($this->request->param('SPEAKER_ID'));
$speaker = $this->speaker_repository->getById($speaker_id);
$speaker = $this->getSummitEntity($request);

if (!isset($speaker)) {
return $this->httpError(404, 'Sorry that speaker could not be found');
Expand All @@ -417,7 +433,7 @@ public function ViewSpeakerProfile()
array
(
'Speaker' => $speaker,
'Summit' => $this->Summit(),
'Summit' => $this->Summit(),
)
);
}
Expand Down Expand Up @@ -476,4 +492,13 @@ public function getPresentationLevels()
{
return Presentation::getLevels();
}

public function MetaTags()
{
$entity = $this->getSummitEntity(Controller::curr()->getRequest());
if(!is_null($entity)){
return $entity->MetaTags();
}
return parent::MetaTags(false);
}
}
40 changes: 40 additions & 0 deletions summit/code/pages/SummitEntityOpenGraphObjectExtension.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 SummitEntityOpenGraphObjectExtension extends SummitPageOpenGraphObjectExtension
{
public function MetaTags(&$tags)
{
parent::MetaTags($tags);
$this->buildAppLinksMetaTags($tags);
}

private function buildAppLinksMetaTags(&$tags){
// IOS
$tags .= sprintf('<meta property="al:ios:app_store_id" content="%s" />', APP_LINKS_IOS_APP_STORE_ID);
$tags .= sprintf('<meta property="al:ios:app_name" content="%s" />', APP_LINKS_IOS_APP_NAME);
$tags .= sprintf('<meta property="al:ios:url" content="%s://%s/%s" />', APP_LINKS_IOS_APP_CUSTOM_SCHEMA, $this->getEntityPath(), $this->owner->ID);
// Android
$tags .= sprintf('<meta property="al:android:package" content="%s" />', APP_LINKS_ANDROID_PACKAGE);
$tags .= sprintf('<meta property="al:android:app_name" content="%s" />', APP_LINKS_ANDROID_APP_NAME);
$tags .= sprintf('<meta property="al:android:url" content="%s://%s/%s" />', APP_LINKS_ANDROID_APP_CUSTOM_SCHEMA, $this->getEntityPath(), $this->owner->ID);
}

protected function getEntityPath(){
//to implement on child class
return "";
}

}
30 changes: 30 additions & 0 deletions summit/code/pages/SummitEventOpenGraphObjectExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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 SummitEventOpenGraphObjectExtension extends SummitEntityOpenGraphObjectExtension
{
public function AbsoluteLink()
{
return Director::absoluteURL($this->owner->link());
}

public function getOGDescription()
{
return $this->owner->getDescription();
}

protected function getEntityPath(){
return "events";
}
}
21 changes: 21 additions & 0 deletions summit/code/pages/SummitLocationOpenGraphObjectExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?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 SummitLocationOpenGraphObjectExtension extends SummitEntityOpenGraphObjectExtension
{
protected function getEntityPath(){
return "venues";
}
}
7 changes: 7 additions & 0 deletions summit/code/pages/SummitPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,11 @@ public function MainNavClass(){
return 'link';
}
}

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

}
23 changes: 23 additions & 0 deletions summit/code/pages/SummitPageOpenGraphObjectExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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 SummitPageOpenGraphObjectExtension extends OpenGraphObjectExtension
{
public static $default_image = '/summit/images/summit-logo.png';

public function getOGImage()
{
return Director::absoluteURL(self::$default_image);
}
}
25 changes: 25 additions & 0 deletions summit/code/pages/SummitSpeakerOpenGraphObjectExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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 SummitSpeakerOpenGraphObjectExtension extends SummitEntityOpenGraphObjectExtension
{
protected function getEntityPath(){
return "speakers";
}

public function getOGImage()
{
return $this->owner->ProfilePhoto();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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.
**/

trait SummitEntityMetaTagGenerator
{
public function MetaTags()
{
$tags = "";
$this->extend('MetaTags', $tags);
return $tags;
}
}
3 changes: 2 additions & 1 deletion summit/templates/SummitPage.ss
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en" $OGNS>

<head>
<% include Head %>
<% include Analytics %>
$MetaTags
$FBTrackingCode
$TwitterTrackingCode
<link rel="stylesheet" type="text/css" href="/themes/openstack/static/css/tooltipster.css" />
Expand Down

0 comments on commit 8e86dd6

Please sign in to comment.