Skip to content

Commit

Permalink
[spalenque] - #12049 * videos page add twitter cards and fix links le…
Browse files Browse the repository at this point in the history
…gacy
  • Loading branch information
santipalenque committed Nov 16, 2016
1 parent 987d269 commit 0cd5dab
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 4 deletions.
4 changes: 4 additions & 0 deletions openstack/_config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ File:
Injector:
TransactionManager:
factory: SapphireTransactionManagerFactory

Page:
extensions:
- 'PageOpenGraphObjectExtension'
41 changes: 41 additions & 0 deletions openstack/code/extensions/PageOpenGraphObjectExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?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.
**/


final class TwitterCardMetadataBuilder
{
public static function buildTwitterCardMetaTags(&$tags, $object){
// IOS
$tags .= '<meta name="twitter:card" content="summary" />'.PHP_EOL;
$tags .= sprintf('<meta name="twitter:site" content="%s" />', OPENSTACK_TWITTER_ACCOUNT).PHP_EOL;
$tags .= sprintf('<meta name="twitter:title" content="%s" />', $object->getOGTitle()).PHP_EOL;
$tags .= sprintf('<meta name="twitter:description" content="%s" />', $object->getOGDescription()).PHP_EOL;
$tags .= sprintf('<meta name="twitter:image" content="%s" />', $object->getOGImage()).PHP_EOL;
}
}

class PageOpenGraphObjectExtension extends OpenGraphObjectExtension
{
public function MetaTags(&$tags)
{
parent::MetaTags($tags);
$this->buildAppLinksMetaTags($tags);
}

private function buildAppLinksMetaTags(&$tags){

TwitterCardMetadataBuilder::buildTwitterCardMetaTags($tags, $this->owner);
}

}
2 changes: 2 additions & 0 deletions sample._ss_environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@

$APP_LINKS_ANDROID_FILE_CONFIG[APP_LINKS_ANDROID_PACKAGE] = [''];

define('OPENSTACK_TWITTER_ACCOUNT', '');

global $_FILE_TO_URL_MAPPING;
$_FILE_TO_URL_MAPPING[''] = '';

8 changes: 8 additions & 0 deletions summit-video-app/code/SummitVideoApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ class SummitVideoApp_Controller extends Page_Controller
'$Group/$ID' => 'handleIndex'
];

/*
* 'api/video/$Type' => 'handleVideo',
- 'api/videos' => 'handleVideos',
- 'api/summits' => 'handleSummits',
- 'api/speakers' => 'handleSpeakers',
'$Page/$Action/$ID' => 'handleIndex'
*/


/**
* @var array
Expand Down
9 changes: 8 additions & 1 deletion summit-video-app/code/SummitVideoAppBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ public function getVideos($params = [])

switch ($group) {
case 'summit':
$summit = Summit::get()->filter('Slug', $criteria)->first();

// legacy urls like /videos/summits/show/6
if (is_numeric($criteria)) {
$summit = Summit::get()->byID($criteria);
} else {
$summit = Summit::get()->filter('Slug', $criteria)->first();
}

if ($summit) {
$videos = $videos
->innerJoin('SummitEvent', 'SummitEvent.ID = PresentationMaterial.PresentationID')
Expand Down
8 changes: 7 additions & 1 deletion summit-video-app/production/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
/******/ }

/******/ var hotApplyOnUpdate = true;
/******/ var hotCurrentHash = "29778d768dfbc57dc68c"; // eslint-disable-line no-unused-vars
/******/ var hotCurrentHash = "09912ea63e2e93f3b8ac"; // eslint-disable-line no-unused-vars
/******/ var hotCurrentModuleData = {};
/******/ var hotCurrentParents = []; // eslint-disable-line no-unused-vars

