Skip to content

GDPR-Compliance & local file cache #9

@Webklex

Description

@Webklex

Hi, Thanks for creating this project :)

I've noticed that there are two remote scripts called, if a graph gets rendered. This is somewhat problematic regarding GDPR-Compliance.
In order to fix this I've created a local cache, which downloads the file in order to serve them locally.

I've added this method to Render::class:

public static function cache($filepath, $source): void {
    if (File::exists($filepath) === false) {
        if (File::exists(dirname($filepath)) === false) {
            File::makeDirectory(dirname($filepath), 677, true);
        }
        File::put($filepath, file_get_contents($source));
    }
}

.. and adjusted Render::html a bit, to use the cache instead:

$jqueryPath = public_path("js/jquery-3.4.1.slim.min.js");
$assetPath = public_path("js/mermaid@{$version}/dist/mermaid.js");
        
self::cache($jqueryPath, "https://code.jquery.com/jquery-3.4.1.slim.min.js");
self::cache($assetPath, "https://unpkg.com/mermaid@{$version}/dist/mermaid.js");

$html = [
    '   <script src="' . asset("js/jquery-3.4.1.slim.min.js") . '"></script>',
    '   <script src="' . asset("js/mermaid@{$version}/dist/mermaid.js") . '"></script>',
    ...
];

Kind regards & happy coding,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions