craftsmancoding / repoman

Repoman allows for easy package development in MODX Revolution. Take back the simplicity!
30 stars 7 forks source link

Problem with [[++mypkg.assets_url]] replacement #22

Closed pk-informatics closed 10 years ago

pk-informatics commented 10 years ago

Maybe it is a stupid question but i didn’t find a solution for the following problem with repoman – even the wiki couldn’t help me:

To avoid static coded paths i have used [[++mypkg.assets_url]] which is correctly replaced at the development site, but after building it will be replaced with [[++assets_url]] and this simply points to assets/ and not to assets/components/mypkg/ (where the files are)

A different assets_path in the composer.json even won’t help because of the replacement with assets_url after building.

The only idea which i have at the moment is to create a different systemsetting for the path – but i think this isn’t the intended usage.

I have even tried it with the „repo-starter“, same problem there after building and installation.

Used modX Version: 2.3.2 Advanced Repoman: Master from today

fireproofsocks commented 10 years ago

I think this relates to the prepare_for_pkg function inside model/repoman/objecttypes/modtemplate_parser.class.php

It replaces the [[++pkg.assets_url]] with [[++assets_url]] on build, but that does create problems when the subdirectories ostensibly change from "assets/" to "assets/components/pkg/"

Gotta think about this one... the "easy" solution is to structure your assets directory to include the subdirectories, but that's not a good solution because 1) it's fugly, and 2) I think the build script will automatically create the subdirectories when the transport package is created...

I think the correct solution here is to update this:

        $string = str_replace('[[++' . $this->Repoman->get('namespace') . '.assets_url', '[[++assets_url', $string);

to instead search for the entire tag and replace it with the full path, e.g.

    $string = str_replace('[[++' . $this->Repoman->get('namespace') . '.assets_url]]', '[[++assets_url]]components/'.$this->Repoman->get('namespace').'/', $string);
fireproofsocks commented 10 years ago

Wanna try pulling the latest version from git?

32b917c..3dadf0c master -> master

That should fix it.

pk-informatics commented 10 years ago

Thank you for the fast fix - now it works :)