From bfa8e57f9af90e1fabfeb945eb5c3e05309899f6 Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Tue, 27 Nov 2018 18:17:53 -0500 Subject: [PATCH] Asset tag (#10) * Fixed robots.txt * Refactored config; Added safeguards for languages/versions; Allow all languages * Work on the languages * Asset tag introduction and reformatting files --- app/config/config.php | 31 ++--- app/controllers/BaseController.php | 45 ++++--- app/controllers/DocsController.php | 16 ++- app/library/Bootstrap.php | 9 +- .../Exception/Handler/ErrorPageHandler.php | 1 - .../Exception/Handler/LoggerHandler.php | 4 +- app/providers/Assets/ServiceProvider.php | 6 +- app/providers/CacheData/ServiceProvider.php | 3 +- app/providers/Logger/ServiceProvider.php | 3 +- app/providers/ViewCache/ServiceProvider.php | 3 +- .../VoltTemplate/ServiceProvider.php | 3 +- app/tasks/ClearCacheTask.php | 3 +- app/tasks/GenerateSitemapTask.php | 1 - app/tasks/GetLanguagesTask.php | 9 +- app/tasks/UpdateSearchTask.php | 23 ++-- app/views/error/show404.volt | 6 +- app/views/error/show500.volt | 3 +- app/views/inc/google.volt | 5 +- app/views/inc/header-languages.volt | 47 ++++---- app/views/inc/header-versions.volt | 33 +++--- app/views/inc/header.volt | 3 +- app/views/inc/search.volt | 58 ++++----- app/views/templates/base.volt | 110 ++++++++++-------- app/views/toCheck/inc/advantages.volt | 9 +- app/views/toCheck/inc/footer.volt | 21 ++-- app/views/toCheck/inc/head-menu.volt | 24 ++-- app/views/toCheck/inc/header-inner.volt | 3 +- app/views/toCheck/inc/header.volt | 6 +- app/views/toCheck/inc/language_selector.volt | 3 +- .../toCheck/inc/language_selector_mobile.volt | 3 +- app/views/toCheck/inc/support-forum-form.volt | 3 +- app/views/toCheck/inc/support.volt | 13 ++- app/views/toCheck/inc/topics-sidebar.volt | 11 +- app/views/toCheck/inc/topics.volt | 3 +- app/views/toCheck/inc/version_selector.volt | 5 +- .../toCheck/inc/version_selector_mobile.volt | 3 +- app/views/toCheck/include/footer.volt | 54 ++++++--- app/views/toCheck/include/icons.volt | 45 ++++--- app/views/toCheck/include/ie-support.volt | 3 +- .../toCheck/include/language_selector.volt | 3 +- app/views/toCheck/include/meta.volt | 3 +- app/views/toCheck/include/nav.volt | 11 +- app/views/toCheck/include/noindex-meta.volt | 3 +- deploy | 7 ++ 44 files changed, 381 insertions(+), 280 deletions(-) diff --git a/app/config/config.php b/app/config/config.php index a43322b..58c1d5e 100644 --- a/app/config/config.php +++ b/app/config/config.php @@ -15,16 +15,16 @@ +------------------------------------------------------------------------+ */ +use Docs\Controllers\DocsController; use function Docs\Functions\app_path; use function Docs\Functions\env; -use Docs\Controllers\DocsController; /** * Get the versions and languages */ -$version = '0.1'; -$languages = []; -$versions = []; +$version = '0.1'; +$languages = []; +$versions = []; $crowdinFile = app_path('/storage/crowdin/crowdin.json'); if (true === file_exists($crowdinFile)) { $crowdin = file_get_contents($crowdinFile); @@ -55,6 +55,7 @@ 'staticUrl' => env('APP_STATIC_URL'), 'lang' => env('APP_LANG'), 'supportEmail' => env('APP_SUPPORT_EMAIL'), + 'assetTag' => 'development' !== env('APP_ENV') ? env('ASSET_TAG') : time(), 'googleAnalytics' => env('GOOGLE_ANALYTICS'), 'algoliaSearchKey' => env('ALGOLIA_SEARCH_KEY'), ], @@ -64,16 +65,16 @@ ], 'highlight' => [ 'version' => '9.11.0', - 'js' => [ - 'cpp', - 'css', - 'json', - 'php', - 'shell', - 'twig', - 'yaml', - 'zephir', - ], + 'js' => [ + 'cpp', + 'css', + 'json', + 'php', + 'shell', + 'twig', + 'yaml', + 'zephir', + ], ], 'providers' => [ // Application Service Providers @@ -91,7 +92,7 @@ Docs\Providers\Dispatcher\ServiceProvider::class, Docs\Providers\Tags\ServiceProvider::class, ], - 'routes' => [ + 'routes' => [ DocsController::class => [ 'methods' => [ 'get' => [ diff --git a/app/controllers/BaseController.php b/app/controllers/BaseController.php index bf5c19b..67bcd7d 100644 --- a/app/controllers/BaseController.php +++ b/app/controllers/BaseController.php @@ -17,16 +17,15 @@ namespace Docs\Controllers; -use function array_search; use Phalcon\Cache\BackendInterface; use Phalcon\Config; use Phalcon\Mvc\Controller as PhController; use Phalcon\Mvc\View\Simple; +use function array_search; use function Docs\Functions\app_path; use function Docs\Functions\config; use function Docs\Functions\environment; use function file_exists; -use function var_dump; /** * Docs\Controllers\BaseController @@ -70,7 +69,7 @@ public function getSidebar($language, $version): array if (true === file_exists($pageName)) { $data = file_get_contents($pageName); - } elseif (true === file_exists($apiFileName)) { + } else if (true === file_exists($apiFileName)) { $data = file_get_contents($apiFileName); } else { // The article does not exist @@ -179,6 +178,25 @@ protected function getSeoTitle(string $language, string $version, string $page): return $title; } + /** + * @param string $language + * @param string $version + * @param string $fileName + * + * @return string + */ + protected function getMenu($language, $version, $fileName): string + { + $document = $this->getDocument($language, $version, $fileName); + $document = str_replace( + '
  • ', + '
  • ', + $document + ); + + return ltrim(rtrim($document, ''), ''), '