add pym.js iframe communication lib for embed bundle

- bump embed-bundle
- bump phraseanet-production-client
This commit is contained in:
Florian BLOUET
2016-06-17 10:41:26 +02:00
parent e6762531cc
commit 1412f98071
10 changed files with 139 additions and 52 deletions

View File

@@ -26,8 +26,7 @@
"fancytree": "~2.7", "fancytree": "~2.7",
"bootstrap-sass": "v2.3.2.2", "bootstrap-sass": "v2.3.2.2",
"jquery.lazyload": "~1.9.7", "jquery.lazyload": "~1.9.7",
"jquery-treeview": "~1.4.2", "jquery-treeview": "~1.4.2"
"alchemy-embed-medias": "~0.3.2"
}, },
"devDependencies": { "devDependencies": {
"mocha": "latest", "mocha": "latest",

View File

@@ -35,7 +35,7 @@
"php": ">=5.5.9", "php": ">=5.5.9",
"ext-intl": "*", "ext-intl": "*",
"alchemy-fr/tcpdf-clone": "~6.0", "alchemy-fr/tcpdf-clone": "~6.0",
"alchemy/embed-bundle": "^0.3.2", "alchemy/embed-bundle": "^0.4.1",
"alchemy/geonames-api-consumer": "~0.1.0", "alchemy/geonames-api-consumer": "~0.1.0",
"alchemy/google-plus-api-client": "~0.6.2", "alchemy/google-plus-api-client": "~0.6.2",
"alchemy/mediavorus": "^0.4.4", "alchemy/mediavorus": "^0.4.4",

16
composer.lock generated
View File

@@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "2d3272f471d3cf0eb5c7d44c46bc7145", "hash": "19164414a7dd4683f8d99d828456fb19",
"content-hash": "f3050bb8fb62cb6b00e3799a8e5c6936", "content-hash": "b908509f786ac7437d41055fbd021bef",
"packages": [ "packages": [
{ {
"name": "alchemy-fr/tcpdf-clone", "name": "alchemy-fr/tcpdf-clone",
@@ -132,16 +132,16 @@
}, },
{ {
"name": "alchemy/embed-bundle", "name": "alchemy/embed-bundle",
"version": "v0.3.3", "version": "v0.4.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/alchemy-fr/embed-bundle.git", "url": "https://github.com/alchemy-fr/embed-bundle.git",
"reference": "2eedc22e0030f6b4a166de2b93ffb108193c43dd" "reference": "edbbb7f0b9de199d5a67ce19fbc41bb94168352d"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/alchemy-fr/embed-bundle/zipball/2eedc22e0030f6b4a166de2b93ffb108193c43dd", "url": "https://api.github.com/repos/alchemy-fr/embed-bundle/zipball/edbbb7f0b9de199d5a67ce19fbc41bb94168352d",
"reference": "2eedc22e0030f6b4a166de2b93ffb108193c43dd", "reference": "edbbb7f0b9de199d5a67ce19fbc41bb94168352d",
"shasum": "" "shasum": ""
}, },
"require-dev": { "require-dev": {
@@ -179,10 +179,10 @@
], ],
"description": "Embed resources bundle", "description": "Embed resources bundle",
"support": { "support": {
"source": "https://github.com/alchemy-fr/embed-bundle/tree/v0.3.3", "source": "https://github.com/alchemy-fr/embed-bundle/tree/v0.4.1",
"issues": "https://github.com/alchemy-fr/embed-bundle/issues" "issues": "https://github.com/alchemy-fr/embed-bundle/issues"
}, },
"time": "2016-06-14 13:51:50" "time": "2016-06-16 09:35:17"
}, },
{ {
"name": "alchemy/geonames-api-consumer", "name": "alchemy/geonames-api-consumer",

View File

@@ -14,9 +14,12 @@ use Alchemy\Phrasea\Application\Helper\EntityManagerAware;
use Alchemy\Phrasea\Application\Helper\SearchEngineAware; use Alchemy\Phrasea\Application\Helper\SearchEngineAware;
use Alchemy\Phrasea\Controller\Controller; use Alchemy\Phrasea\Controller\Controller;
use Alchemy\Phrasea\Controller\RecordsRequest; use Alchemy\Phrasea\Controller\RecordsRequest;
use Alchemy\Phrasea\Model\Entities\BasketElement;
use Alchemy\Phrasea\Model\Repositories\BasketElementRepository; use Alchemy\Phrasea\Model\Repositories\BasketElementRepository;
use Alchemy\Phrasea\Model\Repositories\StoryWZRepository; use Alchemy\Phrasea\Model\Repositories\StoryWZRepository;
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions; use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
use Alchemy\Phrasea\Twig\Fit;
use Alchemy\Phrasea\Twig\PhraseanetExtension;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
@@ -69,15 +72,16 @@ class RecordController extends Controller
); );
if ($record->is_from_reg()) { if ($record->is_from_reg()) {
$currentRecord = $this->getContainerResult($record->get_container());
$train = $this->render('prod/preview/reg_train.html.twig', ['record' => $record]); $train = $this->render('prod/preview/reg_train.html.twig', ['record' => $record]);
} } else if ($record->is_from_basket() && $reloadTrain) {
$currentRecord = $this->getContainerResult($record);
if ($record->is_from_basket() && $reloadTrain) {
$train = $this->render('prod/preview/basket_train.html.twig', ['record' => $record]); $train = $this->render('prod/preview/basket_train.html.twig', ['record' => $record]);
} } else if ($record->is_from_feed()) {
$currentRecord = $this->getContainerResult($record->get_container());
if ($record->is_from_feed()) {
$train = $this->render('prod/preview/feed_train.html.twig', ['record' => $record]); $train = $this->render('prod/preview/feed_train.html.twig', ['record' => $record]);
} else {
$currentRecord = $this->getContainerResult($record);
} }
$recordCaptions = []; $recordCaptions = [];
@@ -86,6 +90,9 @@ class RecordController extends Controller
$recordCaptions[$field->get_name()] = $field->get_serialized_values(); $recordCaptions[$field->get_name()] = $field->get_serialized_values();
} }
// add properties if record is embed in iframe:
return $this->app->json([ return $this->app->json([
"desc" => $this->render('prod/preview/caption.html.twig', [ "desc" => $this->render('prod/preview/caption.html.twig', [
'record' => $record, 'record' => $record,
@@ -102,6 +109,7 @@ class RecordController extends Controller
'baskets' => $record->get_container_baskets($this->getEntityManager(), $this->getAuthenticatedUser()), 'baskets' => $record->get_container_baskets($this->getEntityManager(), $this->getAuthenticatedUser()),
]), ]),
"current" => $train, "current" => $train,
"record" => $currentRecord,
"history" => $this->render('prod/preview/short_history.html.twig', [ "history" => $this->render('prod/preview/short_history.html.twig', [
'record' => $record, 'record' => $record,
]), ]),
@@ -216,4 +224,78 @@ class RecordController extends Controller
{ {
return $this->app['repo.story-wz']; return $this->app['repo.story-wz'];
} }
private function getContainerResult($recordContainer)
{
/* @var $recordPreview \record_preview */
$helpers = new PhraseanetExtension($this->app);
$fit = $this->fitIn($recordContainer);
$recordData = [
'databoxId' => $recordContainer->getBaseId(),
'id' => $recordContainer->get_serialize_key(),
'isGroup' => $recordContainer->isStory(),
//'type' => $recordObj->getType(),
'url' => (string)$helpers->getThumbnailUrl($recordContainer),
'width' => $fit['width'],
'height' => $fit['height'],
'fit' => [
'width' => $fit['width'],
'height' => $fit['height'],
'top' => $fit['top'],
]
];
$userHaveAccess = $this->app->getAclForUser($this->getAuthenticatedUser())->has_access_to_subdef($recordContainer, 'preview');
if ($userHaveAccess) {
$recordPreview = $recordContainer->get_preview();
} else {
$recordPreview = $recordContainer->get_thumbnail();
}
$recordData['preview'] = [
'width' => $recordPreview->get_width(),
'height' => $recordPreview->get_height(),
'url' => $this->app->url('alchemy_embed_view', [
'url' => (string)($this->getAuthenticatedUser() ? $recordPreview->get_url() : $recordPreview->get_permalink()->get_url()),
'autoplay' => false
])
];
return $recordData;
}
/**
* Resize record thumbnail - direct translation from twig macro
* @param $record
* @return array
*/
private function fitIn($record)
{
$thumb_w = 70;
$thumb_h = 70;
$thumbnail = $record->get_thumbnail();
if ($thumbnail != null) {
$thumb_w = $thumbnail->get_width();
$thumb_h = $thumbnail->get_height();
}
$box_w = 70;
$box_h = 80;
$original_h = $thumb_h > 0 ? $thumb_h : 70;
$original_w = $thumb_w > 0 ? $thumb_w : 70;
$fitHelper = new Fit();
$fit_size = $fitHelper->fitIn(
["width" => $original_w, "height" => $original_h],
["width" => $box_w, "height" => $box_h]
);
return $fit_size;
}
} }

View File

@@ -34,6 +34,7 @@
"postinstall": "./node_modules/.bin/gulp install;" "postinstall": "./node_modules/.bin/gulp install;"
}, },
"dependencies": { "dependencies": {
"phraseanet-production-client": "~0.19.0" "alchemy-embed-medias": "^0.4.2",
"phraseanet-production-client": "~0.20.0"
} }
} }

