Skip to content

Commit

Permalink
Introduced brand new design
Browse files Browse the repository at this point in the history
Many thanks to @dzantiev, @Spurius96 and all O2 Team.
  • Loading branch information
Spurius96 authored and sergeyklay committed Feb 6, 2018
1 parent a87c8a9 commit c92c229
Show file tree
Hide file tree
Showing 305 changed files with 156,214 additions and 1,406 deletions.
33 changes: 24 additions & 9 deletions .editorconfig
@@ -1,15 +1,30 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true
charset = utf-8
trim_trailing_whitespace = true
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
charset = utf-8
end_of_line = lf

[*.{bat,sh}]
indent_style = tab
tab_width = 4
trim_trailing_whitespace = true
insert_final_newline = true

[*.php]
indent_style = space
trim_trailing_whitespace = true
insert_final_newline = true

[*.{yml,sh}]
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
insert_final_newline = true

[*.sh]
indent_style = tab
[*.md]
indent_style = space
trim_trailing_whitespace = false
insert_final_newline = true
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -9,4 +9,4 @@
/.env
/public/report.html
/public/google*.html
/public/sitemap.xml
/public/sitemap.xml
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -7,6 +7,7 @@ group: edge
php:
- 7.0
- 7.1
- 7.2

git:
depth: 1
Expand Down
10 changes: 5 additions & 5 deletions app/config/languages.php
Expand Up @@ -19,21 +19,21 @@
'ar' => 'العَرَبِيَّة‎‎',
'bg' => 'Bosanski',
'bs' => 'Български',
'zh' => '中文',
'hr' => 'Рrvatski',
'cs' => 'Čeština',
'en' => 'English',
'fr' => 'Français',
'de' => 'Deutsch',
'el' => 'Ελληνικά',
'hu' => 'Magyar',
'id' => 'Bahasa Indonesia',
'ja' => '日本語',
'pl' => 'Język polski',
'id' => 'Indonesian',
'pl' => 'Polski',
'pt' => 'Português',
'ru' => 'Русский',
'es' => 'Español',
'tr' => 'Türkçe',
'uk' => 'Українська мова',
'uk' => 'Українська',
'vi' => 'Tiếng Việt',
'zh' => '中文',
'ja' => '日本語',
];
1 change: 1 addition & 0 deletions app/config/routes.php
Expand Up @@ -27,6 +27,7 @@
'/{l:[a-z]{2}}/{v}/{p}' => 'mainAction',
'/{l:[a-z]{2}}/{v}/api/{p}' => 'mainAction',
'/sitemap.xml' => 'sitemapAction',
'/search' => 'searchAction',
],

// This is exactly the same execution as GET, but the Response has no body
Expand Down
18 changes: 18 additions & 0 deletions app/config/versions.php
@@ -0,0 +1,18 @@
<?php

/*
+------------------------------------------------------------------------+
| Phalcon |
+------------------------------------------------------------------------+
| Copyright (c) 2011-2017 Phalcon Team (https://phalconphp.com) |
+------------------------------------------------------------------------+
| This source file is subject to the New BSD License that is bundled |
| with this package in the file LICENSE.txt. |
| |
| If you did not receive a copy of the license and are unable to |
| obtain it through the world-wide-web, please send an email |
| to license@phalconphp.com so we can send you a copy immediately. |
+------------------------------------------------------------------------+
*/

return ['3.1','3.2'];
115 changes: 104 additions & 11 deletions app/controllers/BaseController.php
Expand Up @@ -15,17 +15,17 @@
+------------------------------------------------------------------------+
*/

namespace Docs\Controllers;

use function file_exists;
use Phalcon\Config;
use Phalcon\Mvc\View\Simple;
use Phalcon\Cache\BackendInterface;
use Phalcon\Mvc\Controller as PhController;
use function Docs\Functions\config;
use function Docs\Functions\app_path;
use function Docs\Functions\environment;
use function var_dump;
namespace Docs\Controllers;

use function file_exists;
use Phalcon\Config;
use Phalcon\Mvc\View\Simple;
use Phalcon\Cache\BackendInterface;
use Phalcon\Mvc\Controller as PhController;
use function Docs\Functions\config;
use function Docs\Functions\app_path;
use function Docs\Functions\environment;
use function var_dump;

/**
* Docs\Controllers\BaseController
Expand Down Expand Up @@ -75,6 +75,99 @@ protected function getSeoTitle(string $language, string $version, string $page):
return $title;
}

/**
*
*/
public function getSidebar($language, $version):array
{
$pageName = app_path(
sprintf(
'docs/%s/%s/%s.md',
$version,
$language,
'sidebar'
)
);
$apiFileName = app_path(
sprintf(
'docs/%s/%s/api/%s.md',
$version,
$language,
'sidebar'
)
);

if (file_exists($pageName)) {
$data = file_get_contents($pageName);
} elseif (file_exists($apiFileName)) {
$data = file_get_contents($apiFileName);
} else {
// The article does not exist
return '';
}

$namespaces = $this->getNamespaces();
$search = array_keys($namespaces);
$replace = array_values($namespaces);

/**
* API links
*/
$data = str_replace($search, $replace, $data);

/**
* Language and version
*/
$data = str_replace(
[
'[[language]]',
'[[version]]'
],
[
$language,
$this->getVersion()
],
$data
);

$data = explode("\n", $data);
$data = array_diff($data, ['']);
$data = array_diff($data, [' ']);
$parseMarkDown = [];
$parseMarkDownItem = [];
$menuItemKey = 0;

foreach($data as $key => $dataItem)
{
if(preg_match('/(- \w+.*)/iu',$dataItem,$matches))
{
unset($parseMarkDownItem);
// создаю элемент меню
$parseMarkDown[$menuItemKey] = [
'name' => str_replace(["- "], "", $matches[0]),
'subItems' => []
];
$parseMarkDownItem = &$parseMarkDown[$menuItemKey]['subItems'];
$menuItemKey++;

continue;
}
else
{
preg_match('/(- \[\w+.*\])/iu', $dataItem,$subName);
preg_match('/](\(.*\w+.*)/iu', $dataItem,$subLink);


$parseMarkDownItem[$key] = [
'subName' => str_replace(["- [","]"], "", $subName[0]),
'subLink' => str_replace(["]","(",")"], "", $subLink[0])
];
}
}

return $parseMarkDown;
}

/**
* @param string $language
* @param string $version
Expand Down
54 changes: 45 additions & 9 deletions app/controllers/DocsController.php
Expand Up @@ -32,6 +32,35 @@ public function redirectAction(): ResponseInterface
return $this->response->redirect(base_url($this->getVersion('/en/')));
}

/**
* @param null|string $language
* @param null|string $version
* @param string $page
*
* @return ResponseInterface
* @throws HttpException
*/
public function searchAction(string $language = null, string $version = null): ResponseInterface
{
$language = 'en';
$version = $this->getVersion();
$page = 'introduction';

$renderFile = 'index/search';
$contents = $this->viewSimple->render(
$renderFile,
[
'language' => $language,
'version' => $version,
'topicsArray' => $this->getSidebar($language, $version),
'menu' => $this->getDocument($language, $version, $page . '-menu'),
]
);
$this->response->setContent($contents);

return $this->response;
}

/**
* @param null|string $language
* @param null|string $version
Expand All @@ -54,14 +83,19 @@ public function mainAction(string $language = null, string $version = null, stri

$version = $this->getVersion('', $version);

$renderFile = 'index/article';
if (empty($page)) {
$page = 'introduction';
$renderFile = 'index/index';
$page = 'introduction';
}

if (!$article = $this->getDocument($language, $version, $page)) {
throw new HttpException('Not Found', 404);
}

preg_match('/(<div.*?<\/div>)/ius', $article, $article_menu);
$article = preg_replace('/(<div.*?<\/div>)/ius', "", $article);

$canonical = Text::reduceSlashes(base_url("{$language}/{$version}/{$page}"));

// @todo
Expand All @@ -75,14 +109,16 @@ public function mainAction(string $language = null, string $version = null, stri
$this->tag->setTitle($this->getSeoTitle($language, $version, $page));

$contents = $this->viewSimple->render(
'index/index',
$renderFile,
[
'language' => $language,
'version' => $version,
'sidebar' => $this->getDocument($language, $version, 'sidebar'),
'article' => $article,
'menu' => $this->getDocument($language, $version, $page . '-menu'),
'canonical' => $canonical,
'language' => $language,
'version' => $version,
'topicsArray' => $this->getSidebar($language, $version),
//'sidebar' => $this->getDocument($language, $version, 'sidebar'),
'article' => $article,
'article_menu' => $article_menu ? $article_menu[0] : [],
'menu' => $this->getDocument($language, $version, $page . '-menu'),
'canonical' => $canonical,
]
);
$this->response->setContent($contents);
Expand Down
25 changes: 21 additions & 4 deletions app/providers/Assets/ServiceProvider.php
Expand Up @@ -55,6 +55,21 @@ function ($lang) {
);
$supportedJs = implode('+', ['highlight.min.js'] + $supportedJs);

/*$jsCdn = "https://cdn.jsdelivr.net/g/jquery@3.1.1,"
. "bootstrap@3.3.7,"
. "highlight.js@{$highlightVersion}({$supportedJs})";
$assets
->collection('header_css')
->addCss(assets_uri('css/docs.css', $version));
$assets
->collection('footer_js')
->addJs($jsCdn, false)
->addJs(assets_uri('js/edit_button.js', $version));
*/


$cssCdn = "https://cdn.jsdelivr.net/g/font-lato@2.0(Lato/Lato-Black.css),"
. "bootstrap@3.3.7(css/bootstrap.min.css),"
. "highlight.js@{$highlightVersion}(styles/monokai-sublime.min.css)";
Expand All @@ -64,12 +79,14 @@ function ($lang) {

$assets
->collection('header_css')
->addCss($cssCdn, false)
->addCss(assets_uri('css/docs.css', $version));
//->addCss($cssCdn, false)
->addCss(assets_uri('js/highlight/styles/hybrid.css', $version))
->addCss(assets_uri('css/style.css', $version));

$assets
->collection('footer_js')
->addJs($jsCdn, false)
->addJs(assets_uri('js/edit_button.js', $version));
//->addJs($jsCdn, false);
->addJs(assets_uri('js/main.min.js', $version))
->addJs(assets_uri('js/highlight/highlight.pack.js', $version));
}
}

0 comments on commit c92c229

Please sign in to comment.