boiteasite / cmsuno

An easy and clever tool to create one-page responsive websites
27 stars 8 forks source link

CMSUno

An easy and clever content manager system to create one-page responsive websites

 uuuu      uuuu        nnnnnn           ooooooooo
u::::u    u::::u    nn::::::::nn     oo:::::::::::oo
u::::u    u::::u   nn::::::::::nn   o:::::::::::::::o
u::::u    u::::u  n::::::::::::::n  o:::::ooooo:::::o
u::::u    u::::u  n:::::nnnn:::::n  o::::o     o::::o
u::::u    u::::u  n::::n    n::::n  o::::o     o::::o
u::::u    u::::u  n::::n    n::::n  o::::o     o::::o
u:::::uuuu:::::u  n::::n    n::::n  o::::o     o::::o
u::::::::::::::u  n::::n    n::::n  o:::::ooooo:::::o
 u::::::::::::u   n::::n    n::::n  o:::::::::::::::o
  uu::::::::uu    n::::n    n::::n   oo:::::::::::oo
     uuuuuu        nnnn      nnnn       ooooooooo
        ___                                __
       / __\            /\/\              / _\
      / /              /    \             \ \
     / /___           / /\/\ \            _\ \
     \____/           \/    \/            \__/

Presentation

CMSUno is a free tool to create one-page responsive websites. It was designed to be easy to use, comprehensive and particularly rapid in terms of navigation. This strong CMS is a great tool to use jQuery plugins available on the web.

==> DEMO <==

It is very well adapted to SEO and allows to get a score close to 100 on Google PageSpeed Insights.

In a few words:

More details in French here.

Installation

  1. Download ZIP CMSUno.
  2. Unzip the file.
  3. Upload the content (uno.php and uno/) to your website directory via FTP.
  4. Chmod 0755 recursively the uno folder.
  5. In your browser, open www.yoursite/uno.php.

Initial login & password : cmsuno & 654321

To reduce the size of CMSUno to less than 2MB and benefit the speed of GitHub's servers, delete the following folders :

or do it with update button.

Requirement

Use

Connect to the dashboard. There are only three tabs :

Page

This first Tab is the main working tab. It is used to create some contents for the site. It relies on a large window with CKEditor in a recent version. At the top, a menu allows to pass from a chapter to another other one. You can create as many chapters as you like. A button allows access to the powerful and easy file manager ELFinder.

When your changes are complete, press the "publish" button to update the site.

Config

Configuration is limited to the minimum useful.

Plugins

Plugins can substantially improve the capabilities of CMSUno. Plugin can especially add extra buttons to CKEditor and process the results before publication. In use, it's fantastic.

Plugins are available here

Official Plugins List

Template Development

Create a theme is very easy. You just need a folder with the name of your theme and, inside, a file named 'template.html'. That's it. The template file is a simple html file with some specifics tags. Example :

<!DOCTYPE html>
<html>
<head>
    <title>[[title]]</title>
    <meta charset="utf-8">
    <meta name="description" content="[[description]]" />
    <link rel="stylesheet" href="https://github.com/boiteasite/cmsuno/blob/master/[[template]]style.css" />
    [[head]]
</head>
<body>
    <div id="header">
        <h1>[[title]]</h1>
        [[menu]]
    </div><!-- #header -->
    <div class="content">
        [[content]]
    </div><!-- .content -->
    [[foot]]
</body>
</html>

Template Tags

Plugin development

Create a plugin is quite simple and fast. A basic structure is imposed with some mandatory files. Your plugin should be in uno/plugins/foo/ (with a plugin called foo).

foo.php

This file is required.

This file is called in AJAX. It is used to display the PLUGIN tab in Dashboard. It's done with $_POST["action"] = "plugin".

POST var available (Ajax environment) :

This file should look like this :

<?php
session_start(); 
if(!isset($_POST['unox']) || $_POST['unox']!=$_SESSION['unox']) {sleep(2);exit;} // appel depuis uno.php
include('../../config.php'); // Lang
include('lang/lang.php');
$busy = (isset($_POST['ubusy'])?preg_replace("/[^A-Za-z0-9-_]/",'',$_POST['ubusy']):'index');
if (isset($_POST['action'])) {
    switch ($_POST['action']) {
        // ***********************
        //"plugin" case is AJAX Call from CMSUno Core.
        // ***********************
        case 'plugin': ?>
        <div class="blocForm">
            <h2>Foo</h2>
            <p><?php echo T_("This plugin is used to...");?></p>
            <!--   CONFIG FORM IF NEEDED... -->
            <input name="lol" type="text" />
            <select name="yeswecan">
                <option>...</option>

            </select>
            <input type="button" onClick="save_foo();" />
            <!-- ... -->
            ?>
        </div>
        <?php break;
        // ***********************
        // Others cases are AJAX self-call via foo.js (see below).
        // ***********************
        case 'save': // IF NEEDED FOR SAVING CONFIG IN JSON FILE
        $q = @file_get_contents('../../data/'.$busy.'/foo.json'); // or '../../data/foo.json'
        if($q) $a = json_decode($q,true);
        else $a = Array();
        $a['lol'] = $_POST['lol'];
        $a['yeswecan'] = $_POST['yeswecan'];
        $out = json_encode($a);
        if (file_put_contents('../../data/'.$busy.'/foo.json', $out)) echo T_('Backup performed');
        else echo '!'.T_('Impossible backup');
        break;
        // ***********************
    }
    clearstatcache();
    exit;
}
?>