View File

@@ -26,7 +26,7 @@ gulp.task('build', ['build-vendors'], function(){
// standalone vendors used across application // standalone vendors used across application
gulp.task('build-vendors', [ gulp.task('build-vendors', [
'build-alchemy-embed', 'build-alchemy-embed-medias',
'build-phraseanet-production-client', 'build-phraseanet-production-client',
'build-bootstrap', 'build-bootstrap',
'build-html5shiv', 'build-html5shiv',

View File

@@ -4,25 +4,22 @@ var utils = require('../../utils.js');
var debugMode = false; var debugMode = false;
// for dev purposes // for dev purposes
gulp.task('copy-alchemy-embed-debug', function(){ gulp.task('copy-alchemy-embed-medias-debug', function(){
debugMode = true; debugMode = true;
gulp.start('copy-alchemy-embed'); gulp.start('copy-alchemy-embed-medias');
}); });
gulp.task('copy-alchemy-embed', function(){ gulp.task('copy-alchemy-embed-medias', function(){
// copy all dist folder: // copy all dist folder:
if( debugMode === true) {
return gulp.src('vendor/alchemy/embed-bundle/dist/**/*') return gulp.src('node_modules/alchemy-embed-medias/dist/**/*')
.pipe(gulp.dest( config.paths.build + 'vendors/alchemy-embed-medias'));
}
return gulp.src(config.paths.vendors + 'alchemy-embed-medias/dist/**/*')
.pipe(gulp.dest( config.paths.build + 'vendors/alchemy-embed-medias')); .pipe(gulp.dest( config.paths.build + 'vendors/alchemy-embed-medias'));
}); });
gulp.task('watch-alchemy-embed-js', function() { gulp.task('watch-alchemy-embed-medias-js', function() {
debugMode = true; debugMode = true;
// in dev mode, watch composer's vendor path: // in dev mode, watch composer's vendor path:
return gulp.watch('vendor/alchemy/embed-bundle/dist/**/*', ['copy-alchemy-embed']); return gulp.watch('node_modules/alchemy-embed-medias/dist/**/*', ['copy-alchemy-embed-medias']);
});
gulp.task('build-alchemy-embed-medias', function(){
gulp.start('copy-alchemy-embed-medias');
}); });
gulp.task('build-alchemy-embed', function(){
gulp.start('copy-alchemy-embed');
});

View File

@@ -29,7 +29,7 @@ gulp.task('watch-js', function(){
// gulp.start('watch-permaview'); // gulp.start('watch-permaview');
gulp.start('watch-setup-js'); gulp.start('watch-setup-js');
gulp.start('watch-authentication-js'); gulp.start('watch-authentication-js');
gulp.start('watch-alchemy-embed-js'); gulp.start('watch-alchemy-embed-medias-js');
gulp.start('watch-phraseanet-production-client-js'); gulp.start('watch-phraseanet-production-client-js');
}); });

View File

@@ -10,24 +10,23 @@
{% endif %} {% endif %}
{% if record_type == 'VIDEO_MP4' or record_type == 'VIDEO_FLV' %} {% if record_type == 'VIDEO_MP4' or record_type == 'VIDEO_FLV' %}
<div class="videoTips" data-original-width="{{original_w}}" data-original-height="{{original_h}}" data-kind="video"> <div id="phraseanet-embed-frame" class="videoTips"
data-original-width="{{original_w}}"
<iframe width="100%" height="100%" data-original-height="{{original_h}}"
src="{{ url('alchemy_embed_view', {url: url|trim, autoplay: autoplay|default('false') }) }}" data-kind="video"
frameborder="0" allowfullscreen></iframe> data-src="{{ url('alchemy_embed_view', {url: url|trim, autoplay: autoplay|default('false') }) }}"></div>
</div>
{% elseif record_type == 'FLEXPAPER' %} {% elseif record_type == 'FLEXPAPER' %}
<div class="documentTips" data-original-width="{{original_w}}" data-original-height="{{original_h}}" data-kind="document"> <div id="phraseanet-embed-frame" class="documentTips"
<iframe width="100%" height="100%" data-original-width="{{original_w}}"
src="{{ url('alchemy_embed_view', {url: url|trim, autoplay: autoplay|default('false') }) }}" data-original-height="{{original_h}}"
frameborder="0" allowfullscreen></iframe> data-kind="document"
</div> data-src="{{ url('alchemy_embed_view', {url: url|trim, autoplay: autoplay|default('false') }) }}"></div>
{% elseif record_type == 'AUDIO_MP3' %} {% elseif record_type == 'AUDIO_MP3' %}
<div class="audioTips" data-original-width="{{original_w}}" data-original-height="{{original_h}}" data-kind="audio"> <div id="phraseanet-embed-frame" class="audioTips"
<iframe width="100%" height="100%" data-original-width="{{original_w}}"
src="{{ url('alchemy_embed_view', {url: url|trim, autoplay: autoplay|default('false') }) }}" data-original-height="{{original_h}}"
frameborder="0" allowfullscreen></iframe> data-kind="audio"
</div> data-src="{{ url('alchemy_embed_view', {url: url|trim, autoplay: autoplay|default('false') }) }}"></div>
{% else %} {% else %}
{% set fit_size = fitIn( {% set fit_size = fitIn(
{"width":original_w, "height":original_h}, {"width":original_w, "height":original_h},

View File

@@ -22,13 +22,22 @@
<h1>{{ local_title }}</h1> <h1>{{ local_title }}</h1>
<div class="preview"> <div class="preview">
<iframe width="100%" height="{{ subdef.get_height() }}" <div id="phraseanet-embed-frame"></div>
src="{{ recordUrl }}"
frameborder="0" allowfullscreen></iframe>
</div> </div>
<div class="caption"> <div class="caption">
{% include 'common/caption.html.twig' %} {% include 'common/caption.html.twig' %}
</div> </div>
</div> </div>
<script type="text/javascript" src="/assets/production/permaview{% if not app.debug %}.min{% endif %}.js"></script>
<script type="text/javascript">
window.permApp = PermaviewApplication.bootstrap({
lang: "{{ app.locale }}",
baseUrl: '{{ app['request'].getUriForPath('/') }}',
basePath: '{{ app.request.basePath|e('js') }}',
recordUrl: '{{ url('alchemy_embed_view', {url: recordUrl|trim, autoplay: autoplay|default('false') }) }}',
debug: {% if app.debug == true %}true{% else %}false{% endif %}
});
</script>
{% endblock %} {% endblock %}