A simple static site generator for Scriptor CMS – Create your pages dynamically with Scriptor, push them as static pages to your server and benefit from the speed and security that a static website offers.

Rheostatic image

Module description

A time ago, people on the Internet built their static websites by hand and placed each HTML tag with the loving care of an artisan. They spent an enormous amount of time and energy to insert their content letter by letter into the pixel-perfect designs.

Then came the wave of automation and replaced these people with Content Management Systems (CMS) that could do the job on demand. The CMS could faithfully combine templates and content and apply logic to return a page view whenever a request for a resource was received.

Trends comes and goes - static websites have come back into vogue because "static" is hip, fast and secure. This has also contributed to the growing popularity of static site generators (SSGs) in recent years. Even though Scriptor provides very clever caching functionality by default, I have developed a Rheostatic module to further enhance this functionality.

The Rheostatic module saves your Scriptor pages in a file with the .html suffix, turning the data into static webpages that can be hosted on the same kind of web server that the ancestors of modern people hosted their web.

Install Instruction

Download the zip file, unzip it and upload the complete folder Rheostatic to your server in the directory site/modules/. Open your custom.scriptor-config.php file. Add the following configuration to the modules section:

...
'rheostatic' => [
    'menu' => 'rheostatic_menu',
    'position' => 3,
    'active' => true,
    'auth' => true,
    'path' =>  'modules/Rheostatic/Rheostatic',
    'class' => 'Rheostatic',
    'display_type' => [
        'sidebar'
    ],
    'icon' => 'gg-list-tree',
    'description' => 'The Scriptor\'s Static Site Generator',
    'date_time_format' => 'Y.m.d H:i',
    'client' => [
        // SSL
        'verify' => true,
        // Create a client with a differ base URI than the current website.
        'base_uri' => '',
        // Enter GET parameters here if needed
        'request' => [
            'query' => []
        ]
    ],
    // Strings you want to replace in the content
    'replacement' => []
]
...

Recommended: If you want your static pages to be automatically removed from the index when a corresponding original page is deleted in the Scriptor editor, add the following settings to your custom.scriptor-config.php file in the hooks section:

...
'Editor::afterExecute' => [
    [
        'module' => 'rheostatic', 
        'method' => 'loadResources'
    ]
],
'Pages::beforeRemovePage' => [
    [
        'module' => 'rheostatic', 
        'method' => 'clonePage'
    ]
],
'Pages::afterRemovePage' => [
    [
        'module' => 'rheostatic', 
        'method' => 'removePageFromIndex'
    ]
]
...

If you use Scriptor locally and do not implement encryption, you can set client verification to false:

...
    'client' => [
        // SSL
        'verify' => false,
...

By default, after you have generated the static pages, Rheostatic creates a static folder in Scriptor's root, where the static pages are located. You can push its content to your server, do this using Git, SFTP or a tool you like - I don't want to tell you your job...

Tips (optionally)

If your static page is hosted on the same server where Scriptor is running, you can also use .htaccess to redirect your website visitors to the static folder, for example:

RewriteEngine On
AddDefaultCharset UTF-8

Options -Indexes
Options +SymLinksIfOwnerMatch

#RewriteBase /

RewriteCond %{ENV:REDIRECT_STATUS} . [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteCond %{QUERY_STRING} !rheostatic [NC]
RewriteCond %{REQUEST_URI} !(^/static|/editor)
RewriteRule ^(.*)$ static/$1

...

Note this condition in the code shown above: RewriteCond %{QUERY_STRING} !rheostatic [NC]
This ensures that website requests with a rheostatic parameter in the URL are redirected to the dynamic output generated by the Scriptor when the page is scanned. Also note that you need to pass a rheostatic parameter when creating static pages. So you need to adjust your Rheostatic module config in your custom.scriptor-config.php file as follows:

...
        // Enter GET parameters here if needed
        'request' => [
            'query' => ['rheostatic' => 1]
        ]
...

Minimum requirements

cURL >= 7.19.4 compiled with OpenSSL and zlib
Compatible with Scriptor: 1.4.9 +
Author: Bigin
Last Updated: 2020-09-01
Rheostatic: 1.0.1