Une pagination custom sur Bludit

Une pagination custom sur Bludit

La pagination par défaut de Bludit n'est pas terrible. Voici comment l'améliorer.

Dans son thème, remplacer la partie pagination par : (ex pour moi : bl-themes/andy/php/home.php) :

<!-- Pagination -->
<?php if (Paginator::numberOfPages()>1): ?>
<div class="paginator-label">
    Pages : 
</div>

<nav class="paginator">
<?php 
    if(!isset($_GET['page'])){
        $getPage = 1;
    } else {
        $getPage = $_GET['page'];
    } 
?>
    <ul class="list-group flex-md-row">

        <!-- Previous button -->
        <?php if (Paginator::showPrev()): ?>
        <li class="list-group-item">
          <a class="btn" href="<?php echo Paginator::previousPageUrl() ?>" tabindex="-1"><< 
            <?php echo $L->get('Previous'); ?></a>
        </li>
        <?php endif; ?>

        <?php if ($getPage >= 4) { ?>
        <li class="list-group-item">
            <a class="btn" href="<?php echo parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); ?>">Début</a>
        </li>
        <li>...&nbsp;</li>
        <?php } ?>

        <?php if ($getPage >= 3) { ?>
        <li class="list-group-item">
            <a class="btn" href="<?php echo parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); ?>
            ?page=<?php echo $getPage - 2; ?>"><?php echo $getPage - 2; ?></a>
        </li>
        <?php } ?>

        <?php if ($getPage >= 2) { ?>
        <li class="list-group-item">
            <a class="btn" href="<?php echo parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); ?>
            ?page=<?php echo $getPage - 1; ?>"><?php echo $getPage - 1; ?></a>
        </li>
        <?php } ?>

        <?php if ($getPage) { ?>
        <li class="list-group-item">
            <a class="btn btn-selected" href="<?php echo parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); ?>
            ?page=<?php echo $getPage; ?>"><?php echo $getPage; ?></a>
        </li>
        <?php } ?>

        <?php if (Paginator::numberOfPages()-1 >= $getPage) { ?>
        <li class="list-group-item">
            <a class="btn" href="<?php echo parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); ?>
            ?page=<?php echo $getPage + 1; ?>"><?php echo $getPage + 1; ?></a>
        </li>
        <?php } ?>

        <?php if (Paginator::numberOfPages()-2 >= $getPage) { ?>
        <li class="list-group-item">
            <a class="btn" href="<?php echo parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); ?>?page=<?php echo $getPage + 2; ?>"><?php echo $getPage + 2; ?></a>
        </li>
        <?php } ?>

        <?php if (Paginator::numberOfPages()-3 >= $getPage) { ?>
        <li>...&nbsp;</li>
        <li class="list-group-item">
            <a class="btn" href="<?php echo parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH).'?page='.Paginator::numberOfPages(); ?>">Fin</a>
        </li>
        <?php } ?>

        <!-- Next button -->
        <?php if (Paginator::showNext()): ?>
        <li class="list-group-item">
            <a class="btn" href="<?php echo Paginator::nextPageUrl() ?>"><?php echo $L->get('Next'); ?> >> </a>
        </li>
        <?php endif; ?> 

  </ul>
</nav>
<?php endif ?>

Et ajouter le CSS :

.btn {
    padding: 2px 10px 0 10px;
    border: 1px solid rgba(0,0,0,.125);
    border-radius: 3px;
    font-size: 17px;
    }

.btn-selected,
.btn:hover {
    color: #fff !important;
    background-color: #036BAA;
    font-weight:600;
}

.paginator-label {
  float: left;
}

Ce qui offre ce rendu :

Screenshot pagination exemple

IHM Web administration Matrix

IHM Web administration Matrix

Repo git : https://github.com/Awesome-Technologies/synapse-admin (AUR)

Rajouter dans /etc/nginx/nginx.conf pour rendre accessible le endpoint uniquement en local :

    location ~ ^(/_synapse/admin) {
        allow 192.168.1.0/24;
        deny all;
        proxy_pass http://localhost:8008;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $host;
    }

Et créer le serveur accessible uniquement en local également :

server {
   listen 3000;
   http2 on;

   server_name localhost;

   root /usr/share/webapps/synapse-admin/;
   index index.html;

   location / {
      allow 192.168.1.0/24;
      deny all;
   }
}

Profiter du débit maximal de sa Freebox Delta

Comment profiter du débit maximal de sa Freebox Delta

Pour espérer atteindre les 8Gbs avec la Freebox Delta, il faut être en FTTH PON. Si on est en Point a Point, c'est foutu. C'est vérifiable sur votre interface Freebox

Le port ethernet est bridé à 1Gpbs, il faut donc passer par le port SFP+.

Screenshot interface Freebox

Il faut donc acquérir une carte PCIe avec port SFP+ et un câble optique OM3 10Gbps. Trouvables pour une petite centaine d’euros. Il faut évidemment avoir un SSD capable d’assurer des débits d’écriture supérieur à 1,3 Go/s. Je suis dans un petit village d’à peine 250 habitants au fin fond de l’Auvergne, à 5km du NRA, donc très loin. Ping de 10ms, débit de ~7Gbps en download et 700Mbps en upload, la promesse est respectée.

Screenshot speedtest Nperf

Permettre à PHP-FPM dans Nginx de modifier des fichiers

Permettre à PHP-FPM dans Nginx de modifier des fichiers

Si dans /usr/lib/systemd/system/php-fpm.service:

ProtectSystem=full

Mettre à jour les paths voulus dans /usr/lib/systemd/system/php-fpm.service :

[Service]
ReadWritePaths=

Activer / Désactiver rapidement la vue TinyMCE dans l'admin Bludit

Activer / Désactiver rapidement la vue TinyMCE dans l'admin Bludit

Petit script à placer dans Plugins --> Code HTML --> Paramètres --> Admin Area --> Header :

<script>
    /// Fires when an editor is added to the EditorManager collection.
    tinymce.on('addeditor', function( event ) {
        $("<button id=\"switch-tinymce\" class=\"btn btn-sm btn-success\" type=\"button\" onclick=\"tinymce.execCommand('mceToggleEditor',false,'jseditor'); $('#switch-tinymce').toggleClass('btn-success btn-danger');\">ON/OFF</button>").insertAfter("#jsbuttonPreview"); 
        $("#switch-tinymce").before(" ").append(" ");
    }, true );
</script>

Le script est un peu dégueu mais le rendu est largement acceptable :

Screenshot 1 - ON

Screenshot 2 - OFF

Pages :