diff --git a/docs/_static/css/extra.css b/docs/_static/css/extra.css new file mode 100644 index 0000000..0f9bb90 --- /dev/null +++ b/docs/_static/css/extra.css @@ -0,0 +1,3 @@ +.wy-menu p.caption { + margin-top: 10px; +} diff --git a/docs/img/settings/01.png b/docs/_static/img/settings/01.png similarity index 100% rename from docs/img/settings/01.png rename to docs/_static/img/settings/01.png diff --git a/docs/img/settings/02.png b/docs/_static/img/settings/02.png similarity index 100% rename from docs/img/settings/02.png rename to docs/_static/img/settings/02.png diff --git a/docs/img/settings/03.png b/docs/_static/img/settings/03.png similarity index 100% rename from docs/img/settings/03.png rename to docs/_static/img/settings/03.png diff --git a/docs/img/settings/04.png b/docs/_static/img/settings/04.png similarity index 100% rename from docs/img/settings/04.png rename to docs/_static/img/settings/04.png diff --git a/docs/img/tasks/01.png b/docs/_static/img/tasks/01.png similarity index 100% rename from docs/img/tasks/01.png rename to docs/_static/img/tasks/01.png diff --git a/docs/img/tasks/02.png b/docs/_static/img/tasks/02.png similarity index 100% rename from docs/img/tasks/02.png rename to docs/_static/img/tasks/02.png diff --git a/docs/img/tree/01.png b/docs/_static/img/tree/01.png similarity index 100% rename from docs/img/tree/01.png rename to docs/_static/img/tree/01.png diff --git a/docs/img/tree/02.png b/docs/_static/img/tree/02.png similarity index 100% rename from docs/img/tree/02.png rename to docs/_static/img/tree/02.png diff --git a/docs/crud.md b/docs/crud.md deleted file mode 100644 index e08882c..0000000 --- a/docs/crud.md +++ /dev/null @@ -1,2 +0,0 @@ -# Welcome to Murph FR - diff --git a/docs/crud/configuration.md b/docs/crud/configuration.md new file mode 100644 index 0000000..94c18d7 --- /dev/null +++ b/docs/crud/configuration.md @@ -0,0 +1,2 @@ +# Configuration + diff --git a/docs/crud/generator.md b/docs/crud/generator.md new file mode 100644 index 0000000..fd7bc68 --- /dev/null +++ b/docs/crud/generator.md @@ -0,0 +1,2 @@ +# Generator + diff --git a/docs/crud/index.md b/docs/crud/index.md new file mode 100644 index 0000000..7baeaf3 --- /dev/null +++ b/docs/crud/index.md @@ -0,0 +1,2 @@ +# CRUD + diff --git a/docs/settings.md b/docs/settings.md deleted file mode 100644 index d9909fb..0000000 --- a/docs/settings.md +++ /dev/null @@ -1,259 +0,0 @@ -# Settings - -## Global settings - -![](/img/settings/02.png) - -### Create settings - -The creation of settings is based on events. - -Using an event subscriber, you can create settings and define how to edit them. -A setting's value is stored in json so a value could be a string, a boolean, an array, etc. - -See the example below. - -``` -// src/EventSuscriber/SettingEventSubscriber.php -namespace App\EventSuscriber; - -use App\Core\Event\Setting\SettingEvent; -use App\Core\EventSuscriber\SettingEventSubscriber as EventSubscriber; -use App\Core\Setting\SettingManager; -use Symfony\Component\Form\Extension\Core\Type\CheckboxType; -use Symfony\Component\Form\Extension\Core\Type\ColorType; - -class SettingEventSubscriber extends EventSubscriber -{ - protected SettingManager $manager; - - public function __construct(SettingManager $manager) - { - $this->manager = $manager; - } - - public function onInit(SettingEvent $event) - { - $this->manager->init('app_font_color', 'Font color', 'Design', '#fff'); - $this->manager->init('app_background_color', 'Background color', 'Design', '#333'); - $this->manager->init('app_maintenance_enabled', 'Maintenance', 'System', false); - } - - public function onFormInit(SettingEvent $event) - { - $data = $event->getData(); - $builder = $data['builder']; - $entity = $data['entity']; - - if (in_array($entity->getCode(), ['app_font_color', 'app_background_color'])) { - $builder->add( - 'value', - ColorType::class, - [ - 'label' => $entity->getLabel(), - ] - ); - } - - if (in_array($entity->getCode(), ['app_maintenance_enabled'])) { - $builder->add( - 'value', - CheckboxType::class, - [ - 'label' => $entity->getLabel(), - ] - ); - } - } -} -``` - -### Access settings - -Settings are accessible using `App\Core\Setting\SettingManager` which is a service. - -``` -// src/Controller/FooController.php -namespace App\Controller; - -use App\Core\Setting\SettingManager; -use Symfony\Component\HttpFoundation\Response; - -class FooController -{ - public function foo(SettingManager $settingManager): Response - { - $fontColor = $settingManager->get('app_font_color'); - $backgroundColor = $settingManager->get('app_background_color'); - $maintenanceEnabled = $settingManager->get('app_maintenance_enabled'); - - // ... - } -} -``` - -In a template, you can use the function `setting`: - -``` -Font color: {{ setting('app_font_color') }}
-Background color: {{ setting('app_background_color') }}
-Maintenance enabled: {{ setting('app_maintenance_enabled') ? 'Yes' : 'No' }}
-``` - - -### Update settings - -Settings are accessible using `App\Core\Setting\SettingManager` which is a service. - -``` -// src/Controller/FooController.php -namespace App\Controller; - -use App\Core\Setting\SettingManager; -use Symfony\Component\HttpFoundation\Response; - -class FooController -{ - public function foo(SettingManager $settingManager): Response - { - $settingManager->set('app_font_color', '#f00'); - $settingManager->set('app_background_color', '#00f'); - $settingManager->set('app_maintenance_enabled', true); - - // ... - } -} -``` - -You can also edit them from UI: - -![](/img/settings/01.png) - - -## Navigation settings - -![](/img/settings/03.png) - -### Create settings - -The creation of settings is based on events. - -Using an event subscriber, you can create settings and define how to edit them. -A setting's value is stored in json so a value could be a string, a boolean, an array, etc. - -See the example below. - -``` -// src/EventSuscriber/NavigationSettingEventSubscriber.php -namespace App\EventSuscriber; - -use App\Core\Event\Setting\NavigationSettingEvent; -use App\Core\EventSuscriber\NavigationSettingEventSubscriber as EventSubscriber; -use App\Core\Setting\NavigationSettingManager; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\Extension\Core\Type\EmailType; - -class NavigationSettingEventSubscriber extends EventSubscriber -{ - protected NavigationSettingManager $manager; - - public function __construct(NavigationSettingManager $manager) - { - $this->manager = $manager; - } - - public function onInit(NavigationSettingEvent $event) - { - $data = $event->getData(); - $navigation = $data['navigation']; - - $this->manager->init($navigation, 'nav_tracker_code', 'Stats', 'Tracker', ''); - $this->manager->init($navigation, 'nav_contact_email', 'Contact', 'Email', 'foo@example.com'); - } - - public function onFormInit(NavigationSettingEvent $event) - { - $data = $event->getData(); - $builder = $data['builder']; - $entity = $data['entity']; - - if (in_array($entity->getCode(), ['nav_tracker_code'])) { - $builder->add( - 'value', - TextType::class, - [ - 'label' => $entity->getLabel(), - ] - ); - } - - if (in_array($entity->getCode(), ['nav_contact_email'])) { - $builder->add( - 'value', - EmailType::class, - [ - 'label' => $entity->getLabel(), - ] - ); - } - } -} -``` - -### Access settings - -Settings are accessible using `App\Core\Setting\NavigationSettingManager` which is a service. - -``` -// src/Controller/FooController.php -namespace App\Controller; - -use App\Core\Setting\NavigationSettingManager; -use App\Core\Site\SiteRequest; -use Symfony\Component\HttpFoundation\Response; - -class FooController -{ - public function foo(NavigationSettingManager $settingManager, SiteRequest $siteRequest): Response - { - $trackerCode = $settingManager->get($siteRequest->getNavigation(), 'nav_tracker_code'); - $contactEmail = $settingManager->get($siteRequest->getNavigation(), 'nav_contact_email'); - - // ... - } -} -``` - -In a template, you can use the function `navigation_setting`: - -``` -Tracker code: {{ navigation_setting(_navigation, 'nav_tracker_code') }}
-Contact email: {{ navigation_setting('my_nav', 'nav_contact_email') }}
-``` -### Update settings - -Settings are accessible using `App\Core\Setting\NavigationSettingManager` which is a service. - -``` -// src/Controller/FooController.php -namespace App\Controller; - -use App\Core\Setting\NavigationSettingManager; -use App\Core\Site\SiteRequest; -use Symfony\Component\HttpFoundation\Response; - -class FooController -{ - public function foo(NavigationSettingManager $settingManager, SiteRequest $siteRequest): Response - { - $settingManager->set($siteRequest->getNavigation(), 'nav_tracker_code', '...'); - $settingManager->set('my_nav', 'nav_contact_email', '...'); - - // ... - } -} -``` - -You can also edit them from UI: - -![](/img/settings/04.png) diff --git a/docs/settings/global.md b/docs/settings/global.md new file mode 100644 index 0000000..65ed67e --- /dev/null +++ b/docs/settings/global.md @@ -0,0 +1,127 @@ +# Global settings + +![](/_static/img/settings/02.png) + +## Create settings + +The creation of settings is based on events. + +Using an event subscriber, you can create settings and define how to edit them. +A setting's value is stored in json so a value could be a string, a boolean, an array, etc. + +See the example below. + +``` +// src/EventSuscriber/SettingEventSubscriber.php +namespace App\EventSuscriber; + +use App\Core\Event\Setting\SettingEvent; +use App\Core\EventSuscriber\SettingEventSubscriber as EventSubscriber; +use App\Core\Setting\SettingManager; +use Symfony\Component\Form\Extension\Core\Type\CheckboxType; +use Symfony\Component\Form\Extension\Core\Type\ColorType; + +class SettingEventSubscriber extends EventSubscriber +{ + protected SettingManager $manager; + + public function __construct(SettingManager $manager) + { + $this->manager = $manager; + } + + public function onInit(SettingEvent $event) + { + $this->manager->init('app_font_color', 'Font color', 'Design', '#fff'); + $this->manager->init('app_background_color', 'Background color', 'Design', '#333'); + $this->manager->init('app_maintenance_enabled', 'Maintenance', 'System', false); + } + + public function onFormInit(SettingEvent $event) + { + $data = $event->getData(); + $builder = $data['builder']; + $entity = $data['entity']; + + if (in_array($entity->getCode(), ['app_font_color', 'app_background_color'])) { + $builder->add( + 'value', + ColorType::class, + [ + 'label' => $entity->getLabel(), + ] + ); + } + + if (in_array($entity->getCode(), ['app_maintenance_enabled'])) { + $builder->add( + 'value', + CheckboxType::class, + [ + 'label' => $entity->getLabel(), + ] + ); + } + } +} +``` + +## Access settings + +Settings are accessible using `App\Core\Setting\SettingManager` which is a service. + +``` +// src/Controller/FooController.php +namespace App\Controller; + +use App\Core\Setting\SettingManager; +use Symfony\Component\HttpFoundation\Response; + +class FooController +{ + public function foo(SettingManager $settingManager): Response + { + $fontColor = $settingManager->get('app_font_color'); + $backgroundColor = $settingManager->get('app_background_color'); + $maintenanceEnabled = $settingManager->get('app_maintenance_enabled'); + + // ... + } +} +``` + +In a template, you can use the function `setting`: + +``` +Font color: {{ setting('app_font_color') }}
+Background color: {{ setting('app_background_color') }}
+Maintenance enabled: {{ setting('app_maintenance_enabled') ? 'Yes' : 'No' }}
+``` + +## Update settings + +Settings are accessible using `App\Core\Setting\SettingManager` which is a service. + +``` +// src/Controller/FooController.php +namespace App\Controller; + +use App\Core\Setting\SettingManager; +use Symfony\Component\HttpFoundation\Response; + +class FooController +{ + public function foo(SettingManager $settingManager): Response + { + $settingManager->set('app_font_color', '#f00'); + $settingManager->set('app_background_color', '#00f'); + $settingManager->set('app_maintenance_enabled', true); + + // ... + } +} +``` + +You can also edit them from UI: + +![](/_static/img/settings/01.png) diff --git a/docs/settings/navigation.md b/docs/settings/navigation.md new file mode 100644 index 0000000..e7194b1 --- /dev/null +++ b/docs/settings/navigation.md @@ -0,0 +1,128 @@ +# Navigation settings + +![](/_static/img/settings/03.png) + +## Create settings + +The creation of settings is based on events. + +Using an event subscriber, you can create settings and define how to edit them. +A setting's value is stored in json so a value could be a string, a boolean, an array, etc. + +See the example below. + +``` +// src/EventSuscriber/NavigationSettingEventSubscriber.php +namespace App\EventSuscriber; + +use App\Core\Event\Setting\NavigationSettingEvent; +use App\Core\EventSuscriber\NavigationSettingEventSubscriber as EventSubscriber; +use App\Core\Setting\NavigationSettingManager; +use Symfony\Component\Form\Extension\Core\Type\TextType; +use Symfony\Component\Form\Extension\Core\Type\EmailType; + +class NavigationSettingEventSubscriber extends EventSubscriber +{ + protected NavigationSettingManager $manager; + + public function __construct(NavigationSettingManager $manager) + { + $this->manager = $manager; + } + + public function onInit(NavigationSettingEvent $event) + { + $data = $event->getData(); + $navigation = $data['navigation']; + + $this->manager->init($navigation, 'nav_tracker_code', 'Stats', 'Tracker', ''); + $this->manager->init($navigation, 'nav_contact_email', 'Contact', 'Email', 'foo@example.com'); + } + + public function onFormInit(NavigationSettingEvent $event) + { + $data = $event->getData(); + $builder = $data['builder']; + $entity = $data['entity']; + + if (in_array($entity->getCode(), ['nav_tracker_code'])) { + $builder->add( + 'value', + TextType::class, + [ + 'label' => $entity->getLabel(), + ] + ); + } + + if (in_array($entity->getCode(), ['nav_contact_email'])) { + $builder->add( + 'value', + EmailType::class, + [ + 'label' => $entity->getLabel(), + ] + ); + } + } +} +``` + +## Access settings + +Settings are accessible using `App\Core\Setting\NavigationSettingManager` which is a service. + +``` +// src/Controller/FooController.php +namespace App\Controller; + +use App\Core\Setting\NavigationSettingManager; +use App\Core\Site\SiteRequest; +use Symfony\Component\HttpFoundation\Response; + +class FooController +{ + public function foo(NavigationSettingManager $settingManager, SiteRequest $siteRequest): Response + { + $trackerCode = $settingManager->get($siteRequest->getNavigation(), 'nav_tracker_code'); + $contactEmail = $settingManager->get($siteRequest->getNavigation(), 'nav_contact_email'); + + // ... + } +} +``` + +In a template, you can use the function `navigation_setting`: + +``` +Tracker code: {{ navigation_setting(_navigation, 'nav_tracker_code') }}
+Contact email: {{ navigation_setting('my_nav', 'nav_contact_email') }}
+``` + +## Update settings + +Settings are accessible using `App\Core\Setting\NavigationSettingManager` which is a service. + +``` +// src/Controller/FooController.php +namespace App\Controller; + +use App\Core\Setting\NavigationSettingManager; +use App\Core\Site\SiteRequest; +use Symfony\Component\HttpFoundation\Response; + +class FooController +{ + public function foo(NavigationSettingManager $settingManager, SiteRequest $siteRequest): Response + { + $settingManager->set($siteRequest->getNavigation(), 'nav_tracker_code', '...'); + $settingManager->set('my_nav', 'nav_contact_email', '...'); + + // ... + } +} +``` + +You can also edit them from UI: + +![](/_static/img/settings/04.png) diff --git a/docs/tree/index.md b/docs/tree/index.md new file mode 100644 index 0000000..890a450 --- /dev/null +++ b/docs/tree/index.md @@ -0,0 +1,12 @@ +# Tree manager + +Murph manages contents this way: + +* You define navigations +* For each navigation, you define menus +* For each menu, you define elements (nodes) +* and for each element, you define: + - an optional page + - the routing + - some attributes + - a sitemap configuration diff --git a/docs/tree/menu.md b/docs/tree/menu.md new file mode 100644 index 0000000..60246e0 --- /dev/null +++ b/docs/tree/menu.md @@ -0,0 +1,10 @@ +# Menu + +To create a menu, go to `Trees`, select the navigation and click on `Add a menu`. Then fill the form and save. + +* The `label` is the label displayed whenever necessary (eg: `Top menu`) +* The `code` is an unique technical identifier (in the given navigation) and it is useful in templating, routing and settings (eg: `top`) + +When a menu is created then an element is automatically generated. + +![](/_static/img/tree/02.png) diff --git a/docs/tree.md b/docs/tree/navigation.md similarity index 50% rename from docs/tree.md rename to docs/tree/navigation.md index a914572..fc51f6b 100644 --- a/docs/tree.md +++ b/docs/tree/navigation.md @@ -1,17 +1,4 @@ -# Tree manager - -Murph manages contents this way: - -* You define navigations -* For each navigation, you define menus -* For each menu, you define elements (nodes) -* and for each element, you define: - - an optional page - - the routing - - some attributes - - a sitemap configuration - -## Navigation +# Navigation To create a navigation, go to `Navigations` and click on `New`. Then fill the form and save. @@ -24,15 +11,4 @@ To create a navigation, go to `Navigations` and click on `New`. Then fill the fo If several navigations share the same domain, then the locale will by used to prefix routes. But if a navigation uses a single domain then the local will not prefix routes. -![](/img/tree/01.png) - -## Menu - -To create a menu, go to `Trees`, select the navigation and click on `Add a menu`. Then fill the form and save. - -* The `label` is the label displayed whenever necessary (eg: `Top menu`) -* The `code` is an unique technical identifier (in the given navigation) and it is useful in templating, routing and settings (eg: `top`) - -When a menu is created then an element is automatically generated. - -![](/img/tree/02.png) +![](/_static/img/tree/01.png) diff --git a/docs/users.md b/docs/users.md index e08882c..c204f32 100644 --- a/docs/users.md +++ b/docs/users.md @@ -1,2 +1,2 @@ -# Welcome to Murph FR +# Users diff --git a/mkdocs.yml b/mkdocs.yml index f09be14..3bf1104 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,10 +1,23 @@ site_name: Murph documentation -theme: readthedocs +theme: + name: readthedocs +extra_css: + - /_static/css/extra.css nav: - Overview: index.md - Installation: install.md - - Tree manager: tree.md - - CRUD: crud.md - - Settings: settings.md - - Users: users.md - - Tasks: tasks.md + - 'Tree manager': + - Overview: tree/index.md + - Navigation: tree/navigation.md + - Menu: tree/menu.md + - CRUD: + - Overview: crud/index.md + - Generator: crud/generator.md + - Configuration: crud/configuration.md + - Settings: + - 'Global settings': settings/global.md + - 'Navigation settings': settings/navigation.md + - Users: + - Users: users.md + - Others: + - Tasks: tasks.md