Expand Down Expand Up @@ -42388,9 +42388,11 @@
{ path: baseURL, component: _componentsPagesApp2['default'] },
_react2['default'].createElement(_reactRouter.IndexRoute, { component: _componentsPagesAllVideos2['default'] }),
_react2['default'].createElement(_reactRouter.Route, { path: 'summits', component: _componentsPagesSummits2['default'] }),
_react2['default'].createElement(_reactRouter.Route, { path: 'summits/show/:slug', component: _componentsPagesSummitDetail2['default'] }),
_react2['default'].createElement(_reactRouter.Route, { path: 'summits/:slug', component: _componentsPagesSummitDetail2['default'] }),
_react2['default'].createElement(_reactRouter.Route, { path: 'speakers', component: _componentsPagesSpeakers2['default'] }),
_react2['default'].createElement(_reactRouter.Route, { path: 'speakers/:id/:slug', component: _componentsPagesSpeakerDetail2['default'] }),
_react2['default'].createElement(_reactRouter.Route, { path: 'speakers/show/:id', component: _componentsPagesSpeakerDetail2['default'] }),
_react2['default'].createElement(_reactRouter.Route, { path: 'featured', component: _componentsPagesFeatured2['default'] }),
_react2['default'].createElement(_reactRouter.Route, { path: 'search', component: _componentsPagesSearch2['default'] }),
_react2['default'].createElement(_reactRouter.Route, { path: 'tags/:tag', component: _componentsPagesTagDetail2['default'] }),
Expand Down Expand Up @@ -63845,6 +63847,10 @@
$('meta[property="og:url"]').attr('content', window.location.href);
$('meta[property="og:image"]').attr('content', video.thumbnailURL);
$('meta[property="og:description"]').attr('content', video.description);
$('meta[name="twitter:title"]').attr('content', video.title);
$('meta[name="twitter:image"]').attr('content', video.thumbnailURL);
$('meta[name="twitter:description"]').attr('content', video.description);
$('link[rel="image_src"]').attr('href', video.thumbnailURL);

return _react2['default'].createElement(
'div',
Expand Down
5 changes: 4 additions & 1 deletion summit-video-app/source/js/components/pages/VideoDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ class VideoDetail extends React.Component {
$('meta[property="og:url"]').attr('content', window.location.href );
$('meta[property="og:image"]').attr('content', video.thumbnailURL);
$('meta[property="og:description"]').attr('content', video.description);

$('meta[name="twitter:title"]').attr('content', video.title);
$('meta[name="twitter:image"]').attr('content', video.thumbnailURL);
$('meta[name="twitter:description"]').attr('content', video.description);
$('link[rel="image_src"]').attr('href', video.thumbnailURL);

return (
<div className="video-detail">
Expand Down
2 changes: 2 additions & 0 deletions summit-video-app/source/js/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ const Routes = (baseURL) => (
<Route path={baseURL} component={App}>
<IndexRoute component={AllVideos} />
<Route path="summits" component={Summits}/>
<Route path="summits/show/:slug" component={SummitDetail}/>
<Route path="summits/:slug" component={SummitDetail}/>
<Route path="speakers" component={Speakers} />
<Route path="speakers/:id/:slug" component={SpeakerDetail} />
<Route path="speakers/show/:id" component={SpeakerDetail} />
<Route path="featured" component={Featured} />
<Route path="search" component={Search} />
<Route path="tags/:tag" component={TagDetail}/>
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 @@ -43,7 +43,7 @@ public function MetaTags(&$tags)
$this->buildAppLinksMetaTags($tags);
}

private function buildAppLinksMetaTags(&$tags){
protected function buildAppLinksMetaTags(&$tags){
// IOS
$tags .= AppLinkIOSMetadataBuilder::buildAppLinksMetaTags($tags, sprintf("%s/%s",$this->getEntityPath(), $this->owner->ID));
// Android
Expand Down
6 changes: 6 additions & 0 deletions summit/code/pages/SummitEventOpenGraphObjectExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
**/

class SummitEventOpenGraphObjectExtension extends SummitEntityOpenGraphObjectExtension
{
public function AbsoluteLink()
Expand All @@ -27,4 +28,9 @@ public function getOGDescription()
protected function getEntityPath(){
return "events";
}

protected function buildAppLinksMetaTags(&$tags){
parent::buildAppLinksMetaTags($tags);
TwitterCardMetadataBuilder::buildTwitterCardMetaTags($tags, $this->owner);
}
}

0 comments on commit 0cd5dab

Please sign in to comment.