In the same way, you can customize your theme by adding the file __name_of_your_theme.php__ in the theme folder.

foo.js

This file is not required.

This is the complement of foo.php.

If it exists, this file is loaded at the same time as foo.php. The script is added to the head of the page. CMSUno JS Variables are therefore available (Udep, Ubusy, Utem, Unox, Ulang...). It is useful for example to load or save JSON data in AJAX :

function save_foo(){
    let lol=document.getElementById("fooLol").value;
    let yeswecan=document.getElementById("fooYes").options[document.getElementById("fooYes").selectedIndex].value;
    let x=new FormData();
    x.set('action','save');
    x.set('unox',Unox);
    x.set('ubusy',Ubusy);
    x.set('lol',lol);
    x.set('yeswecan',yeswecan);
    fetch('uno/plugins/foo/foo.php',{method:'post',body:x})
    .then(r=>r.text())
    .then(r=>f_alert(r));
}
function load_foo(){
    fetch("uno/data/"+Ubusy+"/foo.json?r="+Math.random()) // or "uno/data/foo.json?...
    .then(r=>r.json())
    .then(function(data){
        if(data.lol!=undefined)document.getElementById('fooLol').value=data.lol;
        if(data.yeswecan){
            let t=document.getElementById("fooYes"),to,v;
            to=t.options;
            for(v=0;v<to.length;v++){
                if(to[v].value==data.yeswecan){
                    to[v].selected=true;
                    v=to.length;
                }
            }
        }
    }
}
load_foo();

f_alert('happy'); displays a green notification in the top bar. If the text starts with '!', the notification is red : f_alert('!not happy');

fooMake.php

This file is not required.

This file is called with an include statement from central.php (case 'publier') when the user pushed "publish" in the Dashboard. The goal is to participate in the writing of the HTML page by replacing, for example, the custom shortcodes with the created content.

If your plugin works with a Shortcode [[foo]] in the content of the page, the code should be like this :

<?php if (!isset($_SESSION['cmsuno'])) exit(); ?>
<?php
    $my_var = "<div>Hello. I'm the plugin</div>";
    $Ucontent = str_replace('[[foo]]',$my_var,$content);
    $Uhead .= '<link rel="stylesheet" type="text/css" href="https://github.com/boiteasite/cmsuno/blob/master/uno/plugins/foo/my-plugin-styles.css" />'."\r\n";
    $Ufoot .= '<script type="text/javascript" src="https://github.com/boiteasite/cmsuno/raw/master/uno/plugins/foo/myfoo-min.js"></script>'."\r\n";
    $unoUbusy = 1;
?>

The plugins are executed in alphabetical order. If a plugin must be executed before any others, you can add an order of precedence in the name :

A same plugin can have several fooMake files with different numbers.

Variables usable all have almost the same name as the shortcodes. Here is a non-exhaustive list :

As a plugin, you can add a makefile in your theme folder :

You can use both.

fooCkeditor.js or fooCkeditor.js.php

This file is not required.

This file is used to customize CKeditor. It's very interesting.

In CKEditor, configuration files work in cascade as Matryoshka doll. Every configuration file calls the following one. It is thus necessary to respect a specific format to not break the chain. Example with your CKEditor plugin ckfoo :

UconfigNum++; // needed
CKEDITOR.plugins.addExternal('ckfoo', UconfigFile[UconfigNum-1]+'/../ckfoo/'); // needed
CKEDITOR.editorConfig = function(config) {
    config.extraPlugins += ',ckfoo';
    config.toolbarGroups.push('ckfoo');
    if(UconfigFile.length>UconfigNum)config.customConfig=UconfigFile[UconfigNum]; // needed for next plugin
};

If you choose to use the PHP file to change the content before execution, remember that the minimum needed (to do nothing) is :

UconfigNum++; // needed
CKEDITOR.editorConfig = function(config) {
    if(UconfigFile.length>UconfigNum)config.customConfig=UconfigFile[UconfigNum]; // needed for next plugin
};

fooHook.js

This file is not required.

This file is used to apply a JavaScript code to the CMSUno core. It can be used to add items in the CMSUno menu bar or whatever.

Example :

document.getElementById('topMenu').insertAdjacentHTML(
    'beforeend',
    '<li><a href="https://github.com">GitHub</a></li>'
);

version.json

This file is required. It allows to update the plugin online.

Example of content :

{"version":"1.0","host":"https://github.com/cmsunoPlugins/foo/"}

You can host your plugin on your own GitHub account. Be sure to specify the address of your repository on this file. By adding a version number 'TAG' when publishing, the update will be directly available from CMSUno.

Data

CMSUno don't use MySQL but flat files in json. These files are stored in uno/data/. You can have different files for the same plugin.

There are two options : "secret"/"not secret" and "available for all pages"/"only for a specific page" (see multipage plugin) :

Name of the page : $Ubusy in php or Ubusy in JS

xxxx : $sdata in config.php

The _sdata-xxxx folder is only readable/writable by owner (PHP). You cannot get access to a file from a javascript tag or from a browser.

License

CMSUno is under MIT license.

Copyright (c) 2014-2024 Jacques Malgrange

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Versions