Skip to content

Commit

Permalink
Merge branch 'develop' into multisource-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
ehough committed Jun 24, 2015
2 parents 1a325e9 + e062185 commit b373dd9
Show file tree
Hide file tree
Showing 50 changed files with 1,487 additions and 359 deletions.
16 changes: 8 additions & 8 deletions build/config/classes-to-concat/headonly.php
Expand Up @@ -46,17 +46,17 @@
'tubepress_app_impl_options_DispatchingReference',
'tubepress_app_impl_options_Persistence',
'tubepress_app_impl_shortcode_Parser',
'tubepress_app_impl_template_DelegatingEngine',
'tubepress_app_impl_template_php_Support',
'tubepress_app_impl_template_TemplatingService',
'tubepress_app_impl_template_ThemeTemplateLocator',
'tubepress_app_impl_template_twig_Engine',
'tubepress_app_impl_template_twig_EnvironmentBuilder',
'tubepress_app_impl_template_twig_FsLoader',
'tubepress_app_impl_template_twig_ThemeLoader',
'tubepress_app_impl_theme_AbstractTheme',
'tubepress_app_impl_theme_CurrentThemeService',
'tubepress_app_impl_theme_FilesystemTheme',
'tubepress_app_template_impl_DelegatingEngine',
'tubepress_app_template_impl_php_Support',
'tubepress_app_template_impl_TemplatingService',
'tubepress_app_template_impl_ThemeTemplateLocator',
'tubepress_app_template_impl_twig_Engine',
'tubepress_app_template_impl_twig_EnvironmentBuilder',
'tubepress_app_template_impl_twig_FsLoader',
'tubepress_app_template_impl_twig_ThemeLoader',
'tubepress_lib_api_event_EventDispatcherInterface',
'tubepress_lib_api_event_EventInterface',
'tubepress_lib_api_http_AjaxInterface',
Expand Down
2 changes: 1 addition & 1 deletion build/config/common.properties
@@ -1,3 +1,3 @@
version.major=4
version.minor=1
version.micro=9
version.micro=10
2 changes: 2 additions & 0 deletions build/include/common.xml
Expand Up @@ -90,7 +90,9 @@
<replace file="${stagingdir}/src/add-ons/core/manifest.json" token="99.99.99" value="${version.major}.${version.minor}.${version.micro}" failOnNoReplacements="true" />
<replace file="${stagingdir}/src/add-ons/deprecated/manifest.json" token="99.99.99" value="${version.major}.${version.minor}.${version.micro}" failOnNoReplacements="true" />
<replace file="${stagingdir}/src/add-ons/embedplus/manifest.json" token="99.99.99" value="${version.major}.${version.minor}.${version.micro}" failOnNoReplacements="true" />
<replace file="${stagingdir}/src/add-ons/htmlcache/manifest.json" token="99.99.99" value="${version.major}.${version.minor}.${version.micro}" failOnNoReplacements="true" />
<replace file="${stagingdir}/src/add-ons/jwplayer5/manifest.json" token="99.99.99" value="${version.major}.${version.minor}.${version.micro}" failOnNoReplacements="true" />
<replace file="${stagingdir}/src/add-ons/template/manifest.json" token="99.99.99" value="${version.major}.${version.minor}.${version.micro}" failOnNoReplacements="true" />
<replace file="${stagingdir}/src/add-ons/vimeo_v2/manifest.json" token="99.99.99" value="${version.major}.${version.minor}.${version.micro}" failOnNoReplacements="true" />
<replace file="${stagingdir}/src/add-ons/wordpress/manifest.json" token="99.99.99" value="${version.major}.${version.minor}.${version.micro}" failOnNoReplacements="true" />
<replace file="${stagingdir}/src/add-ons/youtube_v3/manifest.json" token="99.99.99" value="${version.major}.${version.minor}.${version.micro}" failOnNoReplacements="true" />
Expand Down
13 changes: 8 additions & 5 deletions composer.json
Expand Up @@ -40,18 +40,21 @@
"tubepress_api_const_" : "src/add-ons/deprecated/classes",
"tubepress_addons_" : "src/add-ons/deprecated/classes",

"tubepress_embedplus_" : "src/add-ons/embedplus/classes",
"tubepress_jwplayer5_" : "src/add-ons/jwplayer5/classes",
"tubepress_vimeo2_" : "src/add-ons/vimeo_v2/classes",
"tubepress_wordpress_" : "src/add-ons/wordpress/classes",
"tubepress_youtube3_" : "src/add-ons/youtube_v3/classes",
"tubepress_htmlcache_" : "src/add-ons/htmlcache/classes",
"tubepress_embedplus_" : "src/add-ons/embedplus/classes",
"tubepress_jwplayer5_" : "src/add-ons/jwplayer5/classes",
"tubepress_app_template_" : "src/add-ons/template/classes",
"tubepress_vimeo2_" : "src/add-ons/vimeo_v2/classes",
"tubepress_wordpress_" : "src/add-ons/wordpress/classes",
"tubepress_youtube3_" : "src/add-ons/youtube_v3/classes",

"tubepress_test_integration_" : "tests/integration/classes",
"tubepress_test_platform_" : "tests/unit/platform/classes",
"tubepress_test_app_" : "tests/unit/add-ons/core/classes",
"tubepress_test_lib_" : "tests/unit/add-ons/core/classes",
"tubepress_test_boot_" : "tests/unit/platform/fixtures/mock-user-content-dir/add-ons/bootmocks/classes",
"tubepress_test_translations_" : "tests/unit/translations/classes",
"tubepress_test_app_template_" : "tests/unit/add-ons/template/classes",
"tubepress_test_" : "tests/unit/add-ons/core/classes"
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/add-ons/core/classes/tubepress/app/api/event/Events.php
Expand Up @@ -63,6 +63,17 @@ interface tubepress_app_api_event_Events
*/
const HTML_GENERATION = 'tubepress.app.html.generation';

