KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Settings to make KoolReport able to load widget resource #24

Open KoolReport opened this topic on on Jul 6, 2017 - 3 comments

KoolReport commented on Jul 6, 2017

Questions

I have a public folder is where my webserver will load with starting. I put koolreport folder in the same folder with public, that's why there is no way that web user can access the resources (js,css) of koolreport widgets. How can I make the report run? P/S: Under the public folder, I have a folder called assets where I store all the js and css resources.

Answer:

You do this:

<?php

class MyReport extends \koolreport\KoolReport
{
    public function settings()
    {
        return array(
            "assets"=>array(
                "path"=>"../assets",
                "url"=>"/assets"
            )
        );
    }
}

In the settings() function of KoolReport, you place the property assets. In the path property, we will set relative path from the report to the assets folder. In the url property, we set the url pointing to the assets folder.

By this settings, Widget of KoolReport know where to copy resource to and how to access the resource.

Leho Kraav commented on Mar 1, 2019

How can I turn this off and have assets managed by my own webpack-based toolchain?

It'd be enough if ResourceManager::publishAssetsFolder() would process an extra key like assets['copy'] = false, so only path resolves would be replaced in markup output.

Underlying problem: KR currently does not work at all with deployment systems like http://deployer.org which use symlinks. Assets get resolved to realpath-s outside of webroot - an immediate incremental improvement could be checking everything via http://php.net/manual/en/function.readlink.php first.

EDIT I could make it work as-is, or close, but Utility::getSymbolicPath() destroys correct path, because it thinks everything needs to be in document root, which is a false assumption.

GOOD RM post-standardize

/home/convers/deploy/cxl/institute/releases/20190301.182235-leho/vendor/koolphp/koolreport/src/clients/jquery

BAD RM post-getSymbolic

/home/convers/public_html/institute/releases/20190301.182235-leho/vendor/koolphp/koolreport/src/clients/jquery

David Winterburn commented on May 10, 2019

Hi Leho,

Sorry for the long await reply. We also have this problem with symlink in a few of our development environment but haven't found a good solution so far. If you'd like, you could try our best fix right now for symlink problem. Please open the file core/ResourceManager.php and replace the following lines:

$script_folder = Utility::standardizePathSeparator(
                    realpath(dirname($_SERVER["SCRIPT_FILENAME"]))
                );

with these:

$script_folder = Utility::standardizePathSeparator(
                    dirname($_SERVER["SCRIPT_FILENAME"])
                );

Let us know if it works for you. Thanks!

Leho Kraav commented on May 10, 2019

Thanks for the thoughts.

In the meanwhile, we simply forked on GH, and added a couple of commits, then added our repo to our app composer.json to override upstream.

https://github.com/conversionxl/koolreport/commit/84addce7adc7798d67d1d8506c2abdbb8e560896

Regardless, KR has recently reorganized, so I will have to take a look at the new repo structure now https://github.com/koolreport/core and probably see about filing a PR.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
wiki

None