Skip to content
This repository was archived by the owner on Jan 16, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions app/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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'),
],
Expand All @@ -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
Expand All @@ -91,7 +92,7 @@
Docs\Providers\Dispatcher\ServiceProvider::class,
Docs\Providers\Tags\ServiceProvider::class,
],
'routes' => [
'routes' => [
DocsController::class => [
'methods' => [
'get' => [
Expand Down
45 changes: 22 additions & 23 deletions app/controllers/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
'<li>',
'<li class="toc-entry toc-h2">',
$document
);

return ltrim(rtrim($document, '</ul>'), '<ul>');
}

/**
* @param string $language
* @param string $version
Expand All @@ -194,7 +212,7 @@ protected function getDocument($language, $version, $fileName): string
return $this->cacheData->get($key);
}

$pageName = app_path(
$pageName = app_path(
sprintf(
'docs/%s/%s/%s.md',
$version,
Expand Down Expand Up @@ -229,25 +247,6 @@ protected function getDocument($language, $version, $fileName): string
return $data;
}

/**
* @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(
'<li>',
'<li class="toc-entry toc-h2">',
$document
);

return ltrim(rtrim($document, '</ul>'), '<ul>');
}

/**
* Returns the current version string with its prefix if applicable
*
Expand Down
16 changes: 7 additions & 9 deletions app/controllers/DocsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

namespace Docs\Controllers;

use Docs\Cli\Tasks\GetLanguagesTask;
use Docs\Exception\HttpException;
use Phalcon\Http\ResponseInterface;
use Phalcon\Text;
use function Docs\Functions\base_url;
use function str_replace;

/**
* Docs\Controllers\DocsController
Expand Down Expand Up @@ -63,13 +61,13 @@ public function mainAction(string $language = null, string $version = null, stri
$contents = $this->viewSimple->render(
$renderFile,
[
'page' => $page,
'language' => $language,
'version' => $version,
'sidebar' => $this->getMenu($language, $version, 'sidebar'),
'article' => $article,
'menu' => $this->getMenu($language, $version, $page . '-menu'),
'canonical' => $canonical,
'page' => $page,
'language' => $language,
'version' => $version,
'sidebar' => $this->getMenu($language, $version, 'sidebar'),
'article' => $article,
'menu' => $this->getMenu($language, $version, $page . '-menu'),
'canonical' => $canonical,
]
);
$this->response->setContent($contents);
Expand Down
9 changes: 6 additions & 3 deletions app/library/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ public function __construct($mode = 'normal')
/**
* Initialize the Service Provider.
*
* Usually the Service Provider register a service in the Dependency Injector Container.
* Usually the Service Provider register a service in the Dependency
* Injector Container.
*
* @param ServiceProviderInterface $serviceProvider
*
Expand All @@ -117,7 +118,8 @@ protected function initializeServiceProvider(ServiceProviderInterface $servicePr
* If failed the `development` will be used.
*
* After getting `APP_ENV` variable we set the Bootstrap::$environment
* and the `APPLICATION_ENV` constant which used in other Phalcon related projects eg Incubator.
* and the `APPLICATION_ENV` constant which used in other Phalcon related
* projects eg Incubator.
*/
protected function setupEnvironment()
{
Expand Down Expand Up @@ -228,7 +230,8 @@ public function getApplication()
}

/**
* Gets current application environment: production, staging, development, testing, etc.
* Gets current application environment: production, staging, development,
* testing, etc.
*
* @return string
*/
Expand Down
1 change: 0 additions & 1 deletion app/library/Exception/Handler/ErrorPageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
namespace Docs\Exception\Handler;

use Whoops\Handler\Handler;
use function Docs\Functions\config;
use function Docs\Functions\container;

/**
Expand Down
4 changes: 2 additions & 2 deletions app/library/Exception/Handler/LoggerHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function addTraceToOutput($addTraceToOutput = null)
return $this->addTraceToOutput;
}

$this->addTraceToOutput = (bool)$addTraceToOutput;
$this->addTraceToOutput = (bool) $addTraceToOutput;

return $this;
}
Expand Down Expand Up @@ -193,7 +193,7 @@ public function addTraceFunctionArgsToOutput($args = null)
}

if (!is_integer($args)) {
$this->addTraceFunctionArgsToOutput = (bool)$args;
$this->addTraceFunctionArgsToOutput = (bool) $args;
} else {
$this->addTraceFunctionArgsToOutput = $args;
}
Expand Down
6 changes: 4 additions & 2 deletions app/providers/Assets/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,15 @@ function ($lang) {
// TODO(o2)
// ->addCss($cssCdn, false)
->addCss(assets_uri('js/highlight/styles/googlecode.css', $version))
->addCss(assets_uri('css/style.css', $version));
->addCss(assets_uri('css/style.css', $version))
;

$assets
->collection('footer_js')
// // TODO(o2)
// ->addJs($jsCdn, false);
->addJs(assets_uri('js/main.min.js', $version))
->addJs(assets_uri('js/highlight/highlight.pack.js', $version));
->addJs(assets_uri('js/highlight/highlight.pack.js', $version))
;
}
}
3 changes: 1 addition & 2 deletions app/providers/CacheData/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@

namespace Docs\Providers\CacheData;

use function Docs\Functions\env;
use Phalcon\Cache\Frontend\Data;
use Phalcon\Di\ServiceProviderInterface;
use Phalcon\DiInterface;
use function Docs\Functions\app_path;
use function Docs\Functions\config;
use function Docs\Functions\env;

/**
* Docs\Providers\CacheData\ServiceProvider
Expand Down
3 changes: 1 addition & 2 deletions app/providers/Logger/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@

namespace Docs\Providers\Logger;

use function Docs\Functions\env;
use Phalcon\Di\ServiceProviderInterface;
use Phalcon\DiInterface;
use Phalcon\Logger;
use Phalcon\Logger\Adapter\File;
use Phalcon\Logger\Formatter\Line;
use function Docs\Functions\app_path;
use function Docs\Functions\config;
use function Docs\Functions\env;

/**
* Docs\Providers\Logger\ServiceProvider
Expand Down
3 changes: 1 addition & 2 deletions app/providers/ViewCache/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use Phalcon\Di\ServiceProviderInterface;
use Phalcon\DiInterface;
use function Docs\Functions\app_path;
use function Docs\Functions\config;

/**
* Docs\Providers\ViewCache\ServiceProvider
Expand All @@ -46,7 +45,7 @@ public function register(DiInterface $container)
function () {
$lifetime = env('CACHE_LIFETIME', 3600);
$driver = env('VIEW_CACHE_DRIVER', 'file');
$adapter = '\Phalcon\Cache\Backend\\' . ucfirst($driver);
$adapter = '\Phalcon\Cache\Backend\\' . ucfirst($driver);

return new $adapter(
new Output(['lifetime' => $lifetime]),
Expand Down
3 changes: 2 additions & 1 deletion app/providers/VoltTemplate/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public function register(DiInterface $container)


$volt->getCompiler()
->addExtension(new VoltFunctions());
->addExtension(new VoltFunctions())
;

return $volt;
};
Expand Down
3 changes: 2 additions & 1 deletion app/tasks/ClearCacheTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ private function clearFolder(string $message, string $folder)
$bar = new CliProgressBar($steps);
$bar
->setColorToGreen()
->display();
->display()
;
foreach ($iterator as $file) {
if (true !== $file->isDir() &&
('php' === $file->getExtension() || 'cache' === $file->getExtension())
Expand Down
1 change: 0 additions & 1 deletion app/tasks/GenerateSitemapTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use SplFileInfo;
use function Docs\Functions\app_path;
use function file_put_contents;
use function implode;
use function substr;

/**
Expand Down
9 changes: 3 additions & 6 deletions app/tasks/GetLanguagesTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,15 @@

namespace Docs\Cli\Tasks;

use function array_multisort;
use Phalcon\CLI\Task;
use function asort;
use function array_multisort;
use function Docs\Functions\app_path;
use function Docs\Functions\env;
use function file_put_contents;
use function json_decode;
use const SORT_ASC;
use const SORT_STRING;
use function sprintf;
use const PHP_EOL;
use function sprintf;
use const SORT_ASC;

/**
* GetLanguagesTask
Expand Down Expand Up @@ -67,7 +64,7 @@ public function mainAction()
'en' => [
'name' => 'English',
'code' => 'en',
]
],
];
foreach ($crowdin['languages'] as $language) {
$code = $languageMap[$language['code']] ?? 'en';
Expand Down
Loading