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

This commit is contained in:
dignajar 2021-02-07 22:03:53 +01:00
parent f2b8955e96
commit 231a500a52
7 changed files with 63 additions and 137 deletions

View file

@ -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.
- <a href="https://www.patreon.com/clickwork" target="_blank">Clickwork</a>
- <a href="https://www.patreon.com/user/creators?u=10331784" target="_blank">KreativMind</a>
- <a href="https://www.patreon.com/user/creators?u=28428918" target="_blank">Curious Activity</a>
- <a href="https://www.patreon.com/user/creators?u=27476624" target="_blank">Matěj Adámek</a>
- <a href="https://www.patreon.com/pytesNET/creators" target="_blank">pytesNET</a>
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
- <a href="https://www.patreon.com/user/creators?u=30876037" target="_blank">Thomas Kreth</a>
- <a href="https://www.patreon.com/user/creators?u=14629621" target="_blank">Christian</a>
@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).

View file

@ -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 <title>
$layout['title'] = $L->g('Plugin'). ' [ ' .$plugin->name(). ' ] ' . ' - ' . $layout['title'];

View file

@ -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;
}

View file

@ -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();
?>

View file

@ -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

View file

@ -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>';
}

View file

@ -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) {