/**
* This event is fired after TubePress generates its "primary" HTML (e.g. a media gallery,
* search input widget, embedded media player, etc).
*
* @subject `string` The HTML that will be returned to the user.
*
* @api
* @since 4.1.10
*/
const HTML_GENERATION_POST = 'tubepress.app.html.generation.post';

/**
* This event is fired immediately after TubePress assembles its list of scripts to print.
*
Expand Down
30 changes: 30 additions & 0 deletions src/add-ons/core/classes/tubepress/app/api/options/Names.php
Expand Up @@ -39,6 +39,36 @@ interface tubepress_app_api_options_Names
*/
const CACHE_LIFETIME_SECONDS = 'cacheLifetimeSeconds';

/**
* @api
* @since 4.1.10
*/
const CACHE_HTML_CLEANING_FACTOR = 'htmlCacheCleaningFactor';

/**
* @api
* @since 4.1.10
*/
const CACHE_HTML_CLEANING_KEY = 'htmlCacheCleaningKey';

/**
* @api
* @since 4.1.10
*/
const CACHE_HTML_DIRECTORY = 'htmlCacheDirectory';

/**
* @api
* @since 4.1.10
*/
const CACHE_HTML_ENABLED = 'htmlCacheEnabled';

/**
* @api
* @since 4.1.10
*/
const CACHE_HTML_LIFETIME_SECONDS = 'htmlCacheLifetimeSeconds';

/**
* @api
* @since 4.0.0
Expand Down
15 changes: 12 additions & 3 deletions src/add-ons/core/classes/tubepress/app/impl/html/HtmlGenerator.php
Expand Up @@ -64,20 +64,29 @@ public function getHtml()
{
try {

$htmlProviderSelectionEvent = $this->_eventDispatcher->newEventInstance('');
$htmlGenerationEventPre = $this->_eventDispatcher->newEventInstance('');

$this->_eventDispatcher->dispatch(tubepress_app_api_event_Events::HTML_GENERATION, $htmlProviderSelectionEvent);
$this->_eventDispatcher->dispatch(tubepress_app_api_event_Events::HTML_GENERATION, $htmlGenerationEventPre);

/**
* @var $selected string
*/
$html = $htmlProviderSelectionEvent->getSubject();
$html = $htmlGenerationEventPre->getSubject();

if ($html === null) {

throw new RuntimeException('Unable to generate HTML.');
}

$htmlGenerationEventPost = $this->_eventDispatcher->newEventInstance($html);

$this->_eventDispatcher->dispatch(tubepress_app_api_event_Events::HTML_GENERATION_POST, $htmlGenerationEventPost);

/**
* @var $html string
*/
$html = $htmlGenerationEventPost->getSubject();

return $html;

} catch (Exception $e) {
Expand Down
Expand Up @@ -24,29 +24,57 @@ class tubepress_app_impl_vendor_stash_FilesystemCacheBuilder
*/
private $_bootSettings;

/**
* @var tubepress_platform_api_log_LoggerInterface
*/
private $_logger;

/**
* @var boolean
*/
private $_shouldLog;

public function __construct(tubepress_app_api_options_ContextInterface $context,
tubepress_platform_api_boot_BootSettingsInterface $bootSettings)
tubepress_platform_api_boot_BootSettingsInterface $bootSettings,
tubepress_platform_api_log_LoggerInterface $logger)
{
$this->_context = $context;
$this->_bootSettings = $bootSettings;
$this->_logger = $logger;
$this->_shouldLog = $logger->isEnabled();
}

public function buildFilesystemDriver()
{
$dir = $this->_context->get(tubepress_app_api_options_Names::CACHE_DIRECTORY);

if ($this->_shouldLog) {

$this->_logger->debug(sprintf('Starting to build API cache driver. User candidate is "<code>%s</code>"', $dir));
}

/**
* If a path was given, but it's not a directory, let's try to create it.
*/
if ($dir != '' && !is_dir($dir)) {
if ($dir && !is_dir($dir)) {

if ($this->_shouldLog) {

$this->_logger->debug(sprintf('"<code>%s</code>" is not a directory. Let\'s try to create it...', $dir));
}

@mkdir($dir, 0755, true);
}

/**
* If the directory exists, but isn't writable, let's try to change that.
*/
if (is_dir($dir) && !is_writable($dir)) {
if ($dir && is_dir($dir) && !is_writable($dir)) {

if ($this->_shouldLog) {

$this->_logger->debug(sprintf('"<code>%s</code>" is a directory but we can\'t write to it. Let\'s try to change that...', $dir));
}

@chmod($dir, 0755);
}
Expand All @@ -56,7 +84,17 @@ public function buildFilesystemDriver()
*/
if (!is_dir($dir) || !is_writable($dir)) {

if ($this->_shouldLog) {

$this->_logger->debug(sprintf('We don\'t have a directory that we can use for the API cache. Giving up and falling back to system directory.', $dir));
}

$dir = $this->_bootSettings->getPathToSystemCacheDirectory() . '/api-calls';

if ($this->_shouldLog) {

$this->_logger->debug(sprintf('Final API cache directory is "<code>%s</code>"', $dir));
}
}

$driver = new ehough_stash_driver_FileSystem();
Expand Down

0 comments on commit b373dd9

Please sign in to comment.