Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDPR-Compliance & local file cache #9

Open
Webklex opened this issue Aug 23, 2022 · 0 comments
Open

GDPR-Compliance & local file cache #9

Webklex opened this issue Aug 23, 2022 · 0 comments

Comments

@Webklex
Copy link

Webklex commented Aug 23, 2022

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,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant