mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Embedded youtube videos.
Summary: Markup support for embedding Youtube videos. Test Plan: https://www.youtube.com/watch?v=Vw4KVoEVcr0 was embedded Reviewed By: epriestley Reviewers: epriestley CC: aran, epriestley Differential Revision: 353
This commit is contained in:
parent
ce8a406424
commit
19e10b2b5d
6 changed files with 78 additions and 0 deletions
|
@ -339,6 +339,10 @@ return array(
|
||||||
|
|
||||||
'maniphest.enabled' => true,
|
'maniphest.enabled' => true,
|
||||||
|
|
||||||
|
// -- Remarkup -------------------------------------------------------------- //
|
||||||
|
|
||||||
|
'remarkup.enable-embedded-youtube' => false,
|
||||||
|
|
||||||
// -- Customization --------------------------------------------------------- //
|
// -- Customization --------------------------------------------------------- //
|
||||||
|
|
||||||
// Paths to additional phutil libraries to load.
|
// Paths to additional phutil libraries to load.
|
||||||
|
|
|
@ -410,6 +410,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorRemarkupRuleImageMacro' => 'infrastructure/markup/remarkup/markuprule/imagemacro',
|
'PhabricatorRemarkupRuleImageMacro' => 'infrastructure/markup/remarkup/markuprule/imagemacro',
|
||||||
'PhabricatorRemarkupRuleManiphest' => 'infrastructure/markup/remarkup/markuprule/maniphest',
|
'PhabricatorRemarkupRuleManiphest' => 'infrastructure/markup/remarkup/markuprule/maniphest',
|
||||||
'PhabricatorRemarkupRuleProxyImage' => 'infrastructure/markup/remarkup/markuprule/proxyimage',
|
'PhabricatorRemarkupRuleProxyImage' => 'infrastructure/markup/remarkup/markuprule/proxyimage',
|
||||||
|
'PhabricatorRemarkupRuleYoutube' => 'infrastructure/markup/remarkup/markuprule/youtube',
|
||||||
'PhabricatorRepository' => 'applications/repository/storage/repository',
|
'PhabricatorRepository' => 'applications/repository/storage/repository',
|
||||||
'PhabricatorRepositoryArcanistProject' => 'applications/repository/storage/arcanistproject',
|
'PhabricatorRepositoryArcanistProject' => 'applications/repository/storage/arcanistproject',
|
||||||
'PhabricatorRepositoryArcanistProjectEditController' => 'applications/repository/controller/arcansistprojectedit',
|
'PhabricatorRepositoryArcanistProjectEditController' => 'applications/repository/controller/arcansistprojectedit',
|
||||||
|
@ -843,6 +844,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorRemarkupRuleImageMacro' => 'PhutilRemarkupRule',
|
'PhabricatorRemarkupRuleImageMacro' => 'PhutilRemarkupRule',
|
||||||
'PhabricatorRemarkupRuleManiphest' => 'PhutilRemarkupRule',
|
'PhabricatorRemarkupRuleManiphest' => 'PhutilRemarkupRule',
|
||||||
'PhabricatorRemarkupRuleProxyImage' => 'PhutilRemarkupRule',
|
'PhabricatorRemarkupRuleProxyImage' => 'PhutilRemarkupRule',
|
||||||
|
'PhabricatorRemarkupRuleYoutube' => 'PhutilRemarkupRule',
|
||||||
'PhabricatorRepository' => 'PhabricatorRepositoryDAO',
|
'PhabricatorRepository' => 'PhabricatorRepositoryDAO',
|
||||||
'PhabricatorRepositoryArcanistProject' => 'PhabricatorRepositoryDAO',
|
'PhabricatorRepositoryArcanistProject' => 'PhabricatorRepositoryDAO',
|
||||||
'PhabricatorRepositoryArcanistProjectEditController' => 'PhabricatorRepositoryController',
|
'PhabricatorRepositoryArcanistProjectEditController' => 'PhabricatorRepositoryController',
|
||||||
|
|
|
@ -31,6 +31,11 @@ class DifferentialMarkupEngineFactory {
|
||||||
if (PhabricatorEnv::getEnvConfig('files.enable-proxy')) {
|
if (PhabricatorEnv::getEnvConfig('files.enable-proxy')) {
|
||||||
$rules[] = new PhabricatorRemarkupRuleProxyImage();
|
$rules[] = new PhabricatorRemarkupRuleProxyImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (PhabricatorEnv::getEnvConfig('remarkup.enable-embedded-youtube')) {
|
||||||
|
$rules[] = new PhabricatorRemarkupRuleYoutube();
|
||||||
|
}
|
||||||
|
|
||||||
$rules[] = new PhutilRemarkupRuleHyperlink();
|
$rules[] = new PhutilRemarkupRuleHyperlink();
|
||||||
|
|
||||||
$rules[] = new PhabricatorRemarkupRuleDifferential();
|
$rules[] = new PhabricatorRemarkupRuleDifferential();
|
||||||
|
|
|
@ -12,6 +12,7 @@ phutil_require_module('phabricator', 'infrastructure/markup/remarkup/markuprule/
|
||||||
phutil_require_module('phabricator', 'infrastructure/markup/remarkup/markuprule/imagemacro');
|
phutil_require_module('phabricator', 'infrastructure/markup/remarkup/markuprule/imagemacro');
|
||||||
phutil_require_module('phabricator', 'infrastructure/markup/remarkup/markuprule/maniphest');
|
phutil_require_module('phabricator', 'infrastructure/markup/remarkup/markuprule/maniphest');
|
||||||
phutil_require_module('phabricator', 'infrastructure/markup/remarkup/markuprule/proxyimage');
|
phutil_require_module('phabricator', 'infrastructure/markup/remarkup/markuprule/proxyimage');
|
||||||
|
phutil_require_module('phabricator', 'infrastructure/markup/remarkup/markuprule/youtube');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'markup/engine/remarkup');
|
phutil_require_module('phutil', 'markup/engine/remarkup');
|
||||||
phutil_require_module('phutil', 'markup/engine/remarkup/blockrule/remarkupcode');
|
phutil_require_module('phutil', 'markup/engine/remarkup/blockrule/remarkupcode');
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group markup
|
||||||
|
*/
|
||||||
|
class PhabricatorRemarkupRuleYoutube
|
||||||
|
extends PhutilRemarkupRule {
|
||||||
|
|
||||||
|
public function apply($text) {
|
||||||
|
$this->uri = new PhutilURI($text);
|
||||||
|
|
||||||
|
if ($this->uri->getDomain() &&
|
||||||
|
preg_match('/youtube\.com$/', $this->uri->getDomain())) {
|
||||||
|
return $this->markupYoutubeLink();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function markupYoutubeLink() {
|
||||||
|
$v = idx($this->uri->getQueryParams(), 'v');
|
||||||
|
if ($v) {
|
||||||
|
$youtube_src = 'https://www.youtube.com/embed/'.$v;
|
||||||
|
$iframe =
|
||||||
|
'<div class="embedded-youtube-video">
|
||||||
|
<iframe width="650" height="400" '.
|
||||||
|
'style="margin: 1em auto; border: 0px" '.
|
||||||
|
'src="'.$youtube_src.'" '.
|
||||||
|
'frameborder="0"></iframe>
|
||||||
|
</div>';
|
||||||
|
return $this->getEngine()->storeText($iframe);
|
||||||
|
} else {
|
||||||
|
return $this->uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'markup/engine/remarkup/markuprule/base');
|
||||||
|
phutil_require_module('phutil', 'parser/uri');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('PhabricatorRemarkupRuleYoutube.php');
|
Loading…
Reference in a new issue