From 3dfa1651f61f287f490ddf7003c4748b8a68b3a5 Mon Sep 17 00:00:00 2001 From: Michael Babker Date: Sat, 18 Nov 2017 07:35:48 -0600 Subject: [PATCH 01/53] Start scaffolding for documentation area --- assets/scss/_global.scss | 49 +++++++++++++- assets/scss/font-awesome/_icons.scss | 2 +- assets/scss/pages/_homepage.scss | 8 ++- .../Documentation/IndexController.php | 60 +++++++++++++++++ src/Service/ApplicationProvider.php | 52 ++++++++++++++- src/View/Documentation/IndexHtmlView.php | 65 +++++++++++++++++++ templates/docs/index.twig | 27 ++++++++ templates/homepage.twig | 3 +- templates/index.twig | 3 +- www/media/css/template.css | 2 +- www/media/mix-manifest.json | 2 +- 11 files changed, 263 insertions(+), 10 deletions(-) create mode 100644 src/Controller/Documentation/IndexController.php create mode 100644 src/View/Documentation/IndexHtmlView.php create mode 100644 templates/docs/index.twig diff --git a/assets/scss/_global.scss b/assets/scss/_global.scss index 0b193f2d..cca8694a 100644 --- a/assets/scss/_global.scss +++ b/assets/scss/_global.scss @@ -26,7 +26,7 @@ a { position: relative; } -nav { +nav.main-nav { background: $darker-black; color: #ffffff; padding: .5rem 0; @@ -94,3 +94,50 @@ footer { margin-top: 0; } } + +.sidenav-body { + display: flex; + flex-wrap: wrap; + justify-content: space-around; + .sidebar { + flex-basis: 100%; + @include media-breakpoint-up(md) { + flex-basis: calc(25% - 1vw); + } + @include media-breakpoint-up(lg) { + flex-basis: calc(20% - 1vw); + } + } + .content { + flex-basis: 100%; + @include media-breakpoint-up(md) { + flex-basis: calc(75% - 1vw); + } + @include media-breakpoint-up(lg) { + flex-basis: calc(80% - 1vw); + } + } + @supports (display: grid) { + display: grid; + grid-template-columns: 1fr; + grid-gap: 1.25rem; + @include media-breakpoint-up(md) { + grid-template-columns: 25% 75%; + } + @include media-breakpoint-up(lg) { + grid-template-columns: 20% 80%; + } + .sidebar { + order: 2; + @include media-breakpoint-up(md) { + order: 1; + } + } + .content { + order: 1; + @include media-breakpoint-up(md) { + order: 2; + } + } + } +} diff --git a/assets/scss/font-awesome/_icons.scss b/assets/scss/font-awesome/_icons.scss index 17c40099..903568f7 100644 --- a/assets/scss/font-awesome/_icons.scss +++ b/assets/scss/font-awesome/_icons.scss @@ -362,7 +362,7 @@ //.#{$fa-css-prefix}-bitcoin:before, //.#{$fa-css-prefix}-btc:before { content: $fa-var-btc; } //.#{$fa-css-prefix}-file:before { content: $fa-var-file; } -//.#{$fa-css-prefix}-file-text:before { content: $fa-var-file-text; } +.#{$fa-css-prefix}-file-text:before { content: $fa-var-file-text; } //.#{$fa-css-prefix}-sort-alpha-asc:before { content: $fa-var-sort-alpha-asc; } //.#{$fa-css-prefix}-sort-alpha-desc:before { content: $fa-var-sort-alpha-desc; } //.#{$fa-css-prefix}-sort-amount-asc:before { content: $fa-var-sort-amount-asc; } diff --git a/assets/scss/pages/_homepage.scss b/assets/scss/pages/_homepage.scss index d3b35d0b..b8d935d5 100644 --- a/assets/scss/pages/_homepage.scss +++ b/assets/scss/pages/_homepage.scss @@ -2,8 +2,14 @@ nav.homepage { ul { li { margin-left: 5%; + @include media-breakpoint-up(md) { + margin-left: 1%; + } + @include media-breakpoint-up(lg) { + margin-left: 3%; + } @include media-breakpoint-up(xl) { - margin-left: 6%; + margin-left: 4%; } &:first-child { margin-left: 0; diff --git a/src/Controller/Documentation/IndexController.php b/src/Controller/Documentation/IndexController.php new file mode 100644 index 00000000..2b941d76 --- /dev/null +++ b/src/Controller/Documentation/IndexController.php @@ -0,0 +1,60 @@ +view = $view; + } + + /** + * Execute the controller. + * + * @return boolean + */ + public function execute() : bool + { + // Enable browser caching + $this->getApplication()->allowCache(true); + + $this->getApplication()->setResponse(new HtmlResponse($this->view->render())); + + return true; + } +} diff --git a/src/Service/ApplicationProvider.php b/src/Service/ApplicationProvider.php index eab2b818..bd306223 100644 --- a/src/Service/ApplicationProvider.php +++ b/src/Service/ApplicationProvider.php @@ -22,7 +22,7 @@ }; use Joomla\FrameworkWebsite\Command as AppCommands; use Joomla\FrameworkWebsite\Controller\{ - Api\PackageControllerGet, Api\StatusControllerGet, ContributorsController, HomepageController, PackageController, PageController, StatusController, WrongCmsController + Api\PackageControllerGet, Api\StatusControllerGet, ContributorsController, Documentation\IndexController, HomepageController, PackageController, PageController, StatusController, WrongCmsController }; use Joomla\FrameworkWebsite\Helper\{ GitHubHelper, PackagistHelper @@ -31,7 +31,7 @@ ContributorModel, PackageModel, ReleaseModel }; use Joomla\FrameworkWebsite\View\{ - Contributor\ContributorHtmlView, Package\PackageHtmlView, Package\PackageJsonView, Status\StatusHtmlView, Status\StatusJsonView + Contributor\ContributorHtmlView, Documentation\IndexHtmlView, Package\PackageHtmlView, Package\PackageJsonView, Status\StatusHtmlView, Status\StatusJsonView }; use Joomla\Github\Github; use Joomla\Http\Http; @@ -123,6 +123,9 @@ public function register(Container $container) $container->alias(ContributorsController::class, 'controller.contributors') ->share('controller.contributors', [$this, 'getControllerContributorsService'], true); + $container->alias(IndexController::class, 'controller.documentation.index') + ->share('controller.documentation.index', [$this, 'getControllerDocumentationIndexService'], true); + $container->alias(HomepageController::class, 'controller.homepage') ->share('controller.homepage', [$this, 'getControllerHomepageService'], true); @@ -152,6 +155,9 @@ public function register(Container $container) $container->alias(ContributorHtmlView::class, 'view.contributor.html') ->share('view.contributor.html', [$this, 'getViewContributorHtmlService'], true); + $container->alias(IndexHtmlView::class, 'view.documentation.index.html') + ->share('view.documentation.index.html', [$this, 'getViewDocumentationIndexHtmlService'], true); + $container->alias(PackageHtmlView::class, 'view.package.html') ->share('view.package.html', [$this, 'getViewPackageHtmlService'], true); @@ -335,6 +341,11 @@ public function getApplicationRouterService(Container $container) : Router ContributorsController::class ); + $router->get( + '/docs', + IndexController::class + ); + $router->get( '/status', StatusController::class @@ -430,7 +441,7 @@ public function getControllerApiStatusService(Container $container) : StatusCont } /** - * Get the `controller.homepage` service + * Get the `controller.contributors` service * * @param Container $container The DI container. * @@ -445,6 +456,22 @@ public function getControllerContributorsService(Container $container) : Contrib ); } + /** + * Get the `controller.documentation.index` service + * + * @param Container $container The DI container. + * + * @return IndexController + */ + public function getControllerDocumentationIndexService(Container $container) : IndexController + { + return new IndexController( + $container->get(IndexHtmlView::class), + $container->get(Input::class), + $container->get(WebApplication::class) + ); + } + /** * Get the `controller.homepage` service * @@ -704,6 +731,25 @@ public function getViewContributorHtmlService(Container $container) : Contributo return $view; } + /** + * Get the `view.documentation.index.html` service + * + * @param Container $container The DI container. + * + * @return IndexHtmlView + */ + public function getViewDocumentationIndexHtmlService(Container $container) : IndexHtmlView + { + $view = new IndexHtmlView( + $container->get('model.package'), + $container->get('renderer') + ); + + $view->setLayout('docs/index.twig'); + + return $view; + } + /** * Get the `view.package.html` service * diff --git a/src/View/Documentation/IndexHtmlView.php b/src/View/Documentation/IndexHtmlView.php new file mode 100644 index 00000000..26eb3a79 --- /dev/null +++ b/src/View/Documentation/IndexHtmlView.php @@ -0,0 +1,65 @@ +packageModel = $packageModel; + } + + /** + * Method to render the view + * + * @return string The rendered view + */ + public function render() + { + $packages = $this->packageModel->getPackages(); + + usort( + $packages, + function ($a, $b) + { + return strcmp($a->display, $b->display); + } + ); + + $this->setData( + [ + 'packages' => $packages, + ] + ); + + return parent::render(); + } +} diff --git a/templates/docs/index.twig b/templates/docs/index.twig new file mode 100644 index 00000000..7b862c2e --- /dev/null +++ b/templates/docs/index.twig @@ -0,0 +1,27 @@ +{% extends 'index.twig' %} + +{% block title %}Joomla! Framework Documentation{% endblock %} + +{% block content %} +
+

Framework Documentation

+ +
+ +
+ From this index you can browse the documentation for each of the Framework's packages. +
+
+
+{% endblock %} diff --git a/templates/homepage.twig b/templates/homepage.twig index 9d73d13b..d538a21a 100644 --- a/templates/homepage.twig +++ b/templates/homepage.twig @@ -1,13 +1,14 @@ {% extends "index.twig" %} {% block bodyNavigation %} -