From 231a500a52ab6934b98184efcdef808e94080274 Mon Sep 17 00:00:00 2001 From: dignajar Date: Sun, 7 Feb 2021 22:03:53 +0100 Subject: [PATCH] add some documentation to the readme, now all plugins print the description in the settings form its possible disable as well, clean up css, and refactor Categories plugin --- README.md | 90 ++++++------------- .../admin/controllers/plugins-settings.php | 9 ++ bl-kernel/admin/themes/booty/css/bludit.css | 37 -------- bl-kernel/admin/views/plugins-settings.php | 26 +++--- bl-kernel/functions.php | 2 +- bl-kernel/helpers/bootstrap.class.php | 7 +- bl-plugins/categories/plugin.php | 29 +++--- 7 files changed, 63 insertions(+), 137 deletions(-) diff --git a/README.md b/README.md index 3de040b4..7029eb8a 100644 --- a/README.md +++ b/README.md @@ -1,76 +1,36 @@ [Bludit](https://www.bludit.com/) ================================ -**Simple**, **Fast** and **Flexible** CMS. -Bludit is a web application to build your own **website** or **blog** in seconds, it's completely **free and open source**. Bludit uses files in JSON format to store the content, you don't need to install or configure a database. You only need a web server with PHP support. - -Bludit is a **Flat-File** CMS. - -Bludit supports **Markdown** and **HTML code** for the content. - -- [Plugins](https://plugins.bludit.com) -- [Themes](https://themes.bludit.com) -- [Documentation](https://docs.bludit.com) -- Help and Support [Forum](https://forum.bludit.org) and [Chat](https://gitter.im/bludit/support) - -Follow Bludit ---------------- - -- [Blog](https://blog.bludit.com) -- [Twitter](https://twitter.com/bludit) -- [Facebook](https://www.facebook.com/bluditcms) -- [Youtube](https://www.youtube.com/c/Bluditcms) - -Requirements ------------- - -You just need a web server with PHP support. - -- PHP v5.6 or higher version. -- PHP [mbstring](http://php.net/manual/en/book.mbstring.php) module for full UTF-8 support. -- PHP [gd](http://php.net/manual/en/book.image.php) module for image processing. -- PHP [dom](http://php.net/manual/en/book.dom.php) module for DOM manipulation. -- PHP [json](http://php.net/manual/en/book.json.php) module for JSON manipulation. -- Supported web servers: - * Bludit supports almost every web server - * PHP Built-in web server (`php -S localhost:8000`) - -Installation Guide ------------------- - -1. Download the latest version from the official page. [Bludit.com](https://www.bludit.com) -2. Extract the zip file into a directory like `bludit`. -3. Upload the directory `bludit` to your web server or hosting. -4. Visit your domain https://example.com/bludit/ -5. Follow the Bludit Installer to configure the website. - -Docker Image ------------- -Official Docker image on Docker Hub. -- https://hub.docker.com/r/bludit/docker/ - -Also we provide Kubernetes deployments yaml files. -- https://github.com/bludit/docker/tree/master/kubernetes - -Support Bludit! +Dear developers ------- -Bludit is open soruce and free, but if you really like the project and is useful for your you can contribute in [Patreon](https://www.patreon.com/bePatron?c=921115&rid=2458860), also for the supporters we provide Bludit PRO. -[![Bludit PRO](https://img.shields.io/badge/Bludit-PRO-blue.svg)](https://pro.bludit.com/) +## Frameworks and libraries included in Bludit v4 +Bludit will include the following frameworks, please use them with they native functions. -### Platinum sponsors in Patreon! +Frontend: +- Bootstrap v5. +- Boostrap icons. +- jQuery, you can use vanilla Javascript but for events in the views please use jQuery. -- Clickwork -- KreativMind -- Curious Activity -- Matěj Adámek -- pytesNET +Backend: +- `bl-kernel/functions.php` provides the global function for Bludit; These functions provide connectivity between different objects and databases; These functions should provide different checks and logic before add/edit/delete into the databases. +- PHP SimpleImage for processing images: https://github.com/claviska/SimpleImage -### Golden sponsors in Patreon! +## Comments for functions and methods +Please add the following structure commenting what it does the function, also add the stamp `=== Bludit v4` so I know what is new. +``` +/* Delete a page === Bludit v4 -- Thomas Kreth -- Christian + @key string Array => (key: string) + @return string/bool Returns the page key on successful delete, FALSE otherwise +*/ +function deletePage($args) { + ... +} +``` -License +## Controller and views structure +Please follow complete example for + +Documentation for Bludit v4 ------- -Bludit is open source software licensed under the [MIT license](https://tldrlegal.com/license/mit-license). diff --git a/bl-kernel/admin/controllers/plugins-settings.php b/bl-kernel/admin/controllers/plugins-settings.php index 97931461..1d0d7981 100644 --- a/bl-kernel/admin/controllers/plugins-settings.php +++ b/bl-kernel/admin/controllers/plugins-settings.php @@ -29,5 +29,14 @@ if (!method_exists($plugin, 'form')) { Redirect::page('plugins'); } +// Save the settings +if ($_SERVER['REQUEST_METHOD'] == 'POST') { + $plugin->post(); + $syslog->add(array( + 'dictionaryKey'=>'plugin-configured', + 'notes'=>$plugin->name() + )); +} + // HTML $layout['title'] = $L->g('Plugin'). ' [ ' .$plugin->name(). ' ] ' . ' - ' . $layout['title']; \ No newline at end of file diff --git a/bl-kernel/admin/themes/booty/css/bludit.css b/bl-kernel/admin/themes/booty/css/bludit.css index a56bd26f..5844d778 100644 --- a/bl-kernel/admin/themes/booty/css/bludit.css +++ b/bl-kernel/admin/themes/booty/css/bludit.css @@ -61,40 +61,3 @@ div.sidebar .nav-item h4 { -/* - PLUGINS -*/ - -.plugin-form label { - display: block; - margin-top: 1rem !important; -} - -.plugin-form input[type="text"], -.plugin-form textarea, -.plugin-form select { - display: block; - width: 100%; - padding: .375rem .75rem; - font-size: 1rem; - line-height: 1.5; - color: #495057; - background-color: #fff; - background-clip: padding-box; - border: 1px solid #ced4da; - border-radius: .25rem; - transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out; -} - -.plugin-form textarea { - min-height: 120px; -} - -.plugin-form span.tip { - display: block; - font-size: 80%; - font-weight: 400; - margin-top: .25rem; - color: #6c757d !important; -} - diff --git a/bl-kernel/admin/views/plugins-settings.php b/bl-kernel/admin/views/plugins-settings.php index 03224ceb..2c377e26 100644 --- a/bl-kernel/admin/views/plugins-settings.php +++ b/bl-kernel/admin/views/plugins-settings.php @@ -24,26 +24,28 @@ }); </script> -<?php echo Bootstrap::formOpen(array('id'=>'jsform', 'class'=>'plugin-form')); ?> +<?php echo Bootstrap::formOpen(array('name' => 'pluginSettings')); ?> -<div class="align-middle"> - <?php if ($plugin->formButtons()): ?> - <div class="float-end mt-1"> - <button type="submit" class="btn btn-primary btn-sm" name="save"><?php $L->p('Save') ?></button> - <a class="btn btn-secondary btn-sm" href="<?php echo HTML_PATH_ADMIN_ROOT.'plugins' ?>" role="button"><?php $L->p('Cancel') ?></a> - </div> +<div class="d-flex align-items-center mb-3"> + <h2 class="m-0"><i class="bi bi-node-plus"></i><?php echo $plugin->name() ?></h2> + <?php if ($plugin->formButtons()) : ?> + <div class="ms-auto"> + <button type="submit" class="btn btn-primary btn-sm" name="save"><?php $L->p('Save') ?></button> + <a class="btn btn-secondary btn-sm" href="<?php echo HTML_PATH_ADMIN_ROOT . 'plugins' ?>" role="button"><?php $L->p('Cancel') ?></a> + </div> <?php endif; ?> - <?php echo Bootstrap::pageTitle(array('title'=>$plugin->name(), 'icon'=>'cog')); ?> </div> <?php - // Token CSRF echo Bootstrap::formInputHidden(array( - 'name'=>'tokenCSRF', - 'value'=>$security->getTokenCSRF() + 'name' => 'tokenCSRF', + 'value' => $security->getTokenCSRF() )); - // Print the plugin form + if ($plugin->description()) { + echo '<div class="alert alert-primary" role="alert">'.$plugin->description().'</div>'; + } + echo $plugin->form(); ?> diff --git a/bl-kernel/functions.php b/bl-kernel/functions.php index f0346bb8..69b6291b 100644 --- a/bl-kernel/functions.php +++ b/bl-kernel/functions.php @@ -3,7 +3,7 @@ /* ---------------------------------------------------------------------------- Global functions These functions provide connectivity between different objects and databases. - These function should provide different checks and logic before add/edit/delete into the databases. + These functions should provide different checks and logic before add/edit/delete into the databases. For example, the creation of a user should check: - if the user already exists diff --git a/bl-kernel/helpers/bootstrap.class.php b/bl-kernel/helpers/bootstrap.class.php index 85c0b732..3c0e38c2 100644 --- a/bl-kernel/helpers/bootstrap.class.php +++ b/bl-kernel/helpers/bootstrap.class.php @@ -199,8 +199,9 @@ EOF; public static function formOpen($args) { + $name = $args['name']; + $id = isset($args['id'])?$args['id']:$name; $class = empty($args['class'])?'':'class="'.$args['class'].'"'; - $id = empty($args['id'])?'':'id="'.$args['id'].'"'; $enctype = empty($args['enctype'])?'':'enctype="'.$args['enctype'].'"'; $action = empty($args['action'])?'action=""':'action="'.$args['action'].'"'; $method = empty($args['method'])?'method="post"':'method="'.$args['method'].'"'; @@ -213,9 +214,7 @@ EOF; public static function formClose() { -return <<<EOF -</form> -EOF; + return '</form>'; } diff --git a/bl-plugins/categories/plugin.php b/bl-plugins/categories/plugin.php index 7a0135ab..183efcba 100644 --- a/bl-plugins/categories/plugin.php +++ b/bl-plugins/categories/plugin.php @@ -1,34 +1,29 @@ <?php - class pluginCategories extends Plugin { public function init() { - // Fields and default values for the database of this plugin + // Key and default values for the plugin database $this->dbFields = array( 'label'=>'Categories', 'hideCero'=>true ); } - // Method called on the settings of the plugin on the admin area + // Returns the custom form for the plugin's settings for display in the admin panel public function form() { global $L; - $html = '<div class="alert alert-primary" role="alert">'; - $html .= $this->description(); + $html = '<div class="mb-3">'; + $html .= '<label class="form-label" for="label">'.$L->get('Label').'</label>'; + $html .= '<input class="form-control" id="label" name="label" type="text" value="'.$this->getValue('label').'">'; + $html .= '<div class="form-text">'.$L->get('This title is almost always used in the sidebar of the site').'</div>'; $html .= '</div>'; - $html .= '<div>'; - $html .= '<label>'.$L->get('Label').'</label>'; - $html .= '<input name="label" type="text" value="'.$this->getValue('label').'">'; - $html .= '<span class="tip">'.$L->get('This title is almost always used in the sidebar of the site').'</span>'; - $html .= '</div>'; - - $html .= '<div>'; - $html .= '<label>'.$L->get('Hide Categories without content').'</label>'; - $html .= '<select name="hideCero">'; + $html .= '<div class="mb-3">'; + $html .= '<label class="form-label" for="hideCero">'.$L->get('Hide Categories without content').'</label>'; + $html .= '<select class="form-select" id="hideCero" name="hideCero">'; $html .= '<option value="true" '.($this->getValue('hideCero')===true?'selected':'').'>'.$L->get('Enabled').'</option>'; $html .= '<option value="false" '.($this->getValue('hideCero')===false?'selected':'').'>'.$L->get('Disabled').'</option>'; $html .= '</select>'; @@ -37,19 +32,17 @@ class pluginCategories extends Plugin { return $html; } - // Method called on the sidebar of the website + // Returns the sidebar for display in the website public function siteSidebar() { - global $L; global $categories; - // HTML for sidebar $html = '<div class="plugin plugin-categories">'; $html .= '<h2 class="plugin-label">'.$this->getValue('label').'</h2>'; $html .= '<div class="plugin-content">'; $html .= '<ul>'; - // By default the database of categories are alphanumeric sorted + // By default the categories database is alphanumeric sorted foreach ($categories->db as $key=>$fields) { $count = count($fields['list']); if (!$this->getValue('hideCero') || $count>